扫码支付 区分平台

This commit is contained in:
wangw 2025-02-15 11:02:56 +08:00
parent c05d4ada5d
commit 006e223c71
1 changed files with 18 additions and 4 deletions

View File

@ -84,7 +84,7 @@ public class PayServiceImpl implements PayService {
}
@Override
public CzgResult<CzgRefundResp> refundOrder(@NonNull Long shopId, @NonNull Long orderId,@NonNull String refundReason,@NonNull BigDecimal refundAmount) {
public CzgResult<CzgRefundResp> refundOrder(@NonNull Long shopId, @NonNull Long orderId, @NonNull String refundReason, @NonNull BigDecimal refundAmount) {
// refund(shopId, new CzgRefundReq("1", refundReason, refundAmount.multiply(MONEY_RATE).longValue(),
// "1", refundJsonExtParam));
@ -115,7 +115,6 @@ public class PayServiceImpl implements PayService {
}
private CzgResult<CzgH5PayResp> h5Pay(@NonNull Long shopId, CzgH5PayReq bizData) {
ShopMerchant shopMerchant = shopMerchantService.getById(shopId);
bizData.assignMerchant(shopMerchant.getStoreId(), shopMerchant.getMerchantName(),
@ -125,19 +124,19 @@ public class PayServiceImpl implements PayService {
private CzgResult<CzgJsPayResp> jsPay(@NonNull Long shopId, @NonNull String payType, CzgJsPayReq bizData) {
ShopMerchant shopMerchant = shopMerchantService.getById(shopId);
bizData.setSubAppid("aliPay" .equals(payType) ? shopMerchant.getAlipaySmallAppid() : shopMerchant.getWechatSmallAppid());
AssertUtil.isBlank(bizData.getSubAppid(), "暂不可用,请联系商家配置" + ("aliPay" .equals(payType) ? "支付宝" : "微信") + "小程序");
bizData.assignMerchant(shopMerchant.getStoreId(), shopMerchant.getMerchantName(),
sysParamsService.getSysParamValue(SysParamCodeEnum.PAY_CZG_NOTIFY_URL.getCode()));
bizData.setSubAppid("aliPay" .equals(payType) ? shopMerchant.getAlipaySmallAppid() : shopMerchant.getWechatSmallAppid());
return czgPayService.jsPay(shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
}
private CzgResult<CzgLtPayResp> ltPay(@NonNull Long shopId, String payType, CzgLtPayReq bizData) {
ShopMerchant shopMerchant = shopMerchantService.getById(shopId);
bizData.setSubAppid("aliPay" .equals(payType) ? shopMerchant.getAlipaySmallAppid() : shopMerchant.getWechatSmallAppid());
AssertUtil.isBlank(bizData.getSubAppid(), "暂不可用,请联系商家配置" + ("aliPay" .equals(payType) ? "支付宝" : "微信") + "小程序");
bizData.assignMerchant(shopMerchant.getStoreId(), shopMerchant.getMerchantName(),
sysParamsService.getSysParamValue(SysParamCodeEnum.PAY_CZG_NOTIFY_URL.getCode()));
bizData.setSubAppid("aliPay" .equals(payType) ? shopMerchant.getAlipaySmallAppid() : shopMerchant.getWechatSmallAppid());
return czgPayService.ltPay(shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
}
@ -152,6 +151,21 @@ public class PayServiceImpl implements PayService {
ShopMerchant shopMerchant = shopMerchantService.getById(shopId);
bizData.assignMerchant(shopMerchant.getStoreId(), shopMerchant.getMerchantName(),
sysParamsService.getSysParamValue(SysParamCodeEnum.PAY_CZG_NOTIFY_URL.getCode()));
AssertUtil.isBlank(bizData.getAuthCode(), "扫码失败,请重试");
String firstTwoDigitsStr = bizData.getAuthCode().substring(0, 2);
// 将截取的字符串转换为整数
int firstTwoDigits = Integer.parseInt(firstTwoDigitsStr);
// 判断范围
if (firstTwoDigits >= 10 && firstTwoDigits <= 15) {
//微信支付
bizData.setSubAppid(shopMerchant.getWechatSmallAppid());
} else if (firstTwoDigits >= 25 && firstTwoDigits <= 30) {
//支付宝支付
bizData.setSubAppid(shopMerchant.getAlipaySmallAppid());
}
return czgPayService.microPay(shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
}