Commit 3c0201b0 authored by renjie's avatar renjie

bug修改

parent fe8008da
...@@ -395,44 +395,49 @@ public class AdministratorServiceImpl implements AdministratorService { ...@@ -395,44 +395,49 @@ public class AdministratorServiceImpl implements AdministratorService {
Date dateTime2 = formatter.parse(strDate2); Date dateTime2 = formatter.parse(strDate2);
Page<Account> accountPage = accountRepository.findAllBySignupDateBetweenAndPromotionCodeAndParentIsNull(pageable, dateTime1, dateTime2, account.getPromotion().getCode()); Page<Account> accountPage = accountRepository.findAllBySignupDateBetweenAndPromotionCodeAndParentIsNull(pageable, dateTime1, dateTime2, account.getPromotion().getCode());
List<AccountPromotionDto> accountPromotionDtos = new ArrayList<>(); List<AccountPromotionDto> accountPromotionDtos = new ArrayList<>();
accountPage.get().forEach(account1 -> { if (accountPage.getNumber() > 0) {
accountPromotionDtos.add(new AccountPromotionDto(account1)); accountPage.get().forEach(account1 -> {
}); accountPromotionDtos.add(new AccountPromotionDto(account1));
});
}
Page<AccountPromotionDto> accountPromotionDtoPage = new PageImpl<AccountPromotionDto>(accountPromotionDtos); Page<AccountPromotionDto> accountPromotionDtoPage = new PageImpl<AccountPromotionDto>(accountPromotionDtos);
promotionQueryResultDto.setUsers(accountPromotionDtoPage); promotionQueryResultDto.setUsers(accountPromotionDtoPage);
List<Account> accounts = accountRepository.findAllBySignupDateBetweenAndPromotionCode(dateTime1, dateTime2, account.getPromotion().getCode()); List<Account> accounts = accountRepository.findAllBySignupDateBetweenAndPromotionCode(dateTime1, dateTime2, account.getPromotion().getCode());
Promotion promotion = new Promotion(); Promotion promotion = new Promotion();
Account finalAccount = account; Account finalAccount = account;
accounts.forEach(x -> { if (accounts != null && accounts.size() > 0) {
promotion.setInvitedUsers(promotion.getInvitedUsers() + 1); accounts.forEach(x -> {
List<UserPrePaidBilling> userPrePaidBillings = userPrePaidBillingRepository.findByAdministratorAndPayMethodInAndTimestampBetween(x.getName(), Arrays.asList(1,2,3), dateTime1.getTime(), dateTime2.getTime()); promotion.setInvitedUsers(promotion.getInvitedUsers() + 1);
double totalCommission = 0; List<UserPrePaidBilling> userPrePaidBillings = userPrePaidBillingRepository.findByAdministratorAndPayMethodInAndTimestampBetween(x.getName(), Arrays.asList(1,2,3), dateTime1.getTime(), dateTime2.getTime());
if (userPrePaidBillings != null) double totalCommission = 0;
totalCommission = userPrePaidBillings.stream().mapToDouble(UserPrePaidBilling::getTotal).sum(); if (userPrePaidBillings != null)
promotion.setTotalCommission(promotion.getTotalCommission() + (int)totalCommission); totalCommission = userPrePaidBillings.stream().mapToDouble(UserPrePaidBilling::getTotal).sum();
promotion.setCommission(promotion.getCommission() + x.getPromotion().getCommission()); promotion.setTotalCommission(promotion.getTotalCommission() + (int)totalCommission);
double totalwithdrawn = 0; promotion.setCommission(promotion.getCommission() + x.getPromotion().getCommission());
userPrePaidBillings = userPrePaidBillingRepository.findByAdministratorAndChargeTypeAndTimestampBetween(x.getName(), ChargeType.gift, dateTime1.getTime(), dateTime2.getTime()); double totalwithdrawn = 0;
if (userPrePaidBillings != null && userPrePaidBillings.size() > 0) userPrePaidBillings = userPrePaidBillingRepository.findByAdministratorAndChargeTypeAndTimestampBetween(x.getName(), ChargeType.gift, dateTime1.getTime(), dateTime2.getTime());
totalwithdrawn = userPrePaidBillings.stream().mapToDouble(UserPrePaidBilling::getTotal).sum(); if (userPrePaidBillings != null && userPrePaidBillings.size() > 0)
promotion.setWithdrawn(promotion.getWithdrawn() + totalwithdrawn); totalwithdrawn = userPrePaidBillings.stream().mapToDouble(UserPrePaidBilling::getTotal).sum();
double secondCommission = 0; promotion.setWithdrawn(promotion.getWithdrawn() + totalwithdrawn);
if (finalAccount.getPromotion().isSale() && x.getParent() == null) { double secondCommission = 0;
List<Account> secondPromotes = accountRepository.findByPromotionCode(x.getPromotion().getCode()); if (finalAccount.getPromotion().isSale() && x.getParent() == null) {
if (secondPromotes != null && secondPromotes.size() > 0) { List<Account> secondPromotes = accountRepository.findByPromotionCode(x.getPromotion().getCode());
for (Account secondPromote : secondPromotes) { if (secondPromotes != null && secondPromotes.size() > 0) {
List<UserPrePaidBilling> userPrePaidBillings1 = userPrePaidBillingRepository.findByAdministratorAndYearAndMonthAndPayMethodIn(secondPromote.getName(), for (Account secondPromote : secondPromotes) {
YearMonth.now().minusMonths(1).getYear(), List<UserPrePaidBilling> userPrePaidBillings1 = userPrePaidBillingRepository.findByAdministratorAndYearAndMonthAndPayMethodIn(secondPromote.getName(),
YearMonth.now().minusMonths(1).getMonthValue(), Arrays.asList(1,2,3)); YearMonth.now().minusMonths(1).getYear(),
secondCommission += userPrePaidBillings1.stream().mapToDouble(UserPrePaidBilling::getTotal).sum(); YearMonth.now().minusMonths(1).getMonthValue(), Arrays.asList(1,2,3));
if (userPrePaidBillings1 != null && userPrePaidBillings1.size() > 0)
secondCommission += userPrePaidBillings1.stream().mapToDouble(UserPrePaidBilling::getTotal).sum();
}
} }
} }
} promotion.setAllGift(promotion.getAllGift() + totalCommission * 0.1 + secondCommission * 0.02);
promotion.setAllGift(promotion.getAllGift() + totalCommission * 0.1 + secondCommission * 0.02); promotion.setGift(promotion.getGift() + x.getPromotion().getGift());
promotion.setGift(promotion.getGift() + x.getPromotion().getGift()); promotion.setCommissionLastMonth(promotion.getCommissionLastMonth() + x.getPromotion().getCommissionLastMonth());
promotion.setCommissionLastMonth(promotion.getCommissionLastMonth() + x.getPromotion().getCommissionLastMonth()); });
}); }
promotionQueryResultDto.setPromotion(promotion); promotionQueryResultDto.setPromotion(promotion);
return promotionQueryResultDto; return promotionQueryResultDto;
......
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