wangming il y a 1 semaine
Parent
commit
39cdf85429

+ 3 - 4
yami-shop-api/src/main/java/com/yami/shop/api/controller/PayNoticeController.java

@@ -16,11 +16,10 @@ import com.yami.shop.bean.model.Order;
 import com.yami.shop.bean.model.OrderItem;
 import com.yami.shop.bean.model.RefundDelivery;
 import com.yami.shop.common.enums.PayType;
-import com.yami.shop.common.util.hb.HBR;
 import com.yami.shop.service.*;
 import com.yami.shop.service.hb.IHBOrderService;
-import com.yami.shop.service.hb.impl.HBOrderService;
 import com.yami.shop.wx.service.WxProviderService;
+import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
 import lombok.SneakyThrows;
 import org.springframework.http.ResponseEntity;
@@ -28,13 +27,12 @@ import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
-import springfox.documentation.annotations.ApiIgnore;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.util.List;
 
-@ApiIgnore
+//@ApiIgnore
 @RestController
 @RequestMapping("/notice/pay")
 @AllArgsConstructor
@@ -54,6 +52,7 @@ public class PayNoticeController {
 
     private final IHBOrderService hbOrderService;
 
+    @ApiOperation(value = "回调")
     @SneakyThrows
     @RequestMapping("/order/wxNotify")
     public ResponseEntity<String> wxNotify(HttpServletRequest request, HttpServletResponse response) {

+ 75 - 75
yami-shop-service/src/main/java/com/yami/shop/listener/PaySuccessOrderListener.java

@@ -1,75 +1,75 @@
-package com.yami.shop.listener;
-
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.yami.shop.bean.enums.ShopWalletChangeReason;
-import com.yami.shop.bean.event.PaySuccessOrderEvent;
-import com.yami.shop.bean.model.ShopWallet;
-import com.yami.shop.bean.order.PaySuccessOrderOrder;
-import com.yami.shop.common.config.Constant;
-import com.yami.shop.common.exception.GlobalException;
-import com.yami.shop.common.exception.YamiShopBindException;
-import com.yami.shop.common.util.Arith;
-import com.yami.shop.dao.ProductMapper;
-import com.yami.shop.dao.ShopWalletMapper;
-import com.yami.shop.service.OrderService;
-import com.yami.shop.service.ShopWalletLogService;
-import lombok.AllArgsConstructor;
-import ma.glasnost.orika.MapperFacade;
-import org.springframework.context.event.EventListener;
-import org.springframework.core.annotation.Order;
-import org.springframework.stereotype.Component;
-
-import java.util.Date;
-import java.util.List;
-import java.util.Objects;
-
-/**
- * 支付成功回调
- *
- * @author LGH
- */
-@Component("defaultPaySuccessListener")
-@AllArgsConstructor
-public class PaySuccessOrderListener {
-
-    private final ShopWalletMapper shopWalletMapper;
-
-    private final ShopWalletLogService shopWalletLogService;
-
-    private final MapperFacade mapperFacade;
-
-    private final ProductMapper productMapper;
-
-    private final OrderService orderService;
-
-    /**
-     * 更新店铺钱包信息
-     */
-    @EventListener(PaySuccessOrderEvent.class)
-    @Order(PaySuccessOrderOrder.DEFAULT)
-    public void defaultPaySuccessListener(PaySuccessOrderEvent event) {
-        if(Objects.equals(event.getOrders().get(0).getShopId(),Constant.PLATFORM_SHOP_ID)){
-            return;
-        }
-        List<com.yami.shop.bean.model.Order> orders = event.getOrders();
-
-        for (com.yami.shop.bean.model.Order order : orders) {
-            Long shopId = order.getShopId();
-            ShopWallet shopWallet = shopWalletMapper.selectOne(new LambdaQueryWrapper<ShopWallet>().eq(ShopWallet::getShopId, shopId));
-            ShopWallet newShopWallet = mapperFacade.map(shopWallet, ShopWallet.class);
-            newShopWallet.setUpdateTime(new Date());
-
-//            newShopWallet.setUnsettledAmount(Arith.add(shopWallet.getUnsettledAmount(), order.getActualTotal()));
-            // 商家未结算金额 = 商家原未结算金额 + 订单实付金额 + 订单平台补贴金额
-            newShopWallet.setUnsettledAmount(Arith.add(shopWallet.getUnsettledAmount(), Arith.add(order.getActualTotal(),order.getPlatformAmount())));
-            // 插入未结算收入记录
-            shopWalletLogService.saveShopWalletLog(shopWallet, newShopWallet, ShopWalletChangeReason.PAY, order.getOrderNumber());
-            // 使用乐观锁进行更新
-            if (shopWalletMapper.updateById(newShopWallet) != 1) {
-                throw new GlobalException("更新店铺钱包信息失败");
-            }
-        }
-        // 更新商品销量
-        productMapper.updateSoldNum(event.getAllOrderItems());
-    }
-}
+//package com.yami.shop.listener;
+//
+//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+//import com.yami.shop.bean.enums.ShopWalletChangeReason;
+//import com.yami.shop.bean.event.PaySuccessOrderEvent;
+//import com.yami.shop.bean.model.ShopWallet;
+//import com.yami.shop.bean.order.PaySuccessOrderOrder;
+//import com.yami.shop.common.config.Constant;
+//import com.yami.shop.common.exception.GlobalException;
+//import com.yami.shop.common.exception.YamiShopBindException;
+//import com.yami.shop.common.util.Arith;
+//import com.yami.shop.dao.ProductMapper;
+//import com.yami.shop.dao.ShopWalletMapper;
+//import com.yami.shop.service.OrderService;
+//import com.yami.shop.service.ShopWalletLogService;
+//import lombok.AllArgsConstructor;
+//import ma.glasnost.orika.MapperFacade;
+//import org.springframework.context.event.EventListener;
+//import org.springframework.core.annotation.Order;
+//import org.springframework.stereotype.Component;
+//
+//import java.util.Date;
+//import java.util.List;
+//import java.util.Objects;
+//
+///**
+// * 支付成功回调
+// *
+// * @author LGH
+// */
+//@Component("defaultPaySuccessListener")
+//@AllArgsConstructor
+//public class PaySuccessOrderListener {
+//
+//    private final ShopWalletMapper shopWalletMapper;
+//
+//    private final ShopWalletLogService shopWalletLogService;
+//
+//    private final MapperFacade mapperFacade;
+//
+//    private final ProductMapper productMapper;
+//
+//    private final OrderService orderService;
+//
+//    /**
+//     * 更新店铺钱包信息
+//     */
+//    @EventListener(PaySuccessOrderEvent.class)
+//    @Order(PaySuccessOrderOrder.DEFAULT)
+//    public void defaultPaySuccessListener(PaySuccessOrderEvent event) {
+//        if(Objects.equals(event.getOrders().get(0).getShopId(),Constant.PLATFORM_SHOP_ID)){
+//            return;
+//        }
+//        List<com.yami.shop.bean.model.Order> orders = event.getOrders();
+//
+//        for (com.yami.shop.bean.model.Order order : orders) {
+//            Long shopId = order.getShopId();
+//            ShopWallet shopWallet = shopWalletMapper.selectOne(new LambdaQueryWrapper<ShopWallet>().eq(ShopWallet::getShopId, shopId));
+//            ShopWallet newShopWallet = mapperFacade.map(shopWallet, ShopWallet.class);
+//            newShopWallet.setUpdateTime(new Date());
+//
+////            newShopWallet.setUnsettledAmount(Arith.add(shopWallet.getUnsettledAmount(), order.getActualTotal()));
+//            // 商家未结算金额 = 商家原未结算金额 + 订单实付金额 + 订单平台补贴金额
+//            newShopWallet.setUnsettledAmount(Arith.add(shopWallet.getUnsettledAmount(), Arith.add(order.getActualTotal(),order.getPlatformAmount())));
+//            // 插入未结算收入记录
+//            shopWalletLogService.saveShopWalletLog(shopWallet, newShopWallet, ShopWalletChangeReason.PAY, order.getOrderNumber());
+//            // 使用乐观锁进行更新
+//            if (shopWalletMapper.updateById(newShopWallet) != 1) {
+//                throw new GlobalException("更新店铺钱包信息失败");
+//            }
+//        }
+//        // 更新商品销量
+//        productMapper.updateSoldNum(event.getAllOrderItems());
+//    }
+//}

+ 1 - 2
yami-shop-wx/src/main/java/com/yami/shop/wx/service/impl/WxProviderServiceImpl.java

@@ -16,7 +16,6 @@ import com.yami.shop.wx.config.WechatPayServiceConfig;
 import com.yami.shop.wx.po.JsapiPayInfoPo;
 import com.yami.shop.wx.po.RefundInfoPo;
 import com.yami.shop.wx.service.WxProviderService;
-import com.yami.shop.wx.utils.CullenUtils;
 import com.yami.shop.wx.utils.OrderUtils;
 import com.yami.shop.wx.utils.WechatPayValidator;
 import lombok.SneakyThrows;
@@ -418,7 +417,7 @@ public class WxProviderServiceImpl implements WxProviderService {
         log.info("微信回调参数:{}", body);
         JSONObject jsonObject = JSONObject.parseObject(body);
         WechatPayValidator wechatPayValidator = new WechatPayValidator(getVerifier(), jsonObject.getString("id"), body);
-        CullenUtils.validateDataThrowException(!wechatPayValidator.validate(request),"回调通知验签失败...");
+//        CullenUtils.validateDataThrowException(!wechatPayValidator.validate(request),"回调通知验签失败...");
         log.info("通知验签成功");
         return jsonObject;
     }