xiaoyong931011
2023-07-28 cc9ce86cc24c413c9cbd303b8bb4fd9f5ec5a30f
src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallOrderInfoServiceImpl.java
@@ -13,10 +13,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.ApiLeaderListVo;
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.BrandWCPayRequestData;
import cc.mrbird.febs.pay.model.OrderStateDto;
import cc.mrbird.febs.pay.service.IPayService;
@@ -84,6 +81,7 @@
    private final MallElectronicFenceMapper mallElectronicFenceMapper;
    private final MallMemberWalletMapper mallMemberWalletMapper;
    private final MallRollPerkMapper mallRollPerkMapper;
    private final MallMoneyFlowMapper mallMoneyFlowMapper;
    @Override
    @Transactional(rollbackFor = Exception.class)
@@ -111,7 +109,7 @@
        orderInfo.setStatus(OrderStatusEnum.WAIT_PAY.getValue());
        orderInfo.setRemark(addOrderDto.getRemark());
        orderInfo.setOrderType(addOrderDto.getOrderType());
        orderInfo.setDeliveryType(2);
        orderInfo.setDeliveryType(addOrderDto.getDeliveryType());
        if (CollUtil.isEmpty(addOrderDto.getItems())) {
            throw new FebsException("参数错误");
        }
@@ -389,6 +387,7 @@
                    throw new FebsException("兑换券已使用");
                }
                mallRollPerk.setState(2);
                mallRollPerk.setUpdateTime(DateUtil.date());
                mallRollPerkMapper.updateById(mallRollPerk);
                payResultStr = orderInfo.getOrderNo();
@@ -408,12 +407,12 @@
                BigDecimal balanceThree = mallMemberWalletThree.getBalance();
                BigDecimal amountThree = orderInfo.getAmount();
                int reduceThree = memberWalletService.reduce(balanceThree, member.getId(), "balance");
                if (reduceThree == 2) {
                    throw new FebsException("余额不足");
                }
                mallMoneyFlowService.addMoneyFlow(member.getId(), balanceThree.negate(), MoneyFlowTypeEnum.PAY.getValue(),
                        orderInfo.getOrderNo(), FlowTypeEnum.BALANCE.getValue(),"余额支付",2);
//                int reduceThree = memberWalletService.reduce(balanceThree, member.getId(), "balance");
//                if (reduceThree == 2) {
//                    throw new FebsException("余额不足");
//                }
//                mallMoneyFlowService.addMoneyFlow(member.getId(), balanceThree.negate(), MoneyFlowTypeEnum.PAY.getValue(),
//                        orderInfo.getOrderNo(), FlowTypeEnum.BALANCE.getValue(),"余额支付",2);
                //实际支付余额
                BigDecimal amountActualThree = amountThree.subtract(balanceThree).setScale(2, BigDecimal.ROUND_DOWN);
@@ -427,7 +426,7 @@
                }
                wxResultStr = JSONUtil.toJsonStr(brandWCPayRequestDataThree);
                payResultStr = brandWCPayRequestDataThree.getPrepay_id();
                orderInfo.setPayMethod("微信支付");
                orderInfo.setPayMethod("余额加微信");
                amountActualMsg = amountThree.toString();
                break;
            /**
@@ -465,6 +464,8 @@
                mallMoneyFlowService.addMoneyFlow(member.getId(), amountActualOne.negate(), MoneyFlowTypeEnum.PAY.getValue(),
                        orderInfo.getOrderNo(), FlowTypeEnum.BALANCE.getValue(),"余额支付",2);
                amountActualMsg = amountActualOne.toString();
                orderInfo.setPayMethod("积分加余额");
                mallMoneyFlowService.addMoneyFlow(member.getId(), scoreOne.negate(),
                        MoneyFlowTypeEnum.SCORE_PAY.getValue(), orderInfo.getOrderNo(), FlowTypeEnum.SCORE.getValue(),"积分支付",2);
                break;
@@ -501,7 +502,7 @@
                }
                wxResultStr = JSONUtil.toJsonStr(brandWCPayRequestDataTwo);
                payResultStr = brandWCPayRequestDataTwo.getPrepay_id();
                orderInfo.setPayMethod("微信支付");
                orderInfo.setPayMethod("积分加微信");
                amountActualMsg = amountActualTwo.toString();
                break;
            default:
@@ -613,6 +614,9 @@
            long remainTime = DateUtil.between(new Date(), endTime, DateUnit.SECOND, false);
            orderDetailVo.setRemainTime(remainTime);
        }
        String orderNo = orderInfo.getOrderNo();
        List<MoneyFlowVo> moneyFlowVos = mallMoneyFlowMapper.selectMoneyFlowByOrderNo(orderNo,orderInfo.getMemberId());
        orderDetailVo.setMoneyFlowVos(moneyFlowVos);
        return orderDetailVo;
    }