支付调整
This commit is contained in:
@@ -35,13 +35,6 @@
|
||||
<artifactId>ocr_api20210707</artifactId>
|
||||
<version>3.1.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Source: https://mvnrepository.com/artifact/org.dom4j/dom4j -->
|
||||
<dependency>
|
||||
<groupId>org.dom4j</groupId>
|
||||
<artifactId>dom4j</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -9,7 +9,6 @@ import com.czg.exception.CzgException;
|
||||
import com.czg.third.alipay.AlipayEntryManager;
|
||||
import com.czg.third.alipay.AlipayIsvEntryManager;
|
||||
import com.czg.third.wechat.WechatEntryManager;
|
||||
import com.czg.third.wechat.dto.req.entry.business.sales.WechatEntryStoreInfoReqDto;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import com.czg.utils.AsyncTaskExecutor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -385,8 +384,8 @@ public class EntryManager {
|
||||
// verifyEntryParam(merchantDto);
|
||||
// uploadParamImage(merchantDto);
|
||||
//// System.out.println(merchantDto);
|
||||
// EntryRespDto respDto = entryMerchant(merchantDto, PayCst.Platform.WECHAT);
|
||||
EntryRespDto respDto = entryMerchant(merchantDto, PayCst.Platform.ALIPAY);
|
||||
EntryRespDto respDto = entryMerchant(merchantDto, PayCst.Platform.WECHAT);
|
||||
// entryMerchant(merchantDto, PayCst.Platform.ALIPAY);
|
||||
// entryMerchant(merchantDto, PayCst.Platform.WECHAT, PayCst.Platform.ALIPAY);
|
||||
System.out.println(respDto);
|
||||
}
|
||||
|
||||
@@ -1,51 +1,22 @@
|
||||
package com.czg;
|
||||
|
||||
import com.czg.dto.req.PayParamsDto;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.third.alipay.AlipayIsvPayManager;
|
||||
import com.czg.third.wechat.WechatPayManager;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author yjjie
|
||||
* @date 2026/1/9 11:24
|
||||
*/
|
||||
public class PayManager {
|
||||
|
||||
/**
|
||||
* jsapi支付
|
||||
*
|
||||
* @param paramsDto 参数
|
||||
* @return 结果
|
||||
*/
|
||||
public static Map<String, Object> jsapiPay(PayParamsDto paramsDto) {
|
||||
public static void jsapiPay(PayParamsDto paramsDto) {
|
||||
paramsDto.verifyParams();
|
||||
|
||||
if (PayCst.Platform.WECHAT.equals(paramsDto.getPlatform())) {
|
||||
return WechatPayManager.jsapiPay(null, paramsDto);
|
||||
WechatPayManager.jsapiPay(null, paramsDto);
|
||||
} else if (PayCst.Platform.ALIPAY.equals(paramsDto.getPlatform())) {
|
||||
return AlipayIsvPayManager.jsapiPay(null, paramsDto);
|
||||
} else {
|
||||
throw new CzgException("不支持的支付平台");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 条码支付
|
||||
*
|
||||
* @param paramsDto 参数
|
||||
* @return 结果
|
||||
*/
|
||||
public static Map<String, Object> barPay(PayParamsDto paramsDto) {
|
||||
paramsDto.verifyParams();
|
||||
|
||||
if (PayCst.Platform.WECHAT.equals(paramsDto.getPlatform())) {
|
||||
return WechatPayManager.barPay(null, paramsDto);
|
||||
} else if (PayCst.Platform.ALIPAY.equals(paramsDto.getPlatform())) {
|
||||
return AlipayIsvPayManager.barPay(null, paramsDto);
|
||||
} else {
|
||||
throw new CzgException("不支持的支付平台");
|
||||
AlipayIsvPayManager.jsapiPay(null, paramsDto);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,10 +35,10 @@ public class PayManager {
|
||||
jsapiPay(new PayParamsDto()
|
||||
.setPlatform(PayCst.Platform.WECHAT)
|
||||
.setAppId("wxd88fffa983758a30")
|
||||
.setOpenId("or1l86yipGvwyfPhrKIAcQuSfAV8")
|
||||
.setOpenId("123123123")
|
||||
.setOrderNo("1111231231213")
|
||||
.setTitle("1213")
|
||||
.setMerchantId("1738216504")
|
||||
.setMerchantId("1665469114")
|
||||
.setBody("1213")
|
||||
.setAmount(1000L)
|
||||
.setPayParams("{\"app_auth_token\": \"ssss\"}")
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.czg.dto.req;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.PayCst;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.third.alipay.dto.AlipayAuthInfoDto;
|
||||
import com.czg.pay.AlipayAuthInfoDto;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@@ -9,13 +9,12 @@ import com.czg.dto.req.*;
|
||||
import com.czg.dto.resp.EntryThirdRespDto;
|
||||
import com.czg.dto.resp.QueryStatusResp;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.third.alipay.dto.AlipayAuthInfoDto;
|
||||
import com.czg.pay.AlipayAuthInfoDto;
|
||||
import com.czg.third.alipay.dto.config.AlipayConfigDto;
|
||||
import com.czg.utils.UploadFileUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* 支付宝服务商进件管理
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
package com.czg.third.alipay.dto;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 支付宝授权信息
|
||||
* @author yjjie
|
||||
* @date 2026/1/9 11:31
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AlipayAuthInfoDto {
|
||||
|
||||
/**
|
||||
* 授权商户的user_id
|
||||
*/
|
||||
@JSONField(name = "user_id")
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 授权商户的open_id
|
||||
*/
|
||||
@JSONField(name = "open_id")
|
||||
private String openId;
|
||||
|
||||
/**
|
||||
* 授权商户的appid
|
||||
*/
|
||||
@JSONField(name = "auth_app_id")
|
||||
private String authAppId;
|
||||
|
||||
/**
|
||||
* 应用授权令牌
|
||||
*/
|
||||
@JSONField(name = "app_auth_token")
|
||||
private String appAuthToken;
|
||||
|
||||
/**
|
||||
* 应用授权令牌有效期
|
||||
*/
|
||||
@JSONField(name = "expires_in")
|
||||
private String expiresIn;
|
||||
|
||||
/**
|
||||
* 刷新令牌
|
||||
*/
|
||||
@JSONField(name = "app_refresh_token")
|
||||
private String appRefreshToken;
|
||||
|
||||
/**
|
||||
* 刷新令牌的有效时间
|
||||
*/
|
||||
@JSONField(name = "re_expires_in")
|
||||
private String reExpiresIn;
|
||||
|
||||
/**
|
||||
* 签约单号
|
||||
*/
|
||||
@JSONField(name = "order_no")
|
||||
private String orderNo;
|
||||
}
|
||||
@@ -56,7 +56,6 @@ public class WechatPayConfigDto {
|
||||
return new WechatPayConfigDto()
|
||||
.setMerchantId("1643779408")
|
||||
.setApiV3Key("a92baac5eb7a36ed8ec198113e769a03")
|
||||
.setApiV2Key("3caf37225b6ea77a624ee03b7e3d03bb")
|
||||
.setSerialNumber("4DE9BAC2EA584C3F274F694C9753CA814C4E9BF4")
|
||||
.setPublicKey("""
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
|
||||
@@ -1,124 +0,0 @@
|
||||
package com.czg.entity.req;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
|
||||
/**
|
||||
* @author ww
|
||||
*/
|
||||
@Data
|
||||
public class CzgBaseReq {
|
||||
//必填范围
|
||||
/**
|
||||
* 订单标题
|
||||
*/
|
||||
private String subject;
|
||||
|
||||
/**
|
||||
* 订单描述 String(256)
|
||||
*/
|
||||
private String body;
|
||||
/**
|
||||
* 交易金额
|
||||
*/
|
||||
private Long amount;
|
||||
/**
|
||||
* 货币类型 cny
|
||||
*/
|
||||
private String currency = "cny";
|
||||
/**
|
||||
* 商户订单号 String(30)
|
||||
* 操作方式+雪花算法
|
||||
* 收银机客户端 PC+雪花ID
|
||||
* 微信小程序 WX+雪花ID
|
||||
* 支付宝小程序 ALI+雪花ID
|
||||
* PC管理端 WEB+雪花ID
|
||||
* APP管理端 APP+雪花ID
|
||||
* <p>
|
||||
* 退款 re+雪花ID
|
||||
*/
|
||||
private String mchOrderNo;
|
||||
/**
|
||||
* 门店编号 tb_shop_merchant 的 store_id
|
||||
*/
|
||||
private String storeId;
|
||||
|
||||
|
||||
//非必填项
|
||||
/**
|
||||
* 订单备注 String(50)
|
||||
*/
|
||||
private String buyerRemark;
|
||||
/**
|
||||
* 异步通知地址 String(128)
|
||||
* 支付结果异步回调URL,只有传了该值才会发起回调
|
||||
*/
|
||||
private String notifyUrl;
|
||||
/**
|
||||
* 失效时间 int 15
|
||||
* 订单失效时间,单位分钟,默认15小时.
|
||||
* 取值范围 5-1440 分钟
|
||||
* 订单在(创建时间+失效时间)后失效
|
||||
*/
|
||||
private Integer expiredTime;
|
||||
|
||||
|
||||
/**
|
||||
* 分账模式:
|
||||
* 0-该笔订单不允许分账[默认],
|
||||
* 1-实时分账
|
||||
* 2-延时分账
|
||||
*/
|
||||
private Integer divisionMode;
|
||||
/**
|
||||
* 分账详情
|
||||
*/
|
||||
private String divisionDetail;
|
||||
/**
|
||||
* 扩展参数 String(512)
|
||||
* 商户扩展参数,回调时会原样返回
|
||||
* * 扩展参数
|
||||
* * {
|
||||
* * "pay_type": "order/vip"
|
||||
* * }
|
||||
*/
|
||||
private String extParam;
|
||||
|
||||
/**
|
||||
* 花呗分期数
|
||||
* 支付宝交易时可传 而且金额需要大于或等于 100.00元时生效
|
||||
* 3/6/12
|
||||
*/
|
||||
private Integer hbFqNum;
|
||||
/**
|
||||
* 卖家是否承担手续费
|
||||
* 100,卖家承担手续费
|
||||
* 0,买家承担手续费
|
||||
*/
|
||||
private Integer hbFqPercent;
|
||||
/**
|
||||
* 是否禁用信用卡
|
||||
* -1:不禁用 1:禁用
|
||||
* 不传默认为不限制
|
||||
*/
|
||||
private Integer limitPay;
|
||||
|
||||
public CzgBaseReq() {
|
||||
|
||||
}
|
||||
|
||||
public CzgBaseReq(String mchOrderNo, Long amount, String body,
|
||||
String buyerRemark, String extParam) {
|
||||
this.mchOrderNo = mchOrderNo;
|
||||
this.body = body;
|
||||
this.amount = amount;
|
||||
this.buyerRemark = buyerRemark;
|
||||
this.extParam = extParam;
|
||||
}
|
||||
|
||||
public void assignMerchant(@NonNull String storeId, @NonNull String subject, @NonNull String notifyUrl) {
|
||||
this.storeId = storeId;
|
||||
this.subject = subject;
|
||||
this.notifyUrl = notifyUrl;
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package com.czg.entity.req;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NonNull;
|
||||
|
||||
/**
|
||||
* h5支付请求参数
|
||||
*
|
||||
* @author ww
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class CzgH5PayReq extends CzgBaseReq {
|
||||
//必填范围
|
||||
/**
|
||||
* 用户IP 支付的用户IP
|
||||
*/
|
||||
private String clientIp;
|
||||
private String payType;
|
||||
//?
|
||||
private String openId;
|
||||
|
||||
//非必填范围
|
||||
/**
|
||||
* 跳转通知地址
|
||||
* 支付结果同步跳转通知URL
|
||||
*/
|
||||
private String returnUrl;
|
||||
|
||||
|
||||
public CzgH5PayReq(@NonNull String mchOrderNo, @NonNull Long amount, String body, @NonNull String clientIp,
|
||||
String returnUrl, String buyerRemark, @NonNull String extParam) {
|
||||
super(mchOrderNo, amount, body, buyerRemark, extParam);
|
||||
this.clientIp = clientIp;
|
||||
this.returnUrl = returnUrl;
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
package com.czg.entity.req;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NonNull;
|
||||
|
||||
/**
|
||||
* 公众号/生活号/银联js支付
|
||||
*
|
||||
* @author ww
|
||||
* <p>
|
||||
* ● 码牌、台卡、立牌等
|
||||
* 用户通过扫描微信/支付宝/云闪付APP静态二维码,输入订单金额进行付款动作。
|
||||
* ● 公众号 / 生活号商城
|
||||
* 用户通过公众号下单,输入密码完成付款动作。适用于自有公众号主体交易
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class CzgJsPayReq extends CzgBaseReq {
|
||||
//必填范围
|
||||
/**
|
||||
* 用户唯一标识 String(30)
|
||||
* 微信支付时,传入用户的openId;
|
||||
* 支付宝支付和银联支付时,传入用户的userId
|
||||
*/
|
||||
private String userId;
|
||||
/**
|
||||
* 用户IP
|
||||
* 需要传付款用户客户端IP地址
|
||||
*/
|
||||
private String clientIp;
|
||||
/**
|
||||
* 微信 WECHAT;
|
||||
* 支付宝 ALIPAY;
|
||||
* 银联云闪付 UNIONPAY
|
||||
*/
|
||||
private String payType;
|
||||
|
||||
|
||||
//非必填范围
|
||||
/**
|
||||
* 子商户appid ,微信付款支付的时候 需要上送
|
||||
*/
|
||||
private String subAppid;
|
||||
/**
|
||||
* 跳转通知地址
|
||||
* 支付结果同步跳转通知URL
|
||||
*/
|
||||
private String returnUrl;
|
||||
|
||||
/**
|
||||
* 银联js支付成功前端跳转
|
||||
*/
|
||||
private String frontUrl;
|
||||
/**
|
||||
* 银联js支付失败前端跳转地址
|
||||
*/
|
||||
private String frontFailUrl;
|
||||
|
||||
public CzgJsPayReq(@NonNull String mchOrderNo,
|
||||
@NonNull Long amount, String body,
|
||||
@NonNull String openId, @NonNull String clientIp,
|
||||
String returnUrl, String buyerRemark,@NonNull String extParam) {
|
||||
super(mchOrderNo, amount, body, buyerRemark, extParam);
|
||||
this.userId = openId;
|
||||
this.clientIp = clientIp;
|
||||
this.returnUrl = returnUrl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
package com.czg.entity.req;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NonNull;
|
||||
|
||||
|
||||
/**
|
||||
* 小程序支付
|
||||
*
|
||||
* @author ww
|
||||
* 自有小程序拉起支付
|
||||
* 自有小程序拉起服务商小程序,(微信)半屏小程序支付
|
||||
* 半屏小程序需要在商户自己的小程序中的半屏小程序配置里面申请 否则会拉起全屏小程序支付
|
||||
* <p>
|
||||
* 半屏小程序支付适用场景是商户自己的小程序被纳入微信实物电商类型小程序,导致间联商户无法绑定这类的小程序APPID
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class CzgLtPayReq extends CzgBaseReq {
|
||||
//必填范围
|
||||
/**
|
||||
* 用户唯一标识 String(30)
|
||||
* 微信支付时,传入用户的 openId;
|
||||
* 支付宝支付和银联支付时,传入用户的 userId
|
||||
*/
|
||||
private String userId;
|
||||
private String payType;
|
||||
/**
|
||||
* 用户 IP 支付的用户 IP
|
||||
*/
|
||||
private String clientIp;
|
||||
|
||||
|
||||
//非必填范围
|
||||
/**
|
||||
* 跳转通知地址
|
||||
* 支付结果同步跳转通知 URL
|
||||
*/
|
||||
private String returnUrl;
|
||||
/**
|
||||
* 子商户 appid ,微信付款支付的时候 需要上送
|
||||
* isScreen 为 false 的情况下需要传入
|
||||
*/
|
||||
private String subAppid;
|
||||
/**
|
||||
* 是否半屏
|
||||
* 是否使用半屏小程序,默认为 false
|
||||
* 前提小程序被纳入了实物电商类型的小程序,间联商户无法绑定这类的小程序的 appid
|
||||
*/
|
||||
private boolean isScreen;
|
||||
|
||||
public CzgLtPayReq(@NonNull String mchOrderNo, @NonNull Long amount, @NonNull String payType,
|
||||
String body, @NonNull String openId, @NonNull String clientIp,
|
||||
String returnUrl, String buyerRemark, @NonNull String extParam) {
|
||||
super(mchOrderNo, amount, body, buyerRemark, extParam);
|
||||
this.userId = openId;
|
||||
this.payType = "aliPay".equals(payType) ? "ALIPAY" : "WECHAT";
|
||||
this.clientIp = clientIp;
|
||||
this.returnUrl = returnUrl;
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.czg.entity.req;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NonNull;
|
||||
|
||||
/**
|
||||
* 反扫请求参数
|
||||
*
|
||||
* @author ww
|
||||
* <p>
|
||||
* 被扫免密同步返回支付结果,不推送异步通知。
|
||||
* 被扫输密,推送异步通知。
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class CzgMicroPayReq extends CzgBaseReq {
|
||||
//必填范围
|
||||
/**
|
||||
* 付款码信息 String(30)
|
||||
* 扫码设备获取微信或支付宝上付款的信息
|
||||
*/
|
||||
private String authCode;
|
||||
|
||||
//非必填范围
|
||||
/**
|
||||
* 子商户appid ,微信付款支付的时候 需要上送
|
||||
*/
|
||||
private String subAppid;
|
||||
|
||||
public CzgMicroPayReq(@NonNull String mchOrderNo, @NonNull Long amount, String body,
|
||||
@NonNull String authCode, String buyerRemark, @NonNull String extParam) {
|
||||
super(mchOrderNo, amount, body, buyerRemark, extParam);
|
||||
this.authCode = authCode;
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
package com.czg.entity.req;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
|
||||
/**
|
||||
* @author ww
|
||||
*/
|
||||
@Data
|
||||
public class CzgRefundReq {
|
||||
//必填范围
|
||||
/**
|
||||
* 退款订单号
|
||||
* 商户退款订单号
|
||||
*/
|
||||
private String mchRefundNo;
|
||||
/**
|
||||
* 退款原因
|
||||
*/
|
||||
private String refundReason;
|
||||
/**
|
||||
* 退款金额
|
||||
* 单位为分
|
||||
*/
|
||||
private Long refundAmount;
|
||||
|
||||
|
||||
//非必填范围
|
||||
/**
|
||||
* 原平台订单号 (二选一)
|
||||
*/
|
||||
private String payOrderId;
|
||||
/**
|
||||
* 原商户订单号 (二选一)
|
||||
*/
|
||||
private String mchOrderNo;
|
||||
/**
|
||||
* 扩展参数
|
||||
* * 扩展参数
|
||||
* * {
|
||||
* * "pay_type": "order/vip"
|
||||
* * }
|
||||
*/
|
||||
private String extParam;
|
||||
/**
|
||||
* 回调地址
|
||||
*/
|
||||
private String notifyUrl;
|
||||
|
||||
/**
|
||||
* payOrderId和mchOrderNo 二选一 必填
|
||||
*/
|
||||
public CzgRefundReq(@NonNull String mchRefundNo, @NonNull String refundReason, @NonNull Long refundAmount,
|
||||
String mchOrderNo, String extParam) {
|
||||
this.mchRefundNo = mchRefundNo;
|
||||
this.refundReason = refundReason;
|
||||
this.refundAmount = refundAmount;
|
||||
this.mchOrderNo = mchOrderNo;
|
||||
this.extParam = extParam;
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.czg.entity.req;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NonNull;
|
||||
|
||||
/**
|
||||
* 正扫支付请求参数
|
||||
*
|
||||
* @author ww
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class CzgScanPayReq extends CzgBaseReq {
|
||||
// 必填项
|
||||
/**
|
||||
* 用户IP 支付的用户IP
|
||||
*/
|
||||
private String clientIp;
|
||||
|
||||
//非必填项
|
||||
/**
|
||||
* 跳转通知地址
|
||||
* String(128)
|
||||
*/
|
||||
private String returnUrl;
|
||||
|
||||
public CzgScanPayReq(@NonNull String mchOrderNo, @NonNull Long amount, String body,
|
||||
@NonNull String clientIp, String returnUrl, String buyerRemark, @NonNull String extParam) {
|
||||
super(mchOrderNo, amount, body, buyerRemark, extParam);
|
||||
this.clientIp = clientIp;
|
||||
this.returnUrl = returnUrl;
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>czg-pay</artifactId>
|
||||
<artifactId>poly-pay</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
@@ -8,11 +8,12 @@ import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.alibaba.fastjson2.TypeReference;
|
||||
import com.czg.entity.CzgBaseReqParams;
|
||||
import com.czg.entity.CzgBaseRespParams;
|
||||
import com.czg.entity.req.*;
|
||||
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;
|
||||
@@ -26,10 +27,10 @@ import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author ww
|
||||
* @description 超掌柜支付类
|
||||
* @description 聚合支付类
|
||||
*/
|
||||
@Slf4j
|
||||
public class CzgPayUtils {
|
||||
public class PolyPayUtils {
|
||||
|
||||
/**
|
||||
* h5支付
|
||||
@@ -39,8 +40,8 @@ public class CzgPayUtils {
|
||||
* @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, CzgH5PayReq bizData) {
|
||||
return execPayResult(sendCzg(domain.concat(CzgPayEnum.H5PAY.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, bizData), CzgH5PayResp.class));
|
||||
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));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,8 +52,8 @@ public class CzgPayUtils {
|
||||
* @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, CzgJsPayReq bizData) {
|
||||
return execPayResult(sendCzg(domain.concat(CzgPayEnum.JSPAY.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, bizData), CzgJsPayResp.class));
|
||||
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));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,8 +64,8 @@ public class CzgPayUtils {
|
||||
* @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, CzgLtPayReq bizData) {
|
||||
return execPayResult(sendCzg(domain.concat(CzgPayEnum.LTPAY.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, bizData), CzgLtPayResp.class));
|
||||
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));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,8 +76,8 @@ public class CzgPayUtils {
|
||||
* @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, CzgScanPayReq bizData) {
|
||||
return execPayResult(sendCzg(domain.concat(CzgPayEnum.SCANPAY.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, bizData), CzgScanPayResp.class));
|
||||
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));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,8 +88,8 @@ public class CzgPayUtils {
|
||||
* @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, CzgMicroPayReq bizData) {
|
||||
return execPayResult(sendCzg(domain.concat(CzgPayEnum.MICROPAY.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, bizData), CzgMicroPayResp.class));
|
||||
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));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -105,7 +106,7 @@ public class CzgPayUtils {
|
||||
JSONObject queryPayOrder = new JSONObject();
|
||||
queryPayOrder.put("payOrderId", payOrderId);
|
||||
queryPayOrder.put("mchOrderNo", mchOrderNo);
|
||||
return sendCzg(domain.concat(CzgPayEnum.TRADE.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, queryPayOrder), CzgBaseResp.class);
|
||||
return sendPolyPay(domain.concat(CzgPayEnum.TRADE.getUri()), PolyBaseReq.getInstance(appId, appSecret, queryPayOrder), CzgBaseResp.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -117,7 +118,7 @@ public class CzgPayUtils {
|
||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||
*/
|
||||
public static CzgResult<CzgRefundResp> refundOrder(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgRefundReq bizData) {
|
||||
return sendCzg(domain.concat(CzgPayEnum.REFUND.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, bizData), CzgRefundResp.class);
|
||||
return sendPolyPay(domain.concat(CzgPayEnum.REFUND.getUri()), PolyBaseReq.getInstance(appId, appSecret, bizData), CzgRefundResp.class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,23 +135,23 @@ public class CzgPayUtils {
|
||||
JSONObject queryPayOrder = new JSONObject();
|
||||
queryPayOrder.put("mchRefundNo", mchRefundNo);
|
||||
queryPayOrder.put("refundOrderId", refundOrderId);
|
||||
return sendCzg(domain.concat(CzgPayEnum.QUERY_REFUND.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, queryPayOrder), CzgRefundResp.class);
|
||||
return sendPolyPay(domain.concat(CzgPayEnum.QUERY_REFUND.getUri()), PolyBaseReq.getInstance(appId, appSecret, queryPayOrder), CzgRefundResp.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 回调数据处理
|
||||
*/
|
||||
public static JSONObject getCzg(CzgBaseRespParams respParams) {
|
||||
AssertUtil.isNull(respParams, "超掌柜交易 回调数据为空");
|
||||
log.info("超掌柜交易请求响应,{}", respParams);
|
||||
public static JSONObject getCzg(PolyBaseResp respParams) {
|
||||
AssertUtil.isNull(respParams, "聚合交易 回调数据为空");
|
||||
log.info("聚合交易请求响应,{}", respParams);
|
||||
if (!"000000".equals(respParams.getCode())) {
|
||||
log.error("超掌柜回调响应失败,{}", respParams);
|
||||
log.error("聚合回调响应失败,{}", respParams);
|
||||
return null;
|
||||
}
|
||||
// if (StrUtil.isNotBlank(respParams.getSign())) {
|
||||
// if (validateSign(respParams.getSign(), respParams.getBizData())) {
|
||||
// log.error("超掌柜回调 验签失败");
|
||||
// log.error("聚合回调 验签失败");
|
||||
// }
|
||||
// }
|
||||
return JSONObject.parse(respParams.getBizData());
|
||||
@@ -168,19 +169,19 @@ public class CzgPayUtils {
|
||||
* "data": "返回Json数据",
|
||||
* }
|
||||
*/
|
||||
private static <T> CzgResult<T> sendCzg(String url, CzgBaseReqParams params, Class<T> clazz) {
|
||||
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));
|
||||
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);
|
||||
CzgBaseRespParams respParams = JSONObject.parseObject(respStr, CzgBaseRespParams.class);
|
||||
log.info("超掌柜交易请求响应,{}", respParams);
|
||||
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());
|
||||
@@ -194,15 +195,15 @@ public class CzgPayUtils {
|
||||
}
|
||||
} else {
|
||||
result.setCode(resp.getStatus());
|
||||
result.setMsg("超掌柜交易请求失败");
|
||||
log.error("超掌柜交易请求失败,状态码: {}", resp.getStatus());
|
||||
result.setMsg("聚合交易请求失败");
|
||||
log.error("聚合交易请求失败,状态码: {}", resp.getStatus());
|
||||
}
|
||||
} else {
|
||||
result.setCode(resp.getStatus());
|
||||
result.setMsg("超掌柜交易请求失败");
|
||||
result.setMsg("聚合交易请求失败");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("超掌柜交易请求异常", e);
|
||||
log.error("聚合交易请求异常", e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -221,7 +222,7 @@ public class CzgPayUtils {
|
||||
|
||||
private static String sortFields(TreeMap<String, Object> map) {
|
||||
if (CollectionUtil.isEmpty(map)) {
|
||||
log.error("超掌柜支付参数为空!!!");
|
||||
log.error("聚合支付参数为空!!!");
|
||||
throw new RuntimeException("参数为空");
|
||||
}
|
||||
String sortParam = map.entrySet().stream()
|
||||
@@ -12,7 +12,7 @@ import lombok.Data;
|
||||
* @author ww
|
||||
*/
|
||||
@Data
|
||||
public class CzgBaseReqParams {
|
||||
public class PolyBaseReq {
|
||||
|
||||
/**
|
||||
* 应用ID tb_shop_merchant 表中的 app_id
|
||||
@@ -69,7 +69,7 @@ public class CzgBaseReqParams {
|
||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||
* @param bizData JSON 形式的字符串
|
||||
*/
|
||||
public CzgBaseReqParams(String appId, String bizData, String appSecret) {
|
||||
public PolyBaseReq(String appId, String bizData, String appSecret) {
|
||||
this.appId = appId;
|
||||
this.bizData = bizData;
|
||||
this.appSecret = appSecret;
|
||||
@@ -82,8 +82,8 @@ public class CzgBaseReqParams {
|
||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||
* @param bizData JSON 形式的字符串
|
||||
*/
|
||||
public static CzgBaseReqParams getInstance(String appId, String appSecret, Object bizData) {
|
||||
return new CzgBaseReqParams(appId, ObjectUtil.isNotEmpty(bizData) ? JSONObject.toJSONString(bizData) : "", appSecret);
|
||||
public static PolyBaseReq getInstance(String appId, String appSecret, Object bizData) {
|
||||
return new PolyBaseReq(appId, ObjectUtil.isNotEmpty(bizData) ? JSONObject.toJSONString(bizData) : "", appSecret);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import lombok.Data;
|
||||
* @author ww
|
||||
*/
|
||||
@Data
|
||||
public class CzgBaseRespParams {
|
||||
public class PolyBaseResp {
|
||||
|
||||
|
||||
/**
|
||||
@@ -8,11 +8,11 @@ import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum CzgPayEnum {
|
||||
SCANPAY("/api/open/payment/scanpay", "PC扫码支付"),
|
||||
MICROPAY("/api/open/payment/micropay", "聚合反扫(B扫C)/ 快捷收款"),
|
||||
JSPAY("/api/open/payment/jspay", "公众号/生活号/银联js支付"),
|
||||
LTPAY("/api/open/payment/ltpay", "小程序支付"),
|
||||
H5PAY("/api/open/payment/h5pay", "手机网页支付"),
|
||||
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退款需要使用平台户退款"),
|
||||
@@ -12,7 +12,7 @@
|
||||
<name>third sdk</name>
|
||||
<description>第三方内容</description>
|
||||
<modules>
|
||||
<module>czg-pay</module>
|
||||
<module>poly-pay</module>
|
||||
<module>aggregation-pay</module>
|
||||
</modules>
|
||||
<artifactId>cash-sdk</artifactId>
|
||||
@@ -29,5 +29,10 @@
|
||||
<artifactId>cash-common-tools</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.czg</groupId>
|
||||
<artifactId>cash-common-service</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
Reference in New Issue
Block a user