Commit cc93604f authored by renjie's avatar renjie

Merge branch 'dev-zrj' into 'staging'

bug修改

See merge request !10
parents 3a8148c6 fe8008da
...@@ -24,7 +24,7 @@ public interface UserPrePaidBillingRepository extends MongoRepository<UserPrePai ...@@ -24,7 +24,7 @@ public interface UserPrePaidBillingRepository extends MongoRepository<UserPrePai
Page<UserPrePaidBilling> findAllByYearBetweenAndMonthBetween(Pageable pageable, int year1, int year2, int month1, int month2); Page<UserPrePaidBilling> findAllByYearBetweenAndMonthBetween(Pageable pageable, int year1, int year2, int month1, int month2);
List<UserPrePaidBilling> findByUsernameAndYearAndMonthAndPayMethodIn(String username, int year, int month, List<Integer> payMethod); List<UserPrePaidBilling> findByAdministratorAndYearAndMonthAndPayMethodIn(String username, int year, int month, List<Integer> payMethod);
List<UserPrePaidBilling> findByUsernameAndPayMethodIn(String username, List<Integer> payMethod); List<UserPrePaidBilling> findByUsernameAndPayMethodIn(String username, List<Integer> payMethod);
...@@ -36,9 +36,9 @@ public interface UserPrePaidBillingRepository extends MongoRepository<UserPrePai ...@@ -36,9 +36,9 @@ public interface UserPrePaidBillingRepository extends MongoRepository<UserPrePai
List<UserPrePaidBilling> findByStatus(BillStatus status); List<UserPrePaidBilling> findByStatus(BillStatus status);
List<UserPrePaidBilling> findByUsernameAndPayMethodInAndTimestampBetween(String username, List<Integer> payMehtods, long time1, long time2); List<UserPrePaidBilling> findByAdministratorAndPayMethodInAndTimestampBetween(String username, List<Integer> payMehtods, long time1, long time2);
List<UserPrePaidBilling> findByUsernameAndChargeTypeAndTimestampBetween(String username, int chargeType, long time1, long time2); List<UserPrePaidBilling> findByAdministratorAndChargeTypeAndTimestampBetween(String username, int chargeType, long time1, long time2);
Page<UserPrePaidBilling> findByUsernameAndTimestampGreaterThanOrderByTimestampDesc(String username, long time, Pageable pageable); Page<UserPrePaidBilling> findByUsernameAndTimestampGreaterThanOrderByTimestampDesc(String username, long time, Pageable pageable);
......
...@@ -400,7 +400,7 @@ public class AccountServiceImpl implements AccountService { ...@@ -400,7 +400,7 @@ public class AccountServiceImpl implements AccountService {
double totalCommission = 0; double totalCommission = 0;
totalCommission = 0; totalCommission = 0;
for (Account promote : promotes) { for (Account promote : promotes) {
List<UserPrePaidBilling> userPrePaidBillings = prePaidBillingRepository.findByUsernameAndYearAndMonthAndPayMethodIn(promote.getName(), List<UserPrePaidBilling> userPrePaidBillings = prePaidBillingRepository.findByAdministratorAndYearAndMonthAndPayMethodIn(promote.getName(),
YearMonth.now().getYear(), YearMonth.now().getYear(),
YearMonth.now().getMonthValue(), Arrays.asList(1, 2, 3)); YearMonth.now().getMonthValue(), Arrays.asList(1, 2, 3));
totalCommission += userPrePaidBillings.stream().mapToDouble(UserPrePaidBilling::getTotal).sum(); totalCommission += userPrePaidBillings.stream().mapToDouble(UserPrePaidBilling::getTotal).sum();
......
...@@ -406,19 +406,23 @@ public class AdministratorServiceImpl implements AdministratorService { ...@@ -406,19 +406,23 @@ public class AdministratorServiceImpl implements AdministratorService {
Account finalAccount = account; Account finalAccount = account;
accounts.forEach(x -> { accounts.forEach(x -> {
promotion.setInvitedUsers(promotion.getInvitedUsers() + 1); promotion.setInvitedUsers(promotion.getInvitedUsers() + 1);
double totalCommission = userPrePaidBillingRepository.findByUsernameAndPayMethodInAndTimestampBetween(x.getName(), Arrays.asList(1,2,3), dateTime1.getTime(), dateTime2.getTime()) List<UserPrePaidBilling> userPrePaidBillings = userPrePaidBillingRepository.findByAdministratorAndPayMethodInAndTimestampBetween(x.getName(), Arrays.asList(1,2,3), dateTime1.getTime(), dateTime2.getTime());
.stream().mapToDouble(UserPrePaidBilling::getTotal).sum(); double totalCommission = 0;
if (userPrePaidBillings != null)
totalCommission = userPrePaidBillings.stream().mapToDouble(UserPrePaidBilling::getTotal).sum();
promotion.setTotalCommission(promotion.getTotalCommission() + (int)totalCommission); promotion.setTotalCommission(promotion.getTotalCommission() + (int)totalCommission);
promotion.setCommission(promotion.getCommission() + x.getPromotion().getCommission()); promotion.setCommission(promotion.getCommission() + x.getPromotion().getCommission());
double totalwithdrawn = userPrePaidBillingRepository.findByUsernameAndChargeTypeAndTimestampBetween(x.getName(), ChargeType.gift, dateTime1.getTime(), dateTime2.getTime()) double totalwithdrawn = 0;
.stream().mapToDouble(UserPrePaidBilling::getTotal).sum(); 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); promotion.setWithdrawn(promotion.getWithdrawn() + totalwithdrawn);
double secondCommission = 0; double secondCommission = 0;
if (finalAccount.getPromotion().isSale() && x.getParent() == null) { if (finalAccount.getPromotion().isSale() && x.getParent() == null) {
List<Account> secondPromotes = accountRepository.findByPromotionCode(x.getPromotion().getCode()); List<Account> secondPromotes = accountRepository.findByPromotionCode(x.getPromotion().getCode());
if (secondPromotes != null && secondPromotes.size() > 0) { if (secondPromotes != null && secondPromotes.size() > 0) {
for (Account secondPromote : secondPromotes) { for (Account secondPromote : secondPromotes) {
List<UserPrePaidBilling> userPrePaidBillings1 = userPrePaidBillingRepository.findByUsernameAndYearAndMonthAndPayMethodIn(secondPromote.getName(), List<UserPrePaidBilling> userPrePaidBillings1 = userPrePaidBillingRepository.findByAdministratorAndYearAndMonthAndPayMethodIn(secondPromote.getName(),
YearMonth.now().minusMonths(1).getYear(), YearMonth.now().minusMonths(1).getYear(),
YearMonth.now().minusMonths(1).getMonthValue(), Arrays.asList(1,2,3)); YearMonth.now().minusMonths(1).getMonthValue(), Arrays.asList(1,2,3));
secondCommission += userPrePaidBillings1.stream().mapToDouble(UserPrePaidBilling::getTotal).sum(); secondCommission += userPrePaidBillings1.stream().mapToDouble(UserPrePaidBilling::getTotal).sum();
......
...@@ -39,7 +39,7 @@ public class PromotionTask { ...@@ -39,7 +39,7 @@ public class PromotionTask {
double totalCommission = 0; double totalCommission = 0;
double secondCommission = 0; double secondCommission = 0;
for (Account promote : promotes) { for (Account promote : promotes) {
List<UserPrePaidBilling> userPrePaidBillings = userPrePaidBillingRepository.findByUsernameAndYearAndMonthAndPayMethodIn(promote.getName(), List<UserPrePaidBilling> userPrePaidBillings = userPrePaidBillingRepository.findByAdministratorAndYearAndMonthAndPayMethodIn(promote.getName(),
YearMonth.now().minusMonths(1).getYear(), YearMonth.now().minusMonths(1).getYear(),
YearMonth.now().minusMonths(1).getMonthValue(), Arrays.asList(1,2,3)); YearMonth.now().minusMonths(1).getMonthValue(), Arrays.asList(1,2,3));
totalCommission += userPrePaidBillings.stream().mapToDouble(UserPrePaidBilling::getTotal).sum(); totalCommission += userPrePaidBillings.stream().mapToDouble(UserPrePaidBilling::getTotal).sum();
...@@ -47,7 +47,7 @@ public class PromotionTask { ...@@ -47,7 +47,7 @@ public class PromotionTask {
List<Account> secondPromotes = accountRepository.findByPromotionCode(promote.getPromotion().getCode()); List<Account> secondPromotes = accountRepository.findByPromotionCode(promote.getPromotion().getCode());
if (secondPromotes != null && secondPromotes.size() > 0) { if (secondPromotes != null && secondPromotes.size() > 0) {
for (Account secondPromote : secondPromotes) { for (Account secondPromote : secondPromotes) {
List<UserPrePaidBilling> userPrePaidBillings1 = userPrePaidBillingRepository.findByUsernameAndYearAndMonthAndPayMethodIn(secondPromote.getName(), List<UserPrePaidBilling> userPrePaidBillings1 = userPrePaidBillingRepository.findByAdministratorAndYearAndMonthAndPayMethodIn(secondPromote.getName(),
YearMonth.now().minusMonths(1).getYear(), YearMonth.now().minusMonths(1).getYear(),
YearMonth.now().minusMonths(1).getMonthValue(), Arrays.asList(1,2,3)); YearMonth.now().minusMonths(1).getMonthValue(), Arrays.asList(1,2,3));
secondCommission += userPrePaidBillings1.stream().mapToDouble(UserPrePaidBilling::getTotal).sum(); secondCommission += userPrePaidBillings1.stream().mapToDouble(UserPrePaidBilling::getTotal).sum();
...@@ -77,7 +77,7 @@ public class PromotionTask { ...@@ -77,7 +77,7 @@ public class PromotionTask {
double totalCommission = 0; double totalCommission = 0;
double secondCommission = 0; double secondCommission = 0;
for (Account promote : promotes) { for (Account promote : promotes) {
List<UserPrePaidBilling> userPrePaidBillings = userPrePaidBillingRepository.findByUsernameAndYearAndMonthAndPayMethodIn(promote.getName(), List<UserPrePaidBilling> userPrePaidBillings = userPrePaidBillingRepository.findByAdministratorAndYearAndMonthAndPayMethodIn(promote.getName(),
YearMonth.now().getYear(), YearMonth.now().getYear(),
YearMonth.now().getMonthValue(), Arrays.asList(1,2,3)); YearMonth.now().getMonthValue(), Arrays.asList(1,2,3));
totalCommission += userPrePaidBillings.stream().mapToDouble(UserPrePaidBilling::getTotal).sum(); totalCommission += userPrePaidBillings.stream().mapToDouble(UserPrePaidBilling::getTotal).sum();
...@@ -85,7 +85,7 @@ public class PromotionTask { ...@@ -85,7 +85,7 @@ public class PromotionTask {
List<Account> secondPromotes = accountRepository.findByPromotionCode(promote.getPromotion().getCode()); List<Account> secondPromotes = accountRepository.findByPromotionCode(promote.getPromotion().getCode());
if (secondPromotes != null && secondPromotes.size() > 0) { if (secondPromotes != null && secondPromotes.size() > 0) {
for (Account secondPromote : secondPromotes) { for (Account secondPromote : secondPromotes) {
List<UserPrePaidBilling> userPrePaidBillings1 = userPrePaidBillingRepository.findByUsernameAndYearAndMonthAndPayMethodIn(secondPromote.getName(), List<UserPrePaidBilling> userPrePaidBillings1 = userPrePaidBillingRepository.findByAdministratorAndYearAndMonthAndPayMethodIn(secondPromote.getName(),
YearMonth.now().getYear(), YearMonth.now().getYear(),
YearMonth.now().getMonthValue(), Arrays.asList(1,2,3)); YearMonth.now().getMonthValue(), Arrays.asList(1,2,3));
secondCommission += userPrePaidBillings1.stream().mapToDouble(UserPrePaidBilling::getTotal).sum(); secondCommission += userPrePaidBillings1.stream().mapToDouble(UserPrePaidBilling::getTotal).sum();
......
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