settle warnings

master
yixian 7 years ago
parent 11c524729d
commit bc4122226b

@ -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.management.clearing.core.CleanService;
import au.com.royalpay.payment.manage.mappers.log.*; import au.com.royalpay.payment.manage.mappers.log.*;
import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper; 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.ClientRateMapper;
import au.com.royalpay.payment.manage.mappers.system.ManagerMapper; import au.com.royalpay.payment.manage.mappers.system.ManagerMapper;
import au.com.royalpay.payment.manage.mappers.system.RateMapper; import au.com.royalpay.payment.manage.mappers.system.RateMapper;
import au.com.royalpay.payment.manage.merchants.core.ClientManager; import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import au.com.royalpay.payment.manage.notice.core.MailService; 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.support.abafile.ABAFile;
import au.com.royalpay.payment.manage.tradelog.beans.ClearingLogQuery; import au.com.royalpay.payment.manage.tradelog.beans.ClearingLogQuery;
import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApi; 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.BadRequestException;
import au.com.royalpay.payment.tools.exceptions.ForbiddenException; import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
import au.com.royalpay.payment.tools.exceptions.NotFoundException; 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.permission.enums.ManagerRole;
import au.com.royalpay.payment.tools.tasksupport.TaskFinishNotifyEvent; import au.com.royalpay.payment.tools.tasksupport.TaskFinishNotifyEvent;
import au.com.royalpay.payment.tools.utils.PageListUtils; 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.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.joda.time.DateTime;
import org.joda.time.Days;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value; 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. * Created by davep on 2016-08-29.
*/ */
@Service @Service
public class CleanServiceImpl implements CleanService, ApplicationEventPublisherAware { public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider, ApplicationEventPublisherAware {
private Logger logger = LoggerFactory.getLogger(getClass()); private Logger logger = LoggerFactory.getLogger(getClass());
@Resource @Resource
private SettlementSupport settlementSupport; private SettlementSupport settlementSupport;
@ -107,6 +113,8 @@ public class CleanServiceImpl implements CleanService, ApplicationEventPublisher
@Resource @Resource
private PaymentApi paymentApi; private PaymentApi paymentApi;
@Resource @Resource
private CalendarMapper calendarMapper;
@Resource
private SpringTemplateEngine thymeleaf; private SpringTemplateEngine thymeleaf;
@Value("${app.settlement.email-to}") @Value("${app.settlement.email-to}")
@ -116,7 +124,7 @@ public class CleanServiceImpl implements CleanService, ApplicationEventPublisher
@Value("${app.redis.settle.check-code.prefix}") @Value("${app.redis.settle.check-code.prefix}")
private String reidsCheckCodeKey; 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 ApplicationEventPublisher publisher;
// private final String[] open_ids = { "o32MzuO4s8c7iFOVxnxejkbhMoEc" }; // 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() + "%"; + detail.getBigDecimal("rate").setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "%";
String totalCharge = detail.getBigDecimal("total_charge").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 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"), String[] values = {detail.getString("client_moniker"), "AUD", grossAmount, totalCharge, clearingAmount, detail.getString("bsb_no"),
detail.getString("account_no"), detail.getString("account_name"), settlementDate }; detail.getString("account_no"), detail.getString("account_name"), settlementDate};
csv.printRecord((Object[]) values); csv.printRecord((Object[]) values);
} }
csv.flush(); csv.flush();
@ -457,9 +465,9 @@ public class CleanServiceImpl implements CleanService, ApplicationEventPublisher
BigDecimal.ROUND_HALF_DOWN); BigDecimal.ROUND_HALF_DOWN);
BigDecimal clearingAmount = transaction.getBigDecimal("clearing_amount").multiply(BigDecimal.valueOf(multiply)).setScale(2, BigDecimal clearingAmount = transaction.getBigDecimal("clearing_amount").multiply(BigDecimal.valueOf(multiply)).setScale(2,
BigDecimal.ROUND_HALF_DOWN); 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("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.printRecord((Object[]) values);
} }
csv.flush(); csv.flush();
@ -633,9 +641,9 @@ public class CleanServiceImpl implements CleanService, ApplicationEventPublisher
Sheet sheet = wb.createSheet("Merchant_Settlement_Info_" + DateFormatUtils.format(date, "yyyyMMdd")); Sheet sheet = wb.createSheet("Merchant_Settlement_Info_" + DateFormatUtils.format(date, "yyyyMMdd"));
int rowNum = 0; int rowNum = 0;
Row row = sheet.createRow(rowNum); Row row = sheet.createRow(rowNum);
String[] title = { "order Id", "Client Order Id", "Transaction Time", "Channel", "Gateway", "Exchange Rate", "Transaction Type", "Currency", 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" }; "Input Amount", "Total Amount", "Clearing Amount", "Sruchange Rate", "Settle Amount", "Remark"};
String[] analysis = { "Total Credit", "Total Debit", "Gross Amount", "Total Charge", "Net Amount" }; String[] analysis = {"Total Credit", "Total Debit", "Gross Amount", "Total Charge", "Net Amount"};
for (int i = 0; i < title.length; i++) { for (int i = 0; i < title.length; i++) {
row.createCell(i, Cell.CELL_TYPE_STRING).setCellValue(title[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) { public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.publisher = applicationEventPublisher; this.publisher = applicationEventPublisher;
} }
@Override
public void checkTodo(JSONObject manager, List<TodoNotice> notices) {
if (ManagerRole.OPERATOR.hasRole(manager.getIntValue("role"))) {
checkSettleDateConfig(notices);
rateWarningsCheck(notices);
}
}
private void rateWarningsCheck(List<TodoNotice> 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<TodoNotice> 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"));
}
}
} }

@ -34,6 +34,7 @@
c.client_moniker, c.client_moniker,
c.short_name, c.short_name,
c.bd_user_name, c.bd_user_name,
r.rate_name,
r.rate_value, r.rate_value,
r.expiry_time r.expiry_time
FROM sys_clients c FROM sys_clients c
@ -54,6 +55,7 @@
c.client_moniker, c.client_moniker,
c.short_name, c.short_name,
c.bd_user_name, c.bd_user_name,
r.rate_name,
r.active_time, r.active_time,
r.expiry_time, r.expiry_time,
r.rate_value, r.rate_value,

@ -8,6 +8,7 @@
<tr> <tr>
<th>Client Moniker</th> <th>Client Moniker</th>
<th>Short Name</th> <th>Short Name</th>
<th>Channel</th>
<th>BD</th> <th>BD</th>
<th>Latest Rate</th> <th>Latest Rate</th>
<th>Expire Date</th> <th>Expire Date</th>
@ -20,6 +21,7 @@
<a ui-sref="partners.detail.rates({clientMoniker:client.client_moniker})" ng-bind="client.client_moniker"></a> <a ui-sref="partners.detail.rates({clientMoniker:client.client_moniker})" ng-bind="client.client_moniker"></a>
</td> </td>
<td ng-bind="client.short_name"></td> <td ng-bind="client.short_name"></td>
<td ng-bind="client.rate_name"></td>
<td ng-bind="client.bd_user_name"></td> <td ng-bind="client.bd_user_name"></td>
<td ng-bind="client.rate_value"></td> <td ng-bind="client.rate_value"></td>
<td ng-bind="client.expiry_time|date:'dd/MMM/yyyy'"></td> <td ng-bind="client.expiry_time|date:'dd/MMM/yyyy'"></td>
@ -41,6 +43,7 @@
<tr> <tr>
<th>Client Moniker</th> <th>Client Moniker</th>
<th>Short Name</th> <th>Short Name</th>
<th>Channel</th>
<th>BD</th> <th>BD</th>
<th>Rate</th> <th>Rate</th>
<th>Expire Date</th> <th>Expire Date</th>
@ -53,6 +56,7 @@
<a ui-sref="partners.detail.rates({clientMoniker:client.client_moniker})" ng-bind="client.client_moniker"></a> <a ui-sref="partners.detail.rates({clientMoniker:client.client_moniker})" ng-bind="client.client_moniker"></a>
</td> </td>
<td ng-bind="client.short_name"></td> <td ng-bind="client.short_name"></td>
<td ng-bind="client.rate_name"></td>
<td ng-bind="client.bd_user_name"></td> <td ng-bind="client.bd_user_name"></td>
<td ng-bind="client.rate_value"></td> <td ng-bind="client.rate_value"></td>
<td ng-bind="client.expiry_time|date:'dd/MMM/yyyy'"></td> <td ng-bind="client.expiry_time|date:'dd/MMM/yyyy'"></td>

Loading…
Cancel
Save