123
This commit is contained in:
@@ -2,15 +2,15 @@ package com.ruoyi.web.controller.cai.admin.init;
|
||||
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.dtflys.forest.annotation.JSONBody;
|
||||
import com.ruoyi.cai.pay.PayOrderInfoDTO;
|
||||
import com.ruoyi.cai.service.CitysService;
|
||||
import com.ruoyi.cai.trdpay.TrdPayManager;
|
||||
import com.ruoyi.cai.service.PayTrdConfigService;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@@ -21,7 +21,7 @@ public class CityController {
|
||||
@Autowired
|
||||
private CitysService citysService;
|
||||
@Autowired
|
||||
private TrdPayManager trdPayManager;
|
||||
private PayTrdConfigService payTrdConfigService;
|
||||
|
||||
@GetMapping("/resetRedis")
|
||||
public R<Void> resetRedis(){
|
||||
@@ -30,14 +30,21 @@ public class CityController {
|
||||
}
|
||||
|
||||
@GetMapping("/resetOrder")
|
||||
public R<JSONObject> resetOrder(String orderNo){
|
||||
JSONObject jsonObject = trdPayManager.resetOrder(orderNo);
|
||||
public R<JSONObject> resetOrder(String orderNo,String payType){
|
||||
JSONObject jsonObject = payTrdConfigService.resetOrder(orderNo,payType);
|
||||
return R.ok(jsonObject);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/createOrder")
|
||||
public R<String> createOrder(@RequestBody PayOrderInfoDTO dto){
|
||||
String orderAli = payTrdConfigService.createOrderAli(dto);
|
||||
return R.ok(orderAli);
|
||||
}
|
||||
|
||||
@GetMapping("/queryOrder")
|
||||
public R<JSONObject> queryOrder(String orderNo){
|
||||
JSONObject jsonObject = trdPayManager.queryOrder(orderNo);
|
||||
public R<JSONObject> queryOrder(String orderNo,String payType){
|
||||
JSONObject jsonObject = payTrdConfigService.queryOrder(orderNo,payType);
|
||||
return R.ok(jsonObject);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.ruoyi.cai.dto.app.vo.pay.OrderPayStatusResp;
|
||||
import com.ruoyi.cai.enums.SystemConfigEnum;
|
||||
import com.ruoyi.cai.manager.SystemConfigManager;
|
||||
import com.ruoyi.cai.pay.*;
|
||||
import com.ruoyi.cai.service.PayTrdConfigService;
|
||||
import com.ruoyi.cai.trdpay.TrdPayManager;
|
||||
import com.ruoyi.cai.trdpay.TrdPayProperties;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
@@ -49,11 +50,9 @@ public class PayController {
|
||||
@Autowired
|
||||
private PayManager payManager;
|
||||
@Autowired
|
||||
private TrdPayProperties trdPayProperties;
|
||||
@Autowired
|
||||
private TrdPayManager trdPayManager;
|
||||
@Autowired
|
||||
private SystemConfigManager systemConfigManager;
|
||||
private PayTrdConfigService payTrdConfigService;
|
||||
private static final String NOTIFY_WX_URL = "/api/pay/wx/notify";
|
||||
private static final String NOTIFY_ALI_URL = "/api/pay/ali/notify";
|
||||
|
||||
@@ -86,14 +85,9 @@ public class PayController {
|
||||
return R.fail(600,"支付失败,未找到订单");
|
||||
}
|
||||
try {
|
||||
JSONObject wx = trdPayManager.createOrderWx(payOrderInfo);
|
||||
String code = wx.getString("retCode");
|
||||
if(!"SUCCESS".equals(code)){
|
||||
return R.fail(600,"支付失败!微信支付通道失败!");
|
||||
}
|
||||
String payUrl = wx.getJSONObject("payParams").getString("payUrl");
|
||||
String ali = payTrdConfigService.createOrderAli(payOrderInfo);
|
||||
PayReturnResp payTrdReturnResp = new PayReturnResp();
|
||||
payTrdReturnResp.setData(payUrl);
|
||||
payTrdReturnResp.setData(ali);
|
||||
return R.ok(payTrdReturnResp);
|
||||
}catch (Exception e){
|
||||
log.error("第三方微信支付失败!",e);
|
||||
@@ -251,18 +245,38 @@ public class PayController {
|
||||
}
|
||||
|
||||
|
||||
@PostMapping(value = "/trd/notify")
|
||||
@PostMapping(value = "/trd/notify/v1")
|
||||
@Operation(hidden = true)
|
||||
@Log(title = "第三方支付回调", businessType = BusinessType.OTHER, isSaveDb = false)
|
||||
@Log(title = "第三方支付回调V1", businessType = BusinessType.OTHER, isSaveDb = false)
|
||||
@SaIgnore
|
||||
public String trdNotifyUrl(HttpServletRequest request) {
|
||||
public String trdNotifyUrlV1(HttpServletRequest request) {
|
||||
try {
|
||||
Map<String, String> params = AliPayApi.toMap(request);
|
||||
log.info("第三方支付回调:{}",JSON.toJSONString(params));
|
||||
String mchOrderNo = params.get("mchOrderNo");
|
||||
String payOrderId = params.get("payOrderId");
|
||||
String productId = params.get("productId");
|
||||
payManager.callBack(mchOrderNo,payOrderId,params,productId, PayTypeEnum.TRD);
|
||||
payManager.callBack(mchOrderNo,payOrderId,params,"V1", PayTypeEnum.TRD);
|
||||
return "success";
|
||||
} catch (Exception e) {
|
||||
log.error("第三方支付回调失败!",e);
|
||||
return "failure";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@PostMapping(value = "/trd/notify/v2")
|
||||
@Operation(hidden = true)
|
||||
@Log(title = "第三方支付回调V2", businessType = BusinessType.OTHER, isSaveDb = false)
|
||||
@SaIgnore
|
||||
public String trdNotifyUrlV2(HttpServletRequest request) {
|
||||
try {
|
||||
Map<String, String> params = AliPayApi.toMap(request);
|
||||
log.info("第三方支付回调:{}",JSON.toJSONString(params));
|
||||
String mchOrderNo = params.get("mchOrderNo");
|
||||
String payOrderId = params.get("payOrderId");
|
||||
String productId = params.get("productId");
|
||||
payManager.callBack(mchOrderNo,payOrderId,params,"V2", PayTypeEnum.TRD);
|
||||
return "success";
|
||||
} catch (Exception e) {
|
||||
log.error("第三方支付回调失败!",e);
|
||||
|
||||
@@ -109,9 +109,3 @@ springdoc:
|
||||
enabled: false
|
||||
knife4j:
|
||||
enable: false
|
||||
trd:
|
||||
pay:
|
||||
mch-id: 10418
|
||||
wx-product-id: 8000
|
||||
ali-product-id: 8000
|
||||
notify-url-domain: "http://1.12.220.225:9889"
|
||||
|
||||
Reference in New Issue
Block a user