Commit 4555b949 authored by renjie's avatar renjie

推广礼金

parent 403e8582
......@@ -13,11 +13,12 @@ public class Promotion {
private int invitedUsers;
//好友当月消费
private int commission;
//好友以前消费
private int commissionLeft;
//好友上月总消费
private int commissionLastMonth;
private boolean isSale;
private double gift;
private double giftLeft;
//所有未提现金额
private double allGift;
public int getCommission() {
return commission;
......@@ -59,19 +60,19 @@ public class Promotion {
this.gift = gift;
}
public double getGiftLeft() {
return giftLeft;
public int getCommissionLastMonth() {
return commissionLastMonth;
}
public void setCommissionLeft(int commissionLeft) {
this.commissionLeft = commissionLeft;
public void setCommissionLastMonth(int commissionLastMonth) {
this.commissionLastMonth = commissionLastMonth;
}
public int getCommissionLeft() {
return commissionLeft;
public double getAllGift() {
return allGift;
}
public void setGiftLeft(double giftLeft) {
this.giftLeft = giftLeft;
public void setAllGift(double allGift) {
this.allGift = allGift;
}
}
......@@ -37,4 +37,5 @@ public interface AccountRepository extends MongoRepository<Account, String>, Acc
List<Account> findByPromotionCode(String code);
int countByPromotionCodeAndParentIsNull(String promotionCode);
}
......@@ -392,6 +392,25 @@ public class AccountServiceImpl implements AccountService {
current.setQueryIpUrlList(queryIpUrlList);
current.setWhiteList(whiteList);
int invitedUsers = repository.countByPromotionCodeAndParentIsNull(account.getPromotion().getCode());
String code = account.getPromotion().getCode();
List<Account> promotes = repository.findByPromotionCode(code);
double totalCommission = 0;
totalCommission = 0;
for (Account promote : promotes) {
List<UserPrePaidBilling> userPrePaidBillings = prePaidBillingRepository.findByUsernameAndYearAndMonthAndPayMethodIsNot(promote.getName(),
YearMonth.now().getYear(),
YearMonth.now().getMonthValue(), 0);
totalCommission += userPrePaidBillings.stream().mapToDouble(UserPrePaidBilling::getTotal).sum();
}
account.getPromotion().setCommission((int)totalCommission);
account.getPromotion().setInvitedUsers(invitedUsers);
repository.save(account);
resultDto.setStatus(0);
resultDto.setData(current);
} catch (Exception e) {
......
......@@ -43,8 +43,9 @@ public class PromotionTask {
totalCommission += userPrePaidBillings.stream().mapToDouble(UserPrePaidBilling::getTotal).sum();
}
Promotion promotion = account.getPromotion();
promotion.setCommission((int)totalCommission);
promotion.setCommissionLastMonth((int)totalCommission);
promotion.setGift(totalCommission * 8/100);
promotion.setAllGift(promotion.getAllGift() + promotion.getGift());
accountRepository.save(account);
}
}
......
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