Commit 4555b949 authored by renjie's avatar renjie

推广礼金

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