1.太米支付
This commit is contained in:
parent
78177caf37
commit
ec2fbe5d51
|
@ -4,10 +4,9 @@ import com.alibaba.fastjson2.JSON;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.ruoyi.common.constant.ServiceConstants;
|
import com.ruoyi.common.constant.ServiceConstants;
|
||||||
import com.ruoyi.common.exception.ServiceException;
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
import com.ruoyi.common.pay.syb.enums.SybTrxCode;
|
|
||||||
import com.ruoyi.common.pay.syb.enums.SybTrxStatus;
|
|
||||||
import com.ruoyi.common.pay.syb.service.SybPayService;
|
|
||||||
import com.ruoyi.common.pay.syb.util.SybUtil;
|
import com.ruoyi.common.pay.syb.util.SybUtil;
|
||||||
|
import com.ruoyi.common.pay.tm.TmPayService;
|
||||||
|
import com.ruoyi.common.pay.tm.enums.PayStatus;
|
||||||
import com.ruoyi.common.utils.DateUtils;
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
import com.ruoyi.system.domain.EtCallbackLog;
|
import com.ruoyi.system.domain.EtCallbackLog;
|
||||||
import com.ruoyi.system.domain.vo.AttachVo;
|
import com.ruoyi.system.domain.vo.AttachVo;
|
||||||
|
@ -41,7 +40,7 @@ public class CallbackController {
|
||||||
private CallbackService callbackService;
|
private CallbackService callbackService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SybPayService sybPayService;
|
private TmPayService tmPayService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ScheduledExecutorService scheduledExecutorService;
|
private ScheduledExecutorService scheduledExecutorService;
|
||||||
|
@ -84,30 +83,29 @@ public class CallbackController {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通联微信支付回调
|
* 太米微信支付回调
|
||||||
*/
|
*/
|
||||||
@ApiOperation(value = "通联微信支付回调")
|
@ApiOperation(value = "太米微信支付回调")
|
||||||
@RequestMapping(value = "/tlwx", method = RequestMethod.POST)
|
@RequestMapping(value = "/tmwx", method = RequestMethod.POST)
|
||||||
public String tlwx(HttpServletRequest request) {
|
public String tmwx(HttpServletRequest request) {
|
||||||
try {
|
try {
|
||||||
request.setCharacterEncoding("UTF-8");//通知传输的编码为GBK
|
request.setCharacterEncoding("UTF-8");//通知传输的编码为GBK
|
||||||
// 获取所有参数
|
// 获取所有参数
|
||||||
TreeMap<String, String> params = SybUtil.getParams(request);
|
TreeMap<String, String> params = SybUtil.getParams(request);
|
||||||
boolean sign = sybPayService.validSign(params);
|
log.info("【太米微信支付回调】接收对象 : " + JSON.toJSONString(params));
|
||||||
|
// 验证签名
|
||||||
|
boolean sign = tmPayService.validSign(params);
|
||||||
if (sign) {
|
if (sign) {
|
||||||
EtCallbackLog etCallbackLog = new EtCallbackLog();
|
EtCallbackLog etCallbackLog = new EtCallbackLog();
|
||||||
etCallbackLog.setBody(JSON.toJSONString(params));
|
etCallbackLog.setBody(JSON.toJSONString(params));
|
||||||
etCallbackLog.setType("1");
|
etCallbackLog.setType("1");
|
||||||
|
String payType = params.get("payType"); // 交易类型
|
||||||
String trxCode = params.get("trxcode"); // 交易类型
|
String outTradeNo = params.get("outTradeId"); // 商户自定义订单号
|
||||||
String outTradeNo = params.get("cusorderid"); // 商户自定义订单号
|
String trxStatus = params.get("payStatus"); // 交易结果
|
||||||
String trxStatus = params.get("trxstatus"); // 交易结果
|
String remark = params.get("remark"); // 附加信息,用于判断业务类型
|
||||||
String remark = params.get("trxreserved"); // 附加信息,用于判断业务类型
|
|
||||||
AttachVo attachVo = JSONObject.parseObject(remark,AttachVo.class);
|
AttachVo attachVo = JSONObject.parseObject(remark,AttachVo.class);
|
||||||
log.info("【通联微信支付回调】回调参数--附加信息 : 【{}】",JSON.toJSONString(attachVo));
|
log.info("【太米微信支付回调】回调参数--附加信息 : 【{}】",JSON.toJSONString(attachVo));
|
||||||
|
if(PayStatus.isSuccess(trxStatus) && payType.equals("wx_pay")) {
|
||||||
if (SybTrxStatus.isSuccess(trxStatus) && SybTrxCode.WX_PAY.equalsCode(trxCode)) {
|
|
||||||
// 新版支付订单
|
// 新版支付订单
|
||||||
callbackService.businessHandle(outTradeNo,attachVo, ServiceConstants.PAY_TYPE_TLWX);
|
callbackService.businessHandle(outTradeNo,attachVo, ServiceConstants.PAY_TYPE_TLWX);
|
||||||
}
|
}
|
||||||
|
@ -131,4 +129,6 @@ public class CallbackController {
|
||||||
}
|
}
|
||||||
}, 0, TimeUnit.SECONDS);
|
}, 0, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
package com.ruoyi.common.pay;
|
package com.ruoyi.common.pay;
|
||||||
|
|
||||||
|
import com.ruoyi.common.pay.tm.vo.TmTradeInfo;
|
||||||
import com.wechat.pay.java.service.payments.model.Transaction;
|
import com.wechat.pay.java.service.payments.model.Transaction;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class PaymentResult {
|
public class PaymentResult {
|
||||||
|
|
||||||
private Transaction transaction;
|
private Transaction transaction;
|
||||||
|
|
||||||
private Map<String, String> result;
|
private TmTradeInfo tradeInfo;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.ruoyi.common.pay.tm;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.ruoyi.common.utils.http.HttpUtils;
|
import com.ruoyi.common.utils.http.HttpUtils;
|
||||||
|
import com.ruoyi.common.utils.uuid.IdUtils;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
@ -11,15 +12,16 @@ public class Application {
|
||||||
private final static String SIGNKEY = "ac6d97e67b444b7a43edfc9182634786";
|
private final static String SIGNKEY = "ac6d97e67b444b7a43edfc9182634786";
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
pay();
|
orderQuery("tmwx1727172604248");
|
||||||
|
// miniPay();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单查询
|
* 订单查询
|
||||||
*/
|
*/
|
||||||
public static void orderQuery() {
|
public static void orderQuery(String outTradeId) {
|
||||||
HashMap<String, String> body = new HashMap<String, String>();
|
HashMap<String, String> body = new HashMap<String, String>();
|
||||||
body.put("tradeId", "1");
|
body.put("outTradeId", outTradeId);
|
||||||
body.put("terminalType", "1");
|
body.put("terminalType", "1");
|
||||||
body.put("shopId", "488");
|
body.put("shopId", "488");
|
||||||
doPost("/open/Pay/orderQuery", body);
|
doPost("/open/Pay/orderQuery", body);
|
||||||
|
@ -37,34 +39,23 @@ public class Application {
|
||||||
doPost("/open/Pay/refund", body);
|
doPost("/open/Pay/refund", body);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 付款码支付V2
|
|
||||||
*/
|
|
||||||
public static void microPayV2() {
|
|
||||||
HashMap<String, String> body = new HashMap<String, String>();
|
|
||||||
body.put("payAmount", "0.01");
|
|
||||||
body.put("terminalType", "1");
|
|
||||||
body.put("authCode", "3865199665693980");
|
|
||||||
body.put("shopId", "488");
|
|
||||||
doPost("/open/Pay/microPayV2", body);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* jsapi支付
|
// * jsapi支付
|
||||||
*/
|
// */
|
||||||
public static void pay() {
|
// public static void pay() {
|
||||||
HashMap<String, String> body = new HashMap<String, String>();
|
// HashMap<String, String> body = new HashMap<String, String>();
|
||||||
body.put("payAmount", "1");
|
// body.put("payAmount", "1");
|
||||||
body.put("terminalType", "1");
|
// body.put("terminalType", "1");
|
||||||
body.put("shopId", "488");
|
// body.put("shopId", "488");
|
||||||
// 填充必填字段
|
// // 填充必填字段
|
||||||
body.put("payType", "wx_pay"); // 支付方式,可以是 wx.pay, ali.pay, union.online
|
// body.put("payType", "wx_pay"); // 支付方式,可以是 wx.pay, ali.pay, union.online
|
||||||
body.put("outTradeId", "tradeId123"); // 商户订单号
|
// body.put("outTradeId", "tradeId123"); // 商户订单号
|
||||||
body.put("body", "商品描述"); // 商品描述
|
// body.put("body", "商品描述"); // 商品描述
|
||||||
body.put("notifyUrl", "https://yourdomain.com/notify"); // 异步回调URL
|
// body.put("notifyUrl", "https://yourdomain.com/notify"); // 异步回调URL
|
||||||
body.put("frontUrl", "https://yourdomain.com/front"); // 前端页面跳转URL
|
// body.put("frontUrl", "https://yourdomain.com/front"); // 前端页面跳转URL
|
||||||
doPost("/open/Pay/unifiedOrder", body);
|
// doPost("/open/Pay/unifiedOrder", body);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -77,8 +68,9 @@ public class Application {
|
||||||
body.put("shopId", "488");
|
body.put("shopId", "488");
|
||||||
// 填充必填字段
|
// 填充必填字段
|
||||||
body.put("payType", "wx_pay"); // 支付方式,可以是 wx.pay, ali.pay, union.online
|
body.put("payType", "wx_pay"); // 支付方式,可以是 wx.pay, ali.pay, union.online
|
||||||
body.put("outTradeId", "tradeId123"); // 商户订单号
|
body.put("outTradeId", IdUtils.getOrderNo("tmwx")); // 商户订单号
|
||||||
body.put("openid", "111"); // openid
|
System.out.println("----------------------------------:"+body.get("outTradeId"));
|
||||||
|
body.put("openid", "o6yEK7Z0OdWM2N_d8ehItn-5NBH8"); // openid
|
||||||
body.put("body", "商品描述"); // 商品描述
|
body.put("body", "商品描述"); // 商品描述
|
||||||
body.put("notifyUrl", "https://yourdomain.com/notify"); // 异步回调URL
|
body.put("notifyUrl", "https://yourdomain.com/notify"); // 异步回调URL
|
||||||
body.put("frontUrl", "https://yourdomain.com/front"); // 前端页面跳转URL
|
body.put("frontUrl", "https://yourdomain.com/front"); // 前端页面跳转URL
|
||||||
|
|
|
@ -1,11 +1,17 @@
|
||||||
package com.ruoyi.common.pay.tm;
|
package com.ruoyi.common.pay.tm;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
|
import com.ruoyi.common.pay.tm.vo.RefundInfo;
|
||||||
|
import com.ruoyi.common.pay.tm.vo.TmTradeInfo;
|
||||||
import com.ruoyi.common.pay.wx.Payable;
|
import com.ruoyi.common.pay.wx.Payable;
|
||||||
import com.ruoyi.common.pay.wx.RefundAble;
|
import com.ruoyi.common.pay.wx.RefundAble;
|
||||||
import com.ruoyi.common.utils.http.HttpUtils;
|
import com.ruoyi.common.utils.http.HttpUtils;
|
||||||
|
import com.wechat.pay.java.service.payments.jsapi.model.PrepayWithRequestPaymentResponse;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 太米支付
|
* 太米支付
|
||||||
|
@ -13,27 +19,51 @@ import java.util.HashMap;
|
||||||
@Service
|
@Service
|
||||||
public class TmPayService {
|
public class TmPayService {
|
||||||
|
|
||||||
|
private final static String SIGNKEY = "ac6d97e67b444b7a43edfc9182634786";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单查询
|
* 订单查询
|
||||||
*/
|
*/
|
||||||
public static void orderQuery(IChannelInfo channel, String outTradeNo) {
|
public static TmTradeInfo orderQuery(IChannelInfo channel, String outTradeNo) {
|
||||||
HashMap<String, String> body = new HashMap<String, String>();
|
HashMap<String, String> body = new HashMap<String, String>();
|
||||||
body.put("tradeId", outTradeNo);
|
body.put("outTradeId", outTradeNo);
|
||||||
body.put("terminalType", "1");
|
body.put("terminalType", "1");
|
||||||
body.put("shopId", channel.getShopId());
|
body.put("shopId", channel.getShopId());
|
||||||
doPost("/open/Pay/orderQuery", body,channel);
|
String response = doPost("/open/Pay/orderQuery", body,channel);
|
||||||
|
if (com.ruoyi.common.utils.StringUtils.hasText(response)) {
|
||||||
|
JSONObject jsonResponse = JSON.parseObject(response);
|
||||||
|
if (jsonResponse.getInteger("errCode") == 0 && "ok".equals(jsonResponse.getString("errMsg"))) {
|
||||||
|
JSONObject tradeInfo = jsonResponse.getJSONObject("tradeInfo");
|
||||||
|
TmTradeInfo tmTradeInfo = tradeInfo.toJavaObject(TmTradeInfo.class);
|
||||||
|
return tmTradeInfo;
|
||||||
|
} else {
|
||||||
|
throw new ServiceException("订单查询失败: " + jsonResponse.getString("errMsg"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new ServiceException("订单查询数据为空");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 退款
|
* 退款
|
||||||
*/
|
*/
|
||||||
public static void refund(IChannelInfo channel,RefundAble refundAble) {
|
public static RefundInfo refund(IChannelInfo channel,RefundAble refundAble) {
|
||||||
HashMap<String, String> body = new HashMap<String, String>();
|
HashMap<String, String> body = new HashMap<String, String>();
|
||||||
body.put("refundFee", String.valueOf(refundAble.getAmount()));
|
body.put("refundFee", String.valueOf(refundAble.getAmount()));
|
||||||
body.put("terminalType", "1");
|
body.put("terminalType", "1");
|
||||||
body.put("tradeId", refundAble.getOutRefundNo());
|
body.put("outTradeId", refundAble.getOutRefundNo());
|
||||||
body.put("shopId", channel.getShopId());
|
body.put("shopId", channel.getShopId());
|
||||||
doPost("/open/Pay/refund", body,channel);
|
String response = doPost("/open/Pay/refund", body,channel);
|
||||||
|
if (com.ruoyi.common.utils.StringUtils.hasText(response)) {
|
||||||
|
JSONObject jsonResponse = JSON.parseObject(response);
|
||||||
|
if (jsonResponse.getInteger("errCode") == 0 && "ok".equals(jsonResponse.getString("errMsg"))) {
|
||||||
|
JSONObject tradeInfo = jsonResponse.getJSONObject("tradeInfo");
|
||||||
|
RefundInfo refundInfo = tradeInfo.toJavaObject(RefundInfo.class);
|
||||||
|
return refundInfo;
|
||||||
|
} else {
|
||||||
|
throw new ServiceException("退款失败: " + jsonResponse.getString("errMsg"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new ServiceException("退款数据为空");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -41,34 +71,16 @@ public class TmPayService {
|
||||||
*/
|
*/
|
||||||
public static void closeOrder(IChannelInfo channel, String outTradeNo) {
|
public static void closeOrder(IChannelInfo channel, String outTradeNo) {
|
||||||
HashMap<String, String> body = new HashMap<String, String>();
|
HashMap<String, String> body = new HashMap<String, String>();
|
||||||
body.put("tradeId", outTradeNo);
|
body.put("outTradeId", outTradeNo);
|
||||||
body.put("terminalType", "1");
|
body.put("terminalType", "1");
|
||||||
body.put("shopId", channel.getShopId());
|
body.put("shopId", channel.getShopId());
|
||||||
doPost("/open/Pay/orderQuery", body,channel);
|
doPost("/open/Pay/orderClose", body,channel);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* JSAPI支付
|
|
||||||
*/
|
|
||||||
public void pay(IChannelInfo channel, Payable payable) {
|
|
||||||
HashMap<String, String> body = new HashMap<>();
|
|
||||||
body.put("payAmount", String.valueOf(payable.getAmount()));
|
|
||||||
body.put("terminalType", "1");
|
|
||||||
body.put("shopId", channel.getShopId()); // 从渠道获取shopId
|
|
||||||
body.put("sn", channel.getSn());
|
|
||||||
body.put("payType", "wx_pay");
|
|
||||||
body.put("outTradeId", payable.getOutTradeNo());
|
|
||||||
body.put("body", payable.getDescription());
|
|
||||||
body.put("notifyUrl", channel.getNotifyUrl());
|
|
||||||
body.put("frontUrl", channel.getFrontUrl());
|
|
||||||
|
|
||||||
doPost(channel.getHttpUrl() + "/open/Pay/unifiedOrder", body, channel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 小程序支付
|
* 小程序支付
|
||||||
*/
|
*/
|
||||||
public void miniPay(IChannelInfo channel, Payable payable) {
|
public static PrepayWithRequestPaymentResponse pay(IChannelInfo channel, Payable payable) {
|
||||||
HashMap<String, String> body = new HashMap<>();
|
HashMap<String, String> body = new HashMap<>();
|
||||||
body.put("payAmount", String.valueOf(payable.getAmount()));
|
body.put("payAmount", String.valueOf(payable.getAmount()));
|
||||||
body.put("terminalType", "1");
|
body.put("terminalType", "1");
|
||||||
|
@ -78,14 +90,26 @@ public class TmPayService {
|
||||||
body.put("outTradeId", payable.getOutTradeNo());
|
body.put("outTradeId", payable.getOutTradeNo());
|
||||||
body.put("body", payable.getDescription());
|
body.put("body", payable.getDescription());
|
||||||
body.put("notifyUrl", channel.getNotifyUrl());
|
body.put("notifyUrl", channel.getNotifyUrl());
|
||||||
body.put("frontUrl", channel.getFrontUrl());
|
String response = doPost(channel.getHttpUrl() + "/open/Pay/miniPay", body, channel);
|
||||||
|
|
||||||
doPost(channel.getHttpUrl() + "/open/Pay/miniPay", body, channel);
|
if (com.ruoyi.common.utils.StringUtils.hasText(response)) {
|
||||||
|
// 解析 response,提取 "params" 字段
|
||||||
|
JSONObject jsonResponse = JSON.parseObject(response);
|
||||||
|
if (jsonResponse.getInteger("errCode") == 0 && "ok".equals(jsonResponse.getString("errMsg"))) {
|
||||||
|
// 提取 "params" 并转成 PrepayWithRequestPaymentResponse 对象
|
||||||
|
JSONObject params = jsonResponse.getJSONObject("params");
|
||||||
|
PrepayWithRequestPaymentResponse paymentResponse = params.toJavaObject(PrepayWithRequestPaymentResponse.class);
|
||||||
|
return paymentResponse;
|
||||||
|
} else {
|
||||||
|
throw new ServiceException("支付失败: " + jsonResponse.getString("errMsg"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new ServiceException("支付数据为空");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static void doPost(String url, HashMap<String, String> body, IChannelInfo channel) {
|
private static String doPost(String url, HashMap<String, String> body, IChannelInfo channel) {
|
||||||
body.put("developerId", channel.getDeveloperId());
|
body.put("developerId", channel.getDeveloperId());
|
||||||
body.put("version", "1.0");
|
body.put("version", "1.0");
|
||||||
body.put("timestamp", String.valueOf(System.currentTimeMillis() / 1000));
|
body.put("timestamp", String.valueOf(System.currentTimeMillis() / 1000));
|
||||||
|
@ -99,6 +123,22 @@ public class TmPayService {
|
||||||
headerData.put("Content-Type", "application/json");
|
headerData.put("Content-Type", "application/json");
|
||||||
|
|
||||||
String response = HttpUtils.sendPostWithHeaders(url, headerData, JSON.toJSONString(body));
|
String response = HttpUtils.sendPostWithHeaders(url, headerData, JSON.toJSONString(body));
|
||||||
System.out.println("API Response: " + response);
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean validSign(TreeMap<String, String> params) {
|
||||||
|
// 获取传递过来的签名
|
||||||
|
String receivedSign = params.get("sign"); // 获取签名字段
|
||||||
|
if (receivedSign == null) {
|
||||||
|
return false; // 如果没有传递签名,验签失败
|
||||||
|
}
|
||||||
|
// 移除签名字段后,重新生成签名
|
||||||
|
params.remove("sign");
|
||||||
|
// 按照请求时的签名逻辑,生成签名字符串
|
||||||
|
String paramsStr = StringUtils.getAsciiSort(params); // 按ASCII排序
|
||||||
|
String generatedSign = Md5Utils.getMD5Code(paramsStr + "&key=" + SIGNKEY).toUpperCase(); // 重新生成签名
|
||||||
|
// 比较签名是否一致
|
||||||
|
return generatedSign.equals(receivedSign);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
package com.ruoyi.common.pay.tm.enums;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 交易结果
|
||||||
|
* @author qzz
|
||||||
|
* 2024/9/24
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum PayStatus {
|
||||||
|
|
||||||
|
SUCCESS("SUCCESS", "支付成功"),
|
||||||
|
NOTPAY("NOTPAY", "未支付"),
|
||||||
|
CLOSE("CLOSE", "已关闭"),
|
||||||
|
REVOKED("REVOKED", "已撤销"),
|
||||||
|
USERPAYING("USERPAYING", "用户支付中"),
|
||||||
|
PAYERROR("PAYERROR", "支付失败"),
|
||||||
|
REFUND("REFUND", "转入退款"),
|
||||||
|
OPERATE_SUCCESS("OPERATE_SUCCESS", "预授权请求操作成功"),
|
||||||
|
OPERATE_FAIL("OPERATE_FAIL", "预授权请求操作失败"),
|
||||||
|
OPERATE_SETTLING("OPERATE_SETTLING", "押金消费已受理"),
|
||||||
|
REVOKED_SUCCESS("REVOKED_SUCCESS", "预授权请求撤销成功");
|
||||||
|
|
||||||
|
private final String code;
|
||||||
|
private final String description;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断支付状态是否成功
|
||||||
|
* @param code 支付状态码
|
||||||
|
* @return 是否成功
|
||||||
|
*/
|
||||||
|
public static boolean isSuccess(String code) {
|
||||||
|
return SUCCESS.getCode().equals(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据状态码获取对应的支付状态
|
||||||
|
* @param code 支付状态码
|
||||||
|
* @return 对应的PayStatus枚举
|
||||||
|
*/
|
||||||
|
public static PayStatus getByCode(String code) {
|
||||||
|
for (PayStatus status : PayStatus.values()) {
|
||||||
|
if (status.getCode().equals(code)) {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
package com.ruoyi.common.pay.tm.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 退款状态枚举
|
||||||
|
* @author
|
||||||
|
* 2024/09/24
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum RefundStatus {
|
||||||
|
FAILED(0, "退款失败"),
|
||||||
|
REFUNDED(1, "转入退款");
|
||||||
|
|
||||||
|
private final int code;
|
||||||
|
private final String description;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据状态码判断是否退款成功
|
||||||
|
* @param code 状态码
|
||||||
|
* @return 是否退款成功
|
||||||
|
*/
|
||||||
|
public static boolean isSuccess(int code) {
|
||||||
|
return REFUNDED.getCode() == code;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据状态码获取对应的退款状态枚举
|
||||||
|
* @param code 状态码
|
||||||
|
* @return 对应的 RefundStatus 枚举
|
||||||
|
*/
|
||||||
|
public static RefundStatus getByCode(int code) {
|
||||||
|
for (RefundStatus status : RefundStatus.values()) {
|
||||||
|
if (status.getCode() == code) {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.ruoyi.common.pay.tm.vo;
|
||||||
|
|
||||||
|
import com.ruoyi.common.pay.tm.enums.RefundStatus;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 退款信息对象
|
||||||
|
* @author
|
||||||
|
* 2024/09/24
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class RefundInfo {
|
||||||
|
private Long id; // 太米系统退款记录Id
|
||||||
|
private Long tradeInfoId; // 太米系统流水Id
|
||||||
|
private String module; // 模块: pay, mall, recharge, become_member, eatIn, takeOut, selfTake, payment_card, times_card
|
||||||
|
private String remark; // 备注
|
||||||
|
private Long merchantId; // 品牌Id
|
||||||
|
private Long shopId; // 门店Id
|
||||||
|
private Long merchantUserId; // 门店员工Id
|
||||||
|
private Long codeId; // 款台码Id
|
||||||
|
private Long memberInfoId; // 会员Id
|
||||||
|
private Long workRecordId; // 交班记录Id
|
||||||
|
private String fromType; // 订单来源: wx, alipay, web, mini, pos, pc, desktop, api
|
||||||
|
private String refundTime; // 退款成功时间
|
||||||
|
private String refundMessage; // 退款失败原因
|
||||||
|
private RefundStatus refundStatus; // 退款状态: RefundStatus 枚举
|
||||||
|
private BigDecimal refundAmount; // 已退款金额
|
||||||
|
private String createTime; // 创建时间
|
||||||
|
}
|
|
@ -0,0 +1,181 @@
|
||||||
|
package com.ruoyi.common.pay.tm.vo;
|
||||||
|
|
||||||
|
import com.ruoyi.common.pay.tm.enums.PayStatus;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class TmTradeInfo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 太米系统流水Id
|
||||||
|
*/
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 第三方内部流水号
|
||||||
|
*/
|
||||||
|
private String outTradeId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 微信或支付宝或银联的订单号。个别支付渠道可能无此参数
|
||||||
|
*/
|
||||||
|
private String transactionId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 太米商户订单号
|
||||||
|
*/
|
||||||
|
private String orderNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付凭证条码,个别支付渠道可能返回空
|
||||||
|
*/
|
||||||
|
private String barCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模块:pay:收银;mall:优选卡券货架;recharge:充值;
|
||||||
|
* become_member:会员购买;eatIn:店内下单;
|
||||||
|
* takeOut:外送订单;selfTake:预约自取;
|
||||||
|
* payment_card:付费卡券;times_card:次/月卡
|
||||||
|
*/
|
||||||
|
private String module;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 品牌Id
|
||||||
|
*/
|
||||||
|
private Integer merchantId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 门店Id
|
||||||
|
*/
|
||||||
|
private Integer shopId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 门店员工id
|
||||||
|
*/
|
||||||
|
private Integer merchantUserId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 款台码Id
|
||||||
|
*/
|
||||||
|
private Integer codeId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员Id
|
||||||
|
*/
|
||||||
|
private Integer memberInfoId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 交班记录id
|
||||||
|
*/
|
||||||
|
private Integer workRecordId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单来源:wx:微信收款码;alipay:支付宝收款码;
|
||||||
|
* web:Web页面;mini:小程序;pos:POS机;
|
||||||
|
* pc:PC;desktop:台式消费机;api:开放平台接口
|
||||||
|
*/
|
||||||
|
private String fromType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单总额,单位分
|
||||||
|
*/
|
||||||
|
private Integer orderAmount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员优惠,单位分
|
||||||
|
*/
|
||||||
|
private Integer memberCoupon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 活动优惠,单位分
|
||||||
|
*/
|
||||||
|
private Integer activityCoupon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 卡券优惠,单位分
|
||||||
|
*/
|
||||||
|
private Integer cardCoupon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 积分抵扣,单位分
|
||||||
|
*/
|
||||||
|
private Integer pointDeduction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实收金额,单位分
|
||||||
|
*/
|
||||||
|
private Integer incomeAmount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付方式:wx_pay:微信支付;ali_pay:支付宝;
|
||||||
|
* union_offline:银行卡;union_qrcode:银联扫码;
|
||||||
|
* union_online:银联钱包;member_wallet:会员钱包;cash:现金
|
||||||
|
*/
|
||||||
|
private String payType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 1、已支付 0、未支付
|
||||||
|
*/
|
||||||
|
private Integer isPaid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付状态:
|
||||||
|
* SUCCESS:支付成功;NOTPAY:未支付;CLOSE:已关闭;
|
||||||
|
* REVOKED:已撤销;USERPAYING:用户支付中;
|
||||||
|
* PAYERROR:支付失败;REFUND:转入退款;
|
||||||
|
* OPERATE_SUCCESS:预授权请求操作成功、OPERATE_FAIL:预授权请求操作失败;
|
||||||
|
* OPERATE_SETTLING:押金消费已受理;
|
||||||
|
* REVOKED_SUCCESS:预授权请求撤销成功
|
||||||
|
*/
|
||||||
|
private PayStatus payStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付时间
|
||||||
|
*/
|
||||||
|
private String payTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付失败原因
|
||||||
|
*/
|
||||||
|
private String payError;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 退款状态:0表示未退款,1表示转入退款
|
||||||
|
*/
|
||||||
|
private Integer refundStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 已退款金额,单位分
|
||||||
|
*/
|
||||||
|
private Integer refundAmount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 终端sn号
|
||||||
|
*/
|
||||||
|
private String sn;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应结订单金额(微信代金券用)
|
||||||
|
*/
|
||||||
|
private String settlementTotalFee;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 0 : 普通订单 1:刷脸设备刷脸支付 2 : 刷脸设备扫码支付 3 : 刷脸设备会员钱包支付
|
||||||
|
*/
|
||||||
|
private String isFromFacePay;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 总代金券金额(微信代金券用)
|
||||||
|
*/
|
||||||
|
private String couponFee;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private String createTime;
|
||||||
|
}
|
|
@ -13,8 +13,9 @@ import com.ruoyi.common.core.domain.entity.SysDept;
|
||||||
import com.ruoyi.common.enums.BusinessStatus;
|
import com.ruoyi.common.enums.BusinessStatus;
|
||||||
import com.ruoyi.common.exception.ServiceException;
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
import com.ruoyi.common.pay.PaymentResult;
|
import com.ruoyi.common.pay.PaymentResult;
|
||||||
import com.ruoyi.common.pay.syb.enums.SybTrxStatus;
|
import com.ruoyi.common.pay.tm.TmPayService;
|
||||||
import com.ruoyi.common.pay.syb.service.SybPayService;
|
import com.ruoyi.common.pay.tm.enums.PayStatus;
|
||||||
|
import com.ruoyi.common.pay.tm.vo.TmTradeInfo;
|
||||||
import com.ruoyi.common.utils.CommonUtil;
|
import com.ruoyi.common.utils.CommonUtil;
|
||||||
import com.ruoyi.common.utils.DateUtils;
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
import com.ruoyi.common.utils.PageUtils;
|
import com.ruoyi.common.utils.PageUtils;
|
||||||
|
@ -131,7 +132,7 @@ public class EtOrderServiceImpl implements IEtOrderService
|
||||||
private EtChannelService etChannelService;
|
private EtChannelService etChannelService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SybPayService sybPayService;
|
private TmPayService tmPayService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询订单
|
* 查询订单
|
||||||
|
@ -531,13 +532,13 @@ public class EtOrderServiceImpl implements IEtOrderService
|
||||||
log.info("【押金抵扣】订单【{}】,有outTradeNo = 【{}】,查询订单未支付,关闭订单:{}", order.getOrderNo(),outTradeNo,b);
|
log.info("【押金抵扣】订单【{}】,有outTradeNo = 【{}】,查询订单未支付,关闭订单:{}", order.getOrderNo(),outTradeNo,b);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
Map<String, String> result = paymentResult.getResult();
|
TmTradeInfo tradeInfo = paymentResult.getTradeInfo();
|
||||||
if(SybTrxStatus.isSuccess(result.get("trxstatus"))) {
|
if(PayStatus.isSuccess(tradeInfo.getPayStatus().getCode())) {
|
||||||
handleSuccess(order);
|
handleSuccess(order);
|
||||||
return 1;
|
return 1;
|
||||||
}else{
|
}else{
|
||||||
// 没有支付,则关闭订单
|
// 没有支付,则关闭订单
|
||||||
sybPayService.closeOrderWx(outTradeNo);
|
tmPayService.closeOrder(channelVO,outTradeNo);
|
||||||
log.info("【押金抵扣】订单【{}】,有outTradeNo = 【{}】,查询订单未支付,关闭订单:{}", order.getOrderNo(),outTradeNo);
|
log.info("【押金抵扣】订单【{}】,有outTradeNo = 【{}】,查询订单未支付,关闭订单:{}", order.getOrderNo(),outTradeNo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,11 @@ import com.ruoyi.common.core.redis.RedisLock;
|
||||||
import com.ruoyi.common.enums.PayChannel;
|
import com.ruoyi.common.enums.PayChannel;
|
||||||
import com.ruoyi.common.exception.ServiceException;
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
import com.ruoyi.common.pay.PaymentResult;
|
import com.ruoyi.common.pay.PaymentResult;
|
||||||
import com.ruoyi.common.pay.syb.enums.SybTrxStatus;
|
import com.ruoyi.common.pay.tm.TmPayService;
|
||||||
import com.ruoyi.common.pay.syb.service.SybPayService;
|
import com.ruoyi.common.pay.tm.enums.PayStatus;
|
||||||
|
import com.ruoyi.common.pay.tm.enums.RefundStatus;
|
||||||
|
import com.ruoyi.common.pay.tm.vo.RefundInfo;
|
||||||
|
import com.ruoyi.common.pay.tm.vo.TmTradeInfo;
|
||||||
import com.ruoyi.common.pay.wx.Payable;
|
import com.ruoyi.common.pay.wx.Payable;
|
||||||
import com.ruoyi.common.pay.wx.RefundAble;
|
import com.ruoyi.common.pay.wx.RefundAble;
|
||||||
import com.ruoyi.common.utils.DateUtils;
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
|
@ -33,14 +36,11 @@ import com.wechat.pay.java.service.payments.jsapi.JsapiService;
|
||||||
import com.wechat.pay.java.service.payments.jsapi.JsapiServiceExtension;
|
import com.wechat.pay.java.service.payments.jsapi.JsapiServiceExtension;
|
||||||
import com.wechat.pay.java.service.payments.jsapi.model.*;
|
import com.wechat.pay.java.service.payments.jsapi.model.*;
|
||||||
import com.wechat.pay.java.service.payments.model.Transaction;
|
import com.wechat.pay.java.service.payments.model.Transaction;
|
||||||
import com.wechat.pay.java.service.profitsharing.ProfitsharingService;
|
|
||||||
import com.wechat.pay.java.service.profitsharing.model.*;
|
|
||||||
import com.wechat.pay.java.service.refund.RefundService;
|
import com.wechat.pay.java.service.refund.RefundService;
|
||||||
import com.wechat.pay.java.service.refund.model.AmountReq;
|
import com.wechat.pay.java.service.refund.model.AmountReq;
|
||||||
import com.wechat.pay.java.service.refund.model.CreateRequest;
|
import com.wechat.pay.java.service.refund.model.CreateRequest;
|
||||||
import com.wechat.pay.java.service.refund.model.QueryByOutRefundNoRequest;
|
import com.wechat.pay.java.service.refund.model.QueryByOutRefundNoRequest;
|
||||||
import com.wechat.pay.java.service.refund.model.Refund;
|
import com.wechat.pay.java.service.refund.model.Refund;
|
||||||
import com.wechat.pay.java.service.transferbatch.TransferBatchService;
|
|
||||||
import com.wechat.pay.java.service.transferbatch.model.InitiateBatchTransferRequest;
|
import com.wechat.pay.java.service.transferbatch.model.InitiateBatchTransferRequest;
|
||||||
import com.wechat.pay.java.service.transferbatch.model.InitiateBatchTransferResponse;
|
import com.wechat.pay.java.service.transferbatch.model.InitiateBatchTransferResponse;
|
||||||
import com.wechat.pay.java.service.transferbatch.model.TransferDetailInput;
|
import com.wechat.pay.java.service.transferbatch.model.TransferDetailInput;
|
||||||
|
@ -50,9 +50,7 @@ import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
@ -84,7 +82,7 @@ public class WxPayService implements IWxPayService {
|
||||||
private AsUserMapper asUserMapper;
|
private AsUserMapper asUserMapper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SybPayService sybPayService;
|
private TmPayService tmPayService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private EtChannelService etChannelService;
|
private EtChannelService etChannelService;
|
||||||
|
@ -167,7 +165,7 @@ public class WxPayService implements IWxPayService {
|
||||||
|
|
||||||
if(StrUtil.isNotBlank(order.getOutTradeNo())){
|
if(StrUtil.isNotBlank(order.getOutTradeNo())){
|
||||||
// 关闭订单
|
// 关闭订单
|
||||||
sybPayService.closeOrderWx(order.getOutTradeNo());
|
tmPayService.closeOrder(channelVO,order.getOutTradeNo());
|
||||||
}
|
}
|
||||||
Payable payable = new Payable();
|
Payable payable = new Payable();
|
||||||
payable.setAmount(order.getPayFee().multiply(new BigDecimal(100)).longValue());
|
payable.setAmount(order.getPayFee().multiply(new BigDecimal(100)).longValue());
|
||||||
|
@ -176,7 +174,7 @@ public class WxPayService implements IWxPayService {
|
||||||
payable.setDescription(description);
|
payable.setDescription(description);
|
||||||
payable.setOpenid(user.getWxopenid());
|
payable.setOpenid(user.getWxopenid());
|
||||||
payable.setAppid(channelVO.getAppid());
|
payable.setAppid(channelVO.getAppid());
|
||||||
PrepayWithRequestPaymentResponse res = sybPayService.prepayWxApp(payable);
|
PrepayWithRequestPaymentResponse res = tmPayService.pay(channelVO,payable);
|
||||||
return res;
|
return res;
|
||||||
}else{
|
}else{
|
||||||
throw new ServiceException("支付渠道【"+channelVO.getCode()+"】暂不支持");
|
throw new ServiceException("支付渠道【"+channelVO.getCode()+"】暂不支持");
|
||||||
|
@ -248,12 +246,12 @@ public class WxPayService implements IWxPayService {
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}else if(PayChannel.TM_WX.equalsCode(channelVO.getCode())){
|
}else if(PayChannel.TM_WX.equalsCode(channelVO.getCode())){
|
||||||
log.info("----优惠券------{}-------------","通联微信支付");
|
log.info("----优惠券------{}-------------","太米微信支付");
|
||||||
|
|
||||||
// 获取JSAPI所需参数
|
// 获取JSAPI所需参数
|
||||||
if(StrUtil.isNotBlank(order.getOutTradeNo())){
|
if(StrUtil.isNotBlank(order.getOutTradeNo())){
|
||||||
// 关闭订单
|
// 关闭订单
|
||||||
sybPayService.closeOrderWx(order.getOutTradeNo());
|
tmPayService.closeOrder(channelVO,order.getOutTradeNo());
|
||||||
}
|
}
|
||||||
|
|
||||||
Payable payable = new Payable();
|
Payable payable = new Payable();
|
||||||
|
@ -262,7 +260,7 @@ public class WxPayService implements IWxPayService {
|
||||||
payable.setAttach(JSON.toJSONString(new AttachVo(order.getType(),user.getUserId(), "")));
|
payable.setAttach(JSON.toJSONString(new AttachVo(order.getType(),user.getUserId(), "")));
|
||||||
payable.setDescription(description);
|
payable.setDescription(description);
|
||||||
payable.setOpenid(user.getWxopenid());
|
payable.setOpenid(user.getWxopenid());
|
||||||
PrepayWithRequestPaymentResponse res = sybPayService.prepayWxApp(payable);
|
PrepayWithRequestPaymentResponse res = tmPayService.pay(channelVO,payable);
|
||||||
return res;
|
return res;
|
||||||
}else{
|
}else{
|
||||||
throw new ServiceException("支付渠道【"+channelVO.getCode()+"】暂不支持");
|
throw new ServiceException("支付渠道【"+channelVO.getCode()+"】暂不支持");
|
||||||
|
@ -314,9 +312,9 @@ public class WxPayService implements IWxPayService {
|
||||||
paymentResult1.setTransaction(transaction);
|
paymentResult1.setTransaction(transaction);
|
||||||
return paymentResult1;
|
return paymentResult1;
|
||||||
}else if(PayChannel.TM_WX.equalsCode(channelVO.getCode())){
|
}else if(PayChannel.TM_WX.equalsCode(channelVO.getCode())){
|
||||||
Map<String, String> result = sybPayService.queryOrderByOutTradeNo(order.getOutTradeNo());
|
TmTradeInfo tmTradeInfo = tmPayService.orderQuery(channelVO, order.getOutTradeNo());
|
||||||
if(SybTrxStatus.isSuccess(result.get("trxstatus"))) {
|
if(PayStatus.isSuccess(tmTradeInfo.getPayStatus().getCode())) {
|
||||||
paymentResult1.setResult(result);
|
paymentResult1.setTradeInfo(tmTradeInfo);
|
||||||
return paymentResult1;
|
return paymentResult1;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -389,8 +387,8 @@ public class WxPayService implements IWxPayService {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}else if(PayChannel.TM_WX.equalsCode(channelVO.getCode())){
|
}else if(PayChannel.TM_WX.equalsCode(channelVO.getCode())){
|
||||||
Map<String, String> result = sybPayService.queryOrderByOutTradeNo(order.getOutTradeNo());
|
TmTradeInfo tmTradeInfo = tmPayService.orderQuery(channelVO, order.getOutTradeNo());
|
||||||
if(SybTrxStatus.isSuccess(result.get("trxstatus"))) {
|
if(PayStatus.isSuccess(tmTradeInfo.getPayStatus().getCode())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
@ -440,22 +438,17 @@ public class WxPayService implements IWxPayService {
|
||||||
Refund refund = refundService.create(request);
|
Refund refund = refundService.create(request);
|
||||||
log.info("【退款】微信返回结果:【{}】",JSON.toJSONString(refund));
|
log.info("【退款】微信返回结果:【{}】",JSON.toJSONString(refund));
|
||||||
}else if(PayChannel.TM_WX.equalsCode(channelVO.getCode())){
|
}else if(PayChannel.TM_WX.equalsCode(channelVO.getCode())){
|
||||||
log.info("----------{}-------------","通联微信退款");
|
log.info("----------{}-------------","太米微信退款");
|
||||||
RefundAble refundAble = new RefundAble();
|
RefundAble refundAble = new RefundAble();
|
||||||
refundAble.setOutTradeNo(etOrder.getOutTradeNo());
|
refundAble.setOutTradeNo(etOrder.getOutTradeNo());
|
||||||
refundAble.setOutRefundNo(outRefundNo);
|
refundAble.setOutRefundNo(outRefundNo);
|
||||||
refundAble.setReason(reason);
|
refundAble.setReason(reason);
|
||||||
refundAble.setAmount(amount.multiply(new BigDecimal(100)).longValue());
|
refundAble.setAmount(amount.multiply(new BigDecimal(100)).longValue());
|
||||||
Map<String, String> refundResult = sybPayService.refundWx(refundAble);
|
RefundInfo refund = tmPayService.refund(channelVO, refundAble);
|
||||||
String trxStatus = refundResult.get("trxstatus");
|
ServiceUtil.assertion(!RefundStatus.isSuccess(refund.getRefundStatus().getCode()), "发起退款失败:" + refund.getRefundMessage());
|
||||||
// 当状态不为空,则判断是否处理退款成功
|
|
||||||
if (trxStatus != null) {
|
|
||||||
ServiceUtil.assertion(!SybTrxStatus.isSuccess(trxStatus), "发起退款失败:" + refundResult.get("errmsg"));
|
|
||||||
// 通联退款是同步通知,直接处理退款成功
|
|
||||||
scheduledExecutorService.schedule(() -> {
|
scheduledExecutorService.schedule(() -> {
|
||||||
handleRefundSuccess(outRefundNo);
|
handleRefundSuccess(outRefundNo);
|
||||||
}, 0, TimeUnit.SECONDS);
|
}, 0, TimeUnit.SECONDS);
|
||||||
}
|
|
||||||
}else{
|
}else{
|
||||||
throw new ServiceException("支付渠道【"+channelVO.getCode()+"】暂不支持");
|
throw new ServiceException("支付渠道【"+channelVO.getCode()+"】暂不支持");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user