|
@@ -1,5 +1,6 @@
|
|
|
package com.ym.mec.thirdparty.yeepay;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
@@ -8,141 +9,98 @@ import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.yeepay.yop.sdk.exception.YopClientException;
|
|
|
-import com.yeepay.yop.sdk.service.mer.MerClient;
|
|
|
-import com.yeepay.yop.sdk.service.mer.MerClientBuilder;
|
|
|
-import com.yeepay.yop.sdk.service.mer.request.MerchantInfoModifyRequest;
|
|
|
-import com.yeepay.yop.sdk.service.mer.request.RegisterQueryV2Request;
|
|
|
-import com.yeepay.yop.sdk.service.mer.request.RegisterSaasMerchantV2Request;
|
|
|
-import com.yeepay.yop.sdk.service.mer.response.MerchantInfoModifyResponse;
|
|
|
-import com.yeepay.yop.sdk.service.mer.response.RegisterQueryV2Response;
|
|
|
-import com.yeepay.yop.sdk.service.mer.response.RegisterSaasMerchantV2Response;
|
|
|
+import com.yeepay.g3.sdk.yop.client.YopRequest;
|
|
|
+import com.yeepay.g3.sdk.yop.client.YopResponse;
|
|
|
+import com.yeepay.g3.sdk.yop.client.YopRsaClient;
|
|
|
+import com.yeepay.g3.sdk.yop.exception.YopClientException;
|
|
|
+import com.ym.mec.thirdparty.adapay.entity.HfMerchantConfig;
|
|
|
import com.ym.mec.thirdparty.yeepay.entity.MerchantInfo;
|
|
|
|
|
|
@Service
|
|
|
public class YeepayMerchantService {
|
|
|
-
|
|
|
+
|
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(YeepayMerchantService.class);
|
|
|
|
|
|
- private final MerClient api = MerClientBuilder.builder().build();
|
|
|
-
|
|
|
- public RegisterQueryV2Response registerQueryV2(String requestNo) throws YopClientException {
|
|
|
- RegisterQueryV2Request request = new RegisterQueryV2Request();
|
|
|
- request.setRequestNo(requestNo);
|
|
|
- RegisterQueryV2Response response = api.registerQueryV2(request);
|
|
|
- LOGGER.info("result:{}", response.getResult());
|
|
|
-
|
|
|
- return response;
|
|
|
- }
|
|
|
-
|
|
|
- public RegisterSaasMerchantV2Response registerSaasMerchantV2(String appKey, String parentMerchantNo, MerchantInfo merchantInfo, String notifyURL) throws YopClientException {
|
|
|
- RegisterSaasMerchantV2Request request = new RegisterSaasMerchantV2Request();
|
|
|
- request.getRequestConfig().setAppKey(appKey);
|
|
|
- request.setRequestNo(System.currentTimeMillis() + "");
|
|
|
- request.setBusinessRole("SHARE_MERCHANT");
|
|
|
- request.setParentMerchantNo(parentMerchantNo);
|
|
|
-
|
|
|
- merchantInfo.setRequestNo(request.getRequestNo());
|
|
|
-
|
|
|
- Map<String,String> merchantSubjectInfoMap = new HashMap<String, String>();
|
|
|
- merchantSubjectInfoMap.put("licenceUrl", merchantInfo.getLicenceUrl());
|
|
|
- merchantSubjectInfoMap.put("signName", merchantInfo.getMerchantName());
|
|
|
- merchantSubjectInfoMap.put("signType", "ENTERPRISE");
|
|
|
- merchantSubjectInfoMap.put("licenceNo", merchantInfo.getLicenceNo());
|
|
|
- merchantSubjectInfoMap.put("shortName", merchantInfo.getMerchantName());
|
|
|
- merchantSubjectInfoMap.put("openAccountLicenceUrl", merchantInfo.getOpenAccountLicenceUrl());
|
|
|
- request.setMerchantSubjectInfo(JSONObject.toJSONString(merchantSubjectInfoMap));
|
|
|
-
|
|
|
- Map<String,String> merchantCorporationInfoMap = new HashMap<String, String>();
|
|
|
- merchantCorporationInfoMap.put("legalName", merchantInfo.getLegalName());
|
|
|
- merchantCorporationInfoMap.put("legalLicenceType", merchantInfo.getLegalLicenceType());
|
|
|
- merchantCorporationInfoMap.put("legalLicenceNo", merchantInfo.getLegalLicenceNo());
|
|
|
- merchantCorporationInfoMap.put("legalLicenceFrontUrl", merchantInfo.getLegalLicenceFrontUrl());
|
|
|
- merchantCorporationInfoMap.put("legalLicenceBackUrl", merchantInfo.getLegalLicenceBackUrl());
|
|
|
- request.setMerchantCorporationInfo(JSONObject.toJSONString(merchantCorporationInfoMap));
|
|
|
-
|
|
|
- Map<String,String> merchantContactInfoMap = new HashMap<String, String>();
|
|
|
- merchantContactInfoMap.put("contactName", merchantInfo.getContactName());
|
|
|
- merchantContactInfoMap.put("contactLicenceNo", merchantInfo.getContactLicenceNo());
|
|
|
- merchantContactInfoMap.put("contactMobile", merchantInfo.getContactMobile());
|
|
|
- merchantContactInfoMap.put("contactEmail", merchantInfo.getContactEmail());
|
|
|
- request.setMerchantContactInfo(JSONObject.toJSONString(merchantContactInfoMap));
|
|
|
-
|
|
|
- request.setIndustryCategoryInfo("{ \"primaryIndustryCategory\":\"120\", \"secondaryIndustryCategory\":\"120004\" }");
|
|
|
-
|
|
|
- Map<String,String> businessAddressInfoMap = new HashMap<String, String>();
|
|
|
- businessAddressInfoMap.put("province", merchantInfo.getProvinceCode());
|
|
|
- businessAddressInfoMap.put("city", merchantInfo.getCityCode());
|
|
|
- businessAddressInfoMap.put("district", merchantInfo.getDistrictCode());
|
|
|
- businessAddressInfoMap.put("address", merchantInfo.getAddress());
|
|
|
- request.setBusinessAddressInfo(JSONObject.toJSONString(businessAddressInfoMap));
|
|
|
-
|
|
|
- Map<String,String> settlementAccountInfoMap = new HashMap<String, String>();
|
|
|
- settlementAccountInfoMap.put("settlementDirection", "BANKCARD");
|
|
|
- settlementAccountInfoMap.put("bankCode", merchantInfo.getBankCode());
|
|
|
- settlementAccountInfoMap.put("bankAccountType", merchantInfo.getBankAccountType());
|
|
|
- settlementAccountInfoMap.put("bankCardNo", merchantInfo.getBankCardNo());
|
|
|
- request.setSettlementAccountInfo(JSONObject.toJSONString(settlementAccountInfoMap));
|
|
|
-
|
|
|
- request.setNotifyUrl(notifyURL);
|
|
|
- request.setProductInfo("[{\"productCode\":\"D1\",\"rateType\":\"SINGLE_FIXED\",\"fixedRate\":\"0\",\"paymentMethod\":\"REAL_TIME\"}]");
|
|
|
- //request.setProductQualificationInfo("{ \"paymentScene\": \"RLZYFW\", \"systemScreenshotUrl\": \"https://staticres.yeepay.com/xxx.文件后缀\", \"specialPermitProcessUrl\": \"https://staticres.yeepay.com/xxx.文件后缀\", \"agreementPhotoUrl\": \"https://staticres.yeepay.com/xxx.文件后缀\" }");
|
|
|
- //request.setFunctionService("[\"SHARE\"]");
|
|
|
- //request.setFunctionServiceQualificationInfo("{\"shareScene\":\"FZ_ALL001\"}");
|
|
|
- RegisterSaasMerchantV2Response response = api.registerSaasMerchantV2(request);
|
|
|
- LOGGER.info("result:{}", response.getResult());
|
|
|
-
|
|
|
- return response;
|
|
|
- }
|
|
|
-
|
|
|
- public void merchantInfoModify(String merchantNo, MerchantInfo merchantInfo, String notifyURL) throws YopClientException {
|
|
|
- MerchantInfoModifyRequest request = new MerchantInfoModifyRequest();
|
|
|
- request.setRequestNo(System.currentTimeMillis() + "");
|
|
|
- request.setMerchantNo(merchantNo);
|
|
|
- request.setNotifyUrl(notifyURL);
|
|
|
-
|
|
|
- Map<String,String> merchantSubjectInfoMap = new HashMap<String, String>();
|
|
|
- merchantSubjectInfoMap.put("licenceUrl", merchantInfo.getLicenceUrl());
|
|
|
- merchantSubjectInfoMap.put("signName", merchantInfo.getMerchantName());
|
|
|
- merchantSubjectInfoMap.put("signType", "ENTERPRISE");
|
|
|
- merchantSubjectInfoMap.put("licenceNo", merchantInfo.getLicenceNo());
|
|
|
- merchantSubjectInfoMap.put("shortName", merchantInfo.getMerchantName());
|
|
|
- merchantSubjectInfoMap.put("openAccountLicenceUrl", merchantInfo.getOpenAccountLicenceUrl());
|
|
|
- request.setMerchantSubjectInfo(JSONObject.toJSONString(merchantSubjectInfoMap));
|
|
|
-
|
|
|
- Map<String,String> merchantCorporationInfoMap = new HashMap<String, String>();
|
|
|
- merchantCorporationInfoMap.put("legalName", merchantInfo.getLegalName());
|
|
|
- merchantCorporationInfoMap.put("legalLicenceType", merchantInfo.getLegalLicenceType());
|
|
|
- merchantCorporationInfoMap.put("legalLicenceNo", merchantInfo.getLegalLicenceNo());
|
|
|
- merchantCorporationInfoMap.put("legalLicenceFrontUrl", merchantInfo.getLegalLicenceFrontUrl());
|
|
|
- merchantCorporationInfoMap.put("legalLicenceBackUrl", merchantInfo.getLegalLicenceBackUrl());
|
|
|
- request.setMerchantCorporationInfo(JSONObject.toJSONString(merchantCorporationInfoMap));
|
|
|
-
|
|
|
- Map<String,String> merchantContactInfoMap = new HashMap<String, String>();
|
|
|
- merchantContactInfoMap.put("contactName", merchantInfo.getContactName());
|
|
|
- merchantContactInfoMap.put("contactLicenceNo", merchantInfo.getContactLicenceNo());
|
|
|
- merchantContactInfoMap.put("contactMobile", merchantInfo.getContactMobile());
|
|
|
- merchantContactInfoMap.put("contactEmail", merchantInfo.getContactEmail());
|
|
|
- request.setMerchantContactInfo(JSONObject.toJSONString(merchantContactInfoMap));
|
|
|
-
|
|
|
- Map<String,String> businessAddressInfoMap = new HashMap<String, String>();
|
|
|
- businessAddressInfoMap.put("province", merchantInfo.getProvinceCode());
|
|
|
- businessAddressInfoMap.put("city", merchantInfo.getCityCode());
|
|
|
- businessAddressInfoMap.put("district", merchantInfo.getDistrictCode());
|
|
|
- businessAddressInfoMap.put("address", merchantInfo.getAddress());
|
|
|
- request.setBusinessAddressInfo(JSONObject.toJSONString(businessAddressInfoMap));
|
|
|
-
|
|
|
- Map<String,String> settlementAccountInfoMap = new HashMap<String, String>();
|
|
|
- settlementAccountInfoMap.put("settlementDirection", merchantInfo.getSettlementDirection());
|
|
|
- settlementAccountInfoMap.put("bankCode", merchantInfo.getBankCode());
|
|
|
- settlementAccountInfoMap.put("bankAccountType", merchantInfo.getBankAccountType());
|
|
|
- settlementAccountInfoMap.put("bankCardNo", merchantInfo.getBankCardNo());
|
|
|
- //request.setSettlementAccountInfo(JSONObject.toJSONString(settlementAccountInfoMap));
|
|
|
-
|
|
|
- request.setAccountInfo("{\"bankAccountName\":\"开户名称\",\"bankAccountType\":\"银行账户类型\",\"bankAccountNo\":\"银行账户号码\",\"bankCardTag\":\"[\\\"SETTLEMENT\\\",\\\"WITHDRAW\\\"]\",\"authorizationUrl\":\"https://staticres.yeepay.com/xxx.文件后缀\",\"bankCode\":\"开户总行编码\"}");
|
|
|
- MerchantInfoModifyResponse response = api.merchantInfoModify(request);
|
|
|
- LOGGER.info("result:{}", response.getResult());
|
|
|
- // TODO: test validations
|
|
|
- }
|
|
|
-
|
|
|
+ public JSONObject registerQueryV2(HfMerchantConfig hfMerchantConfig, String requestNo) throws IOException {
|
|
|
+
|
|
|
+ YopRequest request = new YopRequest(hfMerchantConfig.getAppId(), hfMerchantConfig.getRsaPrivateKey());
|
|
|
+
|
|
|
+ request.addParam("requestNo", requestNo);
|
|
|
+
|
|
|
+ YopResponse response = YopRsaClient.get("/rest/v2.0/mer/register/query", request);
|
|
|
+
|
|
|
+ LOGGER.info("易宝[商户入网查询][{}] resp:{}", requestNo, response.getStringResult());
|
|
|
+
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(response.getStringResult());
|
|
|
+
|
|
|
+ return jsonObject;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Map<String, Object> registerSaasMerchantV2(HfMerchantConfig hfMerchantConfig, MerchantInfo merchantInfo, String notifyURL) throws IOException {
|
|
|
+
|
|
|
+ YopRequest request = new YopRequest(hfMerchantConfig.getAppId(), hfMerchantConfig.getRsaPrivateKey());
|
|
|
+
|
|
|
+ request.addParam("requestNo", System.currentTimeMillis() + "");
|
|
|
+ request.addParam("businessRole", "SHARE_MERCHANT");
|
|
|
+ request.addParam("parentMerchantNo", hfMerchantConfig.getPlatformPayeeMemberId());
|
|
|
+
|
|
|
+ Map<String, String> merchantSubjectInfoMap = new HashMap<String, String>();
|
|
|
+ merchantSubjectInfoMap.put("licenceUrl", merchantInfo.getLicenceUrl());
|
|
|
+ merchantSubjectInfoMap.put("signName", merchantInfo.getMerchantName());
|
|
|
+ merchantSubjectInfoMap.put("signType", "ENTERPRISE");
|
|
|
+ merchantSubjectInfoMap.put("licenceNo", merchantInfo.getLicenceNo());
|
|
|
+ merchantSubjectInfoMap.put("shortName", merchantInfo.getMerchantName());
|
|
|
+ merchantSubjectInfoMap.put("openAccountLicenceUrl", merchantInfo.getOpenAccountLicenceUrl());
|
|
|
+ request.addParam("merchantSubjectInfo", JSONObject.toJSONString(merchantSubjectInfoMap));
|
|
|
+
|
|
|
+ Map<String, String> merchantCorporationInfoMap = new HashMap<String, String>();
|
|
|
+ merchantCorporationInfoMap.put("legalName", merchantInfo.getLegalName());
|
|
|
+ merchantCorporationInfoMap.put("legalLicenceType", merchantInfo.getLegalLicenceType());
|
|
|
+ merchantCorporationInfoMap.put("legalLicenceNo", merchantInfo.getLegalLicenceNo());
|
|
|
+ merchantCorporationInfoMap.put("legalLicenceFrontUrl", merchantInfo.getLegalLicenceFrontUrl());
|
|
|
+ merchantCorporationInfoMap.put("legalLicenceBackUrl", merchantInfo.getLegalLicenceBackUrl());
|
|
|
+ request.addParam("merchantCorporationInfo", JSONObject.toJSONString(merchantCorporationInfoMap));
|
|
|
+
|
|
|
+ Map<String, String> merchantContactInfoMap = new HashMap<String, String>();
|
|
|
+ merchantContactInfoMap.put("contactName", merchantInfo.getContactName());
|
|
|
+ merchantContactInfoMap.put("contactLicenceNo", merchantInfo.getContactLicenceNo());
|
|
|
+ merchantContactInfoMap.put("contactMobile", merchantInfo.getContactMobile());
|
|
|
+ merchantContactInfoMap.put("contactEmail", merchantInfo.getContactEmail());
|
|
|
+ request.addParam("merchantContactInfo", JSONObject.toJSONString(merchantContactInfoMap));
|
|
|
+
|
|
|
+ request.addParam("industryCategoryInfo", "{ \"primaryIndustryCategory\":\"120\", \"secondaryIndustryCategory\":\"120004\" }");
|
|
|
+
|
|
|
+ Map<String, String> businessAddressInfoMap = new HashMap<String, String>();
|
|
|
+ businessAddressInfoMap.put("province", merchantInfo.getProvinceCode());
|
|
|
+ businessAddressInfoMap.put("city", merchantInfo.getCityCode());
|
|
|
+ businessAddressInfoMap.put("district", merchantInfo.getDistrictCode());
|
|
|
+ businessAddressInfoMap.put("address", merchantInfo.getAddress());
|
|
|
+ request.addParam("businessAddressInfo", JSONObject.toJSONString(businessAddressInfoMap));
|
|
|
+
|
|
|
+ Map<String, String> settlementAccountInfoMap = new HashMap<String, String>();
|
|
|
+ settlementAccountInfoMap.put("settlementDirection", "BANKCARD");
|
|
|
+ settlementAccountInfoMap.put("bankCode", merchantInfo.getBankCode());
|
|
|
+ settlementAccountInfoMap.put("bankAccountType", merchantInfo.getBankAccountType());
|
|
|
+ settlementAccountInfoMap.put("bankCardNo", merchantInfo.getBankCardNo());
|
|
|
+ request.addParam("settlementAccountInfo", JSONObject.toJSONString(settlementAccountInfoMap));
|
|
|
+
|
|
|
+ request.addParam("notifyUrl", notifyURL);
|
|
|
+ request.addParam("productInfo", "[{\"productCode\":\"D1\",\"rateType\":\"SINGLE_FIXED\",\"fixedRate\":\"0\",\"paymentMethod\":\"REAL_TIME\"}]");
|
|
|
+
|
|
|
+
|
|
|
+ LOGGER.info("易宝[商户入网] req:{}", request);
|
|
|
+
|
|
|
+ YopResponse response = YopRsaClient.post("/rest/v2.0/mer/register/saas/merchant", request);
|
|
|
+
|
|
|
+ LOGGER.info("易宝[商户入网] resp:{}", response.getStringResult());
|
|
|
+
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(response.getStringResult());
|
|
|
+
|
|
|
+ return jsonObject;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void merchantInfoModify(String merchantNo, MerchantInfo merchantInfo, String notifyURL) throws YopClientException {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|