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 efbba73e0..207d21377 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 @@ -320,4 +320,7 @@ public interface ClientManager { void removeSub(String client_moniker, JSONObject manager); String getShortLink(String client_moniker); + + @Transactional + void switchHfLink(JSONObject manager, String clientMoniker,boolean allow); } 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 2b9d22508..0e65584d9 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 @@ -262,6 +262,9 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid private ClearingDetailMapper clearingDetailMapper; @Resource private ClearingLogMapper clearingLogMapper; + @Resource + private ClientConfigMapper clientConfigMapper; + private static final String SOURCE_AGREE_FILE = "source_agree_file"; @@ -3666,6 +3669,30 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid mailService.removeUnsub(sub.getLong("id")); } + @Override + public void switchHfLink(JSONObject manager, String clientMoniker, boolean allow) { + JSONObject client = getClientInfoByMoniker(clientMoniker); + if (client == null) { + throw new InvalidShortIdException(); + } + checkOrgPermission(manager, client); + + if(allow){ + if(StringUtils.isEmpty(client.getString("hf_pay_url"))){ + String hf_pay_url = getShortLink(clientMoniker); + client.put("hf_pay_url",hf_pay_url); + JSONObject clientConfig = new JSONObject(); + clientConfig.put("hf_pay_url",hf_pay_url); + clientConfig.put("client_id",client.getIntValue("client_id")); + clientConfigMapper.update(clientConfig); + clientMapper.update(client); + } + } + clientModifySupport.processClientConfigModify(new SwitchPermissionModify(manager, clientMoniker, "enable_link", allow)); + + + } + @Override public String getShortLink(String client_moniker){ String longUrl = PlatformEnvironment.getEnv().concatUrl("/api/v1.0/hf_gateway/partners/"+client_moniker+"/jump"); 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 57c66375d..2697b2c4c 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 @@ -536,4 +536,9 @@ public class PartnerManageController { clientManager.removeSub(clientMoniker,manager); } + @ManagerMapping(value = "/{clientMoniker}/hf", method = RequestMethod.PUT, role = {ManagerRole.SERVANT, ManagerRole.DEVELOPER}) + public void switchHfPermission(@PathVariable String clientMoniker, @RequestBody JSONObject pass, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { + clientManager.switchHfLink(manager, clientMoniker, pass.getBooleanValue("allow")); + } + } diff --git a/src/main/ui/static/payment/partner/partner-manage.js b/src/main/ui/static/payment/partner/partner-manage.js index 07752f1aa..e0b90af65 100644 --- a/src/main/ui/static/payment/partner/partner-manage.js +++ b/src/main/ui/static/payment/partner/partner-manage.js @@ -1234,7 +1234,7 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter }) }) }; - $scope.init = {jsapi: false, gateway: false, offline: false, refund: false,common_sub_merchant_id:false, channel: {},gateway_alipay_online:false}; + $scope.init = {jsapi: false, gateway: false, offline: false, refund: false,common_sub_merchant_id:false, channel: {},gateway_alipay_online:false,hf_Link:false}; $scope.switchCommonSubMerchantId = function () { if (!$scope.paymentInfo) { return; @@ -1274,6 +1274,28 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter }) }) }; + $scope.toggleHfLink = function (channel) { + if (!channel) { + return; + } + if (!$scope.paymentInfo) { + return; + } + if (!$scope.init.hf_Link) { + $scope.init.hf_Link = true; + return; + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/hf', {allow: $scope.paymentInfo.enable_link}).then(function () { + $scope.loadPartnerPaymentInfo(); + }, function (resp) { + commonDialog.alert({ + title: 'Failed to change enable_link permission status', + content: resp.data.message, + type: 'error' + }); + }) + }; + $scope.toggleJsApi = function () { if (!$scope.paymentInfo) { return; diff --git a/src/main/ui/static/payment/partner/templates/partner_payment_info.html b/src/main/ui/static/payment/partner/templates/partner_payment_info.html index f59af125a..b68472e36 100644 --- a/src/main/ui/static/payment/partner/templates/partner_payment_info.html +++ b/src/main/ui/static/payment/partner/templates/partner_payment_info.html @@ -161,31 +161,31 @@
Channels
-
+
-
+
-
+
-
+
-
+
@@ -313,6 +313,14 @@

+
+
+ +
+ +   {{paymentInfo.hf_pay_url}} +
+