From b5c52944b0231b6c69c025dd08915f4145458bad Mon Sep 17 00:00:00 2001 From: xhxu Date: Fri, 19 Aug 2022 11:34:14 +0800 Subject: [PATCH] // add shar app --- .../enums/EnumSharingReceiverAccountType.java | 21 +-- .../enums/EnumSharingReceiverContactType.java | 22 +-- .../EnumSharingReceiverIdHolderType.java | 22 +-- ...ProfitSharingReceiverApplyServiceImpl.java | 126 +++++++++++++++--- 4 files changed, 142 insertions(+), 49 deletions(-) diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumSharingReceiverAccountType.java b/mallinkService/src/main/java/com/iformall/enums/EnumSharingReceiverAccountType.java index b0bbda126..470ef9ced 100644 --- a/mallinkService/src/main/java/com/iformall/enums/EnumSharingReceiverAccountType.java +++ b/mallinkService/src/main/java/com/iformall/enums/EnumSharingReceiverAccountType.java @@ -1,5 +1,7 @@ package com.iformall.enums; +import com.github.binarywang.wxpay.bean.applyment.enums.BankAccountTypeEnum; + /** * 结算账户信息 * 1、若主体为企业/政府机关/事业单位/社会组织,可填写:对公银行账户。 @@ -9,8 +11,8 @@ package com.iformall.enums; */ public enum EnumSharingReceiverAccountType { - BANK_ACCOUNT_TYPE_CORPORATE(74, "BANK_ACCOUNT_TYPE_CORPORATE", "对公账户"), - BANK_ACCOUNT_TYPE_PERSONAL(75, "BANK_ACCOUNT_TYPE_PERSONAL", "对私账户"), + BANK_ACCOUNT_TYPE_CORPORATE(74, BankAccountTypeEnum.BANK_ACCOUNT_TYPE_CORPORATE,"对公账户"), + BANK_ACCOUNT_TYPE_PERSONAL(75, BankAccountTypeEnum.BANK_ACCOUNT_TYPE_PERSONAL,"对私账户"), ; public static EnumSharingReceiverAccountType getEnum(Integer code) { @@ -22,9 +24,9 @@ public enum EnumSharingReceiverAccountType { return null; } - public static EnumSharingReceiverAccountType getEnum(String codeStr) { + public static EnumSharingReceiverAccountType getEnum(BankAccountTypeEnum bankAccountTypeEnum) { for (EnumSharingReceiverAccountType value : values()) { - if (value.getCodeStr().equals(codeStr)) { + if (value.getBankAccountTypeEnum().equals(bankAccountTypeEnum)) { return value; } } @@ -32,12 +34,12 @@ public enum EnumSharingReceiverAccountType { } private Integer code; - private String codeStr; + private BankAccountTypeEnum bankAccountTypeEnum; private String message; - EnumSharingReceiverAccountType(Integer code, String codeStr, String message) { + EnumSharingReceiverAccountType(Integer code, BankAccountTypeEnum bankAccountTypeEnum, String message) { this.code = code; - this.codeStr = codeStr; + this.bankAccountTypeEnum = bankAccountTypeEnum; this.message = message; } @@ -45,11 +47,12 @@ public enum EnumSharingReceiverAccountType { return code; } - public String getCodeStr() { - return codeStr; + public BankAccountTypeEnum getBankAccountTypeEnum() { + return bankAccountTypeEnum; } public String getMessage() { return message; } + } diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumSharingReceiverContactType.java b/mallinkService/src/main/java/com/iformall/enums/EnumSharingReceiverContactType.java index 0ffb7dff1..d484e0b2c 100644 --- a/mallinkService/src/main/java/com/iformall/enums/EnumSharingReceiverContactType.java +++ b/mallinkService/src/main/java/com/iformall/enums/EnumSharingReceiverContactType.java @@ -1,14 +1,16 @@ package com.iformall.enums; +import com.github.binarywang.wxpay.bean.applyment.enums.ContactTypeEnum; + /** - * 证件持有人类型 + * 超级管理员 证件持有人类型 * LEGAL:法人 * SUPER:经办人 */ public enum EnumSharingReceiverContactType { - LEGAL(1, "LEGAL", "经营者/法人"), - SUPER(2, "SUPER", "经办人"), + LEGAL(1, ContactTypeEnum.LEGAL,"经营者/法人"), + SUPER(2, ContactTypeEnum.SUPER,"经办人"), ; public static EnumSharingReceiverContactType getEnum(Integer code) { @@ -20,9 +22,9 @@ public enum EnumSharingReceiverContactType { return null; } - public static EnumSharingReceiverContactType getEnum(String codeStr) { + public static EnumSharingReceiverContactType getEnum(ContactTypeEnum contactTypeEnum) { for (EnumSharingReceiverContactType value : values()) { - if (value.getCodeStr().equals(codeStr)) { + if (value.getContactTypeEnum().equals(contactTypeEnum)) { return value; } } @@ -30,12 +32,12 @@ public enum EnumSharingReceiverContactType { } private Integer code; - private String codeStr; + private ContactTypeEnum contactTypeEnum; private String message; - EnumSharingReceiverContactType(Integer code, String codeStr, String message) { + EnumSharingReceiverContactType(Integer code, ContactTypeEnum contactTypeEnum, String message) { this.code = code; - this.codeStr = codeStr; + this.contactTypeEnum = contactTypeEnum; this.message = message; } @@ -43,8 +45,8 @@ public enum EnumSharingReceiverContactType { return code; } - public String getCodeStr() { - return codeStr; + public ContactTypeEnum getContactTypeEnum() { + return contactTypeEnum; } public String getMessage() { diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumSharingReceiverIdHolderType.java b/mallinkService/src/main/java/com/iformall/enums/EnumSharingReceiverIdHolderType.java index 9b9919ab6..df9446146 100644 --- a/mallinkService/src/main/java/com/iformall/enums/EnumSharingReceiverIdHolderType.java +++ b/mallinkService/src/main/java/com/iformall/enums/EnumSharingReceiverIdHolderType.java @@ -1,14 +1,16 @@ package com.iformall.enums; +import com.github.binarywang.wxpay.bean.applyment.enums.IdHolderEnum; + /** - * 证件持有人类型 + * 主体信息里面 证件持有人类型 * LEGAL:法人 * SUPER:经办人 */ public enum EnumSharingReceiverIdHolderType { - LEGAL(1, "LEGAL", "法人"), - SUPER(2, "SUPER", "经办人"), + LEGAL(1, IdHolderEnum.LEGAL, "经营者/法人"), + SUPER(2, IdHolderEnum.SUPER,"经办人"), ; public static EnumSharingReceiverIdHolderType getEnum(Integer code) { @@ -20,9 +22,9 @@ public enum EnumSharingReceiverIdHolderType { return null; } - public static EnumSharingReceiverIdHolderType getEnum(String codeStr) { + public static EnumSharingReceiverIdHolderType getEnum(IdHolderEnum idHolderEnum) { for (EnumSharingReceiverIdHolderType value : values()) { - if (value.getCodeStr().equals(codeStr)) { + if (value.getIdHolderEnum().equals(idHolderEnum)) { return value; } } @@ -30,12 +32,12 @@ public enum EnumSharingReceiverIdHolderType { } private Integer code; - private String codeStr; + private IdHolderEnum idHolderEnum; private String message; - EnumSharingReceiverIdHolderType(Integer code, String codeStr,String message) { + EnumSharingReceiverIdHolderType(Integer code, IdHolderEnum idHolderEnum,String message) { this.code = code; - this.codeStr = codeStr; + this.idHolderEnum = idHolderEnum; this.message = message; } @@ -43,8 +45,8 @@ public enum EnumSharingReceiverIdHolderType { return code; } - public String getCodeStr() { - return codeStr; + public IdHolderEnum getIdHolderEnum() { + return idHolderEnum; } public String getMessage() { diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingReceiverApplyServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingReceiverApplyServiceImpl.java index dba16c85d..4ad6ac7a8 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingReceiverApplyServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingReceiverApplyServiceImpl.java @@ -7,7 +7,6 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.github.binarywang.wxpay.bean.applyment.WxPayApplyment4SubCreateRequest; import com.github.binarywang.wxpay.bean.applyment.WxPayApplymentCreateResult; import com.github.binarywang.wxpay.bean.applyment.enums.SalesScenesTypeEnum; -import com.github.binarywang.wxpay.bean.bank.BankingResult; import com.github.binarywang.wxpay.exception.WxPayException; import com.github.binarywang.wxpay.service.WxPayService; import com.github.pagehelper.PageHelper; @@ -646,12 +645,6 @@ public class WxProfitSharingReceiverApplyServiceImpl implements WxProfitSharingR * "id":********, * "organizationType":,//4个体,2企业 * "settlementInfo":"",//json格式在下面 转成字符串 - * } - * //settlementInfo - * { - * "qualification_id":,//选择行业id - * "settlement_id":"",//结算规则id - * "qualification_type":"",//所属行业 * "qualifications":[//特殊资质图片 根据所选行业 是否必传 最多5张 * { * "url":"", @@ -660,6 +653,12 @@ public class WxProfitSharingReceiverApplyServiceImpl implements WxProfitSharingR * ... * ] * } + * //settlementInfo + * { + * "qualification_id":,//选择行业id + * "settlement_id":"",//结算规则id + * "qualification_type":"",//所属行业 + * } * @return */ private boolean isFinishSettlement(WxProfitSharingReceiverApply record){ @@ -697,7 +696,7 @@ public class WxProfitSharingReceiverApplyServiceImpl implements WxProfitSharingR return false; } if(enumQualificationGth.isFlag()){ - JSONArray qualifications = settlementInfoObject.getJSONArray("qualifications"); + JSONArray qualifications = JSONObject.parseArray(record.getQualifications()); List mediaIds = this.getMerchantMediaIds(qualifications); if(mediaIds.isEmpty()){ logger.info("未上传必要资质["+enumQualificationGth.getMessage()+"]"); @@ -715,18 +714,24 @@ public class WxProfitSharingReceiverApplyServiceImpl implements WxProfitSharingR return false; } if(enumQualificationQy.isFlag()){ - JSONArray qualifications = settlementInfoObject.getJSONArray("qualifications"); + JSONArray qualifications = JSONObject.parseArray(record.getQualifications()); List mediaIds = this.getMerchantMediaIds(qualifications); if(mediaIds.isEmpty()){ - logger.info("未上传必要资质["+enumQualificationQy.getMessage()+"]"); + logger.info("未上传必要特殊资质图片["+enumQualificationQy.getMessage()+"]"); return false; } if(mediaIds.size() > 5){ - logger.info("上传资质数量超限"); + logger.info("上传特殊资质图片超限"); return false; } } } + JSONArray activities_additions = settlementInfoObject.getJSONArray("activities_additions"); + List mediaIds = this.getMerchantMediaIds(activities_additions); + if(mediaIds.size() > 5){ + logger.info("上传优惠费率活动补充材料超限"); + return false; + } return true; } @@ -1046,14 +1051,24 @@ public class WxProfitSharingReceiverApplyServiceImpl implements WxProfitSharingR List salesScenesTypeEnumList = EnumSharingReceiverSalesScenesType.getSalesScenesTypeEnumList(salesScenesTypes); salesInfo.setSalesScenesType(salesScenesTypeEnumList); if(salesScenesTypes.contains(EnumSharingReceiverSalesScenesType.SALES_SCENES_STORE.getCode())){ + JSONObject biz_store_info = salesInfoObject.getJSONObject("biz_store_info"); WxPayApplyment4SubCreateRequest.BusinessInfo.SalesInfo.BizStoreInfo bizStoreInfo = new WxPayApplyment4SubCreateRequest.BusinessInfo.SalesInfo.BizStoreInfo(); - //todo 线下场所场景 + bizStoreInfo.setBizStoreName(biz_store_info.getString("biz_store_name")); + bizStoreInfo.setBizAddressCode(biz_store_info.getString("biz_address_code")); + JSONArray store_entrance_pic = biz_store_info.getJSONArray("store_entrance_pic"); + bizStoreInfo.setStoreEntrancePic(this.getMerchantMediaIds(store_entrance_pic)); + JSONArray indoor_pic = biz_store_info.getJSONArray("indoor_pic"); + bizStoreInfo.setIndoorPic(this.getMerchantMediaIds(indoor_pic)); + bizStoreInfo.setBizSubAppid(biz_store_info.getString("biz_sub_appid")); salesInfo.setBizStoreInfo(bizStoreInfo); } if(salesScenesTypes.contains(EnumSharingReceiverSalesScenesType.SALES_SCENES_MP.getCode())){ JSONObject mp_info = salesInfoObject.getJSONObject("mp_info"); WxPayApplyment4SubCreateRequest.BusinessInfo.SalesInfo.MpInfo mpInfo = new WxPayApplyment4SubCreateRequest.BusinessInfo.SalesInfo.MpInfo(); - //todo 公众号场景 + mpInfo.setMpAppid(mp_info.getString("mp_appid")); + mpInfo.setMpSubAppid(mp_info.getString("mp_sub_appid")); + JSONArray mp_pics = mp_info.getJSONArray("mp_pics"); + mpInfo.setMpPics(this.getMerchantMediaIds(mp_pics)); salesInfo.setMpInfo(mpInfo); } if(salesScenesTypes.contains(EnumSharingReceiverSalesScenesType.SALES_SCENES_MINI_PROGRAM.getCode())){ @@ -1070,34 +1085,105 @@ public class WxProfitSharingReceiverApplyServiceImpl implements WxProfitSharingR if(salesScenesTypes.contains(EnumSharingReceiverSalesScenesType.SALES_SCENES_WEB.getCode())){ JSONObject web_info = salesInfoObject.getJSONObject("web_info"); WxPayApplyment4SubCreateRequest.BusinessInfo.SalesInfo.WebInfo webInfo = new WxPayApplyment4SubCreateRequest.BusinessInfo.SalesInfo.WebInfo(); - //todo 互联网网站场景 + webInfo.setDomain(web_info.getString("domain")); + JSONObject web_authorisation_info = web_info.getJSONObject("web_authorisation_info"); + webInfo.setWebAuthorisation(this.getMerchantMediaId(web_authorisation_info)); + webInfo.setWebAppid(web_info.getString("web_appid")); salesInfo.setWebInfo(webInfo); } if(salesScenesTypes.contains(EnumSharingReceiverSalesScenesType.SALES_SCENES_APP.getCode())){ JSONObject app_info = salesInfoObject.getJSONObject("app_info"); WxPayApplyment4SubCreateRequest.BusinessInfo.SalesInfo.AppInfo appInfo = new WxPayApplyment4SubCreateRequest.BusinessInfo.SalesInfo.AppInfo(); - //todo APP场景 + appInfo.setAppAppid(app_info.getString("app_appid")); + appInfo.setAppSubAppid(app_info.getString("app_sub_appid")); + JSONArray app_pics = app_info.getJSONArray("app_pics"); + appInfo.setAppPics(this.getMerchantMediaIds(app_pics)); salesInfo.setAppInfo(appInfo); } if(salesScenesTypes.contains(EnumSharingReceiverSalesScenesType.SALES_SCENES_WEWORK.getCode())){ JSONObject wework_info = salesInfoObject.getJSONObject("wework_info"); WxPayApplyment4SubCreateRequest.BusinessInfo.SalesInfo.WeworkInfo weworkInfo = new WxPayApplyment4SubCreateRequest.BusinessInfo.SalesInfo.WeworkInfo(); - //todo 企业微信场景 + weworkInfo.setSubCorpId(wework_info.getString("sub_corp_id")); + JSONArray wework_pics = wework_info.getJSONArray("wework_pics"); + weworkInfo.setWeworkPics(this.getMerchantMediaIds(wework_pics)); salesInfo.setWeworkInfo(weworkInfo); } businessInfo.setSalesInfo(salesInfo); request.setBusinessInfo(businessInfo); WxPayApplyment4SubCreateRequest.SettlementInfo settlementInfo = new WxPayApplyment4SubCreateRequest.SettlementInfo(); - + JSONObject settlementInfoObject = JSONObject.parseObject(receiverApply.getSettlementInfo()); + settlementInfo.setSettlementId(settlementInfoObject.getString("settlement_id")); + settlementInfo.setQualificationType(settlementInfoObject.getString("qualification_type")); + JSONArray qualifications = JSONObject.parseArray(receiverApply.getQualifications()); + List mediaIds = this.getMerchantMediaIds(qualifications); + if(!mediaIds.isEmpty()){ + settlementInfo.setQualifications(mediaIds); + } + settlementInfo.setActivitiesId(settlementInfoObject.getString("settlement_id")); + settlementInfo.setActivitiesRate(settlementInfoObject.getString("activities_rate")); + JSONArray activities_additions = settlementInfoObject.getJSONArray("activities_additions"); + List mediaIds1 = this.getMerchantMediaIds(activities_additions); + if(!mediaIds1.isEmpty()){ + settlementInfo.setActivitiesAdditions(mediaIds1); + } request.setSettlementInfo(settlementInfo); WxPayApplyment4SubCreateRequest.BankAccountInfo bankAccountInfo = new WxPayApplyment4SubCreateRequest.BankAccountInfo(); - + JSONObject accountInfoObject = JSONObject.parseObject(receiverApply.getAccountInfo()); + EnumSharingReceiverAccountType enumAccountType = EnumSharingReceiverAccountType.getEnum(accountInfoObject.getInteger("bank_account_type")); + bankAccountInfo.setBankAccountType(enumAccountType.getBankAccountTypeEnum()); + bankAccountInfo.setAccountName(accountInfoObject.getString("account_name")); + bankAccountInfo.setAccountBank(accountInfoObject.getString("account_bank")); + bankAccountInfo.setBankAddressCode(accountInfoObject.getString("bank_address_code")); + bankAccountInfo.setBankBranchId(accountInfoObject.getString("bank_branch_id")); + bankAccountInfo.setBankName(accountInfoObject.getString("bank_name")); + bankAccountInfo.setAccountNumber(accountInfoObject.getString("account_number")); + //todo 1. 当主体类型是“政府机关/事业单位”时或所属行业为“党费”时,支持在有合法资金管理关系的情况下结算账户设置为非同名。 + //todo 2. 若结算账户设置为非同名,则需填写非同名证明材料,若结算账户为同名,则无需填写。 request.setBankAccountInfo(bankAccountInfo); WxPayApplyment4SubCreateRequest.ContactInfo contactInfo = new WxPayApplyment4SubCreateRequest.ContactInfo(); - + JSONObject contactInfoObject = JSONObject.parseObject(receiverApply.getContactInfo()); + Integer contact_type = contactInfoObject.getInteger("contact_type"); + EnumSharingReceiverContactType enumContactType = EnumSharingReceiverContactType.getEnum(contact_type); + contactInfo.setContactType(enumContactType.getContactTypeEnum()); + contactInfo.setContactName(contactInfoObject.getString("contact_name")); + if(EnumSharingReceiverContactType.SUPER.equals(enumContactType)){ + Integer contact_id_doc_type = contactInfoObject.getInteger("contact_id_doc_type"); + EnumSharingReceiverIdDocType enumIdDocType = EnumSharingReceiverIdDocType.getEnum(contact_id_doc_type); + contactInfo.setContactIdDocType(enumIdDocType.getIdTypeEnum()); + contactInfo.setContactIdNumber(contactInfoObject.getString("contact_id_number")); + JSONObject contact_id_doc_copy_info = contactInfoObject.getJSONObject("contact_id_doc_copy_info"); + contactInfo.setContactIdDocCopy(this.getMerchantMediaId(contact_id_doc_copy_info)); + if(!EnumSharingReceiverIdDocType.IDENTIFICATION_TYPE_OVERSEA_PASSPORT.equals(enumIdDocType)) { + JSONObject contact_id_doc_copy_back_info = contactInfoObject.getJSONObject("contact_id_doc_copy_back_info"); + contactInfo.setContactIdDocCopyBack(this.getMerchantMediaId(contact_id_doc_copy_back_info)); + } + contactInfo.setContactPeriodBegin(contactInfoObject.getString("contact_period_begin")); + contactInfo.setContactPeriodEnd(contactInfoObject.getString("contact_period_end")); + JSONObject business_authorization_letter_info = contactInfoObject.getJSONObject("business_authorization_letter_info"); + contactInfo.setBusinessAuthorizationLetter(this.getMerchantMediaId(business_authorization_letter_info)); + } + contactInfo.setOpenid(contactInfoObject.getString("openid")); + contactInfo.setMobilePhone(contactInfoObject.getString("mobile_phone")); + contactInfo.setContactEmail(contactInfoObject.getString("contact_email")); request.setContactInfo(contactInfo); WxPayApplyment4SubCreateRequest.AdditionInfo additionInfo = new WxPayApplyment4SubCreateRequest.AdditionInfo(); - + if(StringUtils.isNotBlank(receiverApply.getAdditionInfo())){ + JSONObject additionInfoObject = JSONObject.parseObject(receiverApply.getAdditionInfo()); + JSONObject legal_person_commitment_info = additionInfoObject.getJSONObject("legal_person_commitment_info"); + additionInfo.setLegalPersonCommitment(this.getMerchantMediaId(legal_person_commitment_info)); + JSONObject legal_person_video_info = additionInfoObject.getJSONObject("legal_person_video_info"); + additionInfo.setLegalPersonVideo(this.getMerchantMediaId(legal_person_video_info)); + } + if(StringUtils.isNotBlank(receiverApply.getBusinessAdditionPics())){ + JSONArray business_addition_pics = JSONObject.parseArray(receiverApply.getBusinessAdditionPics()); + List mediaIds2 = this.getMerchantMediaIds(business_addition_pics); + if(!mediaIds2.isEmpty()){ + additionInfo.setBusinessAdditionPics(mediaIds2); + } + } + if(StringUtils.isNotBlank(receiverApply.getBusinessAdditionDesc())){ + additionInfo.setBusinessAdditionMsg(contactInfoObject.getString("business_addition_msg")); + } request.setAdditionInfo(additionInfo); WxPayApplymentCreateResult wxPayApplymentCreateResult = wxPayService.getApplyment4SubService().createApply(request); return new ResultData(wxPayApplymentCreateResult.getApplymentId());