This commit is contained in:
2026-01-14 18:31:52 +08:00
parent e301f996ad
commit c48c0f6d7d
9 changed files with 76 additions and 30 deletions

View File

@@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSONObject;
import com.czg.PayAdapter;
import com.czg.PolyPayUtils;
import com.czg.constant.PayChannelCst;
import com.czg.constants.SystemConstants;
import com.czg.entity.resp.CzgBaseResp;
import com.czg.entity.resp.CzgRefundResp;
import com.czg.enums.CzgPayEnum;
@@ -75,16 +76,14 @@ public class PolyPayAdapter implements PayAdapter {
}
private CzgResult<Map<String, Object>> jsPay(PolyMerchantDTO shopMerchant, String domain, String notifyUrl, CzgPayBaseReq<?> bizData) {
bizData.setSubAppid("aliPay".equals(bizData.getPayType()) ? shopMerchant.getAlipaySmallAppid() : shopMerchant.getWechatSmallAppid());
AssertUtil.isBlank(bizData.getSubAppid(), "暂不可用,请联系商家配置" + ("aliPay".equals(bizData.getPayType()) ? "支付宝" : "微信") + "小程序");
bizData.setPayType("aliPay".equals(bizData.getPayType()) ? "ALIPAY" : "WECHAT");
AssertUtil.isBlank(bizData.getSubAppid(), "暂不可用,请联系商家配置" + (SystemConstants.PayType.ALIPAY.equals(bizData.getPayType()) ? "支付宝" : "微信") + "小程序");
bizData.setPayType(SystemConstants.PayType.ALIPAY.equals(bizData.getPayType()) ? "ALIPAY" : "WECHAT");
bizData.polyBase(shopMerchant.getStoreId(), notifyUrl);
return PolyPayUtils.jsPay(domain, shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
}
private CzgResult<Map<String, Object>> ltPay(PolyMerchantDTO shopMerchant, String domain, String notifyUrl, CzgPayBaseReq<?> bizData) {
bizData.setSubAppid("aliPay".equals(bizData.getPayType()) ? shopMerchant.getAlipaySmallAppid() : shopMerchant.getWechatSmallAppid());
AssertUtil.isBlank(bizData.getSubAppid(), "暂不可用,请联系商家配置" + ("aliPay".equals(bizData.getPayType()) ? "支付宝" : "微信") + "小程序");
bizData.polyBase(shopMerchant.getStoreId(), notifyUrl);
return PolyPayUtils.ltPay(domain, shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
@@ -96,25 +95,7 @@ public class PolyPayAdapter implements PayAdapter {
}
private CzgResult<Map<String, Object>> microPay(PolyMerchantDTO shopMerchant, String domain, String notifyUrl, CzgPayBaseReq<String> bizData) {
AssertUtil.isBlank(bizData.getData(), "扫码失败,请重试");
if (bizData.getData().length() > 26) {
throw new CzgException("支付失败,不支持的条码");
}
bizData.polyBase(shopMerchant.getStoreId(), notifyUrl);
String firstTwoDigitsStr = bizData.getData().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());
} else {
throw new CzgException("扫描码非法或暂不支持");
}
return PolyPayUtils.microPay(domain, shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
}
}