From e134c27257385f4bd5da8e54ffc3c8981da808f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Csunn=E2=80=9D?= <474776329@qq.com> Date: Wed, 31 Jan 2018 16:50:22 +0800 Subject: [PATCH] =?UTF-8?q?[Y]=20=E5=95=86=E6=88=B7=E7=BC=96=E7=A0=81?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=BB=98=E8=AE=A4=E5=80=BC=EF=BC=886?= =?UTF-8?q?=E4=BD=8D=E6=95=B0=E5=AD=97=E5=AD=97=E6=AF=8D=E7=BB=84=E5=90=88?= =?UTF-8?q?=EF=BC=89=E4=B8=94=E4=B8=8D=E5=8F=AF=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../manage/mappers/system/ClientMapper.java | 3 +++ .../merchants/beans/ClientRegisterInfo.java | 2 +- .../manage/merchants/core/ClientManager.java | 2 ++ .../merchants/core/impls/ClientManagerImpl.java | 10 ++++++++++ .../merchants/web/PartnerManageController.java | 4 ++++ .../manage/mappers/system/ClientMapper.xml | 3 +++ .../ui/static/payment/partner/partner-manage.js | 17 ++++++++++++++++- .../payment/partner/templates/add_partner.html | 3 +-- .../templates/add_sub_partner_dialog.html | 2 +- 9 files changed, 41 insertions(+), 5 deletions(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientMapper.java index 3be51a159..e39445f5a 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientMapper.java @@ -72,4 +72,7 @@ public interface ClientMapper { List listCityClientIds(@Param("city") String city, @Param("date") Date date); List listClientByCleanDays(@Param("clean_days") int clean_days); + + @AutoSql(type = SqlType.SELECT) + int getPartnercode(@Param("codes") String codes); } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/beans/ClientRegisterInfo.java b/src/main/java/au/com/royalpay/payment/manage/merchants/beans/ClientRegisterInfo.java index be305c8fc..03d5d20f3 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/beans/ClientRegisterInfo.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/beans/ClientRegisterInfo.java @@ -13,7 +13,7 @@ import javax.validation.constraints.Pattern; public class ClientRegisterInfo { @JSONField(name = "client_moniker") @NotEmpty(message = "error.payment.valid.param_missing") - @Pattern(regexp = "^[a-zA-Z0-9]{4}$", message = "Parameter error(partner code):Only letters or numbers are allowed") + @Pattern(regexp = "^[a-zA-Z0-9]{6}$", message = "Parameter error(partner code):Only letters or numbers are allowed") private String clientMoniker; @NotEmpty(message = "error.payment.valid.param_missing") @JSONField(name = "company_name") 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 7f29c5718..b3e06c72e 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 @@ -264,4 +264,6 @@ public interface ClientManager { void validRefundPwd(JSONObject account, String pwd); void setWeekendDelay(int clientId, boolean delay); + + String initMerchantCode(); } 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 a2814d7ee..504598dc0 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 @@ -2084,6 +2084,16 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid clientMapper.update(clientUpdate); } + @Override + public String initMerchantCode() { + String code = RandomStringUtils.randomAlphanumeric(6).toUpperCase(); + if (clientMapper.getPartnercode(code) > 0) { + return initMerchantCode(); + } + return code; + } + + @Override public void setClientQRCodePaySurCharge(String clientMoniker, boolean paySurcharge) { 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 f9d090a2c..83c9a785c 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 @@ -482,4 +482,8 @@ public class PartnerManageController { public void localMerchantPermission(@PathVariable String clientMoniker, @RequestBody JSONObject pass, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { clientManager.switchPermission(manager, clientMoniker, "local_merchant", pass.getBooleanValue("allow")); } + @RequestMapping(value = "/init/merchant_code", method = RequestMethod.GET) + public String initMerchantCode() { + return clientManager.initMerchantCode(); + } } diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMapper.xml index 7995aa37b..a1efe9f01 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMapper.xml @@ -272,4 +272,7 @@ + \ No newline at end of file diff --git a/src/main/ui/static/payment/partner/partner-manage.js b/src/main/ui/static/payment/partner/partner-manage.js index a4fab9761..92f6e47c2 100644 --- a/src/main/ui/static/payment/partner/partner-manage.js +++ b/src/main/ui/static/payment/partner/partner-manage.js @@ -40,7 +40,12 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter }).state('partners.new', { url: '/new', templateUrl: '/static/payment/partner/templates/add_partner.html', - controller: 'addPartnerCtrl' + controller: 'addPartnerCtrl', + resolve: { + merchant_code: ['$http', function ($http) { + return $http.get('/sys/partners/init/merchant_code'); + }] + } }).state('partners.detail', { url: '/{clientMoniker}/detail', templateUrl: '/static/payment/partner/templates/partner_detail.html', @@ -224,6 +229,9 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter } $scope.partner.company_phone_c = 61; $scope.partner.contact_phone_c = 61; + $http.get('/sys/partners/init/merchant_code').then(function (response) { + $scope.partner.client_moniker = response.data; + }); function remove(arr, val) { if (angular.isArray(arr)) { @@ -1241,6 +1249,10 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter controller: 'partnerNewSubPartnerDialogCtrl', size: 'lg', resolve: { + merchant_code: ['$http', function ($http) { + return $http.get('/sys/partners/init/merchant_code'); + }], + clientMoniker: function () { return $scope.partner.client_moniker; } @@ -1534,6 +1546,9 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter app.controller('partnerNewSubPartnerDialogCtrl', ['$rootScope', '$scope', '$http', '$state', 'Upload', 'commonDialog', 'timezone', 'clientMoniker', 'industryMap', 'businessStructuresMap', 'stateMap', 'countryMap', function ($rootScope, $scope, $http, $state, Upload, commonDialog, timezone, clientMoniker, industryMap, businessStructuresMap, stateMap, countryMap) { + $http.get('/sys/partners/init/merchant_code').then(function (response) { + $scope.partner.client_moniker = response.data; + }); if ($scope.partner_application) { $scope.partner = angular.copy($scope.partner_application); delete $rootScope.partner_application; 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 eaeb79dd6..5f3c3f649 100644 --- a/src/main/ui/static/payment/partner/templates/add_partner.html +++ b/src/main/ui/static/payment/partner/templates/add_partner.html @@ -27,8 +27,7 @@ ng-model="partner.client_moniker" type="text" name="client_moniker" - id="short-id-input" required maxlength="4" - ng-pattern="/^[a-zA-Z0-9]+$/"> + id="short-id-input" readonly>

No further changeable!

diff --git a/src/main/ui/static/payment/partner/templates/add_sub_partner_dialog.html b/src/main/ui/static/payment/partner/templates/add_sub_partner_dialog.html index 64d9f7be1..a27e39df7 100644 --- a/src/main/ui/static/payment/partner/templates/add_sub_partner_dialog.html +++ b/src/main/ui/static/payment/partner/templates/add_sub_partner_dialog.html @@ -20,7 +20,7 @@ + id="short-id-input" readonly>

No further changeable!