Commit 3c0201b0 authored by renjie's avatar renjie

bug修改

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