YeepayMerchantService.java 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. package com.ym.mec.thirdparty.yeepay;
  2. import java.io.IOException;
  3. import java.util.HashMap;
  4. import java.util.Map;
  5. import org.slf4j.Logger;
  6. import org.slf4j.LoggerFactory;
  7. import org.springframework.stereotype.Service;
  8. import com.alibaba.fastjson.JSONObject;
  9. import com.yeepay.g3.sdk.yop.client.YopRequest;
  10. import com.yeepay.g3.sdk.yop.client.YopResponse;
  11. import com.yeepay.g3.sdk.yop.client.YopRsaClient;
  12. import com.yeepay.g3.sdk.yop.exception.YopClientException;
  13. import com.ym.mec.thirdparty.adapay.entity.HfMerchantConfig;
  14. import com.ym.mec.thirdparty.yeepay.entity.MerchantInfo;
  15. @Service
  16. public class YeepayMerchantService {
  17. private static final Logger LOGGER = LoggerFactory.getLogger(YeepayMerchantService.class);
  18. public JSONObject registerQueryV2(HfMerchantConfig hfMerchantConfig, String requestNo) throws IOException {
  19. YopRequest request = new YopRequest(hfMerchantConfig.getAppId(), hfMerchantConfig.getRsaPrivateKey());
  20. request.addParam("requestNo", requestNo);
  21. YopResponse response = YopRsaClient.get("/rest/v2.0/mer/register/query", request);
  22. LOGGER.info("易宝[商户入网查询][{}] resp:{}", requestNo, response.getStringResult());
  23. JSONObject jsonObject = JSONObject.parseObject(response.getStringResult());
  24. return jsonObject;
  25. }
  26. public Map<String, Object> registerSaasMerchantV2(HfMerchantConfig hfMerchantConfig, MerchantInfo merchantInfo, String notifyURL) throws IOException {
  27. YopRequest request = new YopRequest(hfMerchantConfig.getAppId(), hfMerchantConfig.getRsaPrivateKey());
  28. request.addParam("requestNo", System.currentTimeMillis() + "");
  29. request.addParam("businessRole", "SHARE_MERCHANT");
  30. request.addParam("parentMerchantNo", hfMerchantConfig.getPlatformPayeeMemberId());
  31. Map<String, String> merchantSubjectInfoMap = new HashMap<String, String>();
  32. merchantSubjectInfoMap.put("licenceUrl", merchantInfo.getLicenceUrl());
  33. merchantSubjectInfoMap.put("signName", merchantInfo.getMerchantName());
  34. merchantSubjectInfoMap.put("signType", merchantInfo.getMerchantType());
  35. merchantSubjectInfoMap.put("licenceNo", merchantInfo.getLicenceNo());
  36. merchantSubjectInfoMap.put("shortName", merchantInfo.getMerchantName());
  37. merchantSubjectInfoMap.put("openAccountLicenceUrl", merchantInfo.getOpenAccountLicenceUrl());
  38. request.addParam("merchantSubjectInfo", JSONObject.toJSONString(merchantSubjectInfoMap));
  39. Map<String, String> merchantCorporationInfoMap = new HashMap<String, String>();
  40. merchantCorporationInfoMap.put("legalName", merchantInfo.getLegalName());
  41. merchantCorporationInfoMap.put("legalLicenceType", merchantInfo.getLegalLicenceType());
  42. merchantCorporationInfoMap.put("legalLicenceNo", merchantInfo.getLegalLicenceNo());
  43. merchantCorporationInfoMap.put("legalLicenceFrontUrl", merchantInfo.getLegalLicenceFrontUrl());
  44. merchantCorporationInfoMap.put("legalLicenceBackUrl", merchantInfo.getLegalLicenceBackUrl());
  45. request.addParam("merchantCorporationInfo", JSONObject.toJSONString(merchantCorporationInfoMap));
  46. Map<String, String> merchantContactInfoMap = new HashMap<String, String>();
  47. merchantContactInfoMap.put("contactName", merchantInfo.getContactName());
  48. merchantContactInfoMap.put("contactLicenceNo", merchantInfo.getContactLicenceNo());
  49. merchantContactInfoMap.put("contactMobile", merchantInfo.getContactMobile());
  50. merchantContactInfoMap.put("contactEmail", merchantInfo.getContactEmail());
  51. request.addParam("merchantContactInfo", JSONObject.toJSONString(merchantContactInfoMap));
  52. request.addParam("industryCategoryInfo", "{ \"primaryIndustryCategory\":\"120\", \"secondaryIndustryCategory\":\"120004\" }");
  53. Map<String, String> businessAddressInfoMap = new HashMap<String, String>();
  54. businessAddressInfoMap.put("province", merchantInfo.getProvinceCode());
  55. businessAddressInfoMap.put("city", merchantInfo.getCityCode());
  56. businessAddressInfoMap.put("district", merchantInfo.getDistrictCode());
  57. businessAddressInfoMap.put("address", merchantInfo.getAddress());
  58. request.addParam("businessAddressInfo", JSONObject.toJSONString(businessAddressInfoMap));
  59. Map<String, String> settlementAccountInfoMap = new HashMap<String, String>();
  60. settlementAccountInfoMap.put("settlementDirection", "BANKCARD");
  61. settlementAccountInfoMap.put("bankCode", merchantInfo.getBankCode());
  62. settlementAccountInfoMap.put("bankAccountType", merchantInfo.getBankAccountType());
  63. settlementAccountInfoMap.put("bankCardNo", merchantInfo.getBankCardNo());
  64. request.addParam("settlementAccountInfo", JSONObject.toJSONString(settlementAccountInfoMap));
  65. // request.addParam("notifyUrl", notifyURL + "/" + request.getParamValue("requestNo"));
  66. request.addParam("productInfo", "[{\"productCode\":\"D1\",\"rateType\":\"SINGLE_FIXED\",\"fixedRate\":\"0\",\"paymentMethod\":\"REAL_TIME\"}]");
  67. //request.addParam("functionService", "[\"SHARE\"]");
  68. //request.addParam("functionServiceQualificationInfo", "{\"shareScene\":\"FZ_ALL001\"}");
  69. LOGGER.info("易宝[商户入网] req:{}", request);
  70. YopResponse response = YopRsaClient.post("/rest/v2.0/mer/register/saas/merchant", request);
  71. LOGGER.info("易宝[商户入网] resp:{}", response.getStringResult());
  72. JSONObject jsonObject = JSONObject.parseObject(response.getStringResult());
  73. return jsonObject;
  74. }
  75. public void merchantInfoModify(String merchantNo, MerchantInfo merchantInfo, String notifyURL) throws YopClientException {
  76. }
  77. }