Browse Source

Merge branch 'zfb_pay'

zoujiajian 3 năm trước cách đây
mục cha
commit
5a509532f4

+ 1 - 1
netflix-dao/src/main/java/com/cyksj/model/entity/ShopConfig.java

@@ -14,7 +14,7 @@ import lombok.Setter;
 public class ShopConfig extends BaseEntity{
 
     /**
-     * 崇宇支付宝商户
+     * 品如支付宝商户
      */
     public static final String ZFB_DEFAULT_APP_ID = "2021003159660212";
 

+ 21 - 0
netflix-dao/src/main/java/com/cyksj/model/request/AlipayOrderDonReq.java

@@ -0,0 +1,21 @@
+package com.cyksj.model.request;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.validation.constraints.NotNull;
+
+/*
+ *项目名: netflix
+ *文件名: AlipayOrderDonReq
+ *创建者: JavaZou
+ *创建时间:2023/3/2 15:19
+ */
+@Getter
+@Setter
+public class AlipayOrderDonReq {
+	@NotNull
+	private Long orderId;
+
+	private String returnUrl;
+}

+ 1 - 1
netflix-service/src/main/java/com/cyksj/service/order/OrderDonService.java

@@ -51,7 +51,7 @@ public interface OrderDonService extends IService<OrderDon> {
     /**
      * 支付宝预支付
      */
-    AliPayParams aliPay(Long orderId, String productCode, String qrPayMode) throws Exception;
+    AliPayParams aliPay(Long orderId, String returnUrl, String productCode, String qrPayMode) throws Exception;
 
     /**
      * 支付宝回调

+ 6 - 4
netflix-service/src/main/java/com/cyksj/service/order/impl/OrderDonServiceImpl.java

@@ -683,7 +683,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 	}
 
 	@Override
-	public AliPayParams aliPay(Long orderId, String productCode,String qrPayMode) throws Exception {
+	public AliPayParams aliPay(Long orderId, String returnUrl, String productCode, String qrPayMode) throws Exception {
 		OrderDon orderDon = getById(orderId);
 		String appId = ShopConfig.ZFB_DEFAULT_APP_ID;
 
@@ -696,7 +696,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 		orderDon.setType(OrderDon.Type.ALI_PAY);
 		orderDon.setShopId(appId);
 		this.updateById(orderDon);
-		return commonAliPay(orderId, productCode, appId, qrPayMode);
+		return commonAliPay(orderId, returnUrl, productCode, appId, qrPayMode);
 	}
 
 	@Override
@@ -1166,7 +1166,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 		orderDonTransportMapper.insert(transport);
 	}
 
-	public AliPayParams commonAliPay(Long orderId, String productCode, String appId, String qrPayMode) throws Exception {
+	public AliPayParams commonAliPay(Long orderId, String returnUrl, String productCode, String appId, String qrPayMode) throws Exception {
 		ShopConfig shopConfig = shopConfigMapper.getByAppId(Optional.ofNullable(appId).orElse(ShopConfig.ZFB_DEFAULT_APP_ID));
 
 		AlipayClient alipayClient = AliPayCommon.getAlipayClient(shopConfig);
@@ -1179,7 +1179,9 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 		String host = envCommonService.getHost();
 		String notifyUrl = String.format("%s%s", host, BaseZfbConfig.notifyUrl);
 		if (BaseZfbConfig.qrPayMode_redirect.equals(qrPayMode)) {
-			String returnUrl = String.format("%s%s", envCommonService.getDomain(), BaseZfbConfig.loginReturnUrl);
+			returnUrl = String.format("%s%s", envCommonService.getDomain(), BaseZfbConfig.loginReturnUrl);
+			alipayRequest.setReturnUrl(returnUrl);
+		}else if (StrUtil.isNotBlank(returnUrl)){
 			alipayRequest.setReturnUrl(returnUrl);
 		}
 		alipayRequest.setNotifyUrl(notifyUrl);

+ 17 - 11
netflix-web/src/main/java/com/cyksj/web/controller/payment/OrderController.java

@@ -15,6 +15,7 @@ import com.cyksj.model.dto.AliPayParams;
 import com.cyksj.model.dto.H5JsPayParams;
 import com.cyksj.model.entity.OrderDon;
 import com.cyksj.model.manage.views.OrderDonView;
+import com.cyksj.model.request.AlipayOrderDonReq;
 import com.cyksj.model.request.OrderPayRequest;
 import com.cyksj.model.request.WxOrderRefundReq;
 import com.cyksj.model.request.ZfbOrderRefundReq;
@@ -219,10 +220,12 @@ public class OrderController {
      * 支付宝表单支付
 	 * 支付宝调起支付宝表单
 	 */
-	@PostMapping("/post/pay/zfb/{orderId}")
+	@PostMapping("/post/pay/zfb")
     @Deprecated
-	public Result<String> aliPay(@PathVariable Long orderId,HttpServletResponse response) throws Exception {
-        AliPayParams aliPayParams = orderDonService.aliPay(orderId, ZfbProductCode.MOBILE_WEB.getProductCode(), null);
+    public Result<String> aliPay(@RequestBody @Validated AlipayOrderDonReq re) throws Exception {
+        Long orderId = re.getOrderId();
+        String returnUrl = re.getReturnUrl();
+        AliPayParams aliPayParams = orderDonService.aliPay(orderId, returnUrl, ZfbProductCode.MOBILE_WEB.getProductCode(), null);
 //        response.setContentType("text/html;charset=" + BaseZfbConfig.charset);
         //直接将完整的表单html输出到页面
 //        response.getWriter().write(aliPayParams.getBody());
@@ -235,10 +238,12 @@ public class OrderController {
      * 支付宝web支付
      * pc网页内嵌二维码
      */
-    @PostMapping("/get/zfb/orderQrCode/{orderId}")
-    public Result<String> zfbWebQrCode(@PathVariable Long orderId,HttpServletResponse response) throws Exception {
-        AliPayParams aliPayParams = orderDonService.aliPay(orderId, ZfbProductCode.PC_WEB.getProductCode(), BaseZfbConfig.qrPayMode_orderCode);
-        response.setContentType("text/html;charset=" + BaseZfbConfig.charset);
+    @PostMapping("/get/zfb/orderQrCode")
+    public Result<String> zfbWebQrCode(@RequestBody @Validated AlipayOrderDonReq re) throws Exception {
+        Long orderId = re.getOrderId();
+        String returnUrl = re.getReturnUrl();
+        AliPayParams aliPayParams = orderDonService.aliPay(orderId, returnUrl, ZfbProductCode.PC_WEB.getProductCode(), BaseZfbConfig.qrPayMode_orderCode);
+//        response.setContentType("text/html;charset=" + BaseZfbConfig.charset);
         //直接将完整的表单html输出到页面
 //        response.getWriter().write(aliPayParams.getBody());
 //        response.getWriter().flush();
@@ -250,10 +255,11 @@ public class OrderController {
      * 支付宝web支付
      * pc网页跳转二维码
      */
-    @PostMapping("/get/zfb/orderRedirect/{orderId}")
-    public Result<String> zfbWebRedirectQrCode(@PathVariable Long orderId, HttpServletResponse response) throws Exception {
-        AliPayParams aliPayParams = orderDonService.aliPay(orderId, ZfbProductCode.PC_WEB.getProductCode(), BaseZfbConfig.qrPayMode_redirect);
-        response.setContentType("text/html;charset=" + BaseZfbConfig.charset);
+    @PostMapping("/get/zfb/orderRedirect")
+    public Result<String> zfbWebRedirectQrCode(@RequestBody @Validated AlipayOrderDonReq re) throws Exception {
+        Long orderId = re.getOrderId();
+        String returnUrl = re.getReturnUrl();
+        AliPayParams aliPayParams = orderDonService.aliPay(orderId, returnUrl, ZfbProductCode.PC_WEB.getProductCode(), BaseZfbConfig.qrPayMode_redirect);
         return GatewayResponse.SUCCESS.newBuilder().toResult(aliPayParams.getBody());
     }