From f89fda069876b3b6525b5fc9b49d82585aa71061 Mon Sep 17 00:00:00 2001 From: gong <1157756119@qq.com> Date: Wed, 7 Jan 2026 15:01:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9E=84=E5=BB=BA=E6=94=AF=E4=BB=98=E5=AE=9D?= =?UTF-8?q?=E8=BF=9B=E4=BB=B6=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/czg/EntryManager.java | 8 +- .../com/czg/dto/req/SettlementInfoDto.java | 5 + .../czg/third/alipay/AlipayEntryManager.java | 114 +++++++++++++++++- .../czg/third/wechat/WechatEntryManager.java | 11 +- .../com/czg/third/wechat/WechatReqUtils.java | 4 +- 5 files changed, 133 insertions(+), 9 deletions(-) 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 a90b242da..0aa4bc0a8 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 @@ -295,6 +295,8 @@ public class EntryManager { SettlementInfoDto settlementInfo = reqDto.getSettlementInfo(); AssertUtil.isBlank(settlementInfo.getSettlementCardNo(), "结算卡号不能为空"); AssertUtil.isBlank(settlementInfo.getSettlementName(), "结算账户户名不能为空"); + AssertUtil.isBlank(settlementInfo.getBankName(), "结算银行名称不能为空"); + AssertUtil.isBlank(settlementInfo.getBankInstId(), "结算银行缩写不能为空"); AssertUtil.isBlank(settlementInfo.getBankMobile(), "结算银行预留手机号不能为空"); AssertUtil.isBlank(settlementInfo.getSettlementCardType(), "结算卡类型不能为空"); AssertUtil.isBlank(settlementInfo.getOpenAccProvinceId(), "结算开户行省ID不能为空"); @@ -346,8 +348,9 @@ public class EntryManager { verifyEntryParam(merchantDto); uploadParamImage(merchantDto); System.out.println(merchantDto); - entryMerchant(merchantDto, PayCst.Platform.WECHAT); -// entryMerchant(merchantDto, PayCst.Platform.WECHAT, PayCst.Platform.ALIPAY); +// entryMerchant(merchantDto, PayCst.Platform.WECHAT); +// entryMerchant(merchantDto, PayCst.Platform.ALIPAY); + entryMerchant(merchantDto, PayCst.Platform.WECHAT, PayCst.Platform.ALIPAY); } private static AggregateMerchantDto getTestMerchantEntryData() { @@ -420,6 +423,7 @@ public class EntryManager { settlementInfoDto.setOpenAccCity("深圳市"); settlementInfoDto.setOpenAccArea("南山区"); settlementInfoDto.setBankName("中国工商银行"); + settlementInfoDto.setBankInstId("ICBC"); settlementInfoDto.setBankType("1"); settlementInfoDto.setBankBranchName("广东省深圳市南山区"); settlementInfoDto.setBankBranchCode("440300"); diff --git a/cash-sdk/aggregation-pay/src/main/java/com/czg/dto/req/SettlementInfoDto.java b/cash-sdk/aggregation-pay/src/main/java/com/czg/dto/req/SettlementInfoDto.java index b58705cea..c0b9c6dc4 100644 --- a/cash-sdk/aggregation-pay/src/main/java/com/czg/dto/req/SettlementInfoDto.java +++ b/cash-sdk/aggregation-pay/src/main/java/com/czg/dto/req/SettlementInfoDto.java @@ -81,6 +81,11 @@ public class SettlementInfoDto { */ private String bankName; + /** + * 开户行缩写 + */ + private String bankInstId; + /** * 开户行编号 */ 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 de32ddd66..feeb47dc5 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 @@ -4,11 +4,17 @@ 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.AntMerchantExpandIndirectZftCreateModel; import com.alipay.api.domain.AntMerchantExpandIndirectZftSimplecreateModel; +import com.alipay.api.domain.SiteInfo; import com.alipay.api.request.AlipayFinancialnetAuthPbcnameQueryRequest; import com.alipay.api.request.AntMerchantExpandIndirectImageUploadRequest; +import com.alipay.api.request.AntMerchantExpandIndirectZftCreateRequest; +import com.alipay.api.request.AntMerchantExpandIndirectZftSimplecreateRequest; import com.alipay.api.response.AlipayFinancialnetAuthPbcnameQueryResponse; import com.alipay.api.response.AntMerchantExpandIndirectImageUploadResponse; +import com.alipay.api.response.AntMerchantExpandIndirectZftCreateResponse; +import com.alipay.api.response.AntMerchantExpandIndirectZftSimplecreateResponse; import com.alipay.v3.ApiClient; import com.alipay.v3.ApiException; import com.alipay.v3.Configuration; @@ -17,10 +23,11 @@ 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.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.dto.config.AlipayConfigDto; import com.czg.third.wechat.dto.req.entry.WechatEntryReqDto; import com.czg.utils.UploadFileUtil; @@ -50,12 +57,25 @@ public class AlipayEntryManager { * @param reqDto 请求信息 */ public static EntryThirdRespDto entryMerchant(AlipayConfigDto configDto, AggregateMerchantDto reqDto) { - AntMerchantExpandIndirectZftSimplecreateModel entryReqDto = buildEntryParams(reqDto); + AntMerchantExpandIndirectZftCreateModel entryReqDto = buildEntryParams(reqDto); EntryThirdRespDto respDto = new EntryThirdRespDto() .setPlatform(PayCst.Platform.ALIPAY); try { -// entry(configDto, entryReqDto); + AntMerchantExpandIndirectZftCreateRequest request = new AntMerchantExpandIndirectZftCreateRequest(); + DefaultAlipayClient defaultAlipayClient = AlipayClient.getDefaultClient(configDto); + request.setBizModel(entryReqDto); + AntMerchantExpandIndirectZftCreateResponse response = defaultAlipayClient.execute(request); + log.info("支付宝进件结果:{}", response.getBody()); + if (response.isSuccess()) { + respDto.setStatus(PayCst.EntryStatus.INIT); + respDto.setEntryId(response.getOrderId()); + respDto.setErrorMsg(""); + } else { + respDto.setStatus(PayCst.EntryStatus.FAIL); + respDto.setEntryId(""); + respDto.setErrorMsg(response.getSubMsg()); + } } catch (Exception e) { log.error("支付宝进件报错:{}", e.getMessage(), e); respDto.setStatus(PayCst.EntryStatus.FAIL); @@ -135,9 +155,93 @@ public class AlipayEntryManager { * @param reqDto 请求参数 * @return 进件参数 */ - private static AntMerchantExpandIndirectZftSimplecreateModel buildEntryParams(AggregateMerchantDto reqDto) { - AntMerchantExpandIndirectZftSimplecreateModel entryParams = new AntMerchantExpandIndirectZftSimplecreateModel(); + private static AntMerchantExpandIndirectZftCreateModel buildEntryParams(AggregateMerchantDto reqDto) { + AntMerchantExpandIndirectZftCreateModel entryParams = new AntMerchantExpandIndirectZftCreateModel(); + MerchantBaseInfoDto baseInfo = reqDto.getMerchantBaseInfo(); + LegalPersonInfoDto legalPersonInfo = reqDto.getLegalPersonInfo(); + BusinessLicenceInfoDto businessLicenceInfo = reqDto.getBusinessLicenceInfo(); + StoreInfoDto storeInfo = reqDto.getStoreInfo(); + SettlementInfoDto settlementInfo = reqDto.getSettlementInfo(); + + entryParams.setExternalId(reqDto.getMerchantCode()); + if ("0".equals(baseInfo.getUserType())) { + entryParams.setMerchantType("07"); + } else if ("1".equals(baseInfo.getUserType())) { + switch (baseInfo.getCompanyChildType()) { + case "1" -> entryParams.setMerchantType("01"); + case "2" -> entryParams.setMerchantType("02"); + case "3" -> entryParams.setMerchantType("05"); + case "4" -> entryParams.setMerchantType("04"); + default -> throw new CzgException("主体类型错误"); + } + } else { + throw new CzgException("用户类型错误"); + } + entryParams.setName(businessLicenceInfo.getLicenceName()); + entryParams.setAliasName(baseInfo.getShortName()); + entryParams.setMcc(baseInfo.getMccCode()); + entryParams.setService(List.of("当面付", "jsapi支付", "小程序支付")); + entryParams.setInDoorImages(List.of(storeInfo.getInsidePic().getAlipayId(), storeInfo.getCashierDeskPic().getAlipayId())); + entryParams.setOutDoorImages(List.of(storeInfo.getDoorPic().getAlipayId())); + + // 证件类型(目前只支持个体和企业,所以都是营业执照) + entryParams.setCertType("201"); + entryParams.setCertImage(businessLicenceInfo.getLicensePic().getAlipayId()); + entryParams.setCertNo(businessLicenceInfo.getLicenceNo()); + + entryParams.setLegalName(legalPersonInfo.getLegalPersonName()); + entryParams.setLegalCertNo(legalPersonInfo.getLegalPersonId()); + entryParams.setLegalCertFrontImage(legalPersonInfo.getIdCardFrontPic().getAlipayId()); + entryParams.setLegalCertBackImage(legalPersonInfo.getIdCardBackPic().getAlipayId()); + + entryParams.setServicePhone(PayCst.ContactPersonType.LEGAL.equals(baseInfo.getContactPersonType()) ? legalPersonInfo.getLegalPersonPhone() : baseInfo.getContactPhone()); + + com.alipay.api.domain.AddressInfo addressInfo = new com.alipay.api.domain.AddressInfo(); + addressInfo.setCityCode(storeInfo.getMercCityCode()); + addressInfo.setDistrictCode(storeInfo.getMercAreaCode()); + addressInfo.setProvinceCode(storeInfo.getMercProvCode()); + addressInfo.setAddress(storeInfo.getBusinessAddress()); + entryParams.setBusinessAddress(addressInfo); + + com.alipay.api.domain.SettleCardInfo settleCardInfo = new com.alipay.api.domain.SettleCardInfo(); + settleCardInfo.setAccountHolderName(settlementInfo.getSettlementName()); + settleCardInfo.setAccountNo(settlementInfo.getSettlementCardNo()); + settleCardInfo.setAccountInstProvince(settlementInfo.getOpenAccProvince()); + settleCardInfo.setAccountInstCity(settlementInfo.getOpenAccCity()); + settlementInfo.setBankBranchName(settlementInfo.getBankBranchName()); + settleCardInfo.setUsageType("21".equals(settlementInfo.getSettlementCardType()) ? "01" : "02"); + settleCardInfo.setAccountType("DC"); + settleCardInfo.setAccountInstName(settlementInfo.getBankName()); + settleCardInfo.setAccountInstId(settlementInfo.getBankInstId()); + settleCardInfo.setBankCode(settlementInfo.getBankBranchCode()); + entryParams.setBizCards(List.of(settleCardInfo)); + + com.alipay.api.domain.ContactInfo contactInfo = new com.alipay.api.domain.ContactInfo(); + if (PayCst.ContactPersonType.SUPER.equals(baseInfo.getContactPersonType())) { + contactInfo.setName(baseInfo.getContactName()); + contactInfo.setMobile(baseInfo.getContactPhone()); + contactInfo.setEmail(baseInfo.getContactEmail()); + contactInfo.setIdCardNo(baseInfo.getContactPersonId()); + } else if (PayCst.ContactPersonType.LEGAL.equals(baseInfo.getContactPersonType())) { + contactInfo.setName(legalPersonInfo.getLegalPersonName()); + contactInfo.setMobile(legalPersonInfo.getLegalPersonPhone()); + contactInfo.setEmail(legalPersonInfo.getLegalPersonEmail()); + contactInfo.setIdCardNo(legalPersonInfo.getLegalPersonId()); + } else { + throw new CzgException("联系人类型错误"); + } + entryParams.setContactInfos(List.of(contactInfo)); + + entryParams.setLicenseAuthLetterImage(businessLicenceInfo.getLicensePic().getAlipayId()); + + // 小程序 + SiteInfo miniAppInfo = new SiteInfo(); + miniAppInfo.setSiteType("06"); + miniAppInfo.setSiteUrl("https://sxczgkj.cn"); + miniAppInfo.setSiteName("银收客"); + miniAppInfo.setTinyAppId("2021004145625815"); + entryParams.setSites(List.of(miniAppInfo)); return entryParams; } 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 c9904ccaa..29568043a 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 @@ -49,7 +49,16 @@ public class WechatEntryManager { try { String params = JSONObject.toJSONString(entryReqDto, JSONWriter.Feature.IgnoreEmpty); String respBody = WechatReqUtils.postReq(configDto, "/v3/applyment4sub/applyment/", params); - System.out.println("调用成功:" + respBody); + JSONObject object = JSONObject.parseObject(respBody); + if (object.containsKey("applyment_id")) { + respDto.setStatus(PayCst.EntryStatus.INIT); + respDto.setEntryId(object.getString("applyment_id")); + respDto.setErrorMsg(""); + } else { + respDto.setStatus(PayCst.EntryStatus.FAIL); + respDto.setEntryId(""); + respDto.setErrorMsg(object.getString("message")); + } } catch (Exception e) { log.error("微信进件报错:{}", e.getMessage(), e); respDto.setStatus(PayCst.EntryStatus.FAIL); 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 13a1e2137..32c95eec2 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 @@ -1,6 +1,7 @@ package com.czg.third.wechat; import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpResponse; import cn.hutool.http.HttpUtil; import com.czg.exception.CzgException; import com.czg.third.wechat.dto.config.WechatPayConfigDto; @@ -62,7 +63,8 @@ public class WechatReqUtils { .header("Wechatpay-Serial", configDto.getPublicKeyId()); default -> throw new CzgException("不支持的请求方法"); }; - String s = request.execute().body(); + HttpResponse response = request.execute(); + String s = response.body(); log.info("微信支付请求:url = {}, method: {}, body: {}, resp: {}", url, method, body, s); return s; }