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 dacf64869..1b1b54812 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
@@ -1164,6 +1164,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
checkOrgPermission(manager, client);
int clientId = client.getIntValue("client_id");
+ JSONObject org = orgMapper.findOne(client.getIntValue("org_id"));
if (config == null) {
throw new ForbiddenException(clientId + "费率参数配置不完整,请重新输入===>");
}
@@ -1174,15 +1175,22 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
config.put("update_time", new Date());
config.put("active_time", DateFormatUtils.format(config.getDate("active_time"), "yyyy-MM-dd"));
config.put("expiry_time", DateFormatUtils.format(config.getDate("expiry_time"), "yyyy-MM-dd"));
- configNewClientRate(config, clientId, "Alipay", "alipay_rate_value");
- configNewClientRate(config, clientId, "AlipayOnline", "alipayonline_rate_value");
- configNewClientRate(config, clientId, "Wechat", "wechat_rate_value");
- configNewClientRate(config, clientId, "jd", "jd_rate_value");
- configNewClientRate(config, clientId, "Bestpay", "bestpay_rate_value");
+
+ checkAddRate(config,"Wechat", "wechat_rate_value",org,"min_wechat_rate");
+ checkAddRate(config,"Alipay", "alipay_rate_value",org,"min_alipay_rate");
+ checkAddRate(config,"AlipayOnline", "alipayonline_rate_value",org,"min_alipayonline_rate");
+ checkAddRate(config,"Bestpay", "bestpay_rate_value",org,"min_bestpay_rate");
+ checkAddRate(config,"jd", "jd_rate_value",org,"min_jd_rate");
+
+ configNewClientRate(config, clientId, "Wechat", "wechat_rate_value",org,"min_wechat_rate");
+ configNewClientRate(config, clientId, "Alipay", "alipay_rate_value",org,"min_alipay_rate");
+ configNewClientRate(config, clientId, "AlipayOnline", "alipayonline_rate_value",org,"min_alipayonline_rate");
+ configNewClientRate(config, clientId, "Bestpay", "bestpay_rate_value",org,"min_bestpay_rate");
+ configNewClientRate(config, clientId, "jd", "jd_rate_value",org,"min_jd_rate");
}
- private void configNewClientRate(JSONObject config, int clientId, String channel, String rateKey) {
+ private void configNewClientRate(JSONObject config, int clientId, String channel, String rateKey,JSONObject org,String rateValueKey) {
if (config.containsKey(rateKey)) {
JSONObject newConfig = new JSONObject();
newConfig.putAll(config);
@@ -1210,6 +1218,12 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
checkOrgPermission(manager, client);
JSONObject configJson = config.toJSON();
+ JSONObject org = orgMapper.findOne(client.getIntValue("org_id"));
+ checkModifyRate(org,configJson,"Wechat","min_wechat_rate");
+ checkModifyRate(org,configJson,"Alipay","min_alipay_rate");
+ checkModifyRate(org,configJson,"AlipayOnline","min_alipayonline_rate");
+ checkModifyRate(org,configJson,"jd","min_jd_rate");
+ checkModifyRate(org,configJson,"Bestpay","min_bestpay_rate");
configJson.put("client_rate_id", rateId);
configJson.put("manager_id", manager.getString("manager_id"));
configJson.put("manager_name", manager.getString("username"));
@@ -1223,6 +1237,24 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
// clientMapper.updateCleanDays(clientId, config.getCleanDays());
}
+ private void checkModifyRate(JSONObject org,JSONObject configJson,String rateName,String rateValueKey){
+ if(configJson.getString("rate_name").equals(rateName)){
+ if(org.containsKey(rateValueKey)){
+ if(configJson.getDouble("rate_value").compareTo(org.getDouble(rateValueKey)) > 0){
+ throw new ForbiddenException("费率参数大于旗下商户最低"+rateName+"费率,请重新输入===>");
+ };
+ }
+ }
+ }
+ private void checkAddRate(JSONObject config,String channel, String rateKey,JSONObject org,String rateValueKey){
+ if(config.containsKey(rateKey)){
+ if(org.containsKey(rateValueKey)){
+ if(config.getBigDecimal(rateKey).compareTo(org.getBigDecimal(rateValueKey)) > 0){
+ throw new ForbiddenException("费率参数大于旗下商户最低"+channel+"费率,请重新输入===>");
+ };
+ }
+ }
+ }
@Override
public List listSubClients(JSONObject manager, String clientMoniker) {
diff --git a/src/main/java/au/com/royalpay/payment/manage/organizations/beans/OrgInfo.java b/src/main/java/au/com/royalpay/payment/manage/organizations/beans/OrgInfo.java
index 3eda2a10d..04b119196 100644
--- a/src/main/java/au/com/royalpay/payment/manage/organizations/beans/OrgInfo.java
+++ b/src/main/java/au/com/royalpay/payment/manage/organizations/beans/OrgInfo.java
@@ -34,6 +34,12 @@ public class OrgInfo {
private int limit = 10;
private String parent_org_id;
private String org_id;
+ private String commission_type;
+ private Double min_wechat_rate;
+ private Double min_alipay_rate;
+ private Double min_bestpay_rate;
+ private Double min_jd_rate;
+ private Double min_alipayonline_rate;
public JSONObject toJsonParam() {
JSONObject param = new JSONObject();
@@ -229,4 +235,52 @@ public class OrgInfo {
public void setOrg_id(String org_id) {
this.org_id = org_id;
}
+
+ public String getCommission_type() {
+ return commission_type;
+ }
+
+ public void setCommission_type(String commission_type) {
+ this.commission_type = commission_type;
+ }
+
+ public Double getMin_wechat_rate() {
+ return min_wechat_rate;
+ }
+
+ public void setMin_wechat_rate(Double min_wechat_rate) {
+ this.min_wechat_rate = min_wechat_rate;
+ }
+
+ public Double getMin_alipay_rate() {
+ return min_alipay_rate;
+ }
+
+ public void setMin_alipay_rate(Double min_alipay_rate) {
+ this.min_alipay_rate = min_alipay_rate;
+ }
+
+ public Double getMin_bestpay_rate() {
+ return min_bestpay_rate;
+ }
+
+ public void setMin_bestpay_rate(Double min_bestpay_rate) {
+ this.min_bestpay_rate = min_bestpay_rate;
+ }
+
+ public Double getMin_jd_rate() {
+ return min_jd_rate;
+ }
+
+ public void setMin_jd_rate(Double min_jd_rate) {
+ this.min_jd_rate = min_jd_rate;
+ }
+
+ public Double getMin_alipayonline_rate() {
+ return min_alipayonline_rate;
+ }
+
+ public void setMin_alipayonline_rate(Double min_alipayonline_rate) {
+ this.min_alipayonline_rate = min_alipayonline_rate;
+ }
}
diff --git a/src/main/ui/manage.html b/src/main/ui/manage.html
index ed66924d3..dfe950e80 100644
--- a/src/main/ui/manage.html
+++ b/src/main/ui/manage.html
@@ -191,6 +191,8 @@ margin-bottom: 10%;"/>
ng-class="{'text-orange':!('10000000000'|withRole),'text-gray':('10000000000'|withRole)}">
+
diff --git a/src/main/ui/static/config/organizations/organizations.js b/src/main/ui/static/config/organizations/organizations.js
index 175906192..7a2973e40 100644
--- a/src/main/ui/static/config/organizations/organizations.js
+++ b/src/main/ui/static/config/organizations/organizations.js
@@ -11,6 +11,13 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) {
"label": "推荐人",
"value": 1
}];
+ var commission_types = [{
+ "label": "渠道计算法",
+ "value": 1
+ }, {
+ "label": "收益比例",
+ "value": 3
+ }];
var app = angular.module('organizations', ['ui.router', 'ui.bootstrap']);
app.config(['$stateProvider', function ($stateProvider) {
$stateProvider.state('organizations', {
@@ -43,7 +50,7 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) {
}]);
app.controller('orgsCtrl', ['$scope', '$http','commonDialog', function ($scope, $http,commonDialog ) {
$scope.params = {};
- if($scope.currentUser.org_id !=null && !angular.equals({}, $scope.currentUser.org_id)) {
+ if(($scope.currentUser.role & parseInt('1000000000000', 2)) > 0 && $scope.currentUser.org_id) {
$scope.params.org_id = $scope.currentUser.org_id;
}
$scope.pagination = {};
@@ -80,8 +87,9 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) {
}]);
app.controller('orgDetailCtrl', ['$scope', '$http', '$state', 'Upload', '$uibModal','commonDialog', 'org', function ($scope, $http, $state, Upload,$uibModal,commonDialog, org) {
$scope.types = angular.copy(types);
+ $scope.commission_types = angular.copy(commission_types);
$scope.org = angular.copy(org.data);
- if ($scope.currentUser.org_id != null) {
+ if (($scope.currentUser.role & parseInt('1000000000000', 2)) > 0 && $scope.currentUser.org_id) {
$scope.org.type = 0;
}
$scope.uploadLogo = function (file) {
@@ -111,6 +119,9 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) {
});
return;
}
+ if($scope.org.type == 1){
+ $scope.org.commission_type = 2;
+ }
$http.put('/sys/orgs/' + $scope.org.org_id, $scope.org).then(function () {
commonDialog.alert({title: 'Succeed', content: 'Organization update succeeded', type: 'success'});
$state.reload();
@@ -177,8 +188,9 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) {
}]);
app.controller('orgDetailParentCtrl', ['$scope', '$http', '$state', 'Upload', '$uibModal','commonDialog', 'org', function ($scope, $http, $state, Upload,$uibModal,commonDialog, org) {
$scope.types = angular.copy(types);
+ $scope.commission_types = angular.copy(commission_types);
$scope.org = angular.copy(org.data);
- if ($scope.currentUser.org_id != null) {
+ if (($scope.currentUser.role & parseInt('1000000000000', 2)) > 0 && $scope.currentUser.org_id) {
$scope.org.type = 0;
}
$scope.uploadLogo = function (file) {
@@ -274,6 +286,7 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) {
}]);
app.controller('newOrgCtrl', ['$scope', '$http', '$state', 'Upload', 'commonDialog', function ($scope, $http, $state, Upload, commonDialog) {
$scope.types = angular.copy(types);
+ $scope.commission_types = angular.copy(commission_types);
$scope.uploadLogo = function (file) {
if (file == null) {
return;
@@ -301,7 +314,10 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) {
});
return;
}
- if($scope.currentUser.org_id !=null && !angular.equals({}, $scope.currentUser.org_id)) {
+ if($scope.org.type == 1){
+ $scope.org.commission_type = 2;
+ }
+ if(($scope.currentUser.role & parseInt('1000000000000', 2)) > 0 && $scope.currentUser.org_id) {
$scope.org.parent_org_id = angular.copy($scope.currentUser.org.org_id);
$scope.org.type = '0';
}
diff --git a/src/main/ui/static/config/organizations/templates/new_org.html b/src/main/ui/static/config/organizations/templates/new_org.html
index 0682ae4c9..6b54fde0c 100644
--- a/src/main/ui/static/config/organizations/templates/new_org.html
+++ b/src/main/ui/static/config/organizations/templates/new_org.html
@@ -65,7 +65,7 @@
+
-