支付调整
This commit is contained in:
20
cash-sdk/poly-pay/pom.xml
Normal file
20
cash-sdk/poly-pay/pom.xml
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.czg</groupId>
|
||||
<artifactId>cash-sdk</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>poly-pay</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
277
cash-sdk/poly-pay/src/main/java/com/czg/PolyPayUtils.java
Normal file
277
cash-sdk/poly-pay/src/main/java/com/czg/PolyPayUtils.java
Normal file
@@ -0,0 +1,277 @@
|
||||
package com.czg;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.digest.MD5;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.alibaba.fastjson2.TypeReference;
|
||||
import com.czg.entity.PolyBaseReq;
|
||||
import com.czg.entity.PolyBaseResp;
|
||||
import com.czg.entity.resp.*;
|
||||
import com.czg.enums.CzgPayEnum;
|
||||
import com.czg.pay.CzgPayBaseReq;
|
||||
import com.czg.pay.CzgRefundReq;
|
||||
import com.czg.resp.CzgRespCode;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import lombok.NonNull;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author ww
|
||||
* @description 聚合支付类
|
||||
*/
|
||||
@Slf4j
|
||||
public class PolyPayUtils {
|
||||
|
||||
/**
|
||||
* h5支付
|
||||
*
|
||||
* @param domain 域名
|
||||
* @param appId 应用id tb_shop_merchant 表中的 app_id
|
||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||
* CzgResult<CzgH5PayResp>
|
||||
*/
|
||||
public static CzgResult<Map<String, Object>> h5Pay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgPayBaseReq<?> bizData) {
|
||||
return execPayResult(sendPolyPay(domain.concat(CzgPayEnum.H5_PAY.getUri()), PolyBaseReq.getInstance(appId, appSecret, bizData), CzgH5PayResp.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* js支付
|
||||
*
|
||||
* @param domain 域名
|
||||
* @param appId 应用id tb_shop_merchant 表中的 app_id
|
||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||
* CzgResult<CzgJsPayResp>
|
||||
*/
|
||||
public static CzgResult<Map<String, Object>> jsPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgPayBaseReq<?> bizData) {
|
||||
return execPayResult(sendPolyPay(domain.concat(CzgPayEnum.JS_PAY.getUri()), PolyBaseReq.getInstance(appId, appSecret, bizData), CzgJsPayResp.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* 小程序支付
|
||||
*
|
||||
* @param domain 域名
|
||||
* @param appId 应用id tb_shop_merchant 表中的 app_id
|
||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||
* CzgResult<CzgLtPayResp>
|
||||
*/
|
||||
public static CzgResult<Map<String, Object>> ltPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgPayBaseReq<?> bizData) {
|
||||
return execPayResult(sendPolyPay(domain.concat(CzgPayEnum.LT_PAY.getUri()), PolyBaseReq.getInstance(appId, appSecret, bizData), CzgLtPayResp.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* PC扫码支付
|
||||
*
|
||||
* @param domain 域名
|
||||
* @param appId 应用id tb_shop_merchant 表中的 app_id
|
||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||
* CzgResult<CzgScanPayResp>
|
||||
*/
|
||||
public static CzgResult<Map<String, Object>> scanPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgPayBaseReq<?> bizData) {
|
||||
return execPayResult(sendPolyPay(domain.concat(CzgPayEnum.SCAN_PAY.getUri()), PolyBaseReq.getInstance(appId, appSecret, bizData), CzgScanPayResp.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* 聚合反扫
|
||||
*
|
||||
* @param domain 域名
|
||||
* @param appId 应用id tb_shop_merchant 表中的 app_id
|
||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||
* CzgResult<CzgMicroPayResp>
|
||||
*/
|
||||
public static CzgResult<Map<String, Object>> microPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgPayBaseReq<?> bizData) {
|
||||
return execPayResult(sendPolyPay(domain.concat(CzgPayEnum.MICRO_PAY.getUri()), PolyBaseReq.getInstance(appId, appSecret, bizData), CzgMicroPayResp.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单查询
|
||||
*
|
||||
* @param domain 域名
|
||||
* @param appId 应用id tb_shop_merchant 表中的 app_id
|
||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||
* @param payOrderId 平台订单号
|
||||
* @param mchOrderNo 商户订单号
|
||||
*/
|
||||
public static CzgResult<CzgBaseResp> queryPayOrder(@NonNull String domain, @NonNull String appId, @NonNull String appSecret,
|
||||
String payOrderId, String mchOrderNo) {
|
||||
JSONObject queryPayOrder = new JSONObject();
|
||||
queryPayOrder.put("payOrderId", payOrderId);
|
||||
queryPayOrder.put("mchOrderNo", mchOrderNo);
|
||||
return sendPolyPay(domain.concat(CzgPayEnum.TRADE.getUri()), PolyBaseReq.getInstance(appId, appSecret, queryPayOrder), CzgBaseResp.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 订单退款
|
||||
*
|
||||
* @param domain 域名
|
||||
* @param appId 应用id tb_shop_merchant 表中的 app_id
|
||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||
*/
|
||||
public static CzgResult<CzgRefundResp> refundOrder(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgRefundReq bizData) {
|
||||
return sendPolyPay(domain.concat(CzgPayEnum.REFUND.getUri()), PolyBaseReq.getInstance(appId, appSecret, bizData), CzgRefundResp.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 退款订单查询
|
||||
*
|
||||
* @param domain 域名
|
||||
* @param appId 应用id tb_shop_merchant 表中的 app_id
|
||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||
* @param mchRefundNo 商户退款订单号 二选一
|
||||
* @param refundOrderId 平台退款订单号 二选一
|
||||
*/
|
||||
public static CzgResult<CzgRefundResp> queryRefundOrder(@NonNull String domain, @NonNull String appId, @NonNull String appSecret,
|
||||
String mchRefundNo, String refundOrderId) {
|
||||
JSONObject queryPayOrder = new JSONObject();
|
||||
queryPayOrder.put("mchRefundNo", mchRefundNo);
|
||||
queryPayOrder.put("refundOrderId", refundOrderId);
|
||||
return sendPolyPay(domain.concat(CzgPayEnum.QUERY_REFUND.getUri()), PolyBaseReq.getInstance(appId, appSecret, queryPayOrder), CzgRefundResp.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 回调数据处理
|
||||
*/
|
||||
public static JSONObject getCzg(PolyBaseResp respParams) {
|
||||
AssertUtil.isNull(respParams, "聚合交易 回调数据为空");
|
||||
log.info("聚合交易请求响应,{}", respParams);
|
||||
if (!"000000".equals(respParams.getCode())) {
|
||||
log.error("聚合回调响应失败,{}", respParams);
|
||||
return null;
|
||||
}
|
||||
// if (StrUtil.isNotBlank(respParams.getSign())) {
|
||||
// if (validateSign(respParams.getSign(), respParams.getBizData())) {
|
||||
// log.error("聚合回调 验签失败");
|
||||
// }
|
||||
// }
|
||||
return JSONObject.parse(respParams.getBizData());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认Post
|
||||
*
|
||||
* @param url 请求地址
|
||||
* @param params 参数实体
|
||||
* @return {
|
||||
* "code": "状态码", 200为成功
|
||||
* "msg": "描述"
|
||||
* "data": "返回Json数据",
|
||||
* }
|
||||
*/
|
||||
private static <T> CzgResult<T> sendPolyPay(String url, PolyBaseReq params, Class<T> clazz) {
|
||||
CzgResult<T> result = CzgResult.success();
|
||||
Map<String, Object> reqMap = BeanUtil.beanToMap(params, false, false);
|
||||
params.setSign(MD5.create().digestHex(sortFields(new TreeMap<>(reqMap))));
|
||||
log.info("聚合交易请求参数,{}", JSONObject.toJSONString(params));
|
||||
try (HttpResponse resp = HttpRequest.post(url).body(JSONObject.toJSONString(params)).execute()) {
|
||||
if (resp.isOk()) {
|
||||
// 获取响应体
|
||||
String respStr = resp.body();
|
||||
if (StrUtil.isNotEmpty(respStr)) {
|
||||
log.info("聚合交易请求响应元数据,{}", respStr);
|
||||
PolyBaseResp respParams = JSONObject.parseObject(respStr, PolyBaseResp.class);
|
||||
log.info("聚合交易请求响应,{}", respParams);
|
||||
|
||||
result.setCode("000000".equals(respParams.getCode()) ? 200 : Integer.parseInt(respParams.getCode()));
|
||||
result.setMsg(respParams.getMsg());
|
||||
if ("000000".equals(respParams.getCode()) && StrUtil.isNotBlank(respParams.getSign())) {
|
||||
// if (validateSign(respParams.getSign(), JSONObject.toJSONString(respParams))) {
|
||||
// result.setCode(CzgRespCode.FAILURE.getCode());
|
||||
// result.setMsg("验签失败");
|
||||
// log.info("验签失败");
|
||||
// }
|
||||
result.setData(JSONObject.parseObject(respParams.getBizData(), clazz));
|
||||
}
|
||||
} else {
|
||||
result.setCode(resp.getStatus());
|
||||
result.setMsg("聚合交易请求失败");
|
||||
log.error("聚合交易请求失败,状态码: {}", resp.getStatus());
|
||||
}
|
||||
} else {
|
||||
result.setCode(resp.getStatus());
|
||||
result.setMsg("聚合交易请求失败");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("聚合交易请求异常", e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sign 签名
|
||||
* @param dataJsonStr 业务数据
|
||||
* @return false 验签通过 true 验签失败
|
||||
*/
|
||||
private static boolean validateSign(String sign, String dataJsonStr) {
|
||||
Map<String, Object> dataMap = JSONObject.parseObject(dataJsonStr, new TypeReference<>() {
|
||||
});
|
||||
String newSign = MD5.create().digestHex((sortFields(new TreeMap<>(dataMap))));
|
||||
return !StrUtil.equals(sign, newSign);
|
||||
}
|
||||
|
||||
private static String sortFields(TreeMap<String, Object> map) {
|
||||
if (CollectionUtil.isEmpty(map)) {
|
||||
log.error("聚合支付参数为空!!!");
|
||||
throw new RuntimeException("参数为空");
|
||||
}
|
||||
String sortParam = map.entrySet().stream()
|
||||
// 过滤掉键为 "sign" 的元素
|
||||
.filter(entry -> !"sign".equals(entry.getKey()) && !"appSecret".equals(entry.getKey()))
|
||||
// 将每个键值对转换为 "key=value" 格式的字符串
|
||||
.map(entry -> entry.getKey() + "=" + entry.getValue())
|
||||
// 使用 "&" 连接所有转换后的字符串
|
||||
.collect(Collectors.joining("&"));
|
||||
if (map.containsKey("appSecret")) {
|
||||
sortParam = sortParam.concat("&" + "appSecret=" + map.get("appSecret"));
|
||||
}
|
||||
return sortParam;
|
||||
}
|
||||
private static CzgResult<Map<String, Object>> execPayResult(CzgResult<? extends CzgBaseResp> res) {
|
||||
CzgResult<Map<String, Object>> result = CzgResult.success();
|
||||
if (res.getCode() != 200 || res.getData() == null) {
|
||||
result.setCode(500);
|
||||
result.setMsg(res.getMsg());
|
||||
return result;
|
||||
}
|
||||
|
||||
CzgBaseResp data = res.getData();
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
switch (data) {
|
||||
case CzgMicroPayResp ignored -> {
|
||||
if ("TRADE_SUCCESS".equals(data.getState())) {
|
||||
return result;
|
||||
} else if ("TRADE_AWAIT".equals(data.getState())) {
|
||||
result.setCode(CzgRespCode.WAIT_PAY.getCode());
|
||||
result.setMsg("等待用户付款");
|
||||
} else {
|
||||
result.setCode(CzgRespCode.FAILURE.getCode());
|
||||
}
|
||||
}
|
||||
case CzgH5PayResp h5PayResp ->
|
||||
map = JSONObject.parseObject(JSONObject.toJSONString(h5PayResp.getPayInfo()));
|
||||
case CzgJsPayResp jsPayResp ->
|
||||
map = JSONObject.parseObject(JSONObject.toJSONString(jsPayResp.getPayInfo()));
|
||||
case CzgLtPayResp ltPayResp ->
|
||||
map = JSONObject.parseObject(JSONObject.toJSONString(ltPayResp.getPayInfo()));
|
||||
case CzgScanPayResp scanPayResp ->
|
||||
map = JSONObject.parseObject(JSONObject.toJSONString(scanPayResp.getPayInfo()));
|
||||
default -> throw new IllegalStateException("Unexpected value: " + data);
|
||||
}
|
||||
|
||||
result.setData(map);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.czg.entity;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author ww
|
||||
*/
|
||||
@Data
|
||||
public class PolyBaseReq {
|
||||
|
||||
/**
|
||||
* 应用ID tb_shop_merchant 表中的 app_id
|
||||
*/
|
||||
private String appId;
|
||||
|
||||
/**
|
||||
* 签名
|
||||
* MD5( appSecret 参数不做排序 直接放末尾)
|
||||
* 加签字符串拼接方式为字段名 = 字段值并用&符号连接,需要按照既定排序方式相连,并且在末端连接 appSecret=xxx,
|
||||
* 使用 MD5 加签时,验签时使用同样的方式加签对比签名值即可
|
||||
* <p>
|
||||
* RSA2
|
||||
* 加签字符串拼接方式为字段名=字段值并用 & 符号连接,使用应用私钥对该拼接串进行签名
|
||||
*/
|
||||
private String sign;
|
||||
|
||||
/**
|
||||
* 签名方式
|
||||
* 可选值 MD5、RSA2
|
||||
*/
|
||||
private String signType = "MD5";
|
||||
|
||||
/**
|
||||
* 业务数据
|
||||
* JSON 形式的字符串
|
||||
*/
|
||||
private String bizData;
|
||||
|
||||
/**
|
||||
* 版本号 目前固定 1.0
|
||||
*/
|
||||
private String version = "1.0";
|
||||
|
||||
/**
|
||||
* 请求时间 格式为 yyyyMMddHHmmss
|
||||
*/
|
||||
private String reqTime = DateUtil.format(new DateTime(), DatePattern.PURE_DATETIME_PATTERN);
|
||||
|
||||
/**
|
||||
* 唯一请求 Id String(40)
|
||||
*/
|
||||
private String reqId = IdUtil.simpleUUID();
|
||||
|
||||
/**
|
||||
* 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||
*/
|
||||
private String appSecret;
|
||||
|
||||
/**
|
||||
* 必填字段
|
||||
*
|
||||
* @param appId 应用id tb_shop_merchant 表中的 app_id
|
||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||
* @param bizData JSON 形式的字符串
|
||||
*/
|
||||
public PolyBaseReq(String appId, String bizData, String appSecret) {
|
||||
this.appId = appId;
|
||||
this.bizData = bizData;
|
||||
this.appSecret = appSecret;
|
||||
}
|
||||
|
||||
/**
|
||||
* 必填字段
|
||||
*
|
||||
* @param appId 应用id tb_shop_merchant 表中的 app_id
|
||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||
* @param bizData JSON 形式的字符串
|
||||
*/
|
||||
public static PolyBaseReq getInstance(String appId, String appSecret, Object bizData) {
|
||||
return new PolyBaseReq(appId, ObjectUtil.isNotEmpty(bizData) ? JSONObject.toJSONString(bizData) : "", appSecret);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.czg.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author ww
|
||||
*/
|
||||
@Data
|
||||
public class PolyBaseResp {
|
||||
|
||||
|
||||
/**
|
||||
* 000000-处理成功
|
||||
* 其他-处理有误,详见错误码
|
||||
*/
|
||||
private String code;
|
||||
/**
|
||||
* 具体错误原因
|
||||
*/
|
||||
private String msg;
|
||||
/**
|
||||
* 对data内数据签名,如data为空则不返回
|
||||
*/
|
||||
private String sign;
|
||||
/**
|
||||
* 返回json格式数据
|
||||
*/
|
||||
private String bizData;
|
||||
/**
|
||||
* 返回时间 yyyyMMddHHmmss
|
||||
*/
|
||||
private String timestamp;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{" +
|
||||
"\"code\":" + code +
|
||||
", \"msg\":" + msg +
|
||||
", \"sign\":" + sign +
|
||||
", \"bizData\":" + bizData +
|
||||
", \"timestamp\":" + timestamp +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.czg.entity.notify;
|
||||
|
||||
import com.czg.entity.resp.CzgBaseResp;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @author ww
|
||||
* @description
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class CzgPayNotifyDTO extends CzgBaseResp {
|
||||
/**
|
||||
* 消息类型 String(30)
|
||||
* sft.trade.notify 支付通知
|
||||
* sft.refund.notify 退款通知
|
||||
* sft.division.notify 分账通知
|
||||
*/
|
||||
private String msgType;
|
||||
/**
|
||||
* 门店ID String(30)
|
||||
*/
|
||||
private String storeId;
|
||||
/**
|
||||
* 货币代码
|
||||
*/
|
||||
private String currency;
|
||||
private String subject;
|
||||
private String body;
|
||||
|
||||
|
||||
//非必填
|
||||
private String userId;
|
||||
/**
|
||||
* 支付成功时间
|
||||
* yyyy-MM-dd HH:mm:ss
|
||||
*/
|
||||
private String payTime;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.czg.entity.notify;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author ww
|
||||
* @description
|
||||
*/
|
||||
@Data
|
||||
public class CzgRefundNotifyDTO {
|
||||
/**
|
||||
* 消息类型 String(30)
|
||||
* sft.trade.notify 支付通知
|
||||
* sft.refund.notify 退款通知
|
||||
* sft.division.notify 分账通知
|
||||
*/
|
||||
private String msgType;
|
||||
/**
|
||||
* 商户退款订单号 String(30)
|
||||
* 商户上送的退款订单号
|
||||
*/
|
||||
private String mchRefundNo;
|
||||
/**
|
||||
* 平台退款订单号 String(30)
|
||||
*/
|
||||
private String refundOrderId;
|
||||
/**
|
||||
* 退款状态 String(10)
|
||||
* INIT:初始化
|
||||
* ING:退款中
|
||||
* SUCCESS:退款成功
|
||||
* FAIL:退款失败
|
||||
* CLOSE:退款关闭
|
||||
*/
|
||||
private String state;
|
||||
/**
|
||||
* 原平台交易单号 String(32)
|
||||
*/
|
||||
private String oriPayOrderId;
|
||||
/**
|
||||
* 商户号 String(30)
|
||||
*/
|
||||
private String mercNo;
|
||||
/**
|
||||
* 原订单交易金额
|
||||
* 单位 分
|
||||
*/
|
||||
private Long oriAmount;
|
||||
/**
|
||||
* 退款金额
|
||||
* 单位 分
|
||||
*/
|
||||
private Long refundAmt;
|
||||
/**
|
||||
* 退款原因
|
||||
*/
|
||||
private String refundReason;
|
||||
//非必填
|
||||
/**
|
||||
* 所属渠道 String(10)
|
||||
*/
|
||||
private String ifCode;
|
||||
/**
|
||||
* 备注 String(30)
|
||||
*/
|
||||
private String note;
|
||||
/**
|
||||
* 退款完成时间 String(20)
|
||||
* 格式:yyyy-MM-dd HH:mm:ss
|
||||
*/
|
||||
private String refundTime;
|
||||
/**
|
||||
* 自定义扩展参数 String(256)
|
||||
* * 扩展参数
|
||||
* * {
|
||||
* * "pay_type": "order/vip"
|
||||
* * }
|
||||
*/
|
||||
private String extParam;
|
||||
/**
|
||||
* 支付方式
|
||||
* WECHAT:微信
|
||||
* ALIPAY:支付宝
|
||||
* UNIONPAY:银联云闪付
|
||||
*/
|
||||
private String payType;
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package com.czg.entity.resp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 超掌柜通用响应参数
|
||||
*
|
||||
* @author ww
|
||||
*/
|
||||
@Data
|
||||
public class CzgBaseResp {
|
||||
//必填范围
|
||||
/**
|
||||
* 交易金额
|
||||
* 单位:分
|
||||
*/
|
||||
private Long amount;
|
||||
/**
|
||||
* String (32)
|
||||
* 商户订单号
|
||||
*/
|
||||
private String mchOrderNo;
|
||||
/**
|
||||
* 平台订单号
|
||||
*/
|
||||
private String payOrderId;
|
||||
/**
|
||||
* 商户号
|
||||
*/
|
||||
private String mercNo;
|
||||
/**
|
||||
* 订单状态
|
||||
* INIT - 订单初始化;
|
||||
* TRADE_AWAIT - 待支付;
|
||||
* TRADE_SUCCESS - 支付成功;
|
||||
* TRADE_FAIL -支付失败;
|
||||
* TRADE_CANCEL -交易取消;
|
||||
* TRADE_REFUND -已退款;
|
||||
* REFUND_ING - 退款中;
|
||||
* TRADE_CLOSE -订单关闭
|
||||
*/
|
||||
private String state;
|
||||
/**
|
||||
* 订单类型
|
||||
* 微信 WECHAT
|
||||
* 支付宝 ALIPAY
|
||||
* 银联云闪付 UNIONPAY
|
||||
*/
|
||||
private String payType;
|
||||
/**
|
||||
* 支付通道编码
|
||||
*/
|
||||
private String ifCode;
|
||||
|
||||
|
||||
|
||||
|
||||
//非必填范围
|
||||
/**
|
||||
* 发往渠道的流水号
|
||||
* 微信 / 支付宝订单详情中的商户单号
|
||||
*/
|
||||
private String channelSendNo;
|
||||
/**
|
||||
* 渠道订单号
|
||||
* 微信 / 支付宝订单号
|
||||
*/
|
||||
private String channelTradeNo;
|
||||
|
||||
private String extParam;
|
||||
|
||||
|
||||
/**
|
||||
* 描述 如:等待用户付款
|
||||
*/
|
||||
private String note;
|
||||
/**
|
||||
* 交易手续费
|
||||
*/
|
||||
private Long tradeFee;
|
||||
/**
|
||||
* 门店 id
|
||||
*/
|
||||
private String storeId;
|
||||
/**
|
||||
* 订单标题
|
||||
*/
|
||||
private String subject;
|
||||
/**
|
||||
* 交易卡类型
|
||||
* 00:借记卡
|
||||
* 01:贷记卡
|
||||
* 02:零钱/余额
|
||||
* 03:花呗
|
||||
* 04:数字货币
|
||||
* 99:其他
|
||||
*/
|
||||
private String drType;
|
||||
/**
|
||||
* 退款金额
|
||||
*/
|
||||
private Long refundAmt;
|
||||
/**
|
||||
* 退款状态类型
|
||||
* 0-未发生实际退款, 1-部分退款, 2-全额退款
|
||||
*/
|
||||
private Integer refundState;
|
||||
/**
|
||||
* 垫资手续费
|
||||
*/
|
||||
private String cashFee;
|
||||
/**
|
||||
* 结算类型 D0/D1/T1
|
||||
*/
|
||||
private String settlementType;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.czg.entity.resp;
|
||||
|
||||
import com.czg.entity.resp.pay.CzgH5PayInfo;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @author ww
|
||||
* @description H5支付响应参数
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class CzgH5PayResp extends CzgBaseResp {
|
||||
|
||||
private CzgH5PayInfo payInfo;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.czg.entity.resp;
|
||||
|
||||
import com.czg.entity.resp.pay.CzgPayInfo;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* js支付响应参数
|
||||
*
|
||||
* @author ww
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class CzgJsPayResp extends CzgBaseResp {
|
||||
|
||||
private CzgPayInfo payInfo;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.czg.entity.resp;
|
||||
|
||||
import com.czg.entity.resp.pay.CzgLitePayInfo;
|
||||
import com.czg.entity.resp.pay.CzgPayInfo;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 小程序支付 响应
|
||||
*
|
||||
* @author ww
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class CzgLtPayResp extends CzgBaseResp{
|
||||
|
||||
/**
|
||||
* 支付信息
|
||||
*/
|
||||
private CzgPayInfo payInfo;
|
||||
/**
|
||||
* 小程序支付信息
|
||||
*/
|
||||
private CzgLitePayInfo liteInfo;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.czg.entity.resp;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 反扫请求 响应
|
||||
*
|
||||
* @author ww
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class CzgMicroPayResp extends CzgBaseResp{
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.czg.entity.resp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author ww
|
||||
* @description
|
||||
*/
|
||||
@Data
|
||||
public class CzgRefundResp {
|
||||
/**
|
||||
* 商户上送的退款订单号
|
||||
* String(30)
|
||||
*/
|
||||
private String mchRefundNo;
|
||||
/**
|
||||
* 平台退款订单号
|
||||
* String(30)
|
||||
*/
|
||||
private String refundOrderId;
|
||||
/**
|
||||
* 退款状态
|
||||
* String(10)
|
||||
* INIT:初始化
|
||||
* ING:退款中
|
||||
* SUCCESS:退款成功
|
||||
* FAIL:退款失败
|
||||
* CLOSE:退款关闭
|
||||
*/
|
||||
private String state;
|
||||
/**
|
||||
* 备注 String(30)
|
||||
*/
|
||||
private String note;
|
||||
/**
|
||||
* 原平台交易单号
|
||||
* String(32)
|
||||
*/
|
||||
private String oriPayOrderId;
|
||||
/**
|
||||
* 商户号
|
||||
* String(30)
|
||||
*/
|
||||
private String mercNo;
|
||||
/**
|
||||
* 原订单交易金额
|
||||
* 单位分
|
||||
*/
|
||||
private Long oriAmount;
|
||||
/**
|
||||
* 退款金额
|
||||
* 单位分
|
||||
*/
|
||||
private Long refundAmt;
|
||||
/**
|
||||
* 退款原因
|
||||
*/
|
||||
private String refundReason;
|
||||
/**
|
||||
* 所属渠道
|
||||
* String(10)
|
||||
* sxfpay
|
||||
*/
|
||||
private String ifCode;
|
||||
/**
|
||||
* 退款完成时间
|
||||
* String(20)
|
||||
* 格式:yyyy-MM-dd HH:mm:ss
|
||||
*/
|
||||
private String refundTime;
|
||||
/**
|
||||
* 扩展参数
|
||||
*/
|
||||
private String extParam;
|
||||
/**
|
||||
* 支付类型
|
||||
* String(10)
|
||||
* WECHAT:微信
|
||||
* ALIPAY:支付宝
|
||||
* UNIONPAY:银联云闪付
|
||||
*/
|
||||
private String payType;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.czg.entity.resp;
|
||||
|
||||
import com.czg.entity.resp.pay.CzgScanPayInfo;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @author ww
|
||||
* @description H5支付响应参数
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class CzgScanPayResp extends CzgBaseResp {
|
||||
|
||||
private CzgScanPayInfo payInfo;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.czg.entity.resp.pay;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author ww
|
||||
* @description h5支付参数
|
||||
*/
|
||||
@Data
|
||||
public class CzgH5PayInfo {
|
||||
/**
|
||||
* 支付跳转地址
|
||||
*/
|
||||
private String payUrl;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.czg.entity.resp.pay;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 支付信息
|
||||
*
|
||||
* @author ww
|
||||
*/
|
||||
@Data
|
||||
public class CzgLitePayInfo {
|
||||
/**
|
||||
* 微信Appid
|
||||
*/
|
||||
private String appId;
|
||||
/**
|
||||
* 支付路径
|
||||
*/
|
||||
private String path;
|
||||
/**
|
||||
* 小程序的 版本env
|
||||
* release - 正式、
|
||||
* test - 开发、
|
||||
* preview - 体验
|
||||
*/
|
||||
private String envVersion;
|
||||
/**
|
||||
* 微信小程序原始ID
|
||||
*/
|
||||
private String ghId;
|
||||
/**
|
||||
* 支付宝小程序路径
|
||||
*/
|
||||
private String alipayPath;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.czg.entity.resp.pay;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 支付信息
|
||||
* @author ww
|
||||
*/
|
||||
@Data
|
||||
public class CzgPayInfo {
|
||||
/**
|
||||
* 微信 Appid
|
||||
*/
|
||||
private String appId;
|
||||
/**
|
||||
* 微信 timeStamp
|
||||
*/
|
||||
private String timeStamp;
|
||||
/**
|
||||
* 微信 package
|
||||
*/
|
||||
@JSONField(name = "package")
|
||||
private String wechatPackage;
|
||||
/**
|
||||
* 微信支付签名
|
||||
*/
|
||||
private String paySign;
|
||||
/**
|
||||
* 签名类型
|
||||
* MD5/RSA
|
||||
*/
|
||||
private String signType;
|
||||
/**
|
||||
* 微信 nonceStr 微信支付下返回
|
||||
*/
|
||||
private String nonceStr;
|
||||
/**
|
||||
* 支付宝流水号
|
||||
* 对应 trade_no
|
||||
*/
|
||||
private String tradeNo;
|
||||
/**
|
||||
* 银联重定向跳转地址 银联场景下返回
|
||||
*/
|
||||
private String redirectUrl;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.czg.entity.resp.pay;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 扫码支付参数
|
||||
* @author ww
|
||||
* @description
|
||||
*/
|
||||
@Data
|
||||
public class CzgScanPayInfo {
|
||||
/**
|
||||
* 付款二维码地址 qrCodeUrl
|
||||
*/
|
||||
private String payUrl;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.czg.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author ww
|
||||
*/
|
||||
|
||||
@Getter
|
||||
public enum CzgPayEnum {
|
||||
SCAN_PAY("/api/open/payment/scanpay", "PC扫码支付"),
|
||||
MICRO_PAY("/api/open/payment/micropay", "聚合反扫(B扫C)/ 快捷收款"),
|
||||
JS_PAY("/api/open/payment/jspay", "公众号/生活号/银联js支付"),
|
||||
LT_PAY("/api/open/payment/ltpay", "小程序支付"),
|
||||
H5_PAY("/api/open/payment/h5pay", "手机网页支付"),
|
||||
|
||||
TRADE("/api/open/query/trade", "订单状态查询"),
|
||||
REFUND("/api/open/order/refund", "统一退款 D0退款需要使用平台户退款"),
|
||||
QUERY_REFUND("/api/open/query/refund", "退款状态查询"),
|
||||
;
|
||||
|
||||
private final String uri;
|
||||
private final String msg;
|
||||
|
||||
CzgPayEnum(String uri, String msg) {
|
||||
this.uri = uri;
|
||||
this.msg = msg;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user