|
@@ -1,10 +1,10 @@
|
1
|
1
|
package com.yunzhi.nanyang.controller;
|
2
|
2
|
|
3
|
3
|
import com.github.binarywang.wxpay.bean.result.WxPayUnifiedOrderV3Result;
|
4
|
|
-import com.yunzhi.nanyang.common.BaseController;
|
5
|
|
-import com.yunzhi.nanyang.common.Constants;
|
6
|
|
-import com.yunzhi.nanyang.common.ResponseBean;
|
7
|
|
-import com.yunzhi.nanyang.common.StringUtils;
|
|
4
|
+import com.github.binarywang.wxpay.bean.result.enums.TradeTypeEnum;
|
|
5
|
+import com.github.binarywang.wxpay.config.WxPayConfig;
|
|
6
|
+import com.github.binarywang.wxpay.service.WxPayService;
|
|
7
|
+import com.yunzhi.nanyang.common.*;
|
8
|
8
|
import com.yunzhi.nanyang.entity.TaOrder;
|
9
|
9
|
import com.yunzhi.nanyang.service.ITaOrderService;
|
10
|
10
|
import com.yunzhi.nanyang.service.ITaPayService;
|
|
@@ -22,6 +22,9 @@ import java.util.Map;
|
22
|
22
|
@RequestMapping("/")
|
23
|
23
|
public class TaPayController extends BaseController {
|
24
|
24
|
|
|
25
|
+ @Autowired
|
|
26
|
+ WxUtils wxUtils;
|
|
27
|
+
|
25
|
28
|
@Autowired
|
26
|
29
|
ITaPayService iTaPayService;
|
27
|
30
|
|
|
@@ -50,8 +53,17 @@ public class TaPayController extends BaseController {
|
50
|
53
|
return ResponseBean.error("订单已支付");
|
51
|
54
|
}
|
52
|
55
|
|
53
|
|
- WxPayUnifiedOrderV3Result.JsapiResult result = iTaPayService.createPay(client, clientId, taOrder);
|
54
|
|
- return ResponseBean.success(result);
|
|
56
|
+ WxPayUnifiedOrderV3Result payResult = iTaPayService.createPay(client, clientId, taOrder);
|
|
57
|
+
|
|
58
|
+ WxPayConfig payConfig = wxUtils.getPayService().getConfig();
|
|
59
|
+
|
|
60
|
+ if ("wx".equals(client)) {
|
|
61
|
+ WxPayUnifiedOrderV3Result.JsapiResult result = payResult.getPayInfo(TradeTypeEnum.JSAPI, payConfig.getAppId(), payConfig.getMchId(), payConfig.getPrivateKey());
|
|
62
|
+ return ResponseBean.success(result);
|
|
63
|
+ } else {
|
|
64
|
+ WxPayUnifiedOrderV3Result.AppResult result = payResult.getPayInfo(TradeTypeEnum.APP, payConfig.getAppId(), payConfig.getMchId(), payConfig.getPrivateKey());
|
|
65
|
+ return ResponseBean.success(result);
|
|
66
|
+ }
|
55
|
67
|
}
|
56
|
68
|
|
57
|
69
|
|