xiaoyong931011
2022-08-08 519ccbf3bd32e3f691432562b9e1a887e28bb170
20220808
2 files modified
30 ■■■■ changed files
src/main/java/cc/mrbird/febs/mall/service/impl/MemberProfitServiceImpl.java 17 ●●●● patch | view | raw | blame | history
src/test/java/cc/mrbird/febs/ProfitTest.java 13 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/mall/service/impl/MemberProfitServiceImpl.java
@@ -61,6 +61,9 @@
            return;
        }
        /**
         *
         */
        if (profitDate == null) {
            profitDate = DateUtil.offset(new Date(), DateField.DAY_OF_YEAR, -1);
        }
@@ -68,6 +71,7 @@
//        BigDecimal tcIncome = mallOrderInfoMapper.selectTotalAmountUnCostForDate(profitDate, null, "D", 2);
        // 普通商品业绩
//        BigDecimal normalIncome = mallOrderInfoMapper.selectTotalAmountUnCostForDate(profitDate, null, "D", 1);
        //今日总业绩
        BigDecimal totalIncome = mallAchieveRecordMapper.selectAchieveTotal("D", profitDate);
        if (totalIncome.compareTo(BigDecimal.ZERO) == 0) {
@@ -113,9 +117,9 @@
                BigDecimal preStaticProfit = staticProfit.divide(new BigDecimal(list.size()), 2, RoundingMode.HALF_UP);
                for (Map<String, Object> item : list) {
                    Long memberId = (Long) item.get("memberId");
//                    Long memberId = (Long) item.get("memberId");
                    String orderNo = (String) item.get("orderNo");
                    changeAllScoreAndCommission(preStaticProfit,orderNo);
//                    int reduce = walletService.reduce(preStaticProfit, memberId, "score");
//                    if (reduce == 2) {
//                        break;
@@ -124,12 +128,19 @@
//                    walletService.add(preStaticProfit, memberId, "commission");
//                    moneyFlowService.addMoneyFlow(memberId, preStaticProfit, MoneyFlowTypeEnum.STATIC_BONUS.getValue(), orderNo, FlowTypeEnum.COMMISSION.getValue());
//                    moneyFlowService.addMoneyFlow(memberId, preStaticProfit.negate(), MoneyFlowTypeEnum.STATIC_BONUS.getValue(), orderNo, FlowTypeEnum.SCORE.getValue());
                    changeScoreAndCommission(memberId, preStaticProfit, MoneyFlowTypeEnum.STATIC_BONUS.getValue(), orderNo);
//                    changeScoreAndCommission(memberId, preStaticProfit, MoneyFlowTypeEnum.STATIC_BONUS.getValue(), orderNo);
                }
            }
        }
    }
    public void changeAllScoreAndCommission(BigDecimal preStaticProfit,String orderNo){
        List<MallMember> members = mallMemberMapper.selectList(null);
        for(MallMember mallMember : members){
            changeScoreAndCommission(mallMember.getId(), preStaticProfit, MoneyFlowTypeEnum.STATIC_BONUS.getValue(), orderNo);
        }
    }
    @Override
    public void dynamicProfit(Long orderId) {
        dynamicProfit(orderId, 2);
src/test/java/cc/mrbird/febs/ProfitTest.java
@@ -43,10 +43,10 @@
    }
    @Test
    public void staticProfit() {
        memberProfitService.staticProfit(new Date());
    }
//    @Test
//    public void staticProfit() {
//        memberProfitService.staticProfit(new Date());
//    }
    @Test
    public void thankfulProfit() {
@@ -97,4 +97,9 @@
    public void scorePool(){
        memberProfitService.scorePool();
    }
    @Test
    public void staticProfit(){
        memberProfitService.staticProfit(null);
    }
}