Cui Zhi Feng
2024-09-02 31d3f568fe588e11f610244aa2d462d2f53608e1
积分兑换券的使用和恢复
已修改2个文件
35 ■■■■■ 文件已修改
src/main/java/com/mzl/flower/service/payment/OrderService.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mzl/flower/service/payment/UserPaymentV3Service.java 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mzl/flower/service/payment/OrderService.java
@@ -43,6 +43,7 @@
import com.mzl.flower.service.flower.FlowerService;
import com.mzl.flower.service.menber.MemberGrowthRecordService;
import com.mzl.flower.service.point.CustomerPointService;
import com.mzl.flower.service.point.PointGoodsService;
import com.mzl.flower.service.system.CodeService;
import com.mzl.flower.service.system.WeChatService;
import com.mzl.flower.service.transport.TransportService;
@@ -146,6 +147,9 @@
    @Autowired
    private CustomerPointService customerPointService;
    @Autowired
    private PointGoodsService pointGoodsService;
    public void changeFlower2Cart(CartSaveDTO dto) {
        String userId = SecurityUtils.getUserId();
@@ -503,7 +507,12 @@
    }
    private void usePointGoods(String orderId, List<Long> goodsRecordIdList){
        //TODO 使用积分商品兑换券
        //使用积分商品兑换券
        if(goodsRecordIdList != null && goodsRecordIdList.size() > 0){
            for(Long grId : goodsRecordIdList){
                pointGoodsService.useExchangeGoods(grId, orderId);
            }
        }
    }
    /**
src/main/java/com/mzl/flower/service/payment/UserPaymentV3Service.java
@@ -16,6 +16,7 @@
import com.mzl.flower.mapper.system.UserWechatMapper;
import com.mzl.flower.service.BaseService;
import com.mzl.flower.service.flower.FlowerService;
import com.mzl.flower.service.point.PointGoodsService;
import com.mzl.flower.utils.UUIDGenerator;
import com.wechat.pay.java.core.notification.NotificationParser;
import com.wechat.pay.java.core.notification.RequestParam;
@@ -103,6 +104,12 @@
    @Autowired
    private OrderRefundMapper orderRefundMapper;
    @Autowired
    private OrderPointGoodsMapper orderPointGoodsMapper;
    @Autowired
    private PointGoodsService pointGoodsService;
    /**
     * 微信预支付
@@ -439,8 +446,23 @@
    }
    private void releasePrepayLock(Order order){
        log.info("恢复库存: " + order);
        log.info("恢复库存 积分商品兑换券 优惠券: " + order);
        revertFlowerStock(order.getId());
        //恢复积分商品兑换券
        revertPointGoodsRecord(order.getId());
        //TODO 恢复优惠券
    }
    private void revertPointGoodsRecord(String orderId){
        List<OrderPointGoods> ls = orderPointGoodsMapper.selectList(new QueryWrapper<OrderPointGoods>()
                .eq("order_id", orderId));
        if(ls != null && ls.size() > 0){
            for(OrderPointGoods pg : ls){
                pointGoodsService.revertExchangeGoods(pg.getGoodsRecordId());
            }
        }
    }
    public Map payAgain(String orderId){