wangming 4 долоо хоног өмнө
parent
commit
ddfa55e84b

+ 8 - 7
yami-shop-api/src/main/java/com/yami/shop/api/controller/PayController.java

@@ -12,6 +12,7 @@ import com.yami.shop.bean.app.param.PayParam;
 import com.yami.shop.bean.model.Order;
 import com.yami.shop.bean.model.RefundDelivery;
 import com.yami.shop.bean.pay.PayInfoDto;
+import com.yami.shop.common.exception.GlobalException;
 import com.yami.shop.common.util.Arith;
 import com.yami.shop.common.util.IPHelper;
 import com.yami.shop.security.api.model.YamiUser;
@@ -77,12 +78,12 @@ public class PayController {
     @PostMapping("/pay")
     @ApiOperation(value = "根据订单号进行支付", notes = "根据订单号进行支付")
     public ResponseEntity<?> pay(@Valid @RequestBody PayParam payParam) {
-//        YamiUser user = SecurityUtils.getUser();
-//        String userId = user.getUserId();
-//        if (!user.isEnabled()) {
-//            throw new GlobalException("您已被禁用,不能购买,请联系平台客服");
-//        }
-        PayInfoDto payInfo = payService.pay("204d3502c98a4b0c9d0904492edccf61", payParam);
+        YamiUser user = SecurityUtils.getUser();
+        String userId = user.getUserId();
+        if (!user.isEnabled()) {
+            throw new GlobalException("您已被禁用,不能购买,请联系平台客服");
+        }
+        PayInfoDto payInfo = payService.pay(userId, payParam);
 
         if (payInfo.getPayAmount() < 0.01 && payInfo.getIsScore() == 1) {
             return ResponseEntity.ok().build();
@@ -93,7 +94,7 @@ public class PayController {
         po.setDescription(payInfo.getBody());
         //po.setTotal((int) Arith.mul(payInfo.getPayAmount(), 100));
         po.setTotal(1);
-        po.setOpenId("owrSr6y0TGPHBU2tgMVoCO13Gjww");
+        po.setOpenId(user.getBizUserId());
         po.setOutTradeNo(payInfo.getPayNo());
         po.setNotifyUrl(getNotifyUrl("http://localhost:8112"));
         return ResponseEntity.ok(wxProviderService.subJsapi(po));