From 8e109ad2e39aad20caf637337253cb7a5fb489d0 Mon Sep 17 00:00:00 2001 From: "taylor.dang" Date: Wed, 6 Feb 2019 13:29:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E4=BB=98=E5=AE=9D=E8=BF=9B=E4=BB=B6?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../manage/merchants/core/ClientManager.java | 2 ++ .../core/impls/ClientManagerImpl.java | 32 +++++++++++++++++++ .../web/PartnerManageController.java | 5 +++ 3 files changed, 39 insertions(+) diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java index 1a0a346b7..ceb4f0a05 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java @@ -313,6 +313,8 @@ public interface ClientManager { String subMerchantApplication(String clientMoniker, SubMerchantIdApply subMerchantApply,JSONObject manager); + void registerAlipayGms(String clientMoniker,JSONObject manager); + List listMerchantIds(String clientMoniker,JSONObject manager); void clearCacheSubMerchantIdApplices(String clientMoniker); diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java index fbe7bf079..e0f2f3742 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java @@ -1,5 +1,8 @@ package au.com.royalpay.payment.manage.merchants.core.impls; +import au.com.royalpay.payment.channels.alipay.config.AlipayConfig; +import au.com.royalpay.payment.channels.alipay.config.AlipayEnvironment; +import au.com.royalpay.payment.channels.alipay.runtime.AlipayClient; import au.com.royalpay.payment.channels.rpay.runtime.RpayApi; import au.com.royalpay.payment.channels.rpay.runtime.beans.SubRpayMerchantInfo; import au.com.royalpay.payment.channels.wechat.config.WeChatPayConfig; @@ -12,6 +15,7 @@ import au.com.royalpay.payment.channels.yeepay.runtime.YeePayClient; import au.com.royalpay.payment.core.PaymentChannelApi; import au.com.royalpay.payment.core.exceptions.EmailException; import au.com.royalpay.payment.core.exceptions.InvalidShortIdException; +import au.com.royalpay.payment.core.exceptions.ParamInvalidException; import au.com.royalpay.payment.core.utils.OrderExpiryRuleResolver; import au.com.royalpay.payment.manage.analysis.mappers.TransactionAnalysisMapper; import au.com.royalpay.payment.manage.appclient.beans.AppClientBean; @@ -144,6 +148,7 @@ import java.math.BigDecimal; import java.math.RoundingMode; import java.net.URISyntaxException; import java.net.URL; +import java.security.InvalidParameterException; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; @@ -225,6 +230,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid private SignInAccountService signInAccountService; @Resource private WxPayClient wxPayClient; + @Resource + private AlipayClient alipayClient; @Resource private RpayApi rpayApi; @@ -3664,6 +3671,31 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid return sub_merchant_id; } + @Override + public void registerAlipayGms(String clientMoniker, JSONObject manager) { + JSONObject client = getClientInfoByMoniker(clientMoniker); + if (client == null) { + throw new InvalidShortIdException(); + } + checkOrgPermission(manager, client); + if (!client.containsKey("store_photo") || !client.containsKey("company_photo")) { + throw new InvalidParameterException("store photo cannot be empty "); + } + AlipayConfig.AlipayMerchant mch = AlipayEnvironment.getEnv().getAlipayRetailMerchant(); + Element resultElement = alipayClient.registerGmsPortal(mch.getPid(), client); + if (!StringUtils.equalsIgnoreCase("T", resultElement.elementText("is_success"))) { + throw new BadRequestException(resultElement.elementText("error")); + } + try { + Element responseElement = resultElement.element("response").element("alipay"); + if (!StringUtils.equalsIgnoreCase("SUCCESS", responseElement.elementText("result_code"))) { + throw new BadRequestException(responseElement.elementText("result_code")); + } + } catch (Exception e) { + throw new ServerErrorException(e); + } + } + @Override public void subRpayMerchantApplication(String clientMoniker, JSONObject merchantInfo,JSONObject manager) { JSONObject client = getClientInfoByMoniker(clientMoniker); diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java index 3f3ed611b..1a0b3aabd 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java @@ -566,6 +566,11 @@ public class PartnerManageController { return clientManager.subMerchantApplication(clientMoniker,subMerchantIdApply,manager); } + @ManagerMapping(value = "/{clientMoniker}/register/alipay_gms", method = RequestMethod.POST, role = {ManagerRole.OPERATOR, ManagerRole.ADMIN}) + public void registerAlipayGms(@PathVariable String clientMoniker,@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { + clientManager.registerAlipayGms(clientMoniker,manager); + } + @ManagerMapping(value = "/{clientMoniker}/get_merchant_ids",method = RequestMethod.GET,role = {ManagerRole.OPERATOR,ManagerRole.ADMIN}) public List getMerchantIds(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { return clientManager.listMerchantIds(clientMoniker,manager);