Prechádzať zdrojové kódy

update:支付宝小程序支付

liujunchi 3 rokov pred
rodič
commit
cb731a914b

+ 1 - 1
cooleshow-mall/mall-pay/src/main/java/com/yonge/cooleshow/sdk/adapay/PaymentSdk.java

@@ -221,7 +221,7 @@ public class PaymentSdk {
     /**
      *  查看退款订单
      *
-     * {
+     * @param {
      *     "status": "succeeded",
      *     "prod_mode": "true",
      *     "refunds": [

+ 16 - 0
cooleshow-mall/mall-pay/src/main/java/com/yonge/cooleshow/sdk/req/OrderPayReq.java

@@ -50,6 +50,22 @@ public class OrderPayReq {
     @ApiModelProperty(value = "拉起支付信息",hidden = true)
     private String payInfo;
 
+    public String getBuyerId() {
+        return buyerId;
+    }
+
+    public void setBuyerId(String buyerId) {
+        this.buyerId = buyerId;
+    }
+
+    public String getReason() {
+        return reason;
+    }
+
+    public void setReason(String reason) {
+        this.reason = reason;
+    }
+
     public void orderStatus(Integer orderStatus) {
         if (orderStatus == 0) {
             this.orderStatus = OrderStatusEnum.PAYING;

+ 5 - 1
cooleshow-mall/mall-pay/src/main/java/com/yonge/cooleshow/service/impl/AdapayPaymentServiceImpl.java

@@ -68,7 +68,11 @@ public class AdapayPaymentServiceImpl implements PaymentService {
         //异步通知地址
         paymentReq.setNotify_url(HuifuConfiguration.getHuifuProperties().getNotifyUrl());
 
-        if (PayChannelEnum.wx_lite.equals(payReq.getPayChannel())) {
+        if (PayChannelEnum.alipay_lite.equals(payReq.getPayChannel())) {
+            Map<String, Object> expend = new HashMap<>();
+            expend.put("buyer_id", payReq.getBuyerId());
+            paymentReq.setExpend(expend);
+        } else if (PayChannelEnum.wx_lite.equals(payReq.getPayChannel())) {
             Map<String, Object> expend = new HashMap<>();
             expend.put("open_id", payReq.getOpenId());
             paymentReq.setExpend(expend);

+ 14 - 10
cooleshow-mall/mall-portal/src/main/java/com/yonge/cooleshow/portal/controller/PaymentController.java

@@ -17,6 +17,7 @@ import com.yonge.toolset.base.exception.BizException;
 import com.yonge.toolset.utils.web.WebUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.redisson.api.RLock;
 import org.redisson.api.RedissonClient;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -112,22 +113,25 @@ public class PaymentController extends BaseController {
         payReq.setUserId(user.getId());
         payReq.setIpAddress(WebUtil.getRemoteIp(request));
 
-        Future<OrderPayRes> orderPayResFuture = DistributedLock.of(redissonClient)
-              .callIfLockCanGet(OrdeerCacherEnmu.LOCK_PAY_ORDER.getRedisKey(user.getId()),
-                                () -> portalOrderService.orderPay(payReq), 60L, TimeUnit.SECONDS);
-
+        RLock lock = redissonClient.getLock(OrdeerCacherEnmu.LOCK_PAY_ORDER.getRedisKey(user.getId()));
         try {
-            OrderPayRes orderPayRes = orderPayResFuture.get();
-            if (orderPayRes.isStatus()) {
-                return succeed(orderPayRes);
-            }  else {
-                return failed(orderPayRes.getMessage());
+            boolean b = lock.tryLock(60, TimeUnit.SECONDS);
+            if (b) {
+                OrderPayRes orderPayRes = portalOrderService.orderPay(payReq);
+                if (orderPayRes.isStatus()) {
+                    return succeed(orderPayRes);
+                }  else {
+                    return failed(orderPayRes.getMessage());
+                }
             }
+            return failed("请求超时");
         }catch (BizException e) {
             return failed(e.getMessage());
-        }catch (Exception e) {
+        } catch (Exception e) {
             e.printStackTrace();
             return HttpResponseResult.failed("付款失败");
+        }finally {
+            lock.unlock();
         }
     }
 }