Commit dc53301b authored by renjie's avatar renjie Committed by Administrator

Staging

parent 1cf6fd96
...@@ -29,7 +29,7 @@ public interface AccountRepository extends MongoRepository<Account, String>, Acc ...@@ -29,7 +29,7 @@ public interface AccountRepository extends MongoRepository<Account, String>, Acc
Page<Account> findAllBySignupDateBetween(Pageable pageable, Date startDate, Date endDate); Page<Account> findAllBySignupDateBetween(Pageable pageable, Date startDate, Date endDate);
List<Account> findAllBySignupDateBetweenAndPromotionCode(Date startDate, Date endDate, String promotionCode); List<Account> findAllBySignupDateBetweenAndPromotionCodeAndParentIsNull(Date startDate, Date endDate, String promotionCode);
Page<Account> findAllBySignupDateBetweenAndPromotionCodeAndParentIsNull(Pageable pageable, Date startDate, Date endDate, String promotionCode); Page<Account> findAllBySignupDateBetweenAndPromotionCodeAndParentIsNull(Pageable pageable, Date startDate, Date endDate, String promotionCode);
......
...@@ -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> findByUsernameAndPayMethodInAndTimestampGreaterThanAndTimestampLessThan(String username, List<Integer> payMehtods, long time1, long time2); List<UserPrePaidBilling> findByAdministratorAndPayMethodInAndTimestampBetween(String username, List<Integer> payMehtods, long time1, long time2);
List<UserPrePaidBilling> findByUsernameAndChargeTypeAndTimestampGreaterThanAndTimestampLessThan(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();
...@@ -529,7 +529,7 @@ public class AccountServiceImpl implements AccountService { ...@@ -529,7 +529,7 @@ public class AccountServiceImpl implements AccountService {
if (inviter != null) if (inviter != null)
param.put("referral", inviter.getName() + "(" + user.getPromotionCode() + ")"); param.put("referral", inviter.getName() + "(" + user.getPromotionCode() + ")");
else else
param.put("referral", ""); param.put("referral", "123456");
com.edgec.browserbackend.common.commons.utils.SmsUtils.sendNewAccountSms("15919921106", com.edgec.browserbackend.common.commons.utils.SmsUtils.SmsTemplateCode.NEWACCOUNT, param); com.edgec.browserbackend.common.commons.utils.SmsUtils.sendNewAccountSms("15919921106", com.edgec.browserbackend.common.commons.utils.SmsUtils.SmsTemplateCode.NEWACCOUNT, param);
if (inviter != null) { if (inviter != null) {
...@@ -1201,11 +1201,15 @@ public class AccountServiceImpl implements AccountService { ...@@ -1201,11 +1201,15 @@ public class AccountServiceImpl implements AccountService {
throw new ClientRequestException(AccountErrorCode.NAMENOTEXIST); throw new ClientRequestException(AccountErrorCode.NAMENOTEXIST);
if (isAgree) { if (isAgree) {
account.setAuthorized(2); account.setAuthorized(2);
CompanyAuthorize companyAuthorize = companyAuthorizeRepository.findByUsername(username);
account.setCompanyName(companyAuthorize.getCompanyName());
repository.save(account); repository.save(account);
} }
else { else {
account.setAuthorized(3); account.setAuthorized(3);
account.setCompanyName(null);
repository.save(account); repository.save(account);
CompanyAuthorize companyAuthorize = companyAuthorizeRepository.findByUsername(username); CompanyAuthorize companyAuthorize = companyAuthorizeRepository.findByUsername(username);
if (companyAuthorize != null) { if (companyAuthorize != null) {
if (companyAuthorize.getCompanyLicenseId() != null) if (companyAuthorize.getCompanyLicenseId() != null)
......
...@@ -147,7 +147,6 @@ public class AdministratorServiceImpl implements AdministratorService { ...@@ -147,7 +147,6 @@ public class AdministratorServiceImpl implements AdministratorService {
List<UserPrePaidBilling> userPrePaidBillings_child = userPrePaidBillingRepository.findByUsernameAndPayMethodIn(child.getName(), Arrays.asList(1,2)); List<UserPrePaidBilling> userPrePaidBillings_child = userPrePaidBillingRepository.findByUsernameAndPayMethodIn(child.getName(), Arrays.asList(1,2));
if (userPrePaidBillings_child != null) if (userPrePaidBillings_child != null)
childexpense += userPrePaidBillings_child.stream().mapToDouble(UserPrePaidBilling::getTotal).sum(); childexpense += userPrePaidBillings_child.stream().mapToDouble(UserPrePaidBilling::getTotal).sum();
childwithdrawn += child.getPromotion().getWithdrawn();
UserBalance userBalance_child = userBalanceRepository.findById(child.getName()).orElse(null); UserBalance userBalance_child = userBalanceRepository.findById(child.getName()).orElse(null);
if (userBalance_child != null) { if (userBalance_child != null) {
childbalanced += userBalance_child.getBalanced(); childbalanced += userBalance_child.getBalanced();
...@@ -396,32 +395,41 @@ public class AdministratorServiceImpl implements AdministratorService { ...@@ -396,32 +395,41 @@ 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<>();
if (accountPage.getNumberOfElements() > 0) {
accountPage.get().forEach(account1 -> { accountPage.get().forEach(account1 -> {
accountPromotionDtos.add(new AccountPromotionDto(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.findAllBySignupDateBetweenAndPromotionCodeAndParentIsNull(dateTime1, dateTime2, account.getPromotion().getCode());
Promotion promotion = new Promotion(); Promotion promotion = new Promotion();
Account finalAccount = account; Account finalAccount = account;
if (accounts != null && accounts.size() > 0) {
accounts.forEach(x -> { accounts.forEach(x -> {
promotion.setInvitedUsers(promotion.getInvitedUsers() + 1); promotion.setInvitedUsers(promotion.getInvitedUsers() + 1);
double totalCommission = userPrePaidBillingRepository.findByUsernameAndPayMethodInAndTimestampGreaterThanAndTimestampLessThan(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 && userPrePaidBillings.size() > 0)
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.findByUsernameAndChargeTypeAndTimestampGreaterThanAndTimestampLessThan(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));
if (userPrePaidBillings1 != null && userPrePaidBillings1.size() > 0)
secondCommission += userPrePaidBillings1.stream().mapToDouble(UserPrePaidBilling::getTotal).sum(); secondCommission += userPrePaidBillings1.stream().mapToDouble(UserPrePaidBilling::getTotal).sum();
} }
} }
...@@ -430,11 +438,12 @@ public class AdministratorServiceImpl implements AdministratorService { ...@@ -430,11 +438,12 @@ public class AdministratorServiceImpl implements AdministratorService {
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;
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage()); log.error(e.getMessage(), e);
throw new ClientRequestException(BrowserErrorCode.UNKNOWN); throw new ClientRequestException(BrowserErrorCode.UNKNOWN);
} }
} }
......
...@@ -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