From 2ac7c7acec4339bf36298a8f395d40f748ee13c7 Mon Sep 17 00:00:00 2001 From: luoyang Date: Thu, 28 Feb 2019 09:53:57 +0800 Subject: [PATCH 1/6] =?UTF-8?q?fix=20=E8=BF=87=E6=BB=A4=E6=8E=89=E5=90=88?= =?UTF-8?q?=E4=BC=99=E4=BA=BABD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../royalpay/payment/manage/mappers/system/ManagerMapper.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/system/ManagerMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ManagerMapper.java index 2c9b2b25c..3a5ce6bcb 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/system/ManagerMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ManagerMapper.java @@ -65,9 +65,9 @@ public interface ManagerMapper { List listServants(@Param("mask") int mask); - @Select("select email from sys_managers where is_valid=1 AND (role & 256 > 0 OR role & 4 > 0) AND email IS NOT NULL") + @Select("select email from sys_managers where is_valid=1 AND (role & 256 > 0 OR role & 4 > 0) AND (org_id = 1 or org_id is null) AND email IS NOT NULL") List listDevAndBdManager(); - @Select("select wx_openid from sys_managers where is_valid=1 AND (role & 256 > 0 OR role & 4 > 0) AND wx_openid IS NOT NULL") + @Select("select wx_openid from sys_managers where is_valid=1 AND (role & 256 > 0 OR role & 4 > 0) AND (org_id = 1 or org_id is null) AND wx_openid IS NOT NULL") List listDevAndBdOpenId(); } From 4868fd37063de827e1c865ebe00700ccc5768368 Mon Sep 17 00:00:00 2001 From: yangkai Date: Wed, 6 Mar 2019 09:26:34 +0800 Subject: [PATCH 2/6] =?UTF-8?q?bd=E6=8F=90=E6=88=90=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c394163c9..94a2f7150 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ au.com.royalpay.payment payment-parent - 0.2.0-dev + 0.2.0 4.0.0 From fc653ca1f90f270057ecb26a6373b7786c1c0502 Mon Sep 17 00:00:00 2001 From: luoyang Date: Wed, 6 Mar 2019 15:46:50 +0800 Subject: [PATCH 3/6] =?UTF-8?q?add=20=E5=90=8E=E6=B8=85=E7=AE=97=20?= =?UTF-8?q?=E6=94=B6=E6=94=AF=E5=88=86=E7=A6=BB=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ClearingDistributedSurchargeMapper.java | 27 +++ .../ClientsSurchargeAccountsMapper.java | 25 +++ ...FinancialSurchargeAccountDetailMapper.java | 28 +++ .../manage/merchants/core/ClientManager.java | 14 ++ .../core/impls/ClientManagerImpl.java | 164 ++++++++++++--- .../entity/impls/SurchargeModeModify.java | 29 +++ .../web/PartnerManageController.java | 34 +++ .../merchants/web/PartnerViewController.java | 12 ++ .../core/SurchargeAccountService.java | 14 ++ .../impl/SurchargeAccountServiceImpl.java | 66 ++++++ .../web/SurchargeAccountController.java | 30 +++ .../task/SurchargeAccountMonthTask.java | 27 +++ .../ClearingDistributedSurchargeMapper.xml | 31 +++ .../FinancialSurchargeAccountDetailMapper.xml | 27 +++ src/main/ui/index.html | 9 + src/main/ui/manage.html | 5 + src/main/ui/static/boot/index-boot.js | 1 + .../static/payment/partner/partner-manage.js | 195 +++++++++++++++++- .../templates/partner_bankaccounts.html | 31 +++ .../partner/templates/partner_detail.html | 5 + .../templates/partner_surcharge_account.html | 111 ++++++++++ .../partner-surcharge-account.js | 149 +++++++++++++ .../templates/account_month_logs.html | 76 +++++++ .../templates/client_surcharge_account.html | 114 ++++++++++ .../partner_surcharge_account_dialog.html | 88 ++++++++ 25 files changed, 1285 insertions(+), 27 deletions(-) create mode 100644 src/main/java/au/com/royalpay/payment/manage/mappers/system/ClearingDistributedSurchargeMapper.java create mode 100644 src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientsSurchargeAccountsMapper.java create mode 100644 src/main/java/au/com/royalpay/payment/manage/mappers/system/FinancialSurchargeAccountDetailMapper.java create mode 100644 src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/SurchargeModeModify.java create mode 100644 src/main/java/au/com/royalpay/payment/manage/surchargeAccount/core/SurchargeAccountService.java create mode 100644 src/main/java/au/com/royalpay/payment/manage/surchargeAccount/core/impl/SurchargeAccountServiceImpl.java create mode 100644 src/main/java/au/com/royalpay/payment/manage/surchargeAccount/web/SurchargeAccountController.java create mode 100644 src/main/java/au/com/royalpay/payment/manage/task/SurchargeAccountMonthTask.java create mode 100644 src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClearingDistributedSurchargeMapper.xml create mode 100644 src/main/resources/au/com/royalpay/payment/manage/mappers/system/FinancialSurchargeAccountDetailMapper.xml create mode 100644 src/main/ui/static/payment/partner/templates/partner_surcharge_account.html create mode 100644 src/main/ui/static/payment/surchargeaccount/partner-surcharge-account.js create mode 100644 src/main/ui/static/payment/surchargeaccount/templates/account_month_logs.html create mode 100644 src/main/ui/static/payment/surchargeaccount/templates/client_surcharge_account.html create mode 100644 src/main/ui/static/payment/surchargeaccount/templates/partner_surcharge_account_dialog.html diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClearingDistributedSurchargeMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClearingDistributedSurchargeMapper.java new file mode 100644 index 000000000..9ee7f24e5 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClearingDistributedSurchargeMapper.java @@ -0,0 +1,27 @@ +package au.com.royalpay.payment.manage.mappers.system; + +import cn.yixblog.support.mybatis.autosql.annotations.AdvanceSelect; +import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper; +import cn.yixblog.support.mybatis.autosql.annotations.AutoSql; +import cn.yixblog.support.mybatis.autosql.annotations.SqlType; +import com.alibaba.fastjson.JSONObject; +import org.apache.ibatis.annotations.Param; + +import java.util.Date; +import java.util.List; + + +@AutoMapper(tablename = "log_clearing_distributed_surcharge", pkName = "log_id") +public interface ClearingDistributedSurchargeMapper { + + List findTransactions(@Param("client_id") int clientId); + + @AutoSql(type = SqlType.INSERT) + void save(JSONObject transactions); + + List getMonthDetailByClientId(@Param("datefrom") Date datefrom, @Param("dateto") Date dateto); + + List findTransactionsByDate(JSONObject params); + + +} diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientsSurchargeAccountsMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientsSurchargeAccountsMapper.java new file mode 100644 index 000000000..2e28ec96b --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientsSurchargeAccountsMapper.java @@ -0,0 +1,25 @@ +package au.com.royalpay.payment.manage.mappers.system; + +import cn.yixblog.support.mybatis.autosql.annotations.AdvanceSelect; +import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper; +import cn.yixblog.support.mybatis.autosql.annotations.AutoSql; +import cn.yixblog.support.mybatis.autosql.annotations.SqlType; +import com.alibaba.fastjson.JSONObject; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + + +@AutoMapper(tablename = "sys_clients_surcharge_accounts", pkName = "client_id") +public interface ClientsSurchargeAccountsMapper { + + @AutoSql(type = SqlType.SELECT) + @AdvanceSelect(addonWhereClause = "is_valid=1") + JSONObject find(@Param("client_id") int clientId); + + @AutoSql(type = SqlType.INSERT) + void save(JSONObject surchargeAccount); + + @AutoSql(type = SqlType.UPDATE) + void update(JSONObject surchargeAccount); +} diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/system/FinancialSurchargeAccountDetailMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/system/FinancialSurchargeAccountDetailMapper.java new file mode 100644 index 000000000..627d47cbe --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/system/FinancialSurchargeAccountDetailMapper.java @@ -0,0 +1,28 @@ +package au.com.royalpay.payment.manage.mappers.system; + +import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper; +import cn.yixblog.support.mybatis.autosql.annotations.AutoSql; +import cn.yixblog.support.mybatis.autosql.annotations.SqlType; +import com.alibaba.fastjson.JSONObject; +import org.apache.ibatis.annotations.Param; + +import java.util.Date; +import java.util.List; + + +@AutoMapper(tablename = "financial_surcharge_account_detail", pkName = "detail_id") +public interface FinancialSurchargeAccountDetailMapper { + + List findDetailsByMonth(@Param("settle_month") String settle_month); + + List findDetailsByClientId(@Param("client_id") int client_id); + + @AutoSql(type = SqlType.INSERT) + void save(JSONObject detail); + + List listSettlementDatesInMonth(@Param("month") String month); + + + +} + 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 44511c48a..76e4bf096 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 @@ -273,6 +273,20 @@ public interface ClientManager { void setSkipClearing(JSONObject account,String clientMoniker, Boolean skip_clearing,String remark); + void setSurchargeMode(JSONObject account, String clientMoniker, String surcharge_mode); + + JSONObject surchargeAccount(JSONObject account, String clientMoniker); + + void setAllowSurchargeCredit(JSONObject account,String clientMoniker, Boolean allow_surcharge_credit); + + List getAccountTransactions(JSONObject account,String clientMoniker); + + List getAccountTransactionsByDate(JSONObject account,String clientMoniker, String date); + + List getAccountMonthDetails(JSONObject account,String clientMoniker); + + void saveAccountTransaction(JSONObject account,String clientMoniker, JSONObject transaction); + void enableGatewayUpgrade(JSONObject account,String clientMoniker, boolean gatewayUpgrade); void enableGatewayAlipayOnline(JSONObject account,String clientMoniker, boolean gatewayAlipayOnline); 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 fd119646a..3f22c33e5 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 @@ -45,25 +45,7 @@ import au.com.royalpay.payment.manage.merchants.core.ClientConfigService; import au.com.royalpay.payment.manage.merchants.core.ClientInfoCacheSupport; import au.com.royalpay.payment.manage.merchants.core.ClientManager; import au.com.royalpay.payment.manage.merchants.core.ClientModifySupport; -import au.com.royalpay.payment.manage.merchants.entity.impls.ApproveEmailModify; -import au.com.royalpay.payment.manage.merchants.entity.impls.AuditModify; -import au.com.royalpay.payment.manage.merchants.entity.impls.BDUserModify; -import au.com.royalpay.payment.manage.merchants.entity.impls.ClearDaysModify; -import au.com.royalpay.payment.manage.merchants.entity.impls.CredentialCodeModify; -import au.com.royalpay.payment.manage.merchants.entity.impls.CustomerSurchargeRateModify; -import au.com.royalpay.payment.manage.merchants.entity.impls.DisableModify; -import au.com.royalpay.payment.manage.merchants.entity.impls.EmailModify; -import au.com.royalpay.payment.manage.merchants.entity.impls.GreenChannelModify; -import au.com.royalpay.payment.manage.merchants.entity.impls.MaxOrderAmountModify; -import au.com.royalpay.payment.manage.merchants.entity.impls.OpenStatusModify; -import au.com.royalpay.payment.manage.merchants.entity.impls.OrderExpiryModify; -import au.com.royalpay.payment.manage.merchants.entity.impls.ParentIdModify; -import au.com.royalpay.payment.manage.merchants.entity.impls.PaypadVersionModify; -import au.com.royalpay.payment.manage.merchants.entity.impls.RefundAuditModify; -import au.com.royalpay.payment.manage.merchants.entity.impls.RefundPWDModify; -import au.com.royalpay.payment.manage.merchants.entity.impls.SettleHourModify; -import au.com.royalpay.payment.manage.merchants.entity.impls.SwitchPermissionModify; -import au.com.royalpay.payment.manage.merchants.entity.impls.TimeZoneModify; +import au.com.royalpay.payment.manage.merchants.entity.impls.*; import au.com.royalpay.payment.manage.notice.core.MailService; import au.com.royalpay.payment.manage.signin.beans.TodoNotice; import au.com.royalpay.payment.manage.signin.core.ManagerTodoNoticeProvider; @@ -85,6 +67,7 @@ import au.com.royalpay.payment.tools.exceptions.NotFoundException; import au.com.royalpay.payment.tools.exceptions.ServerErrorException; import au.com.royalpay.payment.tools.exceptions.event.WechatExceptionEvent; import au.com.royalpay.payment.tools.locale.LocaleSupport; +import au.com.royalpay.payment.tools.lock.Locker; import au.com.royalpay.payment.tools.mail.SendMail; import au.com.royalpay.payment.tools.merchants.beans.QRCodeConfig; import au.com.royalpay.payment.tools.merchants.beans.UpdateSurchargeDTO; @@ -149,14 +132,10 @@ import java.math.RoundingMode; import java.net.URISyntaxException; import java.net.URL; import java.security.InvalidParameterException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.HashSet; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; import java.util.List; -import java.util.Objects; -import java.util.Set; -import java.util.TimeZone; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; import java.util.zip.ZipEntry; @@ -305,6 +284,14 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid private RiskAttentionMerchantsMapper riskAttentionMerchantsMapper; @Resource private SysChannelConfigMapper sysChannelConfigMapper; + @Resource + private ClientsSurchargeAccountsMapper clientsSurchargeAccountsMapper; + @Resource + private ClearingDistributedSurchargeMapper clearingDistributedSurchargeMapper; + @Resource + private FinancialSurchargeAccountDetailMapper financialSurchargeAccountDetailMapper; + @Resource + private Locker locker; @Resource @@ -3257,6 +3244,131 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } } + @Override + @Transactional + public void setSurchargeMode(JSONObject account, String clientMoniker, String surcharge_mode) { + JSONObject client = getClientInfoByMoniker(clientMoniker); + if (client == null) { + throw new InvalidShortIdException(); + } + clientModifySupport.processClientConfigModify(new SurchargeModeModify(account, clientMoniker, surcharge_mode)); + + if ("distributed".equals(surcharge_mode)) { + JSONObject surchargeAccount = clientsSurchargeAccountsMapper.find(client.getIntValue("client_id")); + + if (surchargeAccount == null) { + JSONObject params = new JSONObject(); + params.put("client_id", client.getIntValue("client_id")); + params.put("create_time", new Date()); + params.put("is_valid", 1); + params.put("balance", 0); + clientsSurchargeAccountsMapper.save(params); + } + } + } + + @Override + public JSONObject surchargeAccount(JSONObject account, String clientMoniker) { + JSONObject client = getClientInfoByMoniker(clientMoniker); + if (client == null) { + throw new InvalidShortIdException(); + } + return clientsSurchargeAccountsMapper.find(client.getIntValue("client_id")); + } + + @Override + @Transactional + public void setAllowSurchargeCredit(JSONObject account, String clientMoniker, Boolean allow_surcharge_credit) { + JSONObject client = getClientInfoByMoniker(clientMoniker); + if (client == null) { + throw new InvalidShortIdException(); + } + clientModifySupport.processClientConfigModify(new SwitchPermissionModify(account, clientMoniker, "allow_surcharge_credit", allow_surcharge_credit)); + } + + @Override + public List getAccountTransactions(JSONObject account, String clientMoniker) { + JSONObject client = getClientInfoByMoniker(clientMoniker); + if (client == null) { + throw new InvalidShortIdException(); + } + List transactions = clearingDistributedSurchargeMapper.findTransactions(client.getIntValue("client_id")); + transactions.forEach(e->{ + if ("Credit".equals(e.getString("type"))) { + JSONObject manager = managerMapper.findDetail(e.getString("operation")); + e.put("operator_displayname", manager.getString("display_name")); + } + }); + return transactions; + } + + @Override + public List getAccountTransactionsByDate(JSONObject account, String clientMoniker, String date) { + JSONObject client = getClientInfoByMoniker(clientMoniker); + if (client == null) { + throw new InvalidShortIdException(); + } + + JSONObject params = new JSONObject(); + params.put("client_id", client.getIntValue("client_id")); + params.put("year", date.substring(0, 4)); + params.put("month", date.substring(date.length()-2, date.length())); + + List transactions = clearingDistributedSurchargeMapper.findTransactionsByDate(params); + transactions.forEach(e->{ + if ("Credit".equals(e.getString("type"))) { + JSONObject manager = managerMapper.findDetail(e.getString("operation")); + e.put("operator_displayname", manager.getString("display_name")); + } + }); + return transactions; + } + + @Override + public List getAccountMonthDetails(JSONObject account, String clientMoniker) { + JSONObject client = getClientInfoByMoniker(clientMoniker); + if (client == null) { + throw new InvalidShortIdException(); + } + List details = financialSurchargeAccountDetailMapper.findDetailsByClientId(client.getIntValue("client_id")); + return details; + } + + @Override + @Transactional + public void saveAccountTransaction(JSONObject account, String clientMoniker, JSONObject transaction) { + JSONObject client = getClientInfoByMoniker(clientMoniker); + if (client == null) { + throw new InvalidShortIdException(); + } + + if (!(ManagerRole.ADMIN.hasRole(account.getIntValue("role")) || ManagerRole.OPERATOR.hasRole(account.getIntValue("role")))) { + throw new ForbiddenException("无法增加充值记录,权限不足"); + } + if (!locker.lock(clientMoniker + "_surcharge_account_save", 120_000)) { + throw new ServerErrorException("Processing task, wait for a moment"); + } + try { + JSONObject surcharge_account = clientsSurchargeAccountsMapper.find(client.getIntValue("client_id")); + + transaction.put("client_id", client.getIntValue("client_id")); + transaction.put("type", "Credit"); + transaction.put("total_surcharge", BigDecimal.ZERO); + transaction.put("tax_amount", BigDecimal.ZERO); + transaction.put("post_balance", surcharge_account.getBigDecimal("balance").add(transaction.getBigDecimal("amount"))); + transaction.put("operation", account.getString("manager_id")); + transaction.put("create_time", new Date()); + clearingDistributedSurchargeMapper.save(transaction); + + surcharge_account.put("balance", surcharge_account.getBigDecimal("balance").add(transaction.getBigDecimal("amount"))); + clientsSurchargeAccountsMapper.update(surcharge_account); + + } finally { + locker.unlock(clientMoniker + "_surcharge_account_save"); + } + + } + @Override public void enableGatewayUpgrade(JSONObject account, String clientMoniker, boolean gatewayUpgrade) { JSONObject client = getClientInfoByMoniker(clientMoniker); diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/SurchargeModeModify.java b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/SurchargeModeModify.java new file mode 100644 index 000000000..ce656306d --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/SurchargeModeModify.java @@ -0,0 +1,29 @@ +package au.com.royalpay.payment.manage.merchants.entity.impls; + +import au.com.royalpay.payment.manage.merchants.entity.ClientConfigModify; +import com.alibaba.fastjson.JSONObject; + +/** + * Create by yixian at 2018-04-12 16:43 + */ +public class SurchargeModeModify extends ClientConfigModify { + private String surcharge_mode; + + + public SurchargeModeModify(JSONObject account, String clientMoniker, String surcharge_mode) { + super(account, clientMoniker); + this.surcharge_mode = surcharge_mode; + } + + @Override + protected String business() { + return "切换商户清算模式(surcharge_mode)"; + } + + @Override + protected JSONObject getModifyResult() { + JSONObject modify = new JSONObject(); + modify.put("surcharge_mode", surcharge_mode); + return modify; + } +} 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 1a0b3aabd..f8d533a09 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 @@ -370,6 +370,40 @@ public class PartnerManageController { clientManager.setSkipClearing(manager,clientMoniker, skip_clearing.getBooleanValue("skip_clearing"),skip_clearing.getString("remark")); } + @ManagerMapping(value = "/{clientMoniker}/surcharge_mode", method = RequestMethod.PUT, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR}) + public void updateSurchargeMode(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable String clientMoniker, @RequestBody JSONObject surcharge_mode) { + clientManager.setSurchargeMode(manager, clientMoniker, surcharge_mode.getString("surcharge_mode")); + } + + @ManagerMapping(value = "/{clientMoniker}/surcharge_account", method = RequestMethod.GET, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR}) + public JSONObject surchargeAccount(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable String clientMoniker) { + return clientManager.surchargeAccount(manager, clientMoniker); + } + + @ManagerMapping(value = "/{clientMoniker}/allow_surcharge_credit", method = RequestMethod.PUT, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR}) + public void allowSurchargeCredit(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable String clientMoniker, @RequestBody JSONObject allow_surcharge_credit) { + clientManager.setAllowSurchargeCredit(manager, clientMoniker, allow_surcharge_credit.getBooleanValue("allow_surcharge_credit")); + } + + @ManagerMapping(value = "/{clientMoniker}/account/transactions", method = RequestMethod.GET, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR}) + public List accountTransactions(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable String clientMoniker) { + return clientManager.getAccountTransactions(manager, clientMoniker); + } + @ManagerMapping(value = "/{clientMoniker}/account/transactions/date", method = RequestMethod.GET, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR}) + public List accountTransactionsByDate(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable String clientMoniker,@RequestParam String date) { + return clientManager.getAccountTransactionsByDate(manager, clientMoniker, date); + } + + @ManagerMapping(value = "/{clientMoniker}/account/save", method = RequestMethod.POST, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR}) + public void saveAccountTransaction(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable String clientMoniker, @RequestBody JSONObject transaction) { + clientManager.saveAccountTransaction(manager, clientMoniker, transaction); + } + + @ManagerMapping(value = "/{clientMoniker}/surcharge_account/month_detail", method = RequestMethod.GET, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR}) + public List surchargeAccountMonthDetail(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable String clientMoniker) { + return clientManager.getAccountMonthDetails(manager, clientMoniker); + } + @ManagerMapping(value = "/{clientMoniker}/settle_hour", method = RequestMethod.PUT, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR, ManagerRole.SERVANT, ManagerRole.FINANCIAL_STAFF}) public void configSettleHour(@PathVariable String clientMoniker, @RequestBody JSONObject config, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { clientManager.configSettleHour(manager, clientMoniker, config.getInteger("hour")); 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 20504fb83..6f1b2e407 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 @@ -164,6 +164,18 @@ public class PartnerViewController { clientManager.toggleAccountReceiveNotice(account.getString("client_moniker"), account.getString("account_id"), enable.getBooleanValue("enable")); } + @PartnerMapping(value = "/{clientMoniker}/surcharge_account", method = RequestMethod.GET, roles = {PartnerRole.ADMIN, PartnerRole.MANAGER}) + @ResponseBody + public JSONObject surchargeAccount(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject manager, @PathVariable String clientMoniker) { + return clientManager.surchargeAccount(manager, clientMoniker); + } + + @PartnerMapping(value = "/{clientMoniker}/account/transactions", method = RequestMethod.GET, roles = {PartnerRole.ADMIN, PartnerRole.MANAGER}) + @ResponseBody + public List accountTransactions(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject manager, @PathVariable String clientMoniker) { + return clientManager.getAccountTransactions(manager, clientMoniker); + } + @PartnerMapping(value = "/accounts/{accountId}/audit_refund", method = RequestMethod.PUT, roles = PartnerRole.ADMIN) @ResponseBody public void toggleAccountAuditRefund(@PathVariable String accountId, @ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject account, @RequestBody JSONObject enable) { diff --git a/src/main/java/au/com/royalpay/payment/manage/surchargeAccount/core/SurchargeAccountService.java b/src/main/java/au/com/royalpay/payment/manage/surchargeAccount/core/SurchargeAccountService.java new file mode 100644 index 000000000..1b86f2c97 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/surchargeAccount/core/SurchargeAccountService.java @@ -0,0 +1,14 @@ +package au.com.royalpay.payment.manage.surchargeAccount.core; + +import com.alibaba.fastjson.JSONObject; + +import java.util.Date; +import java.util.List; + +public interface SurchargeAccountService { + + void generatorMonthDetail(); + + List listSettledDatesInMonth(String mon); + +} diff --git a/src/main/java/au/com/royalpay/payment/manage/surchargeAccount/core/impl/SurchargeAccountServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/surchargeAccount/core/impl/SurchargeAccountServiceImpl.java new file mode 100644 index 000000000..cf83bdac9 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/surchargeAccount/core/impl/SurchargeAccountServiceImpl.java @@ -0,0 +1,66 @@ +package au.com.royalpay.payment.manage.surchargeAccount.core.impl; + +import au.com.royalpay.payment.manage.mappers.system.ClearingDistributedSurchargeMapper; +import au.com.royalpay.payment.manage.mappers.system.FinancialSurchargeAccountDetailMapper; +import au.com.royalpay.payment.manage.surchargeAccount.core.SurchargeAccountService; +import au.com.royalpay.payment.manage.system.core.impl.ClientContractServiceImpl; +import com.alibaba.fastjson.JSONObject; +import org.apache.commons.lang3.time.DateFormatUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +@Service +public class SurchargeAccountServiceImpl implements SurchargeAccountService{ + + @Resource + private ClearingDistributedSurchargeMapper clearingDistributedSurchargeMapper; + @Resource + private FinancialSurchargeAccountDetailMapper financialSurchargeAccountDetailMapper; + + Logger logger = LoggerFactory.getLogger(ClientContractServiceImpl.class); + + + @Override + @Transactional + public void generatorMonthDetail(){ + Calendar monthCal = Calendar.getInstance(); + monthCal.setTime(new Date()); + monthCal.set(Calendar.DAY_OF_MONTH, 1); + monthCal.set(Calendar.HOUR_OF_DAY, 0); + monthCal.set(Calendar.MINUTE, 0); + monthCal.set(Calendar.SECOND, 0); + Date dateto = monthCal.getTime(); + monthCal.set(Calendar.MONTH, (monthCal.get(Calendar.MONTH) - 1)); + Date datefrom = monthCal.getTime(); + + logger.info("===============Start generator surcharge account month detail===============" + new Date()); + List thisMonthDetail = clearingDistributedSurchargeMapper.getMonthDetailByClientId(datefrom, dateto); + logger.info("this month details : " + thisMonthDetail.toString()); + + for (JSONObject detail : thisMonthDetail) { + detail.put("send_mail", 0); + detail.put("wx_send", 0); + detail.put("settle_month", DateFormatUtils.format(datefrom, "yyyy-MM")); + detail.put("create_time", new Date()); + financialSurchargeAccountDetailMapper.save(detail); + } + + logger.info("===============generator OVER===============" + new Date()); + + } + + @Override + public List listSettledDatesInMonth(String mon) { + List settledDates = financialSurchargeAccountDetailMapper.listSettlementDatesInMonth(mon); + + return settledDates; + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/surchargeAccount/web/SurchargeAccountController.java b/src/main/java/au/com/royalpay/payment/manage/surchargeAccount/web/SurchargeAccountController.java new file mode 100644 index 000000000..114f4ba4e --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/surchargeAccount/web/SurchargeAccountController.java @@ -0,0 +1,30 @@ +package au.com.royalpay.payment.manage.surchargeAccount.web; + +import au.com.royalpay.payment.manage.permission.manager.ManagerMapping; +import au.com.royalpay.payment.manage.surchargeAccount.core.SurchargeAccountService; +import au.com.royalpay.payment.tools.CommonConsts; +import au.com.royalpay.payment.tools.exceptions.BadRequestException; +import au.com.royalpay.payment.tools.permission.enums.ManagerRole; +import com.alibaba.fastjson.JSONObject; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; + +@RequestMapping("/sys/surcharge_account") +@RestController +public class SurchargeAccountController { + + + @Resource + private SurchargeAccountService surchargeAccountService; + + @ManagerMapping(value = "/month/{month}/settled_dates", role = {ManagerRole.ADMIN,ManagerRole.OPERATOR}, method = RequestMethod.GET) + public List surchargeAccountSettledDates(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable String month) { + return surchargeAccountService.listSettledDatesInMonth(month); + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/task/SurchargeAccountMonthTask.java b/src/main/java/au/com/royalpay/payment/manage/task/SurchargeAccountMonthTask.java new file mode 100644 index 000000000..4897b1e2b --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/task/SurchargeAccountMonthTask.java @@ -0,0 +1,27 @@ +package au.com.royalpay.payment.manage.task; + +import au.com.royalpay.payment.manage.surchargeAccount.core.SurchargeAccountService; +import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; + +@Component +@ConditionalOnProperty(value = "app.run-tasks", havingValue = "true") +public class SurchargeAccountMonthTask { + @Resource + private SynchronizedScheduler synchronizedScheduler; + @Resource + private SurchargeAccountService surchargeAccountService; + + + + + @Scheduled(cron = "0 30 6 1 * ?") + public void generateSurchargeAccountDetail() { + synchronizedScheduler.executeProcess("manage_task:generateSurchargeAccountMonth", 120_000, () -> + surchargeAccountService.generatorMonthDetail()); + } +} diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClearingDistributedSurchargeMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClearingDistributedSurchargeMapper.xml new file mode 100644 index 000000000..99897a8f2 --- /dev/null +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClearingDistributedSurchargeMapper.xml @@ -0,0 +1,31 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/FinancialSurchargeAccountDetailMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/FinancialSurchargeAccountDetailMapper.xml new file mode 100644 index 000000000..6976f1a2c --- /dev/null +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/FinancialSurchargeAccountDetailMapper.xml @@ -0,0 +1,27 @@ + + + + + + + \ No newline at end of file diff --git a/src/main/ui/index.html b/src/main/ui/index.html index c6b305286..aae5efb26 100644 --- a/src/main/ui/index.html +++ b/src/main/ui/index.html @@ -899,6 +899,15 @@ margin-bottom: 10%;"/> +
  • + +