Commit 3810a089 authored by renjie's avatar renjie

付费bug

parent 93309326
......@@ -416,25 +416,22 @@ public class AdministratorServiceImpl implements AdministratorService {
totalCommission = userPrePaidBillings.stream().mapToDouble(UserPrePaidBilling::getTotal).sum();
promotion.setTotalCommission(promotion.getTotalCommission() + (int)totalCommission);
promotion.setCommission(promotion.getCommission() + x.getPromotion().getCommission());
double totalwithdrawn = 0;
userPrePaidBillings = userPrePaidBillingRepository.findByAdministratorAndChargeTypeAndTimestampBetween(x.getName(), ChargeType.gift, dateTime1.getTime(), dateTime2.getTime());
if (userPrePaidBillings != null && userPrePaidBillings.size() > 0)
totalwithdrawn = userPrePaidBillings.stream().mapToDouble(UserPrePaidBilling::getTotal).sum();
promotion.setWithdrawn(promotion.getWithdrawn() + totalwithdrawn);
double secondCommission = 0;
if (finalAccount.getPromotion().isSale() && x.getParent() == null) {
List<Account> secondPromotes = accountRepository.findByPromotionCode(x.getPromotion().getCode());
if (secondPromotes != null && secondPromotes.size() > 0) {
for (Account secondPromote : secondPromotes) {
List<UserPrePaidBilling> userPrePaidBillings1 = userPrePaidBillingRepository.findByAdministratorAndYearAndMonthAndPayMethodIn(secondPromote.getName(),
YearMonth.now().minusMonths(1).getYear(),
YearMonth.now().minusMonths(1).getMonthValue(), Arrays.asList(1,2,3));
List<UserPrePaidBilling> userPrePaidBillings1 = userPrePaidBillingRepository.findByAdministratorAndPayMethodInAndTimestampBetween(secondPromote.getName(), Arrays.asList(1,2,3), dateTime1.getTime(), dateTime2.getTime());
if (userPrePaidBillings1 != null && userPrePaidBillings1.size() > 0)
secondCommission += userPrePaidBillings1.stream().mapToDouble(UserPrePaidBilling::getTotal).sum();
}
}
}
if (x.getPromotion().isSale())
promotion.setAllGift(promotion.getAllGift() + totalCommission * 0.1 + secondCommission * 0.02);
else
promotion.setAllGift(promotion.getAllGift() + totalCommission * 0.08);
promotion.setWithdrawn(promotion.getWithdrawn() + secondCommission);
promotion.setGift(promotion.getGift() + x.getPromotion().getGift());
promotion.setCommissionLastMonth(promotion.getCommissionLastMonth() + x.getPromotion().getCommissionLastMonth());
});
......
......@@ -36,6 +36,9 @@ public class IpResource implements Serializable {
private String password;
private double price;
private String proxyUsername;
private String proxyPassword;
private String shopId;
private String shopName;
......@@ -262,4 +265,20 @@ public class IpResource implements Serializable {
public void setVendorCn(String vendorCn) {
this.vendorCn = vendorCn;
}
public String getProxyPassword() {
return proxyPassword;
}
public void setProxyPassword(String proxyPassword) {
this.proxyPassword = proxyPassword;
}
public String getProxyUsername() {
return proxyUsername;
}
public void setProxyUsername(String proxyUsername) {
this.proxyUsername = proxyUsername;
}
}
......@@ -179,7 +179,7 @@ public class IpResourceServiceImpl implements IpResourceService {
.filter(x -> Vendor.valueOf(ipResourceRequestDto.getVendor()).getValue().equals(x.substring(0, x.indexOf("-"))))
.map(x -> x.substring(x.lastIndexOf("-") + 1)).collect(Collectors.joining());
double newprice = ipResourceRequestDto.getUnit().equals("week") ? (Integer.valueOf(price)/3) : Integer.valueOf(price);
IpChargeResultDto ipChargeResultDto = accountService.preChargeByMoney(username, newprice * ipResourceRequestDto.getAmount());
IpChargeResultDto ipChargeResultDto = accountService.preChargeByMoney(username, newprice * ipResourceRequestDto.getAmount() * ipResourceRequestDto.getPeriod());
if (!ipChargeResultDto.isSuccess()) {
throw new ClientRequestException(AccountErrorCode.NOTENOUGHBALANCE);
}
......@@ -244,7 +244,7 @@ public class IpResourceServiceImpl implements IpResourceService {
}
IpChargeRequestDto ipChargeRequestDto = buildIpChargeRequestDto(ipResourceRequestDto, 1, ipResourceRequestDto.getPayMethod());
accountService.chargeByMoney(username, newprice * ipChargeRequestDto.getAmount(), ipChargeRequestDto);
accountService.chargeByMoney(username, newprice * ipChargeRequestDto.getAmount() * ipChargeRequestDto.getPeriod(), ipChargeRequestDto);
if (ipResourceRequestDto.getShopId() != null) {
ShopRequestDto shopRequestDto = new ShopRequestDto();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment