xiaoyong931011
2023-03-10 417842b77970a8647945cff4ada68f3707f555e5
src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallOrderInfoServiceImpl.java
@@ -14,10 +14,7 @@
import cc.mrbird.febs.mall.entity.*;
import cc.mrbird.febs.mall.mapper.*;
import cc.mrbird.febs.mall.service.*;
import cc.mrbird.febs.mall.vo.ApiShopApplyVo;
import cc.mrbird.febs.mall.vo.OrderDetailVo;
import cc.mrbird.febs.mall.vo.OrderListVo;
import cc.mrbird.febs.mall.vo.OrderRefundVo;
import cc.mrbird.febs.mall.vo.*;
import cc.mrbird.febs.pay.model.AgreementPayDto;
import cc.mrbird.febs.pay.model.AgreementSignDto;
import cc.mrbird.febs.pay.model.UnipayDto;
@@ -42,6 +39,7 @@
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.util.*;
@@ -79,6 +77,7 @@
    private final MallShopApplyMapper mallShopApplyMapper;
    private final DataDictionaryCustomMapper dataDictionaryCustomMapper;
    private final MallAchieveRecordMapper mallAchieveRecordMapper;
    private final MallMemberWalletMapper mallMemberWalletMapper;
    @Override
    @Transactional(rollbackFor = Exception.class)
@@ -349,9 +348,9 @@
                orderInfo.setPayTime(new Date());
                orderInfo.setPayResult("1");
                changeWallet(orderInfo.getId(), member.getId());
                agentProducer.sendAutoLevelUpMsg(member.getId());
                changeWallet(orderInfo.getId());
                //发送补贴消息
                agentProducer.sendPerkMoneyMsg(orderInfo.getId());
//                agentProducer.sendOrderReturn(orderInfo.getId());
                break;
            case "4":
@@ -431,10 +430,10 @@
     *      增加贡献值,增加流水
     *      产生一条业绩记录
     * @param orderId
     * @param memberId
     */
    public void changeWallet(Long orderId,Long memberId){
    public void changeWallet(Long orderId){
        MallOrderInfo orderInfo = this.baseMapper.selectById(orderId);
        Long memberId = orderInfo.getMemberId();
        boolean hasTc = false;
        //总贡献值
        BigDecimal starSum = BigDecimal.ZERO;
@@ -453,7 +452,7 @@
                 */
                if (mallGoods.getIsNormal() == 2) {
                    hasTc = true;
                    BigDecimal star = mallGoods.getStar();
                    BigDecimal star = mallGoods.getStar()==null ? BigDecimal.ZERO : mallGoods.getStar();
                    starSum = starSum.add(star);
                    scoreSum = scoreSum.add(
                            new BigDecimal(mallGoods.getPresentPrice())
@@ -466,7 +465,7 @@
             * 增加贡献值,增加流水
             */
            if (starSum.compareTo(BigDecimal.ZERO) > 0) {
                memberWalletService.add(starSum, memberId, "star");
                mallMemberWalletMapper.addStarByMemberId(starSum.intValue(), memberId);
                mallMoneyFlowService.addMoneyFlow(
                        memberId,
                        starSum,
@@ -834,7 +833,7 @@
        BigDecimal score = ObjectUtil.isEmpty(addOrderDto.getScore()) ? BigDecimal.ZERO : addOrderDto.getScore();
        if(ObjectUtil.isNotEmpty(scorePercentDic)){
            //商品的现金折扣比例
            BigDecimal scorePercent = new BigDecimal(scorePercentDic.getValue()).divide(new BigDecimal(100), BigDecimal.ROUND_DOWN);
            BigDecimal scorePercent = new BigDecimal(scorePercentDic.getValue()).multiply(BigDecimal.valueOf(0.01));
            //最大折扣金额对应需要的总积分数目
            BigDecimal scorePercentMaxAmount = total.multiply(scorePercent);
            BigDecimal scoreChange = BigDecimal.ONE;
@@ -843,7 +842,9 @@
            }
            scorePercentMaxAmount = scorePercentMaxAmount.multiply(scoreChange);
            if(scorePercentMaxAmount.compareTo(score) < 0){
                return false;
                flag = false;
            }else{
                flag = true;
            }
        }else{
            flag = true;
@@ -851,4 +852,20 @@
        return flag;
    }
    @Override
    public ApiScoreSetVo myScoreSet() {
        ApiScoreSetVo apiScoreSetVo = new ApiScoreSetVo();
        DataDictionaryCustom scorePercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                DataDictionaryEnum.SCORE_PERCENT.getType(),
                DataDictionaryEnum.SCORE_PERCENT.getCode()
        );
        DataDictionaryCustom scoreChangeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                DataDictionaryEnum.SCORE_CHANGE.getType(),
                DataDictionaryEnum.SCORE_CHANGE.getCode()
        );
        apiScoreSetVo.setScorePercent(new BigDecimal(scorePercentDic.getValue()).multiply(BigDecimal.valueOf(0.01)).setScale(2,BigDecimal.ROUND_DOWN));
        apiScoreSetVo.setScoreChange(new BigDecimal(scoreChangeDic.getValue()).setScale(2,BigDecimal.ROUND_DOWN));
        return apiScoreSetVo;
    }
}