通联支付接入

This commit is contained in:
墨大叔 2024-09-09 18:05:20 +08:00
parent 3dbe80c279
commit 90b730c2f8
9 changed files with 323 additions and 233 deletions

View File

@ -5,6 +5,7 @@ import com.ruoyi.common.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.util.Map;
@ -13,7 +14,7 @@ import java.util.Map;
public class ApiTestV2 extends BaseController {
@Autowired
private SybPayService service;
private SybPayClient service;
@GetMapping("/scanPay")
public AjaxResult testScanPay() throws Exception {
@ -47,7 +48,7 @@ public class ApiTestV2 extends BaseController {
public AjaxResult testPay() throws Exception {
String reqsn = String.valueOf(System.currentTimeMillis());
Map<String, String> map = service.pay(1, reqsn, "W06", "标题", "备注", "ol5kD7eeXNGeYE5z7uIhk12K-rBA", "123", "https://test.allinpaygd.com/JWeb/NotifyServlet", "", "", "", "", "", "", "", "", "", "", "", "");
Map<String, String> map = service.pay(1L, reqsn, "W06", "标题", "备注", "ol5kD7eeXNGeYE5z7uIhk12K-rBA", "123", "https://test.allinpaygd.com/JWeb/NotifyServlet", "", "", "", "", "", "", "", "", "", "", "", "");
return success(map);
}
}

View File

@ -0,0 +1,244 @@
package com.ruoyi.common.pay.syb.service;
import com.alibaba.fastjson2.JSON;
import com.ruoyi.common.pay.syb.config.SybConfig;
import com.ruoyi.common.pay.syb.util.HttpConnectionUtil;
import com.ruoyi.common.pay.syb.util.SybUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Map;
import java.util.TreeMap;
@Component
public class SybPayClient {
@Autowired
private SybConfig sybConfig;
/**
*
* @param trxamt
* @param reqsn
* @param paytype
* @param body
* @param remark
* @param acct
* @param validtime
* @param notify_url
* @param limit_pay
* @param idno
* @param truename
* @param asinfo
* @param sub_appid
* @param goods_tag 单品优惠信息
* @param chnlstoreid
* @param subbranch
* @param cusip 限云闪付JS支付业务
* @param fqnum 限支付宝分期业务
* @return
* @throws Exception
*/
public Map<String,String> pay(long trxamt, String reqsn, String paytype, String body, String remark, String acct, String validtime, String notify_url, String limit_pay,
String idno, String truename, String asinfo, String sub_appid, String goods_tag, String benefitdetail, String chnlstoreid, String subbranch, String extendparams, String cusip, String fqnum) throws Exception{
HttpConnectionUtil http = new HttpConnectionUtil(sybConfig.getApiUrl()+"/pay");
http.init();
TreeMap<String,String> params = new TreeMap<String,String>();
if(!SybUtil.isEmpty(sybConfig.getOrgId())) {
params.put("orgid", sybConfig.getOrgId());
}
params.put("cusid", sybConfig.getCusId());
params.put("appid", sybConfig.getAppId());
params.put("version", "11");
params.put("trxamt", String.valueOf(trxamt));
params.put("reqsn", reqsn);
params.put("paytype", paytype);
params.put("randomstr", SybUtil.getValidatecode(8));
params.put("body", body);
params.put("remark", remark);
params.put("validtime", validtime);
params.put("acct", acct);
params.put("notify_url", notify_url);
params.put("limit_pay", limit_pay);
params.put("sub_appid", sub_appid);
params.put("goods_tag", goods_tag);
params.put("benefitdetail", benefitdetail);
params.put("chnlstoreid", chnlstoreid);
params.put("subbranch", subbranch);
params.put("extendparams", extendparams);
params.put("cusip", cusip);
params.put("fqnum", fqnum);
params.put("idno", idno);
params.put("truename", truename);
params.put("asinfo", asinfo);
params.put("signtype", sybConfig.getSignType());
String appkey = "";
if(sybConfig.getSignType().equals("RSA")) {
appkey = sybConfig.getRsaCusPriKey();
} else if(sybConfig.getSignType().equals("SM2")) {
appkey = sybConfig.getSm2CusPriKey();
} else {
appkey = sybConfig.getMd5AppKey();
}
params.put("sign", SybUtil.unionSign(params,appkey,sybConfig.getSignType()));
byte[] bys = http.postParams(params, true);
String result = new String(bys,"UTF-8");
Map<String,String> map = handleResult(result);
return map;
}
public Map<String,String> cancel(long trxamt,String reqsn,String oldtrxid,String oldreqsn) throws Exception{
HttpConnectionUtil http = new HttpConnectionUtil(sybConfig.getApiUrl()+"/cancel");
http.init();
TreeMap<String,String> params = new TreeMap<String,String>();
if(!SybUtil.isEmpty(sybConfig.getOrgId()))
params.put("orgid", sybConfig.getOrgId());
params.put("cusid", sybConfig.getCusId());
params.put("appid", sybConfig.getAppId());
params.put("version", "11");
params.put("trxamt", String.valueOf(trxamt));
params.put("reqsn", reqsn);
params.put("oldtrxid", oldtrxid);
params.put("oldreqsn", oldreqsn);
params.put("randomstr", SybUtil.getValidatecode(8));
params.put("signtype", sybConfig.getSignType());
String appkey = "";
if(sybConfig.getSignType().equals("RSA"))
appkey = sybConfig.getRsaCusPriKey();
else if(sybConfig.getSignType().equals("SM2"))
appkey = sybConfig.getSm2CusPriKey();
else
appkey = sybConfig.getMd5AppKey();
params.put("sign", SybUtil.unionSign(params,appkey,sybConfig.getSignType()));
byte[] bys = http.postParams(params, true);
String result = new String(bys,"UTF-8");
Map<String,String> map = handleResult(result);
return map;
}
public Map<String,String> refund(long trxamt,String reqsn,String oldtrxid,String oldreqsn) throws Exception{
HttpConnectionUtil http = new HttpConnectionUtil(sybConfig.getApiUrl()+"/refund");
http.init();
TreeMap<String,String> params = new TreeMap<String,String>();
if(!SybUtil.isEmpty(sybConfig.getOrgId()))
params.put("orgid", sybConfig.getOrgId());
params.put("cusid", sybConfig.getCusId());
params.put("appid", sybConfig.getAppId());
params.put("version", "11");
params.put("trxamt", String.valueOf(trxamt));
params.put("reqsn", reqsn);
params.put("oldreqsn", oldreqsn);
params.put("oldtrxid", oldtrxid);
params.put("randomstr", SybUtil.getValidatecode(8));
params.put("signtype", sybConfig.getSignType());
String appkey = "";
if(sybConfig.getSignType().equals("RSA"))
appkey = sybConfig.getRsaCusPriKey();
else if(sybConfig.getSignType().equals("SM2"))
appkey = sybConfig.getSm2CusPriKey();
else
appkey = sybConfig.getMd5AppKey();
params.put("sign", SybUtil.unionSign(params,appkey,sybConfig.getSignType()));
byte[] bys = http.postParams(params, true);
String result = new String(bys,"UTF-8");
Map<String,String> map = handleResult(result);
return map;
}
public Map<String,String> query(String reqsn,String trxid) throws Exception{
HttpConnectionUtil http = new HttpConnectionUtil(sybConfig.getApiUrl()+"/query");
http.init();
TreeMap<String,String> params = new TreeMap<String,String>();
if(!SybUtil.isEmpty(sybConfig.getOrgId()))
params.put("orgid", sybConfig.getOrgId());
params.put("cusid", sybConfig.getCusId());
params.put("appid", sybConfig.getAppId());
params.put("version", "11");
params.put("reqsn", reqsn);
params.put("trxid", trxid);
params.put("randomstr", SybUtil.getValidatecode(8));
params.put("signtype", sybConfig.getSignType());
String appkey = "";
if(sybConfig.getSignType().equals("RSA"))
appkey = sybConfig.getRsaCusPriKey();
else if(sybConfig.getSignType().equals("SM2"))
appkey = sybConfig.getSm2CusPriKey();
else
appkey = sybConfig.getMd5AppKey();
params.put("sign", SybUtil.unionSign(params,appkey,sybConfig.getSignType()));
byte[] bys = http.postParams(params, true);
String result = new String(bys,"UTF-8");
Map<String,String> map = handleResult(result);
return map;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public Map<String,String> handleResult(String result) throws Exception{
System.out.println("ret:"+result);
Map map = JSON.parseObject(result, Map.class);
if(map == null){
throw new Exception("返回数据错误");
}
if("SUCCESS".equals(map.get("retcode"))){
TreeMap tmap = new TreeMap();
tmap.putAll(map);
String appkey = "";
if(sybConfig.getSignType().equals("RSA"))
appkey = sybConfig.getRsaTlPubKey();
else if(sybConfig.getSignType().equals("SM2"))
appkey = sybConfig.getSm2TlPubKey();
else
appkey = sybConfig.getMd5AppKey();
if(SybUtil.validSign(tmap, appkey, sybConfig.getSignType())){
System.out.println("签名成功");
return map;
}else{
throw new Exception("验证签名失败");
}
}else{
throw new Exception(map.get("retmsg").toString());
}
}
public Map<String, String> scanPay(long trxamt,String reqsn,String body,String remark,String authcode,String limit_pay,String idno,String truename,String asinfo) throws Exception{
// TODO Auto-generated method stub
HttpConnectionUtil http = new HttpConnectionUtil(sybConfig.getApiUrl()+"/scanqrpay");
http.init();
TreeMap<String,String> params = new TreeMap<String,String>();
if(!SybUtil.isEmpty(sybConfig.getOrgId()))
params.put("orgid", sybConfig.getOrgId());
params.put("cusid", sybConfig.getCusId());
params.put("appid", sybConfig.getAppId());
params.put("version", "11");
params.put("trxamt", String.valueOf(trxamt));
params.put("reqsn", reqsn);
params.put("randomstr", SybUtil.getValidatecode(8));
params.put("body", body);
params.put("remark", remark);
params.put("authcode", authcode);
params.put("limit_pay", limit_pay);
params.put("asinfo", asinfo);
params.put("signtype", sybConfig.getSignType());
String appkey = "";
if(sybConfig.getSignType().equals("RSA"))
appkey = sybConfig.getRsaCusPriKey();
else if(sybConfig.getSignType().equals("SM2"))
appkey = sybConfig.getSm2CusPriKey();
else
appkey = sybConfig.getMd5AppKey();
params.put("sign", SybUtil.unionSign(params,appkey,sybConfig.getSignType()));
byte[] bys = http.postParams(params, true);
String result = new String(bys,"UTF-8");
Map<String,String> map = handleResult(result);
return map;
}
}

View File

@ -1,240 +1,64 @@
package com.ruoyi.common.pay.syb.service;
import com.alibaba.fastjson2.JSON;
import com.ruoyi.common.pay.syb.config.SybConfig;
import com.ruoyi.common.pay.syb.util.HttpConnectionUtil;
import com.ruoyi.common.pay.syb.util.SybUtil;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.pay.wx.domain.Payable;
import com.ruoyi.common.utils.StringUtils;
import com.wechat.pay.java.service.payments.jsapi.model.PrepayWithRequestPaymentResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;
import java.util.TreeMap;
/**
* @author wjh
* 2024/9/9
*/
@Service
public class SybPayService {
@Autowired
private SybConfig sybConfig;
@Autowired
private SybPayClient sybPayClient;
/**
*
* @param trxamt
* @param reqsn
* @param paytype
* @param body
* @param remark
* @param acct
* @param validtime
* @param notify_url
* @param limit_pay
* @param idno
* @param truename
* @param asinfo
* @param sub_appid
* @param goods_tag 单品优惠信息
* @param chnlstoreid
* @param subbranch
* @param cusip 限云闪付JS支付业务
* @param fqnum 限支付宝分期业务
* @return
* @throws Exception
*/
public Map<String,String> pay(long trxamt,String reqsn,String paytype,String body,String remark,String acct,String validtime,String notify_url,String limit_pay,
String idno,String truename,String asinfo,String sub_appid,String goods_tag,String benefitdetail,String chnlstoreid,String subbranch,String extendparams,String cusip,String fqnum) throws Exception{
HttpConnectionUtil http = new HttpConnectionUtil(sybConfig.getApiUrl()+"/pay");
http.init();
TreeMap<String,String> params = new TreeMap<String,String>();
if(!SybUtil.isEmpty(sybConfig.getOrgId())) {
params.put("orgid", sybConfig.getOrgId());
}
params.put("cusid", sybConfig.getCusId());
params.put("appid", sybConfig.getAppId());
params.put("version", "11");
params.put("trxamt", String.valueOf(trxamt));
params.put("reqsn", reqsn);
params.put("paytype", paytype);
params.put("randomstr", SybUtil.getValidatecode(8));
params.put("body", body);
params.put("remark", remark);
params.put("validtime", validtime);
params.put("acct", acct);
params.put("notify_url", notify_url);
params.put("limit_pay", limit_pay);
params.put("sub_appid", sub_appid);
params.put("goods_tag", goods_tag);
params.put("benefitdetail", benefitdetail);
params.put("chnlstoreid", chnlstoreid);
params.put("subbranch", subbranch);
params.put("extendparams", extendparams);
params.put("cusip", cusip);
params.put("fqnum", fqnum);
params.put("idno", idno);
params.put("truename", truename);
params.put("asinfo", asinfo);
params.put("signtype", sybConfig.getSignType());
String appkey = "";
if(sybConfig.getSignType().equals("RSA")) {
appkey = sybConfig.getRsaCusPriKey();
} else if(sybConfig.getSignType().equals("SM2")) {
appkey = sybConfig.getSm2CusPriKey();
} else {
appkey = sybConfig.getMd5AppKey();
}
params.put("sign", SybUtil.unionSign(params,appkey,sybConfig.getSignType()));
byte[] bys = http.postParams(params, true);
String result = new String(bys,"UTF-8");
Map<String,String> map = handleResult(result);
return map;
/**
* 微信小程序预下单
*/
public PrepayWithRequestPaymentResponse prepayWxApp(Payable payable) {
try {
Map<String, String> result = sybPayClient.pay(
payable.payableMoney().longValue(),
payable.payableOutTradeNo(),
"W06",
payable.payableDescription(),
payable.payableDescription(),
payable.payableOpenId(),
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
""
);
}
public Map<String,String> cancel(long trxamt,String reqsn,String oldtrxid,String oldreqsn) throws Exception{
HttpConnectionUtil http = new HttpConnectionUtil(sybConfig.getApiUrl()+"/cancel");
http.init();
TreeMap<String,String> params = new TreeMap<String,String>();
if(!SybUtil.isEmpty(sybConfig.getOrgId()))
params.put("orgid", sybConfig.getOrgId());
params.put("cusid", sybConfig.getCusId());
params.put("appid", sybConfig.getAppId());
params.put("version", "11");
params.put("trxamt", String.valueOf(trxamt));
params.put("reqsn", reqsn);
params.put("oldtrxid", oldtrxid);
params.put("oldreqsn", oldreqsn);
params.put("randomstr", SybUtil.getValidatecode(8));
params.put("signtype", sybConfig.getSignType());
String appkey = "";
if(sybConfig.getSignType().equals("RSA"))
appkey = sybConfig.getRsaCusPriKey();
else if(sybConfig.getSignType().equals("SM2"))
appkey = sybConfig.getSm2CusPriKey();
else
appkey = sybConfig.getMd5AppKey();
params.put("sign", SybUtil.unionSign(params,appkey,sybConfig.getSignType()));
byte[] bys = http.postParams(params, true);
String result = new String(bys,"UTF-8");
Map<String,String> map = handleResult(result);
return map;
}
public Map<String,String> refund(long trxamt,String reqsn,String oldtrxid,String oldreqsn) throws Exception{
HttpConnectionUtil http = new HttpConnectionUtil(sybConfig.getApiUrl()+"/refund");
http.init();
TreeMap<String,String> params = new TreeMap<String,String>();
if(!SybUtil.isEmpty(sybConfig.getOrgId()))
params.put("orgid", sybConfig.getOrgId());
params.put("cusid", sybConfig.getCusId());
params.put("appid", sybConfig.getAppId());
params.put("version", "11");
params.put("trxamt", String.valueOf(trxamt));
params.put("reqsn", reqsn);
params.put("oldreqsn", oldreqsn);
params.put("oldtrxid", oldtrxid);
params.put("randomstr", SybUtil.getValidatecode(8));
params.put("signtype", sybConfig.getSignType());
String appkey = "";
if(sybConfig.getSignType().equals("RSA"))
appkey = sybConfig.getRsaCusPriKey();
else if(sybConfig.getSignType().equals("SM2"))
appkey = sybConfig.getSm2CusPriKey();
else
appkey = sybConfig.getMd5AppKey();
params.put("sign", SybUtil.unionSign(params,appkey,sybConfig.getSignType()));
byte[] bys = http.postParams(params, true);
String result = new String(bys,"UTF-8");
Map<String,String> map = handleResult(result);
return map;
}
public Map<String,String> query(String reqsn,String trxid) throws Exception{
HttpConnectionUtil http = new HttpConnectionUtil(sybConfig.getApiUrl()+"/query");
http.init();
TreeMap<String,String> params = new TreeMap<String,String>();
if(!SybUtil.isEmpty(sybConfig.getOrgId()))
params.put("orgid", sybConfig.getOrgId());
params.put("cusid", sybConfig.getCusId());
params.put("appid", sybConfig.getAppId());
params.put("version", "11");
params.put("reqsn", reqsn);
params.put("trxid", trxid);
params.put("randomstr", SybUtil.getValidatecode(8));
params.put("signtype", sybConfig.getSignType());
String appkey = "";
if(sybConfig.getSignType().equals("RSA"))
appkey = sybConfig.getRsaCusPriKey();
else if(sybConfig.getSignType().equals("SM2"))
appkey = sybConfig.getSm2CusPriKey();
else
appkey = sybConfig.getMd5AppKey();
params.put("sign", SybUtil.unionSign(params,appkey,sybConfig.getSignType()));
byte[] bys = http.postParams(params, true);
String result = new String(bys,"UTF-8");
Map<String,String> map = handleResult(result);
return map;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public Map<String,String> handleResult(String result) throws Exception{
System.out.println("ret:"+result);
Map map = JSON.parseObject(result, Map.class);
if(map == null){
throw new Exception("返回数据错误");
}
if("SUCCESS".equals(map.get("retcode"))){
TreeMap tmap = new TreeMap();
tmap.putAll(map);
String appkey = "";
if(sybConfig.getSignType().equals("RSA"))
appkey = sybConfig.getRsaTlPubKey();
else if(sybConfig.getSignType().equals("SM2"))
appkey = sybConfig.getSm2TlPubKey();
else
appkey = sybConfig.getMd5AppKey();
if(SybUtil.validSign(tmap, appkey, sybConfig.getSignType())){
System.out.println("签名成功");
return map;
}else{
throw new Exception("验证签名失败");
}
}else{
throw new Exception(map.get("retmsg").toString());
}
}
public Map<String, String> scanPay(long trxamt,String reqsn,String body,String remark,String authcode,String limit_pay,String idno,String truename,String asinfo) throws Exception{
// TODO Auto-generated method stub
HttpConnectionUtil http = new HttpConnectionUtil(sybConfig.getApiUrl()+"/scanqrpay");
http.init();
TreeMap<String,String> params = new TreeMap<String,String>();
if(!SybUtil.isEmpty(sybConfig.getOrgId()))
params.put("orgid", sybConfig.getOrgId());
params.put("cusid", sybConfig.getCusId());
params.put("appid", sybConfig.getAppId());
params.put("version", "11");
params.put("trxamt", String.valueOf(trxamt));
params.put("reqsn", reqsn);
params.put("randomstr", SybUtil.getValidatecode(8));
params.put("body", body);
params.put("remark", remark);
params.put("authcode", authcode);
params.put("limit_pay", limit_pay);
params.put("asinfo", asinfo);
params.put("signtype", sybConfig.getSignType());
String appkey = "";
if(sybConfig.getSignType().equals("RSA"))
appkey = sybConfig.getRsaCusPriKey();
else if(sybConfig.getSignType().equals("SM2"))
appkey = sybConfig.getSm2CusPriKey();
else
appkey = sybConfig.getMd5AppKey();
params.put("sign", SybUtil.unionSign(params,appkey,sybConfig.getSignType()));
byte[] bys = http.postParams(params, true);
String result = new String(bys,"UTF-8");
Map<String,String> map = handleResult(result);
return map;
}
if (result != null) {
String payInfo = result.get("payinfo");
if (StringUtils.hasText(payInfo)) {
return JSON.parseObject(payInfo, PrepayWithRequestPaymentResponse.class);
}
}
return null;
} catch(Exception e) {
throw new ServiceException("调起支付失败:" + e.getMessage());
}
}
}

View File

@ -110,7 +110,7 @@ public class PayBillConverterImpl implements PayBillConverter {
po.setChannelCost(this.calcChannelCost(channel, order.getMoney()));
// 支付人
if (TransactionBillPayType.WECHAT.getType().equals(channel.getChannelId())) {
if (TransactionBillPayType.wxList().contains(channel.getChannelId())) {
po.setAccount(user.getWxOpenId());
}

View File

@ -10,6 +10,7 @@ import java.util.concurrent.TimeUnit;
import com.ruoyi.common.core.redis.RedisLock;
import com.ruoyi.common.core.redis.enums.RedisLockKey;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.pay.syb.service.SybPayService;
import com.ruoyi.common.pay.wx.util.WxPayUtil;
import com.ruoyi.common.pay.yst.service.YstPayService;
import com.ruoyi.common.utils.DateUtils;
@ -78,7 +79,7 @@ public class PayBillServiceImpl implements PayBillService
private PayBillConverter payBillConverter;
@Autowired
private YstPayService ystPayService;
private SybPayService sybPayService;
/**
* 查询支付订单
@ -156,6 +157,7 @@ public class PayBillServiceImpl implements PayBillService
@Override
public DoPayVO createPayBill(PayBill bill) {
ServiceUtil.assertion(bill == null, "待新增的支付订单不存在");
//
String lockKey = bill.getBstType() + bill.getBstId();
if (!redisLock.lock(RedisLockKey.PAY_BILL, lockKey)) {
@ -291,8 +293,8 @@ public class PayBillServiceImpl implements PayBillService
} else {
if (TransactionBillPayType.WECHAT.getType().equals(bill.getChannelId())) {
vo.setPayParams(wxPayService.prepayWithRequestPayment(bill));
} else if (TransactionBillPayType.YST_WX.getType().equals(bill.getChannelId())) {
vo.setPayParams(ystPayService.prepayWx(bill));
} else if (TransactionBillPayType.TL_WX.getType().equals(bill.getChannelId())) {
vo.setPayParams(sybPayService.prepayWxApp(bill));
} else {
throw new ServiceException("暂不支持该支付方式");
}

View File

@ -4,8 +4,12 @@ import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.ss.account.domain.enums.AccountType;
import lombok.AllArgsConstructor;
import lombok.Getter;
import nonapi.io.github.classgraph.utils.LogNode;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* 支付方式打款方式
@ -20,7 +24,7 @@ public enum TransactionBillPayType {
ALI(2L, "支付宝", AccountType.ALIPAY),
BANK(3L, "银行卡", AccountType.BANK_CARD),
BALANCE(4L, "余额支付", null),
YST_WX(5L, "通联微信支付", null)
TL_WX(5L, "通联微信支付", null)
;
private final Long type;
@ -35,4 +39,12 @@ public enum TransactionBillPayType {
}
throw new ServiceException("不存在值为" + type + "的支付方式(打款方式)");
}
public static List<Long> asList(TransactionBillPayType ...types) {
return Arrays.stream(types).map(TransactionBillPayType::getType).collect(Collectors.toList());
}
public static List<Long> wxList() {
return asList(WECHAT, TL_WX);
}
}

View File

@ -46,7 +46,7 @@ public interface TransactionBillValidator {
boolean isUser(TransactionBillVO bill, Long userId);
/**
* 微信支付前校验
* 支付前校验
*/
ValidateResult prePay(RechargePayBO bo);

View File

@ -261,6 +261,13 @@ public class TransactionBillValidatorImpl extends BaseValidator implements Trans
if (!TransactionBillType.RECHARGE.getType().equals(order.getType())) {
return error("只能支付充值订单");
}
ChannelVO channel = bo.getChannel();
if (channel == null) {
return error("支付渠道不存在");
}
if (channel.getEnabled() == null || !channel.getEnabled()) {
return error("支付渠道暂不可用");
}
return success();
}

View File

@ -335,7 +335,7 @@ public class AppTransactionBillController extends BaseController
@PutMapping("/pay")
public AjaxResult pay(@RequestBody BillPayDTO dto) {
TransactionBillVO bill = transactionBillService.selectSmTransactionBillByBillNo(dto.getBillNo());
if (transactionBillValidator.isUser(bill, getUserId())) {
if (!transactionBillValidator.isUser(bill, getUserId())) {
return error("这不是您的订单,无法支付");
}
RechargePayBO bo = transactionBillConverter.toRechargePayBO(bill, dto.getChannelId());