From b5e932c6e190a3e07d50c305a145b64939a95714 Mon Sep 17 00:00:00 2001
From: luoyang
Date: Tue, 23 Jul 2019 09:34:25 +0800
Subject: [PATCH] =?UTF-8?q?add=20CBBank=E6=89=8B=E7=BB=AD=E8=B4=B9?=
=?UTF-8?q?=E5=BC=80=E5=85=B3=20&&=20=E5=A2=9E=E5=8A=A0clientconfig?=
=?UTF-8?q?=E5=8D=95=E7=8B=AC=E9=85=8D=E7=BD=AE=E6=96=B9=E6=B3=95=20boolea?=
=?UTF-8?q?n=20onlyModifyConfig?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../manage/merchants/core/ClientManager.java | 4 +++
.../merchants/core/ClientModifySupport.java | 2 ++
.../core/impls/ClientManagerImpl.java | 26 ++++++++++++++++++-
.../core/impls/ClientModifySupportImpl.java | 6 +++++
.../merchants/entity/ClientConfigModify.java | 14 ++++++++++
.../web/PartnerManageController.java | 5 ++++
.../merchants/web/PartnerViewController.java | 6 +++++
.../static/payment/partner/partner-manage.js | 15 +++++++++++
src/main/ui/static/payment/partner/partner.js | 14 ++++++++++
.../templates/client_payment_info.html | 6 +++++
.../templates/partner_payment_info.html | 6 +++++
11 files changed, 103 insertions(+), 1 deletion(-)
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 8130e20e7..80fd0479f 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
@@ -213,6 +213,8 @@ public interface ClientManager {
void setClientRetailPaySurCharge(JSONObject account,String clientMoniker, boolean paySurcharge);
+ void setClientCBBankPaySurCharge(JSONObject account,String clientMoniker, boolean paySurcharge);
+
void setClientTaxInSurcharge(JSONObject account,String clientMoniker, boolean taxInSurcharge);
void setClientCustomerTaxFree(JSONObject account,String clientMoniker, boolean customerTaxFree);
@@ -267,6 +269,8 @@ public interface ClientManager {
void changeRetailPaySurcharge(JSONObject account, boolean paySurcharge);
+ void changeCBBankPaySurcharge(JSONObject account, boolean paySurcharge);
+
void changeRequireCustinfo(JSONObject account, boolean requireCustinfo);
void changeRequireRemark(JSONObject account, boolean requireRemark);
diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientModifySupport.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientModifySupport.java
index c27c697c6..8d32edf4e 100644
--- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientModifySupport.java
+++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientModifySupport.java
@@ -13,5 +13,7 @@ public interface ClientModifySupport {
void processClientConfigModify(ClientConfigModify clientConfigModify);
+ void processClientConfigModify(ClientConfigModify clientConfigModify, boolean onlyModifyConfig);
+
void processClientGatewaySignModify(ClientGatewaySignModify clientGatewaySignModify);
}
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 fea78aecf..29012451f 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
@@ -2899,6 +2899,16 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
+ @Override
+ public void setClientCBBankPaySurCharge(JSONObject account, String clientMoniker, boolean paySurcharge) {
+ JSONObject client = getClientInfoByMoniker(clientMoniker);
+ if (client == null) {
+ throw new InvalidShortIdException();
+ }
+ clientModifySupport.processClientConfigModify(new SwitchPermissionModify(account, clientMoniker, "cbbank_surcharge", paySurcharge), true);
+
+ }
+
@Override
public void setClientTaxInSurcharge(JSONObject account, String clientMoniker, boolean taxInSurcharge) {
JSONObject client = getClientInfoByMoniker(clientMoniker);
@@ -2906,7 +2916,6 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
throw new InvalidShortIdException();
}
clientModifySupport.processClientConfigModify(new SwitchPermissionModify(account, clientMoniker, "tax_in_surcharge", taxInSurcharge));
-
}
@Override
@@ -3434,6 +3443,21 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
.processClientConfigModify(new SwitchPermissionModify(account, client.getString("client_moniker"), "retail_surcharge", paySurcharge));
}
+ @Override
+ public void changeCBBankPaySurcharge(JSONObject account, boolean paySurcharge) {
+ int clientId = account.getIntValue("client_id");
+ JSONObject client = getClientInfo(clientId);
+ if (client == null) {
+ throw new InvalidShortIdException();
+ }
+ if (account.getIntValue("role") == 3) {
+ // cashier cannot change this config
+ throw new ForbiddenException("Cashier has no permission to switch retail surcharge");
+ }
+ clientModifySupport
+ .processClientConfigModify(new SwitchPermissionModify(account, client.getString("client_moniker"), "cbbank_surcharge", paySurcharge),true);
+ }
+
@Override
public void changeRequireCustinfo(JSONObject account, boolean requireCustinfo) {
int clientId = account.getIntValue("client_id");
diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientModifySupportImpl.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientModifySupportImpl.java
index 06b629aa9..f1a1b002b 100644
--- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientModifySupportImpl.java
+++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientModifySupportImpl.java
@@ -45,6 +45,12 @@ public class ClientModifySupportImpl implements ClientModifySupport {
clientInfoCacheSupport.clearClientCache(clientId);
}
+ @Override
+ public void processClientConfigModify(ClientConfigModify clientConfigModify,boolean onlyModifyConfig) {
+ int clientId =clientConfigModify.doModify(merchantInfoProvider, clientConfigMapper,clientMapper,mongoTemplate,onlyModifyConfig);
+ clientInfoCacheSupport.clearClientConfigCache(clientId);
+ }
+
@Override
public void processClientGatewaySignModify(ClientGatewaySignModify clientGatewaySignModify) {
int clientId =clientGatewaySignModify.doModify(merchantInfoProvider, merchantSignInfoMapper,mongoTemplate);
diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/ClientConfigModify.java b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/ClientConfigModify.java
index 0320aa2c5..18c50176c 100644
--- a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/ClientConfigModify.java
+++ b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/ClientConfigModify.java
@@ -50,6 +50,20 @@ public abstract class ClientConfigModify {
return clientId;
}
+ public int doModify(MerchantInfoProvider merchantInfoProvider, ClientConfigMapper clientConfigMapper, ClientMapper clientMapper, MongoTemplate mongoTemplate,boolean onlyModifyConfig) {
+ JSONObject clientConfig = merchantInfoProvider.getClientConfigInfoByMoniker(clientMoniker);
+ JSONObject modifyResult = getModifyResult();
+ try {
+ saveModifyHistory(clientConfig, modifyResult, mongoTemplate);
+ }catch (Exception e){
+
+ }
+ int clientId = clientConfig.getIntValue("client_id");
+ modifyResult.put("client_id", clientId);
+ clientConfigMapper.update(modifyResult);
+ return clientId;
+ }
+
private void saveModifyHistory(JSONObject client, JSONObject modifyResult,MongoTemplate mongoTemplate) {
if (account == null) {
return;
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 8d7ddadfa..1fb19d5d2 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
@@ -230,6 +230,11 @@ public class PartnerManageController {
clientManager.setClientRetailPaySurCharge(manager,clientMoniker, config.getBooleanValue("retail_surcharge"));
}
+ @ManagerMapping(value = "/{clientMoniker}/cbbank_surcharge", method = RequestMethod.PUT, role = {ManagerRole.OPERATOR, ManagerRole.ADMIN, ManagerRole.BD_USER})
+ public void setClientCBBankPaySurCharge(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager,@PathVariable String clientMoniker, @RequestBody JSONObject config) {
+ clientManager.setClientCBBankPaySurCharge(manager,clientMoniker, config.getBooleanValue("cbbank_surcharge"));
+ }
+
@ManagerMapping(value = "/{clientMoniker}/tax_in_surcharge", method = RequestMethod.PUT, role = {ManagerRole.OPERATOR, ManagerRole.ADMIN})
public void setClientTaxPayer(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager,@PathVariable String clientMoniker, @RequestBody JSONObject config) {
clientManager.setClientTaxInSurcharge(manager,clientMoniker, config.getBooleanValue("tax_in_surcharge"));
diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerViewController.java b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerViewController.java
index be7823494..58d389800 100644
--- a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerViewController.java
+++ b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerViewController.java
@@ -419,6 +419,12 @@ public class PartnerViewController {
clientManager.changeRetailPaySurcharge(account, pass.getBooleanValue("retail_surcharge"));
}
+ @PartnerMapping(value = "/cbbank_surcharge", method = RequestMethod.PUT)
+ @ResponseBody
+ public void changeCBBankPaySurCharge(@RequestBody JSONObject pass, @ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject account) {
+ clientManager.changeCBBankPaySurcharge(account, pass.getBooleanValue("cbbank_surcharge"));
+ }
+
@PartnerMapping(value = "/require_custinfo", method = RequestMethod.PUT)
@ResponseBody
public void changeRequireCustinfo(@RequestBody JSONObject pass, @ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject account) {
diff --git a/src/main/ui/static/payment/partner/partner-manage.js b/src/main/ui/static/payment/partner/partner-manage.js
index 2893d7854..67764f20a 100644
--- a/src/main/ui/static/payment/partner/partner-manage.js
+++ b/src/main/ui/static/payment/partner/partner-manage.js
@@ -1659,6 +1659,21 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter
commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'})
});
};
+ $scope.updateClientCBBankPaySurCharge = function () {
+ if (!$scope.paymentInfo) {
+ return;
+ }
+ $http.put('/sys/partners/' + $scope.partner.client_moniker + '/cbbank_surcharge', {cbbank_surcharge: $scope.paymentInfo.cbbank_surcharge}).then(function () {
+ // $scope.loadPartnerPaymentInfo();
+ }, function (resp) {
+ commonDialog.alert({
+ title: 'failed to change Customer Pay for Surcharge for Retail',
+ content: resp.data.message,
+ type: 'error'
+ })
+ })
+ }
+
$scope.updateClientApiSurCharge = function () {
if (!$scope.paymentInfo) {
return;
diff --git a/src/main/ui/static/payment/partner/partner.js b/src/main/ui/static/payment/partner/partner.js
index 3c6b279d4..b13eab1ba 100644
--- a/src/main/ui/static/payment/partner/partner.js
+++ b/src/main/ui/static/payment/partner/partner.js
@@ -999,6 +999,20 @@ define(['angular', 'decimal', 'uiRouter', 'ngBootSwitch', 'ngFileUpload','uiBoot
})
})
}
+ $scope.updateClientCBBankPaySurCharge = function () {
+ if (!$scope.paymentInfo) {
+ return;
+ }
+ $http.put('/client/partner_info/cbbank_surcharge', {cbbank_surcharge: $scope.paymentInfo.cbbank_surcharge}).then(function () {
+ // $scope.loadPartnerPaymentInfo();
+ }, function (resp) {
+ commonDialog.alert({
+ title: 'failed to change Customer Pay for Surcharge for Retail',
+ content: resp.data.message,
+ type: 'error'
+ })
+ })
+ }
$scope.toggleRequireCustInfo = function () {
if (!$scope.paymentInfo) {
return;
diff --git a/src/main/ui/static/payment/partner/templates/client_payment_info.html b/src/main/ui/static/payment/partner/templates/client_payment_info.html
index f5efdb855..62752c87d 100644
--- a/src/main/ui/static/payment/partner/templates/client_payment_info.html
+++ b/src/main/ui/static/payment/partner/templates/client_payment_info.html
@@ -444,6 +444,12 @@
+
+