From 793cbbf02da0c47269456a83a29e2d14704926db Mon Sep 17 00:00:00 2001 From: luoyang Date: Fri, 5 Jul 2019 16:44:17 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E8=8B=B1=E6=96=87=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E6=88=90=E5=8A=9F=E9=A1=B5=20=E9=87=91=E9=A2=9D=E9=87=8D?= =?UTF-8?q?=E5=8F=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../manage/merchants/core/ClientManager.java | 2 ++ .../merchants/core/impls/ClientManagerImpl.java | 10 +++++++++- .../merchants/web/PartnerManageController.java | 5 +++++ .../ui/static/payment/partner/partner-manage.js | 15 +++++++++++++++ .../payment/partner/templates/add_partner.html | 6 +++++- 5 files changed, 36 insertions(+), 2 deletions(-) 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 5d8e10901..8130e20e7 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 @@ -45,6 +45,8 @@ public interface ClientManager { String initMerchantCode(); + boolean getMerchantIsValid(String clientMoniker); + @Transactional JSONObject registerClient(String clientMoniker, ClientRegisterInfo registery, JSONObject manager); 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 1e74e9ae0..c0f5384ca 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 @@ -633,12 +633,20 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid @Override public String initMerchantCode() { String code = RandomStringUtils.randomAlphanumeric(4).toUpperCase(); - if (clientMapper.getPartnercode(code) > 0) { + if (!getMerchantIsValid(code)) { return initMerchantCode(); } return code; } + @Override + public boolean getMerchantIsValid(String clientMoniker) { + if (clientMapper.getPartnercode(clientMoniker) > 0) { + return false; + } + return true; + } + @Override @Transactional public JSONObject registerClient(String clientMoniker, ClientRegisterInfo registery, JSONObject manager) { 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 3df2f98fc..8d7ddadfa 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 @@ -54,6 +54,11 @@ public class PartnerManageController { return clientManager.initMerchantCode(); } + @RequestMapping(value = "/init/check_code_isvalid", method = RequestMethod.GET) + public boolean getMerchantIsValid(@RequestParam String clientMoniker) { + return clientManager.getMerchantIsValid(clientMoniker); + } + @RequestMapping(method = RequestMethod.POST) @RequireManager(role = {ManagerRole.ADMIN, ManagerRole.BD_USER, ManagerRole.OPERATOR}) public JSONObject registerPartner(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @RequestBody @Valid ClientRegisterInfo registery, diff --git a/src/main/ui/static/payment/partner/partner-manage.js b/src/main/ui/static/payment/partner/partner-manage.js index fc9907856..1f2684509 100644 --- a/src/main/ui/static/payment/partner/partner-manage.js +++ b/src/main/ui/static/payment/partner/partner-manage.js @@ -371,6 +371,8 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter $scope.initMerchantCode = function () { $http.get('/sys/partners/init/merchant_code').then(function (response) { $scope.partner.client_moniker = response.data; + $scope.merchantCodeChecked = true; + $scope.merchantIsValid = true; }); }; $scope.initMerchantCode(); @@ -437,6 +439,8 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter $scope.clean_days = angular.copy(clean_days_map); $scope.bd_citys = angular.copy(bd_city_map); $scope.params = {textType: 'all', org_name: 'ALL'}; + $scope.merchantIsValid = false; + $scope.merchantCodeChecked = false; function remove(arr, val) { if (angular.isArray(arr)) { @@ -526,6 +530,17 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter // $scope.t2city_map = angular.copy(t2city_map); $scope.timezones = timezone.configs(); + $scope.checkMerchantCodeIsValid = function (code) { + if (code.length != 4) { + $scope.merchantCodeChecked = false; + $scope.merchantIsValid = false; + return; + } + $http.get('/sys/partners/init/check_code_isvalid',{params:{clientMoniker:code}}).then(function (response) { + $scope.merchantIsValid = response.data; + $scope.merchantCodeChecked = true; + }); + }; $scope.save = function (form) { if (form.$invalid) { angular.forEach(form, function (item, key) { diff --git a/src/main/ui/static/payment/partner/templates/add_partner.html b/src/main/ui/static/payment/partner/templates/add_partner.html index b371dd5c8..1e5dec61c 100644 --- a/src/main/ui/static/payment/partner/templates/add_partner.html +++ b/src/main/ui/static/payment/partner/templates/add_partner.html @@ -40,8 +40,12 @@ type="text" name="client_moniker" id="short-id-input" required maxlength="4" - ng-pattern="/^[a-zA-Z0-9]+$/" readonly> + ng-pattern="/^[a-zA-Z0-9]+$/" ng-change="checkMerchantCodeIsValid(partner.client_moniker)"> + + + +

No further changeable!