From cc960e510331f974f17b02a14f9a81aea0a18c25 Mon Sep 17 00:00:00 2001 From: dalong306 <304592994@qq.com> Date: Fri, 25 Mar 2022 10:08:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E6=B8=A0=E9=81=93=E6=B8=85=E7=AE=97?= =?UTF-8?q?=20=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 10 +- src/db/modify.sql | 7 + .../manage/merchants/beans/SettleDetail.java | 118 ++++++ .../manage/merchants/core/ClientManager.java | 5 + .../core/impls/ClientChannelSettlement.java | 134 +++++++ .../core/impls/ClientManagerImpl.java | 101 ++++- .../PartnerChannelSettlementController.java | 48 +++ .../web/PartnerManageController.java | 25 ++ src/main/ui/static/css/common.css | 46 +++ .../static/payment/partner/partner-manage.js | 209 ++++++++++ .../templates/dialog_settle_day_select.html | 14 + .../templates/partner_bankaccounts.html | 365 ++++++++++++++++-- 12 files changed, 1049 insertions(+), 33 deletions(-) create mode 100644 src/main/java/au/com/royalpay/payment/manage/merchants/beans/SettleDetail.java create mode 100644 src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientChannelSettlement.java create mode 100644 src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerChannelSettlementController.java create mode 100644 src/main/ui/static/payment/partner/templates/dialog_settle_day_select.html diff --git a/pom.xml b/pom.xml index c44941411..0b591e0ae 100644 --- a/pom.xml +++ b/pom.xml @@ -5,11 +5,11 @@ au.com.royalpay.payment payment-parent - 2.3.7 + 2.3.8 4.0.0 manage - 2.4.12 + 2.4.13 UTF-8 2.4.0 @@ -242,7 +242,11 @@ commons-codec 1.12 - + + com.cronutils + cron-utils + 9.1.6 + diff --git a/src/db/modify.sql b/src/db/modify.sql index ff61f3acb..dbb2f1e46 100644 --- a/src/db/modify.sql +++ b/src/db/modify.sql @@ -781,3 +781,10 @@ ALTER TABLE `sys_clients` -- 微信子商户表 字段长度修改 2021.04.07 ALTER TABLE sys_wx_merchant_apply MODIFY merchant_name varchar(128); ALTER TABLE sys_wx_merchant_apply MODIFY merchant_shortname varchar(64); + + + +-- 添加清算规则 2022-03-21 +ALTER TABLE sys_clients add `settle_rule` varchar(20) DEFAULT '* * ?' COMMENT '清算时间规则' AFTER min_settle; +ALTER TABLE sys_clients add `settle_rule_ext` text COMMENT '清算规则扩展,分组清算规则' AFTER settle_rule; +-- 表 sys_permission_functions 字段class_name长度改为255 2022-03-21 diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/beans/SettleDetail.java b/src/main/java/au/com/royalpay/payment/manage/merchants/beans/SettleDetail.java new file mode 100644 index 000000000..76a4e562a --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/beans/SettleDetail.java @@ -0,0 +1,118 @@ +package au.com.royalpay.payment.manage.merchants.beans; + +import au.com.royalpay.payment.core.exceptions.ParamInvalidException; +import au.com.royalpay.payment.tools.merchants.beans.BalanceGroup; +import com.alibaba.fastjson.annotation.JSONField; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; +import java.math.BigDecimal; + +/** + * Create by yixian at 2018-01-07 22:25 + */ +public class SettleDetail { + private Integer hour; + @JSONField(name = "rule_type") + @Pattern(regexp = "^(DAY_OF_MONTH)|(DAY_OF_WEEK)$", message = "Invalid Rule Type") + @NotNull(message = "error.payment.valid.param_missing") + private String rule_type; + + private String rule; + private boolean manual; + private boolean everyday; + private BigDecimal min = BigDecimal.ZERO; + private int max_settle_days; + + private String group= BalanceGroup.RPAY_SVC_CARD.toString(); + + public String ruleToCron() { + if (everyday) { + return "* * ?"; + } + if (!manual && rule_type == null) { + throw new ParamInvalidException("rule_type", "error.payment.valid.param_missing"); + } + if (rule_type != null) { + switch (rule_type) { + case "DAY_OF_MONTH": + return rule + " * ?"; + case "DAY_OF_WEEK": + return "? * " + rule; + default: + throw new ParamInvalidException("rule_type", "Invalid Rule Type"); + } + } + return null; + } + + public Integer getHour() { + return hour; + } + + public SettleDetail setHour(Integer hour) { + this.hour = hour; + return this; + } + + public String getRule_type() { + return rule_type; + } + + public SettleDetail setRule_type(String rule_type) { + this.rule_type = rule_type; + return this; + } + + public String getRule() { + return rule; + } + + public SettleDetail setRule(String rule) { + this.rule = rule; + return this; + } + + public BigDecimal getMin() { + return min; + } + + public SettleDetail setMin(BigDecimal min) { + this.min = min; + return this; + } + + public boolean isManual() { + return manual; + } + + public SettleDetail setManual(boolean manual) { + this.manual = manual; + return this; + } + + public boolean isEveryday() { + return everyday; + } + + public SettleDetail setEveryday(boolean everyday) { + this.everyday = everyday; + return this; + } + + public int getMax_settle_days() { + return max_settle_days; + } + + public void setMax_settle_days(int max_settle_days) { + this.max_settle_days = max_settle_days; + } + + public String getGroup() { + return group; + } + + public void setGroup(String group) { + this.group = group; + } +} 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 2ba0bc925..4a36c272b 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 @@ -619,4 +619,9 @@ public interface ClientManager { JSONObject getApsKycClient(JSONObject account, String clientMoniker); void updateApsKycClient(JSONObject account, JSONObject item); + + JSONObject getSettleConfig(String clientMoniker, JSONObject manager); + + void configSettleDetail(JSONObject manager, String clientMoniker, SettleDetail settleDetail); + } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientChannelSettlement.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientChannelSettlement.java new file mode 100644 index 000000000..5cf6c8085 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientChannelSettlement.java @@ -0,0 +1,134 @@ +package au.com.royalpay.payment.manage.merchants.core.impls; + +import au.com.royalpay.payment.manage.mappers.system.ClientMapper; +import au.com.royalpay.payment.manage.merchants.beans.SettleDetail; +import au.com.royalpay.payment.manage.merchants.core.ClientInfoCacheSupport; +import au.com.royalpay.payment.manage.merchants.core.ClientManager; +import au.com.royalpay.payment.tools.env.PlatformEnvironment; +import au.com.royalpay.payment.tools.utils.CurrencyAmountUtils; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.cronutils.model.Cron; +import com.cronutils.model.CronType; +import com.cronutils.model.definition.CronDefinition; +import com.cronutils.model.definition.CronDefinitionBuilder; +import com.cronutils.model.field.CronFieldName; +import com.cronutils.parser.CronParser; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.math.BigDecimal; + +/** + * 分渠道清算服务 + */ +@Component +public class ClientChannelSettlement { + + private final Logger logger = LoggerFactory.getLogger(getClass()); + + @Autowired + private ClientManager clientManager; + + @Resource + private ClientMapper clientMapper; + +// @Autowired +// private ClientManagerApplication application; + + @Resource + private ClientInfoCacheSupport clientInfoCacheSupport; + + + public JSONObject getClientChannelSettleConfig(String clientMoniker, JSONObject manager, String group) { + JSONObject client = clientManager.getClientInfoByMoniker(clientMoniker); + JSONObject card = this.getGroup(client, group); + if (card == null) { + return null; + } + String settleRule = card.getString("date_rule"); + String minSettle = card.getString("min_settle"); + JSONObject config = new JSONObject(); + config.put("max_settle_days", card.getInteger("max_settle_days")); + config.put("min", new BigDecimal(minSettle).toPlainString()); + if ("* * ?".equals(settleRule)) { + config.put("everyday", true); + } else { + config.put("everyday", false); + CronDefinition cronDefinition = + CronDefinitionBuilder.instanceDefinitionFor(CronType.QUARTZ); + CronParser parser = new CronParser(cronDefinition); + Cron cron = parser.parse("0 0 0 " + settleRule); + if (settleRule.startsWith("? * ")) { + String dayOfWeek = cron.retrieve(CronFieldName.DAY_OF_WEEK).getExpression().asString(); + logger.info("DAY_OF_WEEK CRON => " + dayOfWeek); + config.put("rule_type", "DAY_OF_WEEK"); + config.put("days", dayOfWeek.split(",")); + } + if (settleRule.endsWith(" * ?")) { + String dayOfMon = cron.retrieve(CronFieldName.DAY_OF_MONTH).getExpression().asString(); + logger.info("DAY_OF_WEEK CRON => " + dayOfMon); + config.put("rule_type", "DAY_OF_MONTH"); + config.put("days", dayOfMon.split(",")); + } + } + logger.info("=====>getClientChannelSettleConfig:{}",config.toJSONString()); + return config; + } + + public void configClientChannelSettleDetails(JSONObject manager, String clientMoniker, SettleDetail detail) { + JSONObject client = clientManager.getClientInfoByMoniker(clientMoniker); + JSONArray ruleExt = client.getJSONArray("settle_rule_ext"); + if (ruleExt == null) { + ruleExt = new JSONArray(); + JSONObject object = new JSONObject(); + this.setSettleRuleExt(detail, object); + ruleExt.add(object); + } else { + JSONObject card = this.getGroup(client, detail.getGroup()); + if (card == null) { + JSONObject object = new JSONObject(); + this.setSettleRuleExt(detail, object); + ruleExt.add(object); + } else { + ruleExt.remove(card); + this.setSettleRuleExt(detail, card); + ruleExt.add(card); + } + } + + JSONObject update = new JSONObject(); + update.put("client_id", client.getIntValue("client_id")); + logger.info("SETTLE RULE EXT => " + ruleExt.toString()); + update.put("settle_rule_ext", ruleExt.toString()); + clientMapper.update(update); + + clientInfoCacheSupport.clearClientCache(client.getIntValue("client_id")); + } + + private void setSettleRuleExt(SettleDetail detail, JSONObject object) { + object.put("date_rule", detail.ruleToCron()); + object.put("min_settle", CurrencyAmountUtils.scale(detail.getMin(), PlatformEnvironment.getEnv().getForeignCurrency())); + object.put("group", detail.getGroup()); +// object.put("max_settle_days", detail.getMax_settle_days()); //max_settle_days 在rp中去掉 + } + + private JSONObject getGroup(JSONObject client, String group) { + JSONArray ruleExt = client.getJSONArray("settle_rule_ext"); + if (ruleExt == null) { + return null; + } + for (Object o : ruleExt) { + JSONObject item = (JSONObject) o; + if (group.equalsIgnoreCase(item.getString("group"))) { + return item; + } + } + return null; + } + +} 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 c67591083..b905f8284 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 @@ -177,7 +177,12 @@ import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; - +import com.cronutils.model.Cron; +import com.cronutils.model.CronType; +import com.cronutils.model.definition.CronDefinition; +import com.cronutils.model.definition.CronDefinitionBuilder; +import com.cronutils.model.field.CronFieldName; +import com.cronutils.parser.CronParser; import static au.com.royalpay.payment.manage.permission.utils.OrgCheckUtils.checkOrgPermission; /** @@ -7496,5 +7501,99 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid representativeInfo.put("marketing_wechatid", partner.getString("marketing_wechatid")); sysClientLegalPersonMapper.save(representativeInfo); } + @Override + public JSONObject getSettleConfig(String clientMoniker, JSONObject manager) { + JSONObject client = getClientInfoByMoniker(clientMoniker); + if (client == null) { + throw new InvalidShortIdException(); + } + return getSettleConfigIgnoreValid(client, manager); + } + + /** + * 获取清算配置抽离出来 + * + * @param client + * @param manager + * @return + */ + private JSONObject getSettleConfigIgnoreValid(JSONObject client, JSONObject manager) { + OrgCheckUtils.checkOrgPermission(manager, client); + JSONObject clientConfig = clientConfigService.find(client.getIntValue("client_id")); + JSONObject config = new JSONObject(); + config.put("enable_cross_payment",clientConfig.getBoolean("enable_cross_payment")); + config.put("enable_card_payment",clientConfig.getBoolean("enable_card_payment")); + config.put("manual", client.getBooleanValue("manual_settle") ); + config.put("min", client.getBigDecimal("min_settle")); + config.put("settle_hour", client.getInteger("settle_hour")); + if (clientConfig == null) { + clientConfig = new JSONObject(); + clientConfig.put("client_id", client.getIntValue("client_id")); + clientConfig.put("terminal_charge_rule", "1 * ?"); + clientConfig.put("terminal_charge_skip", 1); + clientConfig.put("free_charge_amount", 0); + clientConfig.put("terminal_per_amount", 0); + clientConfig.put("creation_date", new Date()); + clientConfig.put("creation_by", "System"); + clientConfig.put("last_update_date", new Date()); + clientConfig.put("enable_org_rate_value", 0); + clientConfig.put("ladder_charge", 0); + clientConfig.put("max_settle_days", 0); + clientConfigService.save(clientConfig); + } +// config.put("max_settle_days", clientConfig.getInteger("max_settle_days")); + String settleRule = client.getString("settle_rule"); + if ("* * ?".equals(settleRule)) { + config.put("everyday", true); + } else { + config.put("everyday", false); + CronDefinition cronDefinition = + CronDefinitionBuilder.instanceDefinitionFor(CronType.QUARTZ); + CronParser parser = new CronParser(cronDefinition); + Cron cron = parser.parse("0 0 0 " + settleRule); + if (settleRule.startsWith("? * ")) { + String dayOfWeek = cron.retrieve(CronFieldName.DAY_OF_WEEK).getExpression().asString(); +// logger.info("DAY_OF_WEEK CRON => " + dayOfWeek); + config.put("rule_type", "DAY_OF_WEEK"); + config.put("days", dayOfWeek.split(",")); + } + if (settleRule.endsWith(" * ?")) { + String dayOfMon = cron.retrieve(CronFieldName.DAY_OF_MONTH).getExpression().asString(); +// logger.info("DAY_OF_WEEK CRON => " + dayOfMon); + config.put("rule_type", "DAY_OF_MONTH"); + config.put("days", dayOfMon.split(",")); + } + } + logger.info("=====>config:"+config.toJSONString()); + return config; + } + @Override + public void configSettleDetail(JSONObject manager, String clientMoniker, SettleDetail detail) { + JSONObject client = getClientInfoByMoniker(clientMoniker); + if (client == null) { + throw new InvalidShortIdException(); + } + OrgCheckUtils.checkOrgPermission(manager, client); + logger.info(manager.getString("username") + " changed settle hour to " + detail.getHour()); + JSONObject update = new JSONObject(); + update.put("client_id", client.getIntValue("client_id")); + update.put("settle_hour", detail.getHour()); + update.put("settle_rule", detail.ruleToCron()); +// if (detail.isManual()) { +// update.put("allow_settle", 1); +// update.put("skip_clearing", 1); +// } + update.put("min_settle", CurrencyAmountUtils.scale(detail.getMin(), PlatformEnvironment.getEnv().getForeignCurrency())); + clientMapper.update(update); + logger.info("=====>update:{}",update.toJSONString()); + +// JSONObject clientConfig = clientConfigService.find(client.getIntValue("client_id")); +// clientConfig.put("max_settle_days", detail.getMax_settle_days()); +// clientConfigService.update(clientConfig); + + clientInfoCacheSupport.clearClientCache(client.getIntValue("client_id")); + + } + } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerChannelSettlementController.java b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerChannelSettlementController.java new file mode 100644 index 000000000..889fd689c --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerChannelSettlementController.java @@ -0,0 +1,48 @@ +package au.com.royalpay.payment.manage.merchants.web; + +import au.com.royalpay.payment.manage.merchants.beans.SettleDetail; +import au.com.royalpay.payment.manage.merchants.core.impls.ClientChannelSettlement; +import au.com.royalpay.payment.manage.permission.manager.ManagerMapping; +import au.com.royalpay.payment.tools.CommonConsts; +import au.com.royalpay.payment.tools.permission.enums.ManagerRole; +import com.alibaba.fastjson.JSONObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +/** + * 分渠道清算规则配置资源 + */ +@RestController +@RequestMapping("/sys/partners/{clientMoniker}/channel_settle_config") +public class PartnerChannelSettlementController { + + @Autowired + private ClientChannelSettlement channelSettlement; + + /** + * 结算规则配置详情 + * + * @param clientMoniker + * @param manager + * @return + */ + @ManagerMapping(method = RequestMethod.GET) + public JSONObject getClientChannelSettleConfig(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @RequestParam(value = "group") String group) { + return channelSettlement.getClientChannelSettleConfig(clientMoniker, manager, group); + } + + + /** + * 设置结算规则配置 + * + * @param clientMoniker + * @param settleDetail + * @param manager + */ + @ManagerMapping(method = RequestMethod.PUT, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR, ManagerRole.FINANCIAL_STAFF}) + public void configClientChannelSettleDetails(@PathVariable String clientMoniker, @RequestBody SettleDetail settleDetail, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { + channelSettlement.configClientChannelSettleDetails(manager, clientMoniker, settleDetail); + } + + +} 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 4ded773f3..5f847b1f1 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 @@ -1095,4 +1095,29 @@ public class PartnerManageController { result.put("response_str", clientManager.queryAlipayPlusOnlineStatus(true,clientMoniker, manager)); return result; } + + /** + * 结算规则配置详情 + * + * @param clientMoniker + * @param manager + * @return + */ + @ManagerMapping(value = "/{clientMoniker}/settle_config", method = RequestMethod.GET) + public JSONObject getClientSettleConfig(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { + return clientManager.getSettleConfig(clientMoniker, manager); + } + + /** + * 设置结算规则配置 + * + * @param clientMoniker + * @param settleDetail + * @param manager + */ +// @PartnerChangesLog(description = "配置解决细节") + @ManagerMapping(value = "/{clientMoniker}/settle_config", method = RequestMethod.PUT, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR, ManagerRole.FINANCIAL_STAFF}) + public void configSettleDetails(@PathVariable String clientMoniker, @RequestBody SettleDetail settleDetail, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { + clientManager.configSettleDetail(manager, clientMoniker, settleDetail); + } } diff --git a/src/main/ui/static/css/common.css b/src/main/ui/static/css/common.css index 90b7f7930..a2f5656a5 100644 --- a/src/main/ui/static/css/common.css +++ b/src/main/ui/static/css/common.css @@ -874,3 +874,49 @@ .menu-group .is-hide { display: none; } + + +.date-box { + display: block; + margin: -5px; +} + +.date-box:after { + content: ''; + display: block; + clear: both; +} + +.date-box > .day { + position: relative; + float: left; + display: block; + width: 40px; + height: 40px; + margin: 5px; + text-align: center; + font-size: 26px; + line-height: 40px; +} + +.date-box > .day > .del-btn { + position: absolute; + opacity: 0; + top: 0; + left: 0; + width: 100%; + height: 100%; + background: rgba(0, 0, 0, .4); + color: #fff; + font-size: 26px; + line-height: 40px; + -webkit-transition: opacity 0.5s; + -moz-transition: opacity 0.5s; + -ms-transition: opacity 0.5s; + -o-transition: opacity 0.5s; + transition: opacity 0.5s; +} + +.date-box > .day:hover > .del-btn{ + opacity: 1; +} \ 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 ee5562f0f..7f495bfb6 100644 --- a/src/main/ui/static/payment/partner/partner-manage.js +++ b/src/main/ui/static/payment/partner/partner-manage.js @@ -3161,18 +3161,227 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter $scope.bankCtrl = {edit: true, rate_name: 'Wechat', modify_min_settle: false} $scope.cardBankCtrl = {edit: true, rate_name: 'rpaypmt_card', modify_min_settle: false} $scope.apsBankCtrl = {edit: true, rate_name: 'ApsInStore', modify_min_settle: false} + $scope.settle_rule_form = {edit: false} $scope.init = { skip_clearing: false, tax_in_surcharge: false, customer_tax_free: false, allow_surcharge_credit: false, } + $scope.loadSettleRule = function () { + $http.get("/sys/partners/" + $scope.partner.client_moniker + "/settle_config").then(function (resp) { + $scope.settleRule = resp.data + + }) + } + $scope.loadSettleRule() $scope.getBankAccount = function () { $http.get('/sys/partners/' + $scope.partner.client_moniker + '/bank_account').then(function (resp) { $scope.bankaccount = resp.data $scope.bankCtrl.edit = false }) } + $scope.toggleSettleRuleDay = function (day) { + var $idx = $scope.settleRule.days.indexOf(day) + if ($idx >= 0) { + $scope.settleRule.days.splice($idx, 1) + } else { + $scope.settleRule.days.push(day) + $scope.settleRule.days.sort() + } + } + $scope.settleAddDay = function () { + $uibModal + .open({ + templateUrl: "/static/payment/partner/templates/dialog_settle_day_select.html", + size: "lg", + controller: [ + "$scope", + "chosenDays", + function ($scope, chosenDays) { + $scope.chosenDays = chosenDays + $scope.formData = {} + $scope.availableDays = [] + for (var d = 1; d <= 31; d++) { + $scope.availableDays.push(d) + } + $scope.choose = function () { + $scope.$close($scope.formData.chosenDay) + } + }, + ], + resolve: { + chosenDays: function () { + return $scope.settleRule.days + }, + }, + }) + .result.then(function (day) { + $scope.toggleSettleRuleDay(day) + }) + } + $scope.submitSettleRule = function () { + var config = angular.copy($scope.settleRule) + config.rule = !config.manual && !config.everyday ? config.days.join(",") : null + if (!config.manual && !config.everyday) { + if (config.days.length == 0) { + commonDialog.alert({ + title: "Error", + content: "请选择结算日", + type: "error", + }) + return + } + } + $http.put("/sys/partners/" + $scope.partner.client_moniker + "/settle_config", config).then( + function (resp) { + commonDialog.alert({ + title: "Success", + content: "Rule Updated", + type: "success", + }) + $state.reload() + }, + function (resp) { + commonDialog.alert({ + title: "Error", + content: resp.data.message, + type: "error", + }) + $state.reload() + } + ) + } + $scope.cancelSettleRule = function () { + $scope.loadSettleRule() + $scope.settle_rule_form.edit = false + } + // 卡支付结算规则配置 + $scope.statusCtrl = { + isShowSwitchButton: true, // switch + isCanEdit: true, // 控制是否可编辑 + isShowSettings: true, // 是否显示配置 + } + // 加载按钮 + $scope.loadSwitchButton = function () { + $("input[name='switch']").bootstrapSwitch({ + onText: "ON", + offText: "OFF", + size: "mini", + state: $scope.statusCtrl.isShowSettings, + onSwitchChange: function (event, state) { + //监听switch change事件,可以根据状态把相应的业务逻辑代码写在这里 + $scope.statusCtrl.isShowSettings = state + $scope.statusCtrl.isCanEdit = state + $scope.$applyAsync() + }, + }) + } + // 初始化数据 + $scope.loadCardSettings = function () { + $http.get("/sys/partners/" + $scope.partner.client_moniker + "/channel_settle_config?group=RPAY_SVC_CARD").then(function (resp) { + if (resp.data) { + $scope.cardSettings = resp.data + $scope.statusCtrl.isShowSwitchButton = false + $scope.statusCtrl.isCanEdit = false + } else { + $scope.statusCtrl.isShowSettings = false + $scope.loadSwitchButton() + $scope.cardSettings = { + max_settle_days: null, + min: 0, + rule_type: "DAY_OF_WEEK", + days: [], + manual: false, + settle_hour: null, + everyday: false, + } + } + }) + } + $scope.loadCardSettings() + // 选择日期 + $scope.toggleCardSettingsDay = function (day) { + var $idx = $scope.cardSettings.days.indexOf(day) + if ($idx >= 0) { + $scope.cardSettings.days.splice($idx, 1) + } else { + $scope.cardSettings.days.push(day) + $scope.cardSettings.days.sort() + } + } + // 选择月结算日 + $scope.setMonthSomeday = function () { + $uibModal + .open({ + templateUrl: "/static/payment/partner/templates/dialog_settle_day_select.html", + size: "lg", + controller: [ + "$scope", + "chosenDays", + function ($scope, chosenDays) { + $scope.chosenDays = chosenDays + $scope.formData = {} + $scope.availableDays = [] + for (var d = 1; d <= 31; d++) { + $scope.availableDays.push(d) + } + $scope.choose = function () { + $scope.$close($scope.formData.chosenDay) + } + }, + ], + resolve: { + chosenDays: function () { + return $scope.cardSettings.days + }, + }, + }) + .result.then(function (day) { + $scope.toggleCardSettingsDay(day) + }) + } + // 保存设置 + $scope.submitCardSettings = function () { + var config = angular.copy($scope.cardSettings) + config.group = "RPAY_SVC_CARD" + config.rule = !config.manual && !config.everyday ? config.days.join(",") : null + if (!config.manual && !config.everyday) { + if (config.days.length == 0) { + commonDialog.alert({ + title: "Error", + content: "请选择结算日", + type: "error", + }) + return + } + } + $http.put("/sys/partners/" + $scope.partner.client_moniker + "/channel_settle_config", config).then( + function (resp) { + commonDialog.alert({ + title: "Success", + content: "Rule Updated", + type: "success", + }) + $scope.loadCardSettings() + }, + function (resp) { + commonDialog.alert({ + title: "Error", + content: resp.data.message, + type: "error", + }) + } + ) + } + // 取消 + $scope.cancelCardSettings = function () { + if ($scope.statusCtrl.isShowSwitchButton) { + $("#switch").bootstrapSwitch("toggleState") + } + $scope.statusCtrl.isCanEdit = false + $scope.loadCardSettings() + } $scope.switchSurchargeMode = function () { if ($scope.partner.surcharge_mode === 'balance') { commonDialog diff --git a/src/main/ui/static/payment/partner/templates/dialog_settle_day_select.html b/src/main/ui/static/payment/partner/templates/dialog_settle_day_select.html new file mode 100644 index 000000000..611a5eb50 --- /dev/null +++ b/src/main/ui/static/payment/partner/templates/dialog_settle_day_select.html @@ -0,0 +1,14 @@ + + + \ No newline at end of file diff --git a/src/main/ui/static/payment/partner/templates/partner_bankaccounts.html b/src/main/ui/static/payment/partner/templates/partner_bankaccounts.html index de1d6507a..470f68e0d 100644 --- a/src/main/ui/static/payment/partner/templates/partner_bankaccounts.html +++ b/src/main/ui/static/payment/partner/templates/partner_bankaccounts.html @@ -3,35 +3,49 @@ width: 95%; float: left; } + .panel-heading-new { + background-image: -webkit-linear-gradient(top, #d9edf7 0%, #c4e3f3 100%); + background-image: -o-linear-gradient(top, #d9edf7 0%, #c4e3f3 100%); + background-image: -webkit-gradient(linear, left top, left bottom, from(#d9edf7), to(#c4e3f3)); + background-image: linear-gradient(to bottom, #d9edf7 0%, #c4e3f3 100%); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9edf7', endColorstr='#ffc4e3f3', GradientType=0); + background-repeat: repeat-x; + color: #31708f; + background-color: #d9edf7; + border-color: #bce8f1; + padding: 10px 15px; + border-bottom: 1px solid transparent; + border-top-left-radius: 3px; + border-top-right-radius: 3px; + } -
-
-

Bank Account - - - -

+
+
+

+ Settle Rule Config + +

+
- -
+ +

{{surcharge.balance | currency:'AUD'}}

- -
+ +
- -
+ +

balance

- -
+ +
- -
+ +
- -
+ +
- -
+ +
- -
+ +

AU${{partner.min_settle || 'Not Configure'}} @@ -101,15 +115,308 @@

- -
-

- Y - N + +

+

+ Y + N

+
+
+
+

+ Cross Payment Settle Rule Config + + +

+
+
+
+ + + + + + + + + + + + + + +
+
+ +
+ Everyday +
+
+
+ +
+ +
+
+
+
+ +
+ Every Month + Every Week +
+
+ +
+
+
+ +
+ Sunday + + Monday + + Tuesday + Wednesday + Thursday + + Friday + Saturday +
+
+
+ + + + + + + +
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+ +
+ +
+
+ + + + + + + + + +
+
+ + + + +
+
+
+

+ Card Payment Settle Rule Config + + + + + +

+
+
+
+
+
+ +
+ Everyday +
+
+
+ +
+ +
+
+
+
+ +
+ Every Month + Every Week +
+
+ +
+
+
+ +
+ Sunday + + Monday + + Tuesday + Wednesday + Thursday + + Friday + Saturday +
+
+
+ + + + + + + +
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+ +
+ +
+
+ + +
+
+ +
+
+
+
+

Bank Account + + + +

+
+ +