xiaoyong931011
2023-03-01 c3f2f93821ac8d351fe7c9d1f0f28c39b36cfef1
src/main/java/cc/mrbird/febs/pay/controller/XcxPayController.java
@@ -1,9 +1,7 @@
package cc.mrbird.febs.pay.controller;
import cc.mrbird.febs.common.entity.FebsResponse;
import cc.mrbird.febs.common.enumerates.DataDictionaryEnum;
import cc.mrbird.febs.common.enumerates.OrderDeliveryStateEnum;
import cc.mrbird.febs.common.enumerates.OrderStatusEnum;
import cc.mrbird.febs.common.enumerates.*;
import cc.mrbird.febs.common.properties.XcxProperties;
import cc.mrbird.febs.common.utils.RedisUtils;
import cc.mrbird.febs.common.utils.SpringContextHolder;
@@ -13,7 +11,9 @@
import cc.mrbird.febs.mall.entity.MallMoneyFlow;
import cc.mrbird.febs.mall.entity.MallOrderInfo;
import cc.mrbird.febs.mall.mapper.*;
import cc.mrbird.febs.mall.service.IApiMallMemberService;
import cc.mrbird.febs.mall.service.IApiMallMemberWalletService;
import cc.mrbird.febs.mall.service.IMallMoneyFlowService;
import cc.mrbird.febs.pay.model.NotifyData;
import cc.mrbird.febs.pay.model.OrderStateDto;
import cc.mrbird.febs.pay.model.OrderStateMsgVo;
@@ -66,9 +66,13 @@
    @Autowired
    DataDictionaryCustomMapper dataDictionaryCustomMapper;
    @Autowired
    IMallMoneyFlowService mallMoneyFlowService;
    @Autowired
    RedisUtils redisUtils;
    @Autowired
    private IApiMallMemberWalletService memberWalletService;
    @Autowired
    private IApiMallMemberService mallMemberService;
    @Autowired
    private IXcxPayService iXcxPayService;
@@ -109,6 +113,7 @@
                attrStr = data.getAttach();
                JSONObject jsonObject = JSONUtil.parseObj(attrStr);
                String rechargeNo = (String) jsonObject.get("rechargeNo");
                Integer type = (Integer) jsonObject.get("type");
                Long memberId = Long.parseLong(jsonObject.get("memberId").toString());
                // 检验订单状态
                MallMoneyFlow mallMoneyFlow = mallMoneyFlowMapper.selectOneByOrderNoAndMemberId(rechargeNo,memberId);
@@ -132,10 +137,40 @@
                        if (ObjectUtil.isNotEmpty(mallMoneyFlow)) {
                            log.debug("检查支付金额payMoney={},mallMoneyFlow.getPayMoney()={}", payMoney, mallMoneyFlow.getAmount());
                            if(2 == type){
                                mallMemberService.updateMemberAgent(memberId);
                            }
                            memberWalletService.addBalance(payMoney,memberId);
                            mallMoneyFlow.setStatus(2);
                            mallMoneyFlowMapper.updateById(mallMoneyFlow);
                            /**
                             * 充值赠送金额
                             */
                            DataDictionaryCustom giveStateDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                                    DataDictionaryEnum.GIVE_STATE.getType(),
                                    DataDictionaryEnum.GIVE_STATE.getCode());
                            DataDictionaryCustom giveAmountDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                                    DataDictionaryEnum.GIVE_AMOUNT.getType(),
                                    DataDictionaryEnum.GIVE_AMOUNT.getCode());
                            if(ObjectUtil.isNotEmpty(giveStateDic)
                                && "1" == giveStateDic.getValue()
                                    && ObjectUtil.isNotEmpty(giveAmountDic)){
                                BigDecimal giveAmount = ObjectUtil.isEmpty(giveAmountDic.getValue()) ?
                                        BigDecimal.ZERO :
                                        new BigDecimal(giveAmountDic.getValue()).abs().setScale(2,BigDecimal.ROUND_DOWN);
                                mallMoneyFlowService.addMoneyFlow(
                                        memberId,
                                        giveAmount,
                                        MoneyFlowTypeEnum.RECHARGE_SEND.getValue(),
                                        rechargeNo+"ZS",
                                        FlowTypeEnum.BALANCE.getValue());
                                memberWalletService.addBalance(giveAmount,memberId);
                            }
                            RechargeWalletMessageSendDto rechargeWalletMessageSendDto = new RechargeWalletMessageSendDto();
                            rechargeWalletMessageSendDto.setRechargeNo(rechargeNo);
                            rechargeWalletMessageSendDto.setRechargeAmount(payMoney.toString());