This commit is contained in:
鲨鱼
2024-12-26 17:34:59 +08:00
parent 71de3b10ea
commit a630481981
9 changed files with 382 additions and 68 deletions

View File

@@ -32,6 +32,7 @@ import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.helper.LoginHelper;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.StringUtils;
import com.sun.org.apache.bcel.internal.generic.RETURN;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
@@ -304,77 +305,29 @@ public class PayController {
}
@PostMapping(value = "/trd/notify/v1")
@PostMapping(value = "/trd/notify/{type}")
@Operation(hidden = true)
@Log(title = "第三方支付回调V1", businessType = BusinessType.OTHER, isSaveDb = false)
@Log(title = "第三方支付回调", businessType = BusinessType.OTHER, isSaveDb = false)
@SaIgnore
public String trdNotifyUrlV1(HttpServletRequest request) {
public String trdNotifyUrlV1(HttpServletRequest request,@PathVariable("type") String type) {
try {
TrdPayTypeEnum trdPayTypeEnum = TrdPayTypeEnum.getByCode(type);
if(trdPayTypeEnum == null){
log.error("收到第三方支付回调,未找到支付类型 type={}",type);
return "failure";
}
Map<String, String> params = AliPayApi.toMap(request);
log.info("第三方支付回调V1:{}",JSON.toJSONString(params));
NotifyResp notifyResp = trdPayManager.getNotifyResp(params, TrdPayTypeEnum.V1);
log.info("收到第三方支付回调 {}:{}",trdPayTypeEnum.name(), JSON.toJSONString(params));
NotifyResp notifyResp = trdPayManager.getNotifyResp(params, trdPayTypeEnum);
if(!notifyResp.isSuccess()){
return "failure";
}
payManager.callBack(notifyResp.getOrderNo(),notifyResp.getTrdOrderNo(),params,notifyResp.getPayTypeEnum().name(), PayTypeEnum.TRD);
return "success";
return trdPayTypeEnum.getNotifyResp();
} catch (Exception e) {
log.error("第三方支付回调失败V1!",e);
log.error("第三方支付回调失败! type={}",type, 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("第三方支付回调V2:{}",JSON.toJSONString(params));
NotifyResp notifyResp = trdPayManager.getNotifyResp(params, TrdPayTypeEnum.V2);
payManager.callBack(notifyResp.getOrderNo(),notifyResp.getTrdOrderNo(),params,notifyResp.getPayTypeEnum().name(), PayTypeEnum.TRD);
return "success";
} catch (Exception e) {
log.error("第三方支付回调失败V2!",e);
return "failure";
}
}
@PostMapping(value = "/trd/notify/v3")
@Operation(hidden = true)
@Log(title = "第三方支付回调V3", businessType = BusinessType.OTHER, isSaveDb = false)
@SaIgnore
public String trdNotifyUrlV3(HttpServletRequest request) {
try {
Map<String, String> params = AliPayApi.toMap(request);
log.info("第三方支付回调V3:{}",JSON.toJSONString(params));
NotifyResp notifyResp = trdPayManager.getNotifyResp(params, TrdPayTypeEnum.V3);
payManager.callBack(notifyResp.getOrderNo(),notifyResp.getTrdOrderNo(),params,notifyResp.getPayTypeEnum().name(), PayTypeEnum.TRD);
return "success";
} catch (Exception e) {
log.error("第三方支付回调失败V3!",e);
return "failure";
}
}
@PostMapping(value = "/trd/notify/v4")
@Operation(hidden = true)
@Log(title = "第三方支付回调V4", businessType = BusinessType.OTHER, isSaveDb = false)
@SaIgnore
public String trdNotifyUrlV4(HttpServletRequest request) {
try {
Map<String, String> params = AliPayApi.toMap(request);
log.info("第三方支付回调V4:{}",JSON.toJSONString(params));
NotifyResp notifyResp = trdPayManager.getNotifyResp(params, TrdPayTypeEnum.V4);
payManager.callBack(notifyResp.getOrderNo(),notifyResp.getTrdOrderNo(),params,notifyResp.getPayTypeEnum().name(), PayTypeEnum.TRD);
return "success";
} catch (Exception e) {
log.error("第三方支付回调失败V4!",e);
return "failure";
}
}
}