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

@@ -7,6 +7,7 @@ import com.czg.account.service.ShopUserService;
import com.czg.account.service.UserInfoService;
import com.czg.constant.TableValueConstant;
import com.czg.constants.PayTypeConstants;
import com.czg.constants.SystemConstants;
import com.czg.enums.CzgPayEnum;
import com.czg.exception.CzgException;
import com.czg.market.service.MkDistributionConfigService;
@@ -82,7 +83,7 @@ public class DistributionPayServiceImpl implements DistributionPayService {
} else {
UserInfo userInfo = userInfoService.getById(userId);
initInfo.setPayment(orderPayment).setShopUser(shopUserInfo)
.setOpenId("aliPay".equals(payParam.getPayType()) ? userInfo.getAlipayOpenId() : userInfo.getWechatOpenId());
.setOpenId(SystemConstants.PayType.ALIPAY.equals(payParam.getPayType()) ? userInfo.getAlipayOpenId() : userInfo.getWechatOpenId());
}
return initInfo;
}

View File

@@ -6,6 +6,7 @@ import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONObject;
import com.czg.PayAdapter;
import com.czg.PayAdapterFactory;
import com.czg.constants.SystemConstants;
import com.czg.order.entity.ShopMerchant;
import com.czg.order.service.ShopMerchantService;
import com.czg.constant.PayChannelCst;
@@ -63,6 +64,10 @@ public class PayServiceImpl implements PayService {
} else if (shopMerchant.getChannel().equals(PayChannelCst.POLY)) {
payData = shopMerchant.getPolyPayJson();
}
bizData.setSubAppid(SystemConstants.PayType.ALIPAY.equals(bizData.getPayType()) ? shopMerchant.getAlipayAppId() : shopMerchant.getWechatAppId());
if (payType.equals(CzgPayEnum.MICRO_PAY)) {
checkMicroPay((CzgPayBaseReq<String>) bizData, shopMerchant);
}
return adapter.pay(payType, payData, getDomain(), getNotifyUrl(shopMerchant.getChannel()), bizData);
}
@@ -211,4 +216,25 @@ public class PayServiceImpl implements PayService {
}
return notifyUrl;
}
private void checkMicroPay(CzgPayBaseReq<String> bizData, ShopMerchant shopMerchant) {
String data = bizData.getData();
AssertUtil.isBlank(data, "扫码失败,请重试");
if (data.length() > 26) {
throw new CzgException("支付失败,不支持的条码");
}
String firstTwoDigitsStr = data.substring(0, 2);
// 将截取的字符串转换为整数
int firstTwoDigits = Integer.parseInt(firstTwoDigitsStr);
// 判断范围
if (firstTwoDigits >= 10 && firstTwoDigits <= 15) {
//微信支付
bizData.setSubAppid(shopMerchant.getWechatAppId());
} else if (firstTwoDigits >= 25 && firstTwoDigits <= 30) {
//支付宝支付
bizData.setSubAppid(shopMerchant.getAlipayAppId());
} else {
throw new CzgException("扫描码非法或暂不支持");
}
}
}

View File

@@ -4,6 +4,7 @@ import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONObject;
import com.czg.account.service.ShopInfoService;
import com.czg.constant.PayChannelCst;
import com.czg.constants.SystemConstants;
import com.czg.order.dto.ShopMerchantDTO;
import com.czg.order.entity.ShopDirectMerchant;
import com.czg.order.entity.ShopMerchant;
@@ -75,6 +76,8 @@ public class ShopMerchantServiceImpl extends ServiceImpl<ShopMerchantMapper, Sho
shopMerchant = new ShopMerchant();
shopMerchant.setChannel(shopMerchantParam.getChannel());
shopMerchant.setRelatedLicenceNo(shopMerchantParam.getRelatedLicenceNo());
shopMerchant.setAlipayAppId(SystemConstants.PayType.ALIPAY_APP_ID);
shopMerchant.setWechatAppId(SystemConstants.PayType.WECHAT_APP_ID);
if (PayChannelCst.NATIVE.equals(shopMerchantParam.getChannel()) && shopMerchantParam.getNativeMerchantDTO() != null) {
shopMerchant.setNativePayJson(JSONObject.toJSONString(shopMerchantParam.getNativeMerchantDTO()));
} else if (PayChannelCst.POLY.equals(shopMerchantParam.getChannel()) && shopMerchantParam.getPolyMerchantDTO() != null) {