From bc4122226b88d18ca79fc107020a8bb80550810a Mon Sep 17 00:00:00 2001 From: yixian Date: Wed, 3 Jan 2018 09:23:35 +0800 Subject: [PATCH] settle warnings --- .../clearing/core/impl/CleanServiceImpl.java | 52 +++++++++++++++---- .../mappers/system/ClientRateMapper.xml | 2 + .../analysis/templates/settle_warnings.html | 4 ++ 3 files changed, 49 insertions(+), 9 deletions(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/impl/CleanServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/impl/CleanServiceImpl.java index 8226ccf24..e00826762 100644 --- a/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/impl/CleanServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/impl/CleanServiceImpl.java @@ -6,11 +6,14 @@ import au.com.royalpay.payment.core.tasksupport.SettlementSupport; import au.com.royalpay.payment.manage.management.clearing.core.CleanService; import au.com.royalpay.payment.manage.mappers.log.*; import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper; +import au.com.royalpay.payment.manage.mappers.system.CalendarMapper; import au.com.royalpay.payment.manage.mappers.system.ClientRateMapper; import au.com.royalpay.payment.manage.mappers.system.ManagerMapper; import au.com.royalpay.payment.manage.mappers.system.RateMapper; import au.com.royalpay.payment.manage.merchants.core.ClientManager; 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; import au.com.royalpay.payment.manage.support.abafile.ABAFile; import au.com.royalpay.payment.manage.tradelog.beans.ClearingLogQuery; import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApi; @@ -21,6 +24,7 @@ import au.com.royalpay.payment.tools.env.PlatformEnvironment; import au.com.royalpay.payment.tools.exceptions.BadRequestException; import au.com.royalpay.payment.tools.exceptions.ForbiddenException; import au.com.royalpay.payment.tools.exceptions.NotFoundException; +import au.com.royalpay.payment.tools.locale.LocaleSupport; import au.com.royalpay.payment.tools.permission.enums.ManagerRole; import au.com.royalpay.payment.tools.tasksupport.TaskFinishNotifyEvent; import au.com.royalpay.payment.tools.utils.PageListUtils; @@ -42,6 +46,8 @@ import org.apache.poi.hssf.usermodel.HSSFFont; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.*; import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.joda.time.DateTime; +import org.joda.time.Days; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; @@ -74,7 +80,7 @@ import static au.com.royalpay.payment.manage.permission.utils.OrgCheckUtils.chec * 清算 Created by davep on 2016-08-29. */ @Service -public class CleanServiceImpl implements CleanService, ApplicationEventPublisherAware { +public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider, ApplicationEventPublisherAware { private Logger logger = LoggerFactory.getLogger(getClass()); @Resource private SettlementSupport settlementSupport; @@ -107,6 +113,8 @@ public class CleanServiceImpl implements CleanService, ApplicationEventPublisher @Resource private PaymentApi paymentApi; @Resource + private CalendarMapper calendarMapper; + @Resource private SpringTemplateEngine thymeleaf; @Value("${app.settlement.email-to}") @@ -116,7 +124,7 @@ public class CleanServiceImpl implements CleanService, ApplicationEventPublisher @Value("${app.redis.settle.check-code.prefix}") private String reidsCheckCodeKey; - private final String[] open_ids = { "o32MzuEeb5ZT_DJQYbzZf6VCu1HQ", "o32MzuIsa3OBOkvC9pL90h9pgHPg", "o32MzuCpqGQJTlvTK7VQ7m_LVXiQ" }; + private final String[] open_ids = {"o32MzuEeb5ZT_DJQYbzZf6VCu1HQ", "o32MzuIsa3OBOkvC9pL90h9pgHPg", "o32MzuCpqGQJTlvTK7VQ7m_LVXiQ"}; private ApplicationEventPublisher publisher; // private final String[] open_ids = { "o32MzuO4s8c7iFOVxnxejkbhMoEc" }; @@ -435,8 +443,8 @@ public class CleanServiceImpl implements CleanService, ApplicationEventPublisher + detail.getBigDecimal("rate").setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "%"; String totalCharge = detail.getBigDecimal("total_charge").setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString(); String clearingAmount = detail.getBigDecimal("clearing_amount").setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString(); - String[] values = { detail.getString("client_moniker"), "AUD", grossAmount, totalCharge, clearingAmount, detail.getString("bsb_no"), - detail.getString("account_no"), detail.getString("account_name"), settlementDate }; + String[] values = {detail.getString("client_moniker"), "AUD", grossAmount, totalCharge, clearingAmount, detail.getString("bsb_no"), + detail.getString("account_no"), detail.getString("account_name"), settlementDate}; csv.printRecord((Object[]) values); } csv.flush(); @@ -457,9 +465,9 @@ public class CleanServiceImpl implements CleanService, ApplicationEventPublisher BigDecimal.ROUND_HALF_DOWN); BigDecimal clearingAmount = transaction.getBigDecimal("clearing_amount").multiply(BigDecimal.valueOf(multiply)).setScale(2, BigDecimal.ROUND_HALF_DOWN); - String[] values = { transaction.getString("system_transaction_id"), transaction.getString("order_id"), transaction.getString("client_id"), + String[] values = {transaction.getString("system_transaction_id"), transaction.getString("order_id"), transaction.getString("client_id"), transaction.getString("device_id"), transaction.getString("transaction_currency"), transactionAmount.toPlainString(), - transaction.getString("clearing_currency"), clearingAmount.toPlainString(), transaction.getString("channel"), transactionTime, "0" }; + transaction.getString("clearing_currency"), clearingAmount.toPlainString(), transaction.getString("channel"), transactionTime, "0"}; csv.printRecord((Object[]) values); } csv.flush(); @@ -633,9 +641,9 @@ public class CleanServiceImpl implements CleanService, ApplicationEventPublisher Sheet sheet = wb.createSheet("Merchant_Settlement_Info_" + DateFormatUtils.format(date, "yyyyMMdd")); int rowNum = 0; Row row = sheet.createRow(rowNum); - String[] title = { "order Id", "Client Order Id", "Transaction Time", "Channel", "Gateway", "Exchange Rate", "Transaction Type", "Currency", - "Input Amount", "Total Amount", "Clearing Amount", "Sruchange Rate", "Settle Amount", "Remark" }; - String[] analysis = { "Total Credit", "Total Debit", "Gross Amount", "Total Charge", "Net Amount" }; + String[] title = {"order Id", "Client Order Id", "Transaction Time", "Channel", "Gateway", "Exchange Rate", "Transaction Type", "Currency", + "Input Amount", "Total Amount", "Clearing Amount", "Sruchange Rate", "Settle Amount", "Remark"}; + String[] analysis = {"Total Credit", "Total Debit", "Gross Amount", "Total Charge", "Net Amount"}; for (int i = 0; i < title.length; i++) { row.createCell(i, Cell.CELL_TYPE_STRING).setCellValue(title[i]); } @@ -958,4 +966,30 @@ public class CleanServiceImpl implements CleanService, ApplicationEventPublisher public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) { this.publisher = applicationEventPublisher; } + + @Override + public void checkTodo(JSONObject manager, List notices) { + if (ManagerRole.OPERATOR.hasRole(manager.getIntValue("role"))) { + checkSettleDateConfig(notices); + rateWarningsCheck(notices); + } + } + + private void rateWarningsCheck(List notices) { + JSONObject rateWarnings = rateWarnings(); + if (rateWarnings.getJSONArray("no_rate").size() + rateWarnings.getJSONArray("rate_warning").size() > 0) { + String rateWarningSettingMsg = LocaleSupport.localeMessage("todo.rate.expire_warning"); + notices.add(new TodoNotice("clearing_rate", rateWarningSettingMsg, "#/analysis/clearing_logs/rate_warnings")); + } + } + + private void checkSettleDateConfig(List notices) { + Date lastSettleDate = calendarMapper.getLastSettleDate(); + Date today = DateUtils.truncate(new Date(), Calendar.DATE); + int days = Days.daysBetween(new DateTime(today), new DateTime(lastSettleDate)).getDays(); + if (days < 7) { + String settleDateSettingMsg = LocaleSupport.localeMessage("todo.settlement.date_setting"); + notices.add(new TodoNotice("settlement", settleDateSettingMsg, "#/analysis/clearing_logs/date_setting")); + } + } } diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientRateMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientRateMapper.xml index 636106e50..e49faa46d 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientRateMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientRateMapper.xml @@ -34,6 +34,7 @@ c.client_moniker, c.short_name, c.bd_user_name, + r.rate_name, r.rate_value, r.expiry_time FROM sys_clients c @@ -54,6 +55,7 @@ c.client_moniker, c.short_name, c.bd_user_name, + r.rate_name, r.active_time, r.expiry_time, r.rate_value, diff --git a/src/main/ui/static/analysis/templates/settle_warnings.html b/src/main/ui/static/analysis/templates/settle_warnings.html index be1ab79fb..dcda53830 100644 --- a/src/main/ui/static/analysis/templates/settle_warnings.html +++ b/src/main/ui/static/analysis/templates/settle_warnings.html @@ -8,6 +8,7 @@ Client Moniker Short Name + Channel BD Latest Rate Expire Date @@ -20,6 +21,7 @@ + @@ -41,6 +43,7 @@ Client Moniker Short Name + Channel BD Rate Expire Date @@ -53,6 +56,7 @@ +