diff --git a/cash-sdk/aggregation-pay/src/main/java/com/czg/EntryManager.java b/cash-sdk/aggregation-pay/src/main/java/com/czg/EntryManager.java index b8bb1dc50..a90b242da 100644 --- a/cash-sdk/aggregation-pay/src/main/java/com/czg/EntryManager.java +++ b/cash-sdk/aggregation-pay/src/main/java/com/czg/EntryManager.java @@ -1,14 +1,17 @@ package com.czg; +import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.StrUtil; import com.czg.dto.req.*; import com.czg.dto.resp.BankBranchDto; import com.czg.dto.resp.EntryRespDto; +import com.czg.dto.resp.EntryThirdRespDto; import com.czg.exception.CzgException; import com.czg.third.alipay.AlipayEntryManager; import com.czg.third.wechat.WechatEntryManager; import com.czg.utils.AssertUtil; import com.czg.utils.AsyncTaskExecutor; +import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.List; @@ -39,20 +42,46 @@ public class EntryManager { * 1. {@link com.czg.EntryManager#verifyEntryParam(AggregateMerchantDto)} 验证进件参数 * 2. {@link com.czg.EntryManager#uploadParamImage(AggregateMerchantDto)} 上传图片至第三方 * - * @param reqDto 进件参数 + * @param reqDto 进件参数 + * @param platform 平台 {@link com.czg.PayCst.Platform} */ - public static EntryRespDto entryMerchant(AggregateMerchantDto reqDto) { - List> tasks = new ArrayList<>(); - tasks.add(() -> WechatEntryManager.entryMerchant(null, reqDto)); - tasks.add(() -> AlipayEntryManager.entryMerchant(null, reqDto)); + public static EntryRespDto entryMerchant(AggregateMerchantDto reqDto, String... platform) { + List> tasks = new ArrayList<>(); - // 执行所有任务 - List> results = AsyncTaskExecutor.executeAll(tasks); - for (AsyncTaskExecutor.TaskResult result : results) { - // 合并两个进件结果 + if (platform == null || platform.length == 0) { + platform = new String[]{PayCst.Platform.WECHAT, PayCst.Platform.ALIPAY}; } - return new EntryRespDto(); + if (ArrayUtil.contains(platform, PayCst.Platform.WECHAT)) { + tasks.add(() -> WechatEntryManager.entryMerchant(null, reqDto)); + } + if (ArrayUtil.contains(platform, PayCst.Platform.ALIPAY)) { + tasks.add(() -> AlipayEntryManager.entryMerchant(null, reqDto)); + } + + // 执行所有任务 + List> results = AsyncTaskExecutor.executeAll(tasks); + + return getEntryRespDto(results); + } + + @NotNull + private static EntryRespDto getEntryRespDto(List> results) { + EntryRespDto entryRespDto = new EntryRespDto(); + for (AsyncTaskExecutor.TaskResult result : results) { + // 合并两个进件结果 + EntryThirdRespDto respDto = result.result(); + if (PayCst.Platform.WECHAT.equals(respDto.getPlatform())) { + entryRespDto.setWechatApplyId(respDto.getEntryId()); + entryRespDto.setWechatStatus(respDto.getStatus()); + entryRespDto.setWechatErrorMsg(respDto.getErrorMsg()); + } else if (PayCst.Platform.ALIPAY.equals(respDto.getPlatform())) { + entryRespDto.setAlipayOrderId(respDto.getEntryId()); + entryRespDto.setAlipayStatus(respDto.getStatus()); + entryRespDto.setAlipayErrorMsg(respDto.getErrorMsg()); + } + } + return entryRespDto; } /** @@ -184,18 +213,22 @@ public class EntryManager { MerchantBaseInfoDto baseInfo = reqDto.getMerchantBaseInfo(); AssertUtil.isBlank(baseInfo.getUserType(), "商户类型不能为空"); AssertUtil.isBlank(baseInfo.getShortName(), "商户简称不能为空"); - AssertUtil.isBlank(baseInfo.getCertType(), "证件类型不能为空"); - if (!"0".equals(baseInfo.getCertType())) { - throw new CzgException("证件类型错误"); - } AssertUtil.isBlank(baseInfo.getMccCode(), "商户行业编码不能为空"); - if ("SUPER".equals(baseInfo.getContactPersonType())) { + AssertUtil.isBlank(baseInfo.getContactPersonType(), "联系人类型不能为空"); + if (!PayCst.ContactPersonType.SUPER.equals(baseInfo.getContactPersonType()) && !PayCst.ContactPersonType.LEGAL.equals(baseInfo.getContactPersonType())) { + throw new CzgException("联系人类型错误"); + } + if (PayCst.ContactPersonType.SUPER.equals(baseInfo.getContactPersonType())) { + AssertUtil.isBlank(baseInfo.getCertType(), "证件类型不能为空"); + if (!"0".equals(baseInfo.getCertType())) { + throw new CzgException("证件类型错误"); + } AssertUtil.isBlank(baseInfo.getContactName(), "联系人姓名不能为空"); AssertUtil.isBlank(baseInfo.getContactPersonId(), "联系人身份证号不能为空"); AssertUtil.isBlank(baseInfo.getContactPhone(), "联系人电话不能为空"); AssertUtil.isBlank(baseInfo.getContactAddr(), "联系人地址不能为空"); AssertUtil.isBlank(baseInfo.getContactEmail(), "联系人邮箱不能为空"); - AssertUtil.isBlank(baseInfo.getContactIdStartDate(), "联系人身份证开始日期不能为空"); + AssertUtil.isBlank(baseInfo.getContactPersonIdStartDate(), "联系人身份证开始日期不能为空"); AssertUtil.isBlank(baseInfo.getContactPersonIdEndDate(), "联系人身份证到期日期不能为空"); AssertUtil.isNull(baseInfo.getContactIdCardBackPic(), "联系人身份证反面不能为空"); AssertUtil.isBlank(baseInfo.getContactIdCardBackPic().getUrl(), "联系人身份证反面不能为空"); @@ -228,9 +261,10 @@ public class EntryManager { LegalPersonInfoDto legalPersonInfo = reqDto.getLegalPersonInfo(); AssertUtil.isBlank(legalPersonInfo.getLegalPersonName(), "法人姓名不能为空"); AssertUtil.isBlank(legalPersonInfo.getLegalPersonId(), "法人身份证号不能为空"); - AssertUtil.isBlank(legalPersonInfo.getLegalIdStartDate(), "法人身份证开始日期不能为空"); + AssertUtil.isBlank(legalPersonInfo.getLegalIdPersonStartDate(), "法人身份证开始日期不能为空"); AssertUtil.isBlank(legalPersonInfo.getLegalPersonIdEndDate(), "法人身份证到期日期不能为空"); AssertUtil.isBlank(legalPersonInfo.getLegalPersonPhone(), "法人电话不能为空"); + AssertUtil.isBlank(legalPersonInfo.getLegalPersonEmail(), "法人邮箱不能为空"); AssertUtil.isBlank(legalPersonInfo.getLegalGender(), "法人性别不能为空"); AssertUtil.isBlank(legalPersonInfo.getLegalAddress(), "法人地址不能为空"); AssertUtil.isNull(legalPersonInfo.getIdCardHandPic(), "法人身份证手持不能为空"); @@ -242,9 +276,9 @@ public class EntryManager { AssertUtil.isNull(reqDto.getStoreInfo(), "门店信息不能为空"); StoreInfoDto storeInfo = reqDto.getStoreInfo(); - AssertUtil.isBlank(storeInfo.getMercProvId(), "门店省ID不能为空"); - AssertUtil.isBlank(storeInfo.getMercCityId(), "门店市ID不能为空"); - AssertUtil.isBlank(storeInfo.getMercAreaId(), "门店区ID不能为空"); + AssertUtil.isBlank(storeInfo.getMercProvCode(), "门店省ID不能为空"); + AssertUtil.isBlank(storeInfo.getMercCityCode(), "门店市ID不能为空"); + AssertUtil.isBlank(storeInfo.getMercAreaCode(), "门店区ID不能为空"); AssertUtil.isBlank(storeInfo.getMercProv(), "门店省不能为空"); AssertUtil.isBlank(storeInfo.getMercCity(), "门店市不能为空"); AssertUtil.isBlank(storeInfo.getMercArea(), "门店区不能为空"); @@ -303,10 +337,97 @@ public class EntryManager { public static void main(String[] args) { + + AggregateMerchantDto merchantDto = getTestMerchantEntryData(); + +// verifyEntryParam(merchantDto); +// uploadParamImage(merchantDto); + + verifyEntryParam(merchantDto); + uploadParamImage(merchantDto); + System.out.println(merchantDto); + entryMerchant(merchantDto, PayCst.Platform.WECHAT); +// entryMerchant(merchantDto, PayCst.Platform.WECHAT, PayCst.Platform.ALIPAY); + } + + private static AggregateMerchantDto getTestMerchantEntryData() { AggregateMerchantDto merchantDto = new AggregateMerchantDto(); merchantDto.setMerchantCode("20220106000000000001"); -// verifyEntryParam(merchantDto); - uploadParamImage(merchantDto); + MerchantBaseInfoDto baseInfoDto = new MerchantBaseInfoDto(); + baseInfoDto.setUserType("1"); + baseInfoDto.setCompanyChildType("1"); + baseInfoDto.setShortName("测试商户"); + baseInfoDto.setMccCode("0741"); + baseInfoDto.setContactPersonType(PayCst.ContactPersonType.SUPER); + baseInfoDto.setContactName("张三"); + baseInfoDto.setContactPersonId("110101199001011234"); + baseInfoDto.setContactPersonIdStartDate("2021-01-01"); + baseInfoDto.setContactPersonIdEndDate("2025-01-01"); + baseInfoDto.setContactPhone("13800000000"); + baseInfoDto.setContactEmail("1157756119@qq.com"); + baseInfoDto.setContactAddr("广东省深圳市南山区"); + baseInfoDto.setContactIdCardFrontPic(new ImageDto("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240312/31476c871c224389aea0ac4e17c964a3.jpg")); + baseInfoDto.setContactIdCardBackPic(new ImageDto("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240312/31476c871c224389aea0ac4e17c964a3.jpg")); + merchantDto.setMerchantBaseInfo(baseInfoDto); + + BusinessLicenceInfoDto businessLicenceInfoDto = new BusinessLicenceInfoDto(); + businessLicenceInfoDto.setLicenceName("测试商户"); + businessLicenceInfoDto.setLicenceNo("110101199001011234"); + businessLicenceInfoDto.setLicenceStartDate("2021-01-01"); + businessLicenceInfoDto.setLicenceEndDate("2052-01-01"); + businessLicenceInfoDto.setRegisteredAddress("广东省深圳市南山区"); + businessLicenceInfoDto.setLicensePic(new ImageDto("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240312/31476c871c224389aea0ac4e17c964a3.jpg")); + merchantDto.setBusinessLicenceInfo(businessLicenceInfoDto); + + LegalPersonInfoDto legalPersonInfoDto = new LegalPersonInfoDto(); + legalPersonInfoDto.setLegalPersonName("张三"); + legalPersonInfoDto.setLegalPersonId("110101199001011234"); + legalPersonInfoDto.setLegalIdPersonStartDate("2021-01-01"); + legalPersonInfoDto.setLegalPersonIdEndDate("2055-01-01"); + legalPersonInfoDto.setLegalPersonPhone("13800000000"); + legalPersonInfoDto.setLegalPersonEmail("1157756119@qq.com"); + legalPersonInfoDto.setLegalGender("1"); + legalPersonInfoDto.setLegalAddress("广东省深圳市南山区"); + legalPersonInfoDto.setIdCardHandPic(new ImageDto("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240312/31476c871c224389aea0ac4e17c964a3.jpg")); + legalPersonInfoDto.setIdCardFrontPic(new ImageDto("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240312/31476c871c224389aea0ac4e17c964a3.jpg")); + legalPersonInfoDto.setIdCardBackPic(new ImageDto("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240312/31476c871c224389aea0ac4e17c964a3.jpg")); + merchantDto.setLegalPersonInfo(legalPersonInfoDto); + + StoreInfoDto storeInfoDto = new StoreInfoDto(); + storeInfoDto.setMercProvCode("440000"); + storeInfoDto.setMercCityCode("440300"); + storeInfoDto.setMercAreaCode("440303"); + storeInfoDto.setMercProv("广东省"); + storeInfoDto.setMercCity("深圳市"); + storeInfoDto.setMercArea("南山区"); + storeInfoDto.setBusinessAddress("广东省深圳市南山区"); + storeInfoDto.setInsidePic(new ImageDto("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240312/31476c871c224389aea0ac4e17c964a3.jpg")); + storeInfoDto.setDoorPic(new ImageDto("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240312/31476c871c224389aea0ac4e17c964a3.jpg")); + storeInfoDto.setCashierDeskPic(new ImageDto("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240312/31476c871c224389aea0ac4e17c964a3.jpg")); + merchantDto.setStoreInfo(storeInfoDto); + + SettlementInfoDto settlementInfoDto = new SettlementInfoDto(); + settlementInfoDto.setSettlementType("1"); + settlementInfoDto.setSettlementCardType("21"); + settlementInfoDto.setSettlementName("张三"); + settlementInfoDto.setSettlementCardNo("110101199001011234"); + settlementInfoDto.setBankMobile("13800000000"); + settlementInfoDto.setOpenAccProvinceId("440000"); + settlementInfoDto.setOpenAccCityId("440300"); + settlementInfoDto.setOpenAccAreaId("440303"); + settlementInfoDto.setOpenAccProvince("广东省"); + settlementInfoDto.setOpenAccCity("深圳市"); + settlementInfoDto.setOpenAccArea("南山区"); + settlementInfoDto.setBankName("中国工商银行"); + settlementInfoDto.setBankType("1"); + settlementInfoDto.setBankBranchName("广东省深圳市南山区"); + settlementInfoDto.setBankBranchCode("440300"); + settlementInfoDto.setBankCardFrontPic(new ImageDto("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240312/31476c871c224389aea0ac4e17c964a3.jpg")); + settlementInfoDto.setBankCardBackPic(new ImageDto("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240312/31476c871c224389aea0ac4e17c964a3.jpg")); + settlementInfoDto.setOpenAccountLicencePic(new ImageDto("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240312/31476c871c224389aea0ac4e17c964a3.jpg")); + merchantDto.setSettlementInfo(settlementInfoDto); + + return merchantDto; } } diff --git a/cash-sdk/aggregation-pay/src/main/java/com/czg/PayCst.java b/cash-sdk/aggregation-pay/src/main/java/com/czg/PayCst.java new file mode 100644 index 000000000..5000c63ac --- /dev/null +++ b/cash-sdk/aggregation-pay/src/main/java/com/czg/PayCst.java @@ -0,0 +1,53 @@ +package com.czg; + +/** + * 支付相关常量 + * @author yjjie + * @date 2026/1/7 09:20 + */ +public interface PayCst { + + /** + * 平台 + */ + class Platform { + /** + * 微信 + */ + public static final String WECHAT = "wechat"; + /** + * 支付宝 + */ + public static final String ALIPAY = "alipay"; + } + + /** + * 进件状态 + */ + class EntryStatus { + /** + * 待处理 + */ + public static final String INIT = "INIT"; + + /** + * 失败 + */ + public static final String FAIL = "FAIL"; + } + + /** + * 联系人类型 + */ + class ContactPersonType { + /** + * 法人 + */ + public static final String LEGAL = "LEGAL"; + + /** + * 经办人 + */ + public static final String SUPER = "SUPER"; + } +} diff --git a/cash-sdk/aggregation-pay/src/main/java/com/czg/dto/req/ImageDto.java b/cash-sdk/aggregation-pay/src/main/java/com/czg/dto/req/ImageDto.java index 5784464d7..b46a6c05a 100644 --- a/cash-sdk/aggregation-pay/src/main/java/com/czg/dto/req/ImageDto.java +++ b/cash-sdk/aggregation-pay/src/main/java/com/czg/dto/req/ImageDto.java @@ -1,12 +1,14 @@ package com.czg.dto.req; import lombok.Data; +import lombok.experimental.Accessors; /** * @author yjjie * @date 2026/1/6 16:53 */ @Data +@Accessors(chain = true) public class ImageDto { /** @@ -23,4 +25,10 @@ public class ImageDto { * 支付宝 图片 mediaId */ private String alipayId; + + public ImageDto() {} + + public ImageDto(String url) { + this.url = url; + } } diff --git a/cash-sdk/aggregation-pay/src/main/java/com/czg/dto/req/LegalPersonInfoDto.java b/cash-sdk/aggregation-pay/src/main/java/com/czg/dto/req/LegalPersonInfoDto.java index 203cbfdc4..8f631d00e 100644 --- a/cash-sdk/aggregation-pay/src/main/java/com/czg/dto/req/LegalPersonInfoDto.java +++ b/cash-sdk/aggregation-pay/src/main/java/com/czg/dto/req/LegalPersonInfoDto.java @@ -26,7 +26,7 @@ public class LegalPersonInfoDto { * 【必填】 * 法人身份证开始日期 */ - private String legalIdStartDate; + private String legalIdPersonStartDate; /** * 【必填】 @@ -40,6 +40,12 @@ public class LegalPersonInfoDto { */ private String legalPersonPhone; + /** + * 【必填】 + * 法人邮箱 + */ + private String legalPersonEmail; + /** * 法人性别(0男 1女) */ diff --git a/cash-sdk/aggregation-pay/src/main/java/com/czg/dto/req/MerchantBaseInfoDto.java b/cash-sdk/aggregation-pay/src/main/java/com/czg/dto/req/MerchantBaseInfoDto.java index 3515e8dc0..ae8384f60 100644 --- a/cash-sdk/aggregation-pay/src/main/java/com/czg/dto/req/MerchantBaseInfoDto.java +++ b/cash-sdk/aggregation-pay/src/main/java/com/czg/dto/req/MerchantBaseInfoDto.java @@ -26,12 +26,6 @@ public class MerchantBaseInfoDto { */ private String shortName; - /** - * 证件类型 - * 目前只支持身份证 传值:0 - */ - private String certType = "0"; - /** * 【必填】 * 行业编码 @@ -46,61 +40,58 @@ public class MerchantBaseInfoDto { private String contactPersonType = "LEGAL"; /** - * 【必填】 * 联系人姓名 */ private String contactName; /** - * 【必填】 + * 证件类型 + * 目前只支持身份证 传值:0 + */ + private String certType = "0"; + + /** * 联系人身份证号 */ private String contactPersonId; /** - * 【必填】 * 联系人身份证开始日期 */ - private String contactIdStartDate; + private String contactPersonIdStartDate; /** - * 【必填】 * 联系人身份证到期日期 */ private String contactPersonIdEndDate; /** - * 【必填】 * 联系人身份证背面 */ private ImageDto contactIdCardBackPic; /** - * 【必填】 * 联系人身份证正面 */ private ImageDto contactIdCardFrontPic; /** - * 【必填】 * 联系人电话 */ private String contactPhone; /** - * 【必填】 * 联系人通讯地址 */ private String contactAddr; /** - * 【必填】 * 联系人邮箱 */ private String contactEmail; /** - * 企业类型,1:普通企业,2:事业单位,3:其他组织 + * 企业类型,1:普通企业,2:事业单位,3:政府机关,4:社会组织 */ private String companyChildType = "1"; } diff --git a/cash-sdk/aggregation-pay/src/main/java/com/czg/dto/req/StoreInfoDto.java b/cash-sdk/aggregation-pay/src/main/java/com/czg/dto/req/StoreInfoDto.java index ee4c32613..09b4f18e8 100644 --- a/cash-sdk/aggregation-pay/src/main/java/com/czg/dto/req/StoreInfoDto.java +++ b/cash-sdk/aggregation-pay/src/main/java/com/czg/dto/req/StoreInfoDto.java @@ -12,21 +12,21 @@ public class StoreInfoDto { /** * 【必填】 - * 商户归属省id + * 商户归属省Code */ - private String mercProvId; + private String mercProvCode; /** * 【必填】 - * 商户归属市id + * 商户归属市Code */ - private String mercCityId; + private String mercCityCode; /** * 【必填】 - * 商户归属区id + * 商户归属区Code */ - private String mercAreaId; + private String mercAreaCode; /** * 商户归属省 diff --git a/cash-sdk/aggregation-pay/src/main/java/com/czg/dto/resp/EntryRespDto.java b/cash-sdk/aggregation-pay/src/main/java/com/czg/dto/resp/EntryRespDto.java index 1780c699e..f6abe75e4 100644 --- a/cash-sdk/aggregation-pay/src/main/java/com/czg/dto/resp/EntryRespDto.java +++ b/cash-sdk/aggregation-pay/src/main/java/com/czg/dto/resp/EntryRespDto.java @@ -19,9 +19,15 @@ public class EntryRespDto { /** * 微信状态 + * {@link com.czg.PayCst.EntryStatus} */ private String wechatStatus; + /** + * 微信进件错误信息 + */ + private String wechatErrorMsg; + /** * 支付宝订单 Id */ @@ -29,6 +35,12 @@ public class EntryRespDto { /** * 支付宝状态 + * {@link com.czg.PayCst.EntryStatus} */ private String alipayStatus; + + /** + * 支付宝进件错误信息 + */ + private String alipayErrorMsg; } diff --git a/cash-sdk/aggregation-pay/src/main/java/com/czg/dto/resp/EntryThirdRespDto.java b/cash-sdk/aggregation-pay/src/main/java/com/czg/dto/resp/EntryThirdRespDto.java new file mode 100644 index 000000000..449b56f46 --- /dev/null +++ b/cash-sdk/aggregation-pay/src/main/java/com/czg/dto/resp/EntryThirdRespDto.java @@ -0,0 +1,34 @@ +package com.czg.dto.resp; + +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * @author yjjie + * @date 2026/1/7 09:07 + */ +@Data +@Accessors(chain = true) +public class EntryThirdRespDto { + + /** + * 录入id + */ + private String entryId; + + /** + * 平台 + */ + private String platform; + + /** + * 状态 + * {@link com.czg.PayCst.EntryStatus} + */ + private String status; + + /** + * 错误信息 + */ + private String errorMsg; +} diff --git a/cash-sdk/aggregation-pay/src/main/java/com/czg/third/alipay/AlipayClient.java b/cash-sdk/aggregation-pay/src/main/java/com/czg/third/alipay/AlipayClient.java index 7af9a1578..93c6527c4 100644 --- a/cash-sdk/aggregation-pay/src/main/java/com/czg/third/alipay/AlipayClient.java +++ b/cash-sdk/aggregation-pay/src/main/java/com/czg/third/alipay/AlipayClient.java @@ -24,7 +24,10 @@ public class AlipayClient { } } - public static ApiClient getApiClient(AlipayConfigDto configDto) { + public static void setApiClient(AlipayConfigDto configDto) { + if (configDto == null) { + configDto = AlipayConfigDto.getDefaultConfig(); + } try { ApiClient defaultClient = Configuration.getDefaultApiClient(); // 初始化alipay参数(全局设置一次) @@ -34,10 +37,8 @@ public class AlipayClient { alipayConfig.setAlipayPublicKey(configDto.getAlipayPublicKey()); alipayConfig.setPrivateKey(configDto.getPrivateKey()); defaultClient.setAlipayConfig(alipayConfig); - return defaultClient; } catch (Exception e) { log.error("创建支付宝客户端失败", e); - return null; } } diff --git a/cash-sdk/aggregation-pay/src/main/java/com/czg/third/alipay/AlipayEntryManager.java b/cash-sdk/aggregation-pay/src/main/java/com/czg/third/alipay/AlipayEntryManager.java index 909b7cb7b..de32ddd66 100644 --- a/cash-sdk/aggregation-pay/src/main/java/com/czg/third/alipay/AlipayEntryManager.java +++ b/cash-sdk/aggregation-pay/src/main/java/com/czg/third/alipay/AlipayEntryManager.java @@ -2,9 +2,13 @@ package com.czg.third.alipay; import com.alibaba.fastjson2.JSONArray; import com.alipay.api.DefaultAlipayClient; +import com.alipay.api.FileItem; import com.alipay.api.domain.AlipayFinancialnetAuthPbcnameQueryModel; +import com.alipay.api.domain.AntMerchantExpandIndirectZftSimplecreateModel; import com.alipay.api.request.AlipayFinancialnetAuthPbcnameQueryRequest; +import com.alipay.api.request.AntMerchantExpandIndirectImageUploadRequest; import com.alipay.api.response.AlipayFinancialnetAuthPbcnameQueryResponse; +import com.alipay.api.response.AntMerchantExpandIndirectImageUploadResponse; import com.alipay.v3.ApiClient; import com.alipay.v3.ApiException; import com.alipay.v3.Configuration; @@ -12,10 +16,13 @@ import com.alipay.v3.api.AlipayOpenAgentApi; import com.alipay.v3.api.AntMerchantExpandIndirectImageApi; import com.alipay.v3.model.*; import com.alipay.v3.util.model.AlipayConfig; +import com.czg.PayCst; import com.czg.dto.req.AggregateMerchantDto; import com.czg.dto.resp.BankBranchDto; import com.czg.dto.resp.EntryRespDto; +import com.czg.dto.resp.EntryThirdRespDto; import com.czg.third.alipay.dto.config.AlipayConfigDto; +import com.czg.third.wechat.dto.req.entry.WechatEntryReqDto; import com.czg.utils.UploadFileUtil; import lombok.extern.slf4j.Slf4j; @@ -42,8 +49,21 @@ public class AlipayEntryManager { * @param configDto 配置信息 * @param reqDto 请求信息 */ - public static EntryRespDto entryMerchant(AlipayConfigDto configDto, AggregateMerchantDto reqDto) { - return new EntryRespDto(); + public static EntryThirdRespDto entryMerchant(AlipayConfigDto configDto, AggregateMerchantDto reqDto) { + AntMerchantExpandIndirectZftSimplecreateModel entryReqDto = buildEntryParams(reqDto); + EntryThirdRespDto respDto = new EntryThirdRespDto() + .setPlatform(PayCst.Platform.ALIPAY); + + try { +// entry(configDto, entryReqDto); + } catch (Exception e) { + log.error("支付宝进件报错:{}", e.getMessage(), e); + respDto.setStatus(PayCst.EntryStatus.FAIL); + respDto.setEntryId(""); + respDto.setErrorMsg(e.getMessage()); + } + + return respDto; } /** @@ -54,9 +74,6 @@ public class AlipayEntryManager { * @return 图片ID */ public static String uploadImage(AlipayConfigDto configDto, String url) { - if (configDto == null) { - configDto = AlipayConfigDto.getDefaultConfig(); - } try { byte[] bytes = UploadFileUtil.downloadImage(url); @@ -67,13 +84,17 @@ public class AlipayEntryManager { File file = tempFile.toFile(); - AntMerchantExpandIndirectImageApi imageApi = new AntMerchantExpandIndirectImageApi(); - imageApi.setApiClient(AlipayClient.getApiClient(configDto)); - AntMerchantExpandIndirectImageUploadModel model = new AntMerchantExpandIndirectImageUploadModel(); - // 从 url 中获取图片 后缀 - model.setImageType(UploadFileUtil.extractImageExtension(url)); - AntMerchantExpandIndirectImageUploadResponseModel upload = imageApi.upload(model, file); - return upload.getImageId(); + AntMerchantExpandIndirectImageUploadRequest request = new AntMerchantExpandIndirectImageUploadRequest(); + request.setImageType(UploadFileUtil.extractImageExtension(url)); + + // 设置图片内容 + FileItem imageContent = new FileItem(file); + request.setImageContent(imageContent); + + DefaultAlipayClient defaultAlipayClient = AlipayClient.getDefaultClient(configDto); + AntMerchantExpandIndirectImageUploadResponse response = defaultAlipayClient.execute(request); + + return response.getImageId(); } catch (Exception e) { log.error("支付宝上传图片报错,URL:{},错误信息:{}", "url", e.getMessage(), e); return ""; @@ -108,9 +129,23 @@ public class AlipayEntryManager { } } + /** + * 构建进件参数 + * + * @param reqDto 请求参数 + * @return 进件参数 + */ + private static AntMerchantExpandIndirectZftSimplecreateModel buildEntryParams(AggregateMerchantDto reqDto) { + AntMerchantExpandIndirectZftSimplecreateModel entryParams = new AntMerchantExpandIndirectZftSimplecreateModel(); + + + return entryParams; + } + public static void main(String[] args) { - queryBankBranchList("CMB", "西安市", "陕西省"); +// queryBankBranchList("CMB", "陕西省", "西安市"); + uploadImage(null, "https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240312/31476c871c224389aea0ac4e17c964a3.jpg"); } diff --git a/cash-sdk/aggregation-pay/src/main/java/com/czg/third/alipay/AlipayReqUtils.java b/cash-sdk/aggregation-pay/src/main/java/com/czg/third/alipay/AlipayReqUtils.java index 0ab504b1e..c81f50ed6 100644 --- a/cash-sdk/aggregation-pay/src/main/java/com/czg/third/alipay/AlipayReqUtils.java +++ b/cash-sdk/aggregation-pay/src/main/java/com/czg/third/alipay/AlipayReqUtils.java @@ -17,7 +17,9 @@ import java.util.List; */ public class AlipayReqUtils { public static void main(String[] args) throws AlipayApiException { - DefaultAlipayClient defaultAlipayClient = AlipayClient.getDefaultClient(null); +// DefaultAlipayClient defaultAlipayClient = AlipayClient.getDefaultClient(null); +// AlipayClient alipayClient = new DefaultAlipayClient(getAlipayConfig()); + DefaultAlipayClient defaultAlipayClient = new DefaultAlipayClient(getAlipayConfig()); // 构造请求参数以调用接口 AntMerchantExpandIndirectZftSimplecreateRequest request = new AntMerchantExpandIndirectZftSimplecreateRequest(); @@ -205,4 +207,18 @@ public class AlipayReqUtils { } } + private static AlipayConfig getAlipayConfig() { + String privateKey = "MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQD48HaUoV7OH7os+9L01kHgxzwIhJick4OkFq4aHsntsXEJ J3gedhuEZtV8oHKZ30DPW12IJ4S8NXtpr8OWaqrAPFonf4wVaRY1d0yIAea57kfLEn9oOEEy4FzARgMNDkyxC+/3OUdGbLHpTjfVX3gusXsEhUDy1/WewihAkoNYF37+W3W/uVLzeWoPq0EcUbRv/G/t/p6gL69ltsMAiVFG4Q/Yk24YAN6lYgBPNLXUEwQ1Q+T+1omjfavHgvarKOp33z3JOUH+aGOmDsJ5Y9gyGtJzOCipAd8Zcv+T1ygsEzZYO1/gzcbPnfO1ShqStCHzssuw8FBVx2JdfQKXKMMNAgMBAAECggEAVTrO/pg5Q00titU1Jspsh67u6OOs9H605Ws2dI7yB8VmtAGlaJh7V1t14FN2qSP8poHbhhAxq9aLyGV7C3a9u09udnN+3J28EtYjh7VO732bavWMV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MpyClbSr52puHpRRdvAiIEQ74yYh0JX8q96g=="; + String alipayPublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAiQkrz+emAuS1mB3KKDOMmAZRd/BlPbh7fAIHAqAj1+QCZNcV3o2BTLIIqnuKpSlFXDG3uDzp2VsBxcizXuBbFyPGylnD9CgCj5abyh3+FIHPAZ2IM3TtpqImZ0TSPGXrMli4Nir7MvZktgccCqQKCC4o6iaDGz+UwWwJUIPna8fm2tiTZ+KH150CZbKVj4ZGNpBh5XSV/1dRgyQIV9D/EwSbkZ0n6VgKQLJBi0C2UE3QB17aL1Ir6+gDXIDbknN8O7GUD3aMGdThYdSRUb5wp9CZ5qfV7vCS/CgaRo38nhH3NOzkTL+7v0m1ZDHPmqEkn9VzZN6sCQdL7PoAOjHOCwIDAQAB"; + AlipayConfig alipayConfig = new AlipayConfig(); + alipayConfig.setServerUrl("https://openapi.alipay.com/gateway.do"); + alipayConfig.setAppId("2021004174605036"); + alipayConfig.setPrivateKey(privateKey); + alipayConfig.setFormat("json"); + alipayConfig.setAlipayPublicKey(alipayPublicKey); + alipayConfig.setCharset("UTF-8"); + alipayConfig.setSignType("RSA2"); + return alipayConfig; + } + } diff --git a/cash-sdk/aggregation-pay/src/main/java/com/czg/third/alipay/dto/config/AlipayConfigDto.java b/cash-sdk/aggregation-pay/src/main/java/com/czg/third/alipay/dto/config/AlipayConfigDto.java index f2838086f..d1ce39399 100644 --- a/cash-sdk/aggregation-pay/src/main/java/com/czg/third/alipay/dto/config/AlipayConfigDto.java +++ b/cash-sdk/aggregation-pay/src/main/java/com/czg/third/alipay/dto/config/AlipayConfigDto.java @@ -38,5 +38,10 @@ public class AlipayConfigDto { .setPrivateKey("MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQD48HaUoV7OH7os+9L01kHgxzwIhJick4OkFq4aHsntsXEJ J3gedhuEZtV8oHKZ30DPW12IJ4S8NXtpr8OWaqrAPFonf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ebUI6Fjo3xlegLJRiwV6INkNTJOYM5hD/mSxUACwXQFfkJipBINXBIgraWD1RLQKBgQCj49axWq0F6+WjZVOyPaD3uh37p9trRUxRhWTxw3fB23WdktaKMgbCqHOmwzP4bRLSEVQtf2dOz1gMqu14b8HqJvgAf/F/11YJ9hz09LEhmjZVjE68HZfqT7uK2W5OX8/lfXmK7TFcj6SjG5YB96lZMhTZ0WnufEd6QkdKDZYXIQKBgQD9GDTcIMbFwbEaKHnfZaTD3f876EGRgsgrCxwdEk7LBCRPwWo7yI929M4psIlpNwNeiyjBkBunWIVkpznp6qPtJqagIPUYesU4f5v6/okq5wcpaNKSkWbIvWVLaLGOiA1aeGJtbpMpyClbSr52puHpRRdvAiIEQ74yYh0JX8q96g==") .setAlipayPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAiQkrz+emAuS1mB3KKDOMmAZRd/BlPbh7fAIHAqAj1+QCZNcV3o2BTLIIqnuKpSlFXDG3uDzp2VsBxcizXuBbFyPGylnD9CgCj5abyh3+FIHPAZ2IM3TtpqImZ0TSPGXrMli4Nir7MvZktgccCqQKCC4o6iaDGz+UwWwJUIPna8fm2tiTZ+KH150CZbKVj4ZGNpBh5XSV/1dRgyQIV9D/EwSbkZ0n6VgKQLJBi0C2UE3QB17aL1Ir6+gDXIDbknN8O7GUD3aMGdThYdSRUb5wp9CZ5qfV7vCS/CgaRo38nhH3NOzkTL+7v0m1ZDHPmqEkn9VzZN6sCQdL7PoAOjHOCwIDAQAB") .setDomain("https://openapi.alipay.com/gateway.do"); +// return new AlipayConfigDto() +// .setAppId("2021004145625815") +// .setPrivateKey("MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCAjDBuS8K/IJb9ui+KuNm/sTUdEiaji4BNpZ92avO1N5JpNlGmac6ec4p3tNFT950sBLcQkClcUpQxUHQzAT6DYNNXOKyvfI/EmcqwCw6PaMNLs/8cV//J2WWZBUhLaOsjKurpm9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vf6tR4wl8w9b2HqTMV08iEIqzGvVC1Dh0c/Zop/EJgN4CzUfIMOSBwGaAVAApzs+pD6QPgGP2OTwWTioo/qa4R05sbxDHNN1XJFa2jhZV6HiqMWOrNs5jm1zJ/zRjtHuJTdtyO9CvKiLbESy9XScY4/8lEfSiK5HIoJzTXkFUCgYAkYkvkW6psJpWj05XWq44UN0n6QOU/Igl35Um/iuOMVhsTmIt09STQVTuzJzfH82+sCqoRsD1blE5unKNUC1DK77aNKTv3Z0dxN9R7FAyfZRiYQXTrbBPBqWjay6FCNxn8e8UsJN4Z6FIV2LGlQI114krSap1MALKLVvnld0NaUQ==") +// .setAlipayPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAiQkrz+emAuS1mB3KKDOMmAZRd/BlPbh7fAIHAqAj1+QCZNcV3o2BTLIIqnuKpSlFXDG3uDzp2VsBxcizXuBbFyPGylnD9CgCj5abyh3+FIHPAZ2IM3TtpqImZ0TSPGXrMli4Nir7MvZktgccCqQKCC4o6iaDGz+UwWwJUIPna8fm2tiTZ+KH150CZbKVj4ZGNpBh5XSV/1dRgyQIV9D/EwSbkZ0n6VgKQLJBi0C2UE3QB17aL1Ir6+gDXIDbknN8O7GUD3aMGdThYdSRUb5wp9CZ5qfV7vCS/CgaRo38nhH3NOzkTL+7v0m1ZDHPmqEkn9VzZN6sCQdL7PoAOjHOCwIDAQAB") +// .setDomain("https://openapi.alipay.com/gateway.do"); } } diff --git a/cash-sdk/aggregation-pay/src/main/java/com/czg/third/wechat/WechatEntryManager.java b/cash-sdk/aggregation-pay/src/main/java/com/czg/third/wechat/WechatEntryManager.java index 64a5d5d90..c9904ccaa 100644 --- a/cash-sdk/aggregation-pay/src/main/java/com/czg/third/wechat/WechatEntryManager.java +++ b/cash-sdk/aggregation-pay/src/main/java/com/czg/third/wechat/WechatEntryManager.java @@ -2,21 +2,33 @@ package com.czg.third.wechat; import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONWriter; -import com.czg.dto.req.AggregateMerchantDto; -import com.czg.dto.resp.EntryRespDto; +import com.czg.PayCst; +import com.czg.dto.req.*; +import com.czg.dto.resp.EntryThirdRespDto; +import com.czg.exception.CzgException; import com.czg.third.wechat.dto.config.WechatPayConfigDto; -import com.czg.third.wechat.dto.req.entry.WechatEntryReqDto; +import com.czg.third.wechat.dto.req.entry.*; +import com.czg.third.wechat.dto.req.entry.business.WechatEntryBusinessReqDto; +import com.czg.third.wechat.dto.req.entry.business.WechatEntryIdentityReqDto; +import com.czg.third.wechat.dto.req.entry.business.WechatEntryLicenseReqDto; +import com.czg.third.wechat.dto.req.entry.business.sales.WechatEntryMiniProgramReqDto; +import com.czg.third.wechat.dto.req.entry.business.sales.WechatEntrySalesInfoReqDto; +import com.czg.third.wechat.dto.req.entry.business.sales.WechatEntryStoreInfoReqDto; import com.czg.utils.UploadFileUtil; +import com.wechat.pay.java.core.Config; +import com.wechat.pay.java.core.cipher.PrivacyEncryptor; import com.wechat.pay.java.service.file.FileUploadService; import com.wechat.pay.java.service.file.model.FileUploadResponse; import lombok.extern.slf4j.Slf4j; import java.io.IOException; +import java.util.List; import java.util.Map; /** * 微信支付进件 管理 * 参考地址 ... + * * @author yjjie * @date 2025/12/26 10:57 */ @@ -29,8 +41,23 @@ public class WechatEntryManager { * @param configDto 配置信息 * @param reqDto 请求信息 */ - public static EntryRespDto entryMerchant(WechatPayConfigDto configDto, AggregateMerchantDto reqDto) { - return new EntryRespDto(); + public static EntryThirdRespDto entryMerchant(WechatPayConfigDto configDto, AggregateMerchantDto reqDto) { + WechatEntryReqDto entryReqDto = buildEntryParams(configDto, reqDto); + EntryThirdRespDto respDto = new EntryThirdRespDto() + .setPlatform(PayCst.Platform.WECHAT); + + try { + String params = JSONObject.toJSONString(entryReqDto, JSONWriter.Feature.IgnoreEmpty); + String respBody = WechatReqUtils.postReq(configDto, "/v3/applyment4sub/applyment/", params); + System.out.println("调用成功:" + respBody); + } catch (Exception e) { + log.error("微信进件报错:{}", e.getMessage(), e); + respDto.setStatus(PayCst.EntryStatus.FAIL); + respDto.setEntryId(""); + respDto.setErrorMsg(e.getMessage()); + } + + return respDto; } public static JSONObject queryBankList(WechatPayConfigDto configDto, Integer offset, Integer limit) { @@ -50,28 +77,15 @@ public class WechatEntryManager { } public static JSONObject queryCityList(WechatPayConfigDto configDto, String provinceCode) { - String resp = WechatReqUtils.getReq(configDto, "/v3/capital/capitallhh/areas/provinces/" + provinceCode + "/cities", Map.of()); + String resp = WechatReqUtils.getReq(configDto, "/v3/capital/capitallhh/areas/provinces/" + provinceCode + "/cities", Map.of()); return JSONObject.parseObject(resp); } - /** - * 商户进件 - * - * @param configDto 配置 - * @param reqDto 请求参数 - */ - public static void entryMerchant(WechatPayConfigDto configDto, WechatEntryReqDto reqDto) { - String params = JSONObject.toJSONString(reqDto, JSONWriter.Feature.IgnoreEmpty); - -// String string = WechatReqUtils.encryptReqParam(configDto, "/v3/applyment4sub/applyment/", params); - - WechatReqUtils.postReq(configDto, "/v3/applyment4sub/applyment/", params); - } /** * 上传图片 * - * @param url 图片URL + * @param url 图片URL * @return 图片ID */ public static String uploadImage(WechatPayConfigDto configDto, String url) { @@ -119,6 +133,120 @@ public class WechatEntryManager { return ""; } + /** + * 构建进件参数 + * + * @param reqDto 请求参数 + * @return 进件参数 + */ + private static WechatEntryReqDto buildEntryParams(WechatPayConfigDto configDto, AggregateMerchantDto reqDto) { + WechatEntryReqDto entryParams = new WechatEntryReqDto(); + + Config config = WechatConfig.getRsaConfig(configDto); + PrivacyEncryptor encryptor = config.createEncryptor(); + + entryParams.setBusinessCode(reqDto.getMerchantCode()); + + MerchantBaseInfoDto baseInfo = reqDto.getMerchantBaseInfo(); + LegalPersonInfoDto legalPersonInfo = reqDto.getLegalPersonInfo(); + BusinessLicenceInfoDto businessLicenceInfo = reqDto.getBusinessLicenceInfo(); + StoreInfoDto storeInfo = reqDto.getStoreInfo(); + SettlementInfoDto settlementInfo = reqDto.getSettlementInfo(); + + WechatEntryContactReqDto contactInfo = new WechatEntryContactReqDto(); + contactInfo.setContactType(baseInfo.getContactPersonType()); + // 默认都使用身份证 暂不支持其他证件 + contactInfo.setContactIdDocCopy("IDENTIFICATION_TYPE_IDCARD"); + if (PayCst.ContactPersonType.SUPER.equals(baseInfo.getContactPersonType())) { + contactInfo.setContactName(encryptor.encrypt(baseInfo.getContactName())); + contactInfo.setContactIdNumber(encryptor.encrypt(baseInfo.getContactPersonId())); + contactInfo.setContactIdDocCopy(baseInfo.getContactIdCardFrontPic().getWechatId()); + contactInfo.setContactIdDocCopyBack(baseInfo.getContactIdCardBackPic().getWechatId()); + contactInfo.setContactPeriodBegin(baseInfo.getContactPersonIdStartDate()); + contactInfo.setContactPeriodEnd(baseInfo.getContactPersonIdEndDate()); + contactInfo.setMobilePhone(encryptor.encrypt(baseInfo.getContactPhone())); + contactInfo.setContactEmail(encryptor.encrypt(baseInfo.getContactEmail())); + } else if (PayCst.ContactPersonType.LEGAL.equals(baseInfo.getContactPersonType())) { + contactInfo.setContactName(encryptor.encrypt(legalPersonInfo.getLegalPersonName())); + contactInfo.setContactIdNumber(encryptor.encrypt(legalPersonInfo.getLegalPersonId())); + contactInfo.setContactIdDocCopy(legalPersonInfo.getIdCardFrontPic().getWechatId()); + contactInfo.setContactIdDocCopyBack(legalPersonInfo.getIdCardBackPic().getWechatId()); + contactInfo.setContactPeriodBegin(legalPersonInfo.getLegalIdPersonStartDate()); + contactInfo.setContactPeriodEnd(legalPersonInfo.getLegalPersonIdEndDate()); + contactInfo.setMobilePhone(encryptor.encrypt(legalPersonInfo.getLegalPersonPhone())); + contactInfo.setContactEmail(encryptor.encrypt(legalPersonInfo.getLegalPersonEmail())); + } else { + throw new CzgException("联系人类型错误"); + } + entryParams.setContactInfo(contactInfo); + + WechatEntrySubjectReqDto subjectInfo = new WechatEntrySubjectReqDto(); + if ("0".equals(baseInfo.getUserType())) { + subjectInfo.setSubjectType("SUBJECT_TYPE_INDIVIDUAL"); + } else if ("1".equals(baseInfo.getUserType())) { + switch (baseInfo.getCompanyChildType()) { + case "1" -> subjectInfo.setSubjectType("SUBJECT_TYPE_ENTERPRISE"); + case "2" -> subjectInfo.setSubjectType("SUBJECT_TYPE_INSTITUTIONS"); + case "3" -> subjectInfo.setSubjectType("SUBJECT_TYPE_GOVERNMENT"); + case "4" -> subjectInfo.setSubjectType("SUBJECT_TYPE_OTHERS"); + default -> throw new CzgException("主体类型错误"); + } + } else { + throw new CzgException("用户类型错误"); + } + subjectInfo.setFinanceInstitution(false); + + WechatEntryLicenseReqDto licenseReqDto = new WechatEntryLicenseReqDto(); + licenseReqDto.setLicenseCopy(businessLicenceInfo.getLicensePic().getWechatId()); + licenseReqDto.setLicenseNumber(businessLicenceInfo.getLicenceNo()); + licenseReqDto.setMerchantName(businessLicenceInfo.getLicenceName()); + licenseReqDto.setLegalPerson(legalPersonInfo.getLegalPersonName()); + licenseReqDto.setLicenseAddress(businessLicenceInfo.getRegisteredAddress()); + licenseReqDto.setPeriodBegin(businessLicenceInfo.getLicenceStartDate()); + licenseReqDto.setPeriodEnd(businessLicenceInfo.getLicenceEndDate()); + subjectInfo.setBusinessLicenseInfo(licenseReqDto); + WechatEntryIdentityReqDto identityInfo = new WechatEntryIdentityReqDto(); + identityInfo.setIdHolderType(PayCst.ContactPersonType.LEGAL); + subjectInfo.setIdentityInfo(identityInfo); + entryParams.setSubjectInfo(subjectInfo); + + WechatEntryBusinessReqDto businessReqInfo = new WechatEntryBusinessReqDto(); + businessReqInfo.setMerchantShortname(baseInfo.getShortName()); + businessReqInfo.setServicePhone(PayCst.ContactPersonType.LEGAL.equals(baseInfo.getContactPersonType()) ? legalPersonInfo.getLegalPersonPhone() : baseInfo.getContactPhone()); + WechatEntrySalesInfoReqDto salesInfo = new WechatEntrySalesInfoReqDto(); + salesInfo.setSalesScenesType(List.of("SALES_SCENES_STORE", "SALES_SCENES_MINI_PROGRAM")); + WechatEntryStoreInfoReqDto bizStoreInfo = new WechatEntryStoreInfoReqDto(); + bizStoreInfo.setBizStoreName(baseInfo.getShortName()); + bizStoreInfo.setBizAddressCode(storeInfo.getMercAreaCode()); + bizStoreInfo.setBizStoreAddress(storeInfo.getBusinessAddress()); + bizStoreInfo.setStoreEntrancePic(List.of(storeInfo.getDoorPic().getWechatId())); + bizStoreInfo.setIndoorPic(List.of(storeInfo.getInsidePic().getWechatId(), storeInfo.getCashierDeskPic().getWechatId())); + salesInfo.setBizStoreInfo(bizStoreInfo); + WechatEntryMiniProgramReqDto miniProgramInfo = new WechatEntryMiniProgramReqDto(); + miniProgramInfo.setMiniProgramAppid("wxd88fffa983758a30"); + salesInfo.setMiniProgramInfo(miniProgramInfo); + businessReqInfo.setSalesInfo(salesInfo); + entryParams.setBusinessInfo(businessReqInfo); + + WechatEntrySettleReqDto settlementReqInfo = new WechatEntrySettleReqDto(); + settlementReqInfo.setSettlementId("0".equals(baseInfo.getUserType()) ? "719" : "716"); + settlementReqInfo.setQualificationType("餐饮"); + settlementReqInfo.setActivitiesId("20191030111cff5b5e"); + settlementReqInfo.setActivitiesRate("0.38"); + entryParams.setSettlementInfo(settlementReqInfo); + + WechatEntryBankAccountReqDto bankAccountReqInfo = new WechatEntryBankAccountReqDto(); + bankAccountReqInfo.setBankAccountType("21".equals(settlementInfo.getSettlementCardType()) ? "BANK_ACCOUNT_TYPE_CORPORATE" : "BANK_ACCOUNT_TYPE_PERSONAL"); + bankAccountReqInfo.setAccountName(encryptor.encrypt(settlementInfo.getSettlementName())); + bankAccountReqInfo.setAccountBank(settlementInfo.getBankName()); + bankAccountReqInfo.setBankBranchId(settlementInfo.getBankBranchCode()); + bankAccountReqInfo.setBankName(settlementInfo.getBankBranchName()); + bankAccountReqInfo.setAccountNumber(encryptor.encrypt(settlementInfo.getSettlementCardNo())); + entryParams.setBankAccountInfo(bankAccountReqInfo); + + return entryParams; + } + public static void main(String[] args) throws IOException { WechatPayConfigDto dto = new WechatPayConfigDto() .setMerchantId("1643779408") diff --git a/cash-sdk/aggregation-pay/src/main/java/com/czg/third/wechat/WechatReqUtils.java b/cash-sdk/aggregation-pay/src/main/java/com/czg/third/wechat/WechatReqUtils.java index 57a831c80..13a1e2137 100644 --- a/cash-sdk/aggregation-pay/src/main/java/com/czg/third/wechat/WechatReqUtils.java +++ b/cash-sdk/aggregation-pay/src/main/java/com/czg/third/wechat/WechatReqUtils.java @@ -40,6 +40,9 @@ public class WechatReqUtils { } private static String req(WechatPayConfigDto configDto, String url, String method, String body) { + if (configDto == null) { + configDto = WechatPayConfigDto.getDefaultConfig(); + } long timestamp = getTimestamp(); String nonce = getNonceStr(); String signature = encryptReqParam(configDto, method, url, body, timestamp, nonce); @@ -83,12 +86,11 @@ public class WechatReqUtils { public static String encryptReqParam(WechatPayConfigDto configDto, String method, String url, String body, long timestamp, String nonce) { String encryptStr = String.format("%s\n%s\n%d\n%s\n%s\n", method, url, timestamp, nonce, body); - log.info("encryptStr = {}", encryptStr); Config config = WechatConfig.getRsaConfig(configDto); Signer signer = config.createSigner(); String signature = signer.sign(encryptStr).getSign(); - log.info("签名 signature:{}", signature); + log.info("微信签名 encryptStr = {},\nsignature:{}", encryptStr, signature); return signature; }