Commit 7e4e6398 authored by renjie's avatar renjie

账单bug

parent 2efbb398
......@@ -7,6 +7,7 @@ import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository;
import java.util.Arrays;
import java.util.List;
@Repository
......@@ -22,9 +23,9 @@ public interface UserPrePaidBillingRepository extends MongoRepository<UserPrePai
Page<UserPrePaidBilling> findAllByYearBetweenAndMonthBetween(Pageable pageable, int year1, int year2, int month1, int month2);
List<UserPrePaidBilling> findByUsernameAndYearAndMonthAndPayMethodIsNot(String username, int year, int month, int payMethod);
List<UserPrePaidBilling> findByUsernameAndYearAndMonthAndPayMethodIn(String username, int year, int month, List<Integer> payMethod);
List<UserPrePaidBilling> findByUsernameAndPayMethodIsNot(String username, int payMethod);
List<UserPrePaidBilling> findByUsernameAndPayMethodIn(String username, List<Integer> payMethod);
List<UserPrePaidBilling> findByUsernameAndChargeType(String username, int chargeType);
......
......@@ -400,9 +400,9 @@ public class AccountServiceImpl implements AccountService {
double totalCommission = 0;
totalCommission = 0;
for (Account promote : promotes) {
List<UserPrePaidBilling> userPrePaidBillings = prePaidBillingRepository.findByUsernameAndYearAndMonthAndPayMethodIsNot(promote.getName(),
List<UserPrePaidBilling> userPrePaidBillings = prePaidBillingRepository.findByUsernameAndYearAndMonthAndPayMethodIn(promote.getName(),
YearMonth.now().getYear(),
YearMonth.now().getMonthValue(), 0);
YearMonth.now().getMonthValue(), Arrays.asList(1,2));
totalCommission += userPrePaidBillings.stream().mapToDouble(UserPrePaidBilling::getTotal).sum();
}
......
......@@ -22,10 +22,7 @@ import java.text.SimpleDateFormat;
import java.time.YearMonth;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.StringTokenizer;
import java.util.*;
import java.util.stream.DoubleStream;
......@@ -112,7 +109,7 @@ public class AdministratorServiceImpl implements AdministratorService {
Page<UserPrePaidBilling> userBillingList = userPrePaidBillingRepository.findAllByUsername(name, pageable);
if (userBillingList == null)
throw new ClientRequestException(AccountErrorCode.NAMENOTEXIST, "Username does not exist: " + name);
List<UserPrePaidBilling> userPrePaidBillings = userPrePaidBillingRepository.findByUsernameAndPayMethodIsNot(name, 0);
List<UserPrePaidBilling> userPrePaidBillings = userPrePaidBillingRepository.findByUsernameAndPayMethodIn(name, Arrays.asList(1,2));
double totalexpense = 0;
if (userPrePaidBillings != null)
totalexpense = userPrePaidBillings.stream().mapToDouble(UserPrePaidBilling::getTotal).sum();
......
......@@ -486,7 +486,7 @@ public class PaymentServiceImpl implements PaymentService {
userBalance.setUsername(username);
userBalance.setUsed(0);
userBalance.setBalanced(amount);
bill.setBalanced(userBalance.getBalanced() + amount);
bill.setBalanced(amount);
userPrePaidBillingRepository.save(bill);
return userBalanceRepository.save(userBalance);
} else {
......
......@@ -15,6 +15,7 @@ import org.springframework.stereotype.Component;
import java.time.Instant;
import java.time.YearMonth;
import java.time.ZoneOffset;
import java.util.Arrays;
import java.util.List;
@Component
......@@ -37,9 +38,9 @@ public class PromotionTask {
List<Account> promotes = accountRepository.findByPromotionCode(code);
double totalCommission = 0;
for (Account promote : promotes) {
List<UserPrePaidBilling> userPrePaidBillings = userPrePaidBillingRepository.findByUsernameAndYearAndMonthAndPayMethodIsNot(promote.getName(),
List<UserPrePaidBilling> userPrePaidBillings = userPrePaidBillingRepository.findByUsernameAndYearAndMonthAndPayMethodIn(promote.getName(),
YearMonth.now().minusMonths(1).getYear(),
YearMonth.now().minusMonths(1).getMonthValue(), 0);
YearMonth.now().minusMonths(1).getMonthValue(), Arrays.asList(1,2));
totalCommission += userPrePaidBillings.stream().mapToDouble(UserPrePaidBilling::getTotal).sum();
}
Promotion promotion = account.getPromotion();
......
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