Administrator
2025-06-10 92c26cea4de00349b346f71da3cf530b26c31eb0
src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallActServiceImpl.java
@@ -3,8 +3,10 @@
import cc.mrbird.febs.common.enumerates.DataDictionaryEnum;
import cc.mrbird.febs.common.enumerates.FlowTypeEnum;
import cc.mrbird.febs.common.enumerates.MoneyFlowTypeEnum;
import cc.mrbird.febs.common.enumerates.ScoreFlowTypeEnum;
import cc.mrbird.febs.common.exception.FebsException;
import cc.mrbird.febs.common.utils.LoginUserUtil;
import cc.mrbird.febs.common.utils.MallUtils;
import cc.mrbird.febs.mall.dto.ApiMallActListDto;
import cc.mrbird.febs.mall.dto.ApiMallActWinDetailsDto;
import cc.mrbird.febs.mall.entity.*;
@@ -134,7 +136,7 @@
        BigDecimal prizeScore = wallet.getPrizeScore();
        Integer actScoreCnt = mallActSet.getActScoreCnt();
        if(prizeScore.compareTo(new BigDecimal(actScoreCnt))<0){
            throw new FebsException("竞猜积分不足");
            throw new FebsException("积分不足");
        }
        /**
         * 中奖概率 20%
@@ -150,7 +152,7 @@
                DataDictionaryEnum.WIN_CASH.getCode());
        String scoreDicValue = scoreDic.getValue() == null? "0":scoreDic.getValue();
        String cashDicValue = cashDic.getValue() == null? "0":cashDic.getValue();
        BigDecimal totalProbability = new BigDecimal(scoreDicValue).add(new BigDecimal(cashDicValue));
        BigDecimal totalProbability = new BigDecimal(scoreDicValue).multiply(new BigDecimal(cashDicValue));
        //获取那个更大一点的几率
        BigDecimal maxProbability = BigDecimal.ZERO;
        BigDecimal minProbability = BigDecimal.ZERO;
@@ -559,16 +561,40 @@
        // 消耗积分
        BigDecimal useScore = new BigDecimal(actScoreCnt);
        mallMemberWalletService.reduce(useScore, wallet.getMemberId(), "prizeScore");
        mallMoneyFlowService.addMoneyFlow(wallet.getMemberId(), useScore.negate(), MoneyFlowTypeEnum.PRIZE.getValue(), null, FlowTypeEnum.PRIZE_SCORE.getValue());
        mallMoneyFlowService.addMoneyFlow(
                wallet.getMemberId(),
                useScore.negate(),
                ScoreFlowTypeEnum.LUCKY_DRAW.getValue(),
                MallUtils.getOrderNum(),
                FlowTypeEnum.PRIZE_SCORE.getValue(),
                StrUtil.format(ScoreFlowTypeEnum.LUCKY_DRAW.getDesc(),useScore),
                2
        );
        if (apiMallAwardDetailsVo.getAwardType() != 3) {
            BigDecimal prize = new BigDecimal(apiMallAwardDetailsVo.getAwardValue());
            if (apiMallAwardDetailsVo.getAwardType() == 1) {
                mallMemberWalletService.add(prize, wallet.getMemberId(), "prizeScore");
                mallMoneyFlowService.addMoneyFlow(wallet.getMemberId(), prize, MoneyFlowTypeEnum.PRIZE.getValue(), null, FlowTypeEnum.PRIZE_SCORE.getValue());
                mallMoneyFlowService.addMoneyFlow(
                        wallet.getMemberId(),
                        prize,
                        ScoreFlowTypeEnum.LUCKY_DRAW_SCORE.getValue(),
                        MallUtils.getOrderNum(),
                        FlowTypeEnum.PRIZE_SCORE.getValue(),
                        StrUtil.format(ScoreFlowTypeEnum.LUCKY_DRAW_SCORE.getDesc(),apiMallAwardDetailsVo.getAwardName()),
                        2
                );
            } else if (apiMallAwardDetailsVo.getAwardType() == 2) {
                mallMemberWalletService.add(prize, wallet.getMemberId(), "commission");
                mallMoneyFlowService.addMoneyFlow(wallet.getMemberId(), prize, MoneyFlowTypeEnum.PRIZE.getValue(), null, FlowTypeEnum.COMMISSION.getValue());
                mallMoneyFlowService.addMoneyFlow(
                        wallet.getMemberId(),
                        prize,
                        ScoreFlowTypeEnum.LUCKY_DRAW_COMMISSION.getValue(),
                        MallUtils.getOrderNum(),
                        FlowTypeEnum.COMMISSION.getValue(),
                        StrUtil.format(ScoreFlowTypeEnum.LUCKY_DRAW_COMMISSION.getDesc(),apiMallAwardDetailsVo.getAwardName()),
                        2
                );
            }
        }
        return apiMallAwardDetailsVo;