|
|
|
|
@@ -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;
|
|
|
|
|
}
|
|
|
|
|
|