| New file |
| | |
| | | package com.stylefeng.guns.modular.huifu.biz; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.huifu.bspay.sdk.opps.core.BasePay; |
| | | import com.huifu.bspay.sdk.opps.core.config.MerConfig; |
| | | import com.huifu.bspay.sdk.opps.core.net.BasePayRequest; |
| | | import com.stylefeng.guns.core.util.DateUtil; |
| | | import com.stylefeng.guns.core.util.RequestSeqUtil; |
| | | import com.stylefeng.guns.modular.huifu.properties.HuiFuProperties; |
| | | import com.stylefeng.guns.modular.system.model.TEnterpriseWithdrawal; |
| | | import com.stylefeng.guns.modular.system.model.UserWithdrawal; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 斗拱进件业务 |
| | | * |
| | | * @author mitao |
| | | * @date 2025/11/14 |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | public class DouGongBasicDataBiz { |
| | | @Autowired |
| | | private HuiFuProperties huiFuProperties; |
| | | |
| | | /** |
| | | * 个人用户基本信息开户 |
| | | * |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public Map<String, Object> userBasicDataIndv(UserWithdrawal userWithdrawal) throws Exception { |
| | | // 1. 数据初始化,填入对应的商户配置 |
| | | MerConfig merConfig = new MerConfig(); |
| | | merConfig.setProcutId(huiFuProperties.getProductId()); |
| | | merConfig.setSysId(huiFuProperties.getSysId()); |
| | | merConfig.setRsaPrivateKey(huiFuProperties.getRsaPrivateKey()); |
| | | merConfig.setRsaPublicKey(huiFuProperties.getRsaPublicKey()); |
| | | BasePay.initWithMerConfig(merConfig); |
| | | // 2.组装请求参数 |
| | | Map<String, Object> paramsInfo = new HashMap<>(); |
| | | // 请求流水号(动态生成,确保唯一性) |
| | | paramsInfo.put("req_seq_id", RequestSeqUtil.generateForHuiFu()); |
| | | // 请求日期 |
| | | paramsInfo.put("req_date", DateUtil.format(new Date(), "yyyyMMdd")); |
| | | // 个人证件类型 |
| | | paramsInfo.put("cert_type", "00"); |
| | | String[] certificateExpireDateArr = userWithdrawal.getCertificateExpireTime().split(","); |
| | | String startDateStr = certificateExpireDateArr[0]; |
| | | // 个人证件有效期开始日期 |
| | | paramsInfo.put("cert_begin_date", startDateStr.replace("-", "")); |
| | | // 个人证件有效期截止日期 |
| | | String endDateStr = certificateExpireDateArr[1]; |
| | | if (!"长期".equals(endDateStr)) { |
| | | String formatEndDate = endDateStr.replace("-", ""); |
| | | paramsInfo.put("cert_end_date", formatEndDate); |
| | | // 个人证件有效期类型 |
| | | paramsInfo.put("cert_validity_type", "0"); |
| | | } else { |
| | | // 个人证件有效期类型 |
| | | paramsInfo.put("cert_validity_type", "1"); |
| | | } |
| | | // 手机号 |
| | | paramsInfo.put("mobile_no", userWithdrawal.getPhone()); |
| | | // 个人姓名 |
| | | paramsInfo.put("name", userWithdrawal.getOpenAccountName()); |
| | | // 个人证件号码 |
| | | paramsInfo.put("cert_no", userWithdrawal.getCertificateCode()); |
| | | // 是否发送短信标识 |
| | | paramsInfo.put("sms_send_flag", "1"); |
| | | // 3. 发起API调用 |
| | | log.info("个人用户基本信息开户请求参数:{}", paramsInfo); |
| | | Map<String, Object> response = BasePayRequest.requestBasePay("v2/user/basicdata/indv", paramsInfo, null, false); |
| | | log.info("个人用户基本信息开户返回参数:{}", response); |
| | | return response; |
| | | } |
| | | |
| | | /** |
| | | * 个人用户基本信息修改 |
| | | * |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public Map<String, Object> userBasicDataIndvModify(UserWithdrawal userWithdrawal) throws Exception { |
| | | // 1. 数据初始化,填入对应的商户配置 |
| | | MerConfig merConfig = new MerConfig(); |
| | | merConfig.setProcutId(huiFuProperties.getProductId()); |
| | | merConfig.setSysId(huiFuProperties.getSysId()); |
| | | merConfig.setRsaPrivateKey(huiFuProperties.getRsaPrivateKey()); |
| | | merConfig.setRsaPublicKey(huiFuProperties.getRsaPublicKey()); |
| | | BasePay.initWithMerConfig(merConfig); |
| | | // 2.组装请求参数 |
| | | Map<String, Object> paramsInfo = new HashMap<>(); |
| | | // 请求流水号 |
| | | paramsInfo.put("req_seq_id", RequestSeqUtil.generateForHuiFu()); |
| | | // 请求日期 |
| | | paramsInfo.put("req_date", DateUtil.format(new Date(), "yyyyMMdd")); |
| | | // 汇付客户Id |
| | | paramsInfo.put("huifu_id", userWithdrawal.getHuiFuId()); |
| | | String[] certificateExpireDateArr = userWithdrawal.getCertificateExpireTime().split(","); |
| | | String startDateStr = certificateExpireDateArr[0]; |
| | | // 个人证件有效期开始日期 |
| | | paramsInfo.put("cert_begin_date", startDateStr.replace("-", "")); |
| | | // 个人证件有效期截止日期 |
| | | String endDateStr = certificateExpireDateArr[1]; |
| | | if (!"长期".equals(endDateStr)) { |
| | | String formatEndDate = endDateStr.replace("-", ""); |
| | | paramsInfo.put("cert_end_date", formatEndDate); |
| | | // 个人证件有效期类型 |
| | | paramsInfo.put("cert_validity_type", "0"); |
| | | } else { |
| | | // 个人证件有效期类型 |
| | | paramsInfo.put("cert_validity_type", "1"); |
| | | } |
| | | // 手机号 |
| | | paramsInfo.put("mobile_no", userWithdrawal.getPhone()); |
| | | log.info("个人用户基本信息修改返回参数:{}", paramsInfo); |
| | | // 3. 发起API调用 |
| | | Map<String, Object> response = BasePayRequest.requestBasePay("v2/user/basicdata/indv/modify", paramsInfo, null, false); |
| | | log.info("个人用户基本信息修改返回参数:{}", response); |
| | | return response; |
| | | } |
| | | |
| | | /** |
| | | * 企业用户基本信息开户 |
| | | * |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public Map<String, Object> userBasicDataEnt(TEnterpriseWithdrawal tEnterpriseWithdrawal) throws Exception { |
| | | // 1. 数据初始化,填入对应的商户配置 |
| | | MerConfig merConfig = new MerConfig(); |
| | | merConfig.setProcutId(huiFuProperties.getProductId()); |
| | | merConfig.setSysId(huiFuProperties.getSysId()); |
| | | merConfig.setRsaPrivateKey(huiFuProperties.getRsaPrivateKey()); |
| | | merConfig.setRsaPublicKey(huiFuProperties.getRsaPublicKey()); |
| | | BasePay.initWithMerConfig(merConfig); |
| | | // 2.组装请求参数 |
| | | Map<String, Object> paramsInfo = new HashMap<>(); |
| | | // 请求流水号(动态生成,确保唯一性) |
| | | paramsInfo.put("req_seq_id", RequestSeqUtil.generateForHuiFu()); |
| | | // 请求日期 |
| | | paramsInfo.put("req_date", DateUtil.format(new Date(), "yyyyMMdd")); |
| | | // 企业用户名称 |
| | | paramsInfo.put("reg_name", "企业商户名称8225"); |
| | | // 营业执照编号 |
| | | paramsInfo.put("license_code", "20220222013747149"); |
| | | // 证照有效期类型 |
| | | paramsInfo.put("license_validity_type", "1"); |
| | | // 证照有效期起始日期 |
| | | paramsInfo.put("license_begin_date", "20200117"); |
| | | // 证照有效期结束日期日期格式:yyyyMMdd; 非长期有效时必填;<font color="green">示例值:20320905</font> |
| | | paramsInfo.put("license_end_date", "20400117"); |
| | | // 注册地址(省) |
| | | paramsInfo.put("reg_prov_id", "310000"); |
| | | // 注册地址(市) |
| | | paramsInfo.put("reg_area_id", "310100"); |
| | | // 注册地址(区) |
| | | paramsInfo.put("reg_district_id", "310104"); |
| | | // 注册地址(详细信息) |
| | | paramsInfo.put("reg_detail", "上海市宜山路"); |
| | | // 法人姓名 |
| | | paramsInfo.put("legal_name", "陈立五"); |
| | | // 法人证件类型 |
| | | paramsInfo.put("legal_cert_type", "00"); |
| | | // 法人证件号码 |
| | | paramsInfo.put("legal_cert_no", "321084198912066582"); |
| | | // 法人证件有效期类型 |
| | | paramsInfo.put("legal_cert_validity_type", "1"); |
| | | // 法人证件有效期开始日期 |
| | | paramsInfo.put("legal_cert_begin_date", "20120801"); |
| | | // 法人证件有效期截止日期日期格式:yyyyMMdd; 非长期有效时必填,长期有效为空;<font color="green">示例值:20320905</font> |
| | | paramsInfo.put("legal_cert_end_date", "20300801"); |
| | | // 法人国籍法人的证件类型为外国人居留证时,必填,参见《[国籍编码](https://cloudpnrcdn.oss-cn-shanghai.aliyuncs.com/opps/api/prod/download_file/area/%E5%9B%BD%E7%B1%8D.xlsx)》<font color="green">示例值:CHN</font> |
| | | paramsInfo.put("legal_cert_nationality", "test"); |
| | | // 联系人姓名 |
| | | paramsInfo.put("contact_name", "小的"); |
| | | // 联系人手机号 |
| | | paramsInfo.put("contact_mobile", "13764462211"); |
| | | // 管理员账号如需短信通知则必填;<font color="green">示例值:Lg20220222013747</font> |
| | | paramsInfo.put("login_name", "Lg2022022201374721361"); |
| | | // 经营简称 |
| | | paramsInfo.put("short_name", "企业商户"); |
| | | // 联系人电子邮箱 |
| | | paramsInfo.put("contact_email", "jeff.peng@huifu.com"); |
| | | // 是否发送短信标识 |
| | | paramsInfo.put("sms_send_flag", "1"); |
| | | // 3. 发起API调用 |
| | | Map<String, Object> response = BasePayRequest.requestBasePay("v2/user/basicdata/ent", paramsInfo, null, false); |
| | | ; |
| | | return response; |
| | | } |
| | | |
| | | /** |
| | | * 企业用户基本信息修改 |
| | | * |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public Map<String, Object> userBasicDataEntModify(TEnterpriseWithdrawal tEnterpriseWithdrawal) throws Exception { |
| | | // 1. 数据初始化,填入对应的商户配置 |
| | | MerConfig merConfig = new MerConfig(); |
| | | merConfig.setProcutId(huiFuProperties.getProductId()); |
| | | merConfig.setSysId(huiFuProperties.getSysId()); |
| | | merConfig.setRsaPrivateKey(huiFuProperties.getRsaPrivateKey()); |
| | | merConfig.setRsaPublicKey(huiFuProperties.getRsaPublicKey()); |
| | | BasePay.initWithMerConfig(merConfig); |
| | | Map<String, Object> paramsInfo = new HashMap<>(); |
| | | log.info("个人用户基本信息修改返回参数:{}", paramsInfo); |
| | | // 3. 发起API调用 |
| | | Map<String, Object> response = BasePayRequest.requestBasePay("v2/user/basicdata/indv/modify", paramsInfo, null, false); |
| | | log.info("个人用户基本信息修改返回参数:{}", response); |
| | | return response; |
| | | } |
| | | |
| | | /** |
| | | * 用户业务入驻 |
| | | * |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public Map<String, Object> userBusinessOpen(UserWithdrawal userWithdrawal) throws Exception { |
| | | // 1. 数据初始化,填入对应的商户配置 |
| | | MerConfig merConfig = new MerConfig(); |
| | | merConfig.setProcutId(huiFuProperties.getProductId()); |
| | | merConfig.setSysId(huiFuProperties.getSysId()); |
| | | merConfig.setRsaPrivateKey(huiFuProperties.getRsaPrivateKey()); |
| | | merConfig.setRsaPublicKey(huiFuProperties.getRsaPublicKey()); |
| | | BasePay.initWithMerConfig(merConfig); |
| | | // 2.组装请求参数 |
| | | Map<String, Object> paramsInfo = new HashMap<>(); |
| | | // 汇付ID |
| | | paramsInfo.put("huifu_id", userWithdrawal.getHuiFuId()); |
| | | // 请求流水号 |
| | | paramsInfo.put("req_seq_id", RequestSeqUtil.generateForHuiFu()); |
| | | // 请求日期 |
| | | paramsInfo.put("req_date", DateUtil.format(new Date(), "yyyyMMdd")); |
| | | // 渠道商/商户汇付Id |
| | | paramsInfo.put("upper_huifu_id", huiFuProperties.getUpperHuifuId()); |
| | | //// 结算信息配置 |
| | | //paramsInfo.put("settle_config", "{\"settle_cycle\":\"D1\",\"min_amt\":\"0.01\",\"remained_amt\":\"10.00\",\"settle_abstract\":\"结算摘要\",\"out_settle_flag\":\"2\",\"settle_batch_no\":\"300\",\"fixed_ratio\":\"2\"}"); |
| | | // 结算卡信息 |
| | | JSONObject cardInfo = new JSONObject(); |
| | | cardInfo.put("card_type", "1"); |
| | | cardInfo.put("card_name", userWithdrawal.getBindAcctName()); |
| | | cardInfo.put("card_no", userWithdrawal.getBankCardCode()); |
| | | cardInfo.put("prov_id", userWithdrawal.getBankCardProvinceCode()); |
| | | cardInfo.put("area_id", userWithdrawal.getBankCardCityCode()); |
| | | cardInfo.put("cert_type", "00"); |
| | | cardInfo.put("cert_no", userWithdrawal.getCertificateCode()); |
| | | String[] certificateExpireDateArr = userWithdrawal.getCertificateExpireTime().split(","); |
| | | String startDateStr = certificateExpireDateArr[0]; |
| | | // 个人证件有效期开始日期 |
| | | cardInfo.put("cert_begin_date", startDateStr.replace("-", "")); |
| | | // 个人证件有效期截止日期 |
| | | String endDateStr = certificateExpireDateArr[1]; |
| | | if (!"长期".equals(endDateStr)) { |
| | | String formatEndDate = endDateStr.replace("-", ""); |
| | | cardInfo.put("cert_end_date", formatEndDate); |
| | | // 个人证件有效期类型 |
| | | cardInfo.put("cert_validity_type", "0"); |
| | | } else { |
| | | // 个人证件有效期类型 |
| | | cardInfo.put("cert_validity_type", "1"); |
| | | } |
| | | paramsInfo.put("card_info", cardInfo.toJSONString()); |
| | | log.info("用户业务入驻返回参数:{}", paramsInfo); |
| | | // 3. 发起API调用 |
| | | Map<String, Object> response = BasePayRequest.requestBasePay("v2/user/busi/open", paramsInfo, null, false); |
| | | ; |
| | | log.info("用户业务入驻返回参数:{}", response); |
| | | return response; |
| | | } |
| | | |
| | | /** |
| | | * 用户业务入驻 |
| | | * |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public Map<String, Object> userBusinessOpenModify(UserWithdrawal userWithdrawal) throws Exception { |
| | | // 1. 数据初始化,填入对应的商户配置 |
| | | MerConfig merConfig = new MerConfig(); |
| | | merConfig.setProcutId(huiFuProperties.getProductId()); |
| | | merConfig.setSysId(huiFuProperties.getSysId()); |
| | | merConfig.setRsaPrivateKey(huiFuProperties.getRsaPrivateKey()); |
| | | merConfig.setRsaPublicKey(huiFuProperties.getRsaPublicKey()); |
| | | BasePay.initWithMerConfig(merConfig); |
| | | // 2.组装请求参数 |
| | | Map<String, Object> paramsInfo = new HashMap<>(); |
| | | // 汇付ID |
| | | paramsInfo.put("huifu_id", userWithdrawal.getHuiFuId()); |
| | | // 请求流水号 |
| | | paramsInfo.put("req_seq_id", RequestSeqUtil.generateForHuiFu()); |
| | | // 请求日期 |
| | | paramsInfo.put("req_date", DateUtil.format(new Date(), "yyyyMMdd")); |
| | | // 渠道商/商户汇付Id |
| | | paramsInfo.put("upper_huifu_id", huiFuProperties.getUpperHuifuId()); |
| | | // 结算卡信息 |
| | | JSONObject cardInfo = new JSONObject(); |
| | | cardInfo.put("card_type", "1"); |
| | | cardInfo.put("card_name", userWithdrawal.getBindAcctName()); |
| | | cardInfo.put("card_no", userWithdrawal.getBankCardCode()); |
| | | cardInfo.put("prov_id", userWithdrawal.getBankCardProvinceCode()); |
| | | cardInfo.put("area_id", userWithdrawal.getBankCardCityCode()); |
| | | cardInfo.put("cert_type", "00"); |
| | | cardInfo.put("cert_no", userWithdrawal.getCertificateCode()); |
| | | String[] certificateExpireDateArr = userWithdrawal.getCertificateExpireTime().split(","); |
| | | String startDateStr = certificateExpireDateArr[0]; |
| | | // 个人证件有效期开始日期 |
| | | cardInfo.put("cert_begin_date", startDateStr.replace("-", "")); |
| | | // 个人证件有效期截止日期 |
| | | String endDateStr = certificateExpireDateArr[1]; |
| | | if (!"长期".equals(endDateStr)) { |
| | | String formatEndDate = endDateStr.replace("-", ""); |
| | | cardInfo.put("cert_end_date", formatEndDate); |
| | | // 个人证件有效期类型 |
| | | cardInfo.put("cert_validity_type", "0"); |
| | | } else { |
| | | // 个人证件有效期类型 |
| | | cardInfo.put("cert_validity_type", "1"); |
| | | } |
| | | paramsInfo.put("card_info", cardInfo.toJSONString()); |
| | | log.info("用户业务入驻修改返回参数:{}", paramsInfo); |
| | | // 3. 发起API调用 |
| | | Map<String, Object> response = BasePayRequest.requestBasePay("v2/user/busi/open", paramsInfo, null, false); |
| | | ; |
| | | log.info("用户业务入驻修改返回参数:{}", response); |
| | | return response; |
| | | } |
| | | } |