This commit is contained in:
77
2024-11-25 20:41:43 +08:00
parent fa1d6df347
commit 904dbbe37b
9 changed files with 93 additions and 38 deletions

View File

@@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.cai.domain.PayTrdConfig;
import com.ruoyi.cai.pay.PayOrderInfoDTO;
import com.ruoyi.cai.pay.PayReturnResp;
/**
* 四方支付配置Service接口
@@ -12,7 +13,7 @@ import com.ruoyi.cai.pay.PayOrderInfoDTO;
* @date 2024-11-25
*/
public interface PayTrdConfigService extends IService<PayTrdConfig> {
String createOrderAli(PayOrderInfoDTO dto);
PayReturnResp createOrderAli(PayOrderInfoDTO dto);
JSONObject queryOrder(String orderNo, String trdPayType);

View File

@@ -8,11 +8,13 @@ import com.ruoyi.cai.domain.PayTrdConfig;
import com.ruoyi.cai.mapper.PayTrdConfigMapper;
import com.ruoyi.cai.pay.PayManager;
import com.ruoyi.cai.pay.PayOrderInfoDTO;
import com.ruoyi.cai.pay.PayReturnResp;
import com.ruoyi.cai.pay.PayTypeEnum;
import com.ruoyi.cai.service.PayTrdConfigService;
import com.ruoyi.cai.trdpay.TrdPayManager;
import com.ruoyi.cai.trdpay.TrdPayTypeEnum;
import com.ruoyi.common.exception.ServiceException;
import com.tencentcloudapi.gme.v20180711.models.AppStatisticsItem;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -36,7 +38,7 @@ public class PayTrdConfigServiceImpl extends ServiceImpl<PayTrdConfigMapper, Pay
private PayManager payManager;
@Override
public String createOrderAli(PayOrderInfoDTO dto){
public PayReturnResp createOrderAli(PayOrderInfoDTO dto){
PayTrdConfig payTrdConfig = getEnableStatus();
if(payTrdConfig == null){
throw new ServiceException("未开启支付,请联系客服");
@@ -55,13 +57,19 @@ public class PayTrdConfigServiceImpl extends ServiceImpl<PayTrdConfigMapper, Pay
log.info("第三方支付失败 V1统一支付失败失败 dto={}, payTrdConfig={}, typeEnum={}", JSON.toJSONString(dto), JSON.toJSONString(payTrdConfig),JSON.toJSONString(typeEnum));
throw new ServiceException("调用支付失败");
}
return jsonObject.getJSONObject("payParams").getString("payUrl");
String payUrl = jsonObject.getJSONObject("payParams").getString("payUrl");
return PayReturnResp.createH5(payUrl);
}else if(typeEnum == TrdPayTypeEnum.V2){
if(!"0".equals(jsonObject.getString("retCode"))){
log.info("第三方支付失败 V2统一支付失败失败 dto={}, payTrdConfig={}, typeEnum={}", JSON.toJSONString(dto), JSON.toJSONString(payTrdConfig),JSON.toJSONString(typeEnum));
throw new ServiceException("调用支付失败");
}
return JSON.toJSONString(jsonObject);
String payMethod = jsonObject.getString("payMethod");
if("alipayApp".equals(payMethod)){
String appStr = jsonObject.getJSONObject("payParams").getString("appStr");
return PayReturnResp.createApp(appStr);
}
return PayReturnResp.createH5(JSON.toJSONString(jsonObject));
}
return null;
}