diff --git a/pom.xml b/pom.xml index bc28e6d54..0ad19d395 100644 --- a/pom.xml +++ b/pom.xml @@ -5,15 +5,16 @@ au.com.royalpay.payment payment-parent - 2.2.30 + 2.2.31 4.0.0 manage - 2.3.87-SNAPSHOT + 2.3.88 UTF-8 2.4.0 1.0.12 + 8.0.20 diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/ManageAppServiceImp.java b/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/ManageAppServiceImp.java index 50564b732..b971de222 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/ManageAppServiceImp.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/ManageAppServiceImp.java @@ -514,7 +514,7 @@ public class ManageAppServiceImp implements ManageAppService { String nationCode = phone.getString("nation_code"); String phoneNumber = phone.getString("contact_phone"); try { - smsSender.sendAuthCodeMessage(nationCode.trim(), phoneNumber, Locale.ENGLISH, new AuthCodeMessage("绑定手机号", codeKeyValue, 5)); + smsSender.sendAuthCodeMessage(nationCode.trim(), phoneNumber, Locale.ENGLISH, new AuthCodeMessage("Binding mobile number", codeKeyValue, 5)); } catch (Exception e) { e.printStackTrace(); throw new ServerErrorException("Phone number is wrong.Please try again."); diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java b/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java index b0e474a75..59ae53947 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java @@ -851,14 +851,9 @@ public class RetailAppServiceImp implements RetailAppService { PageList logs = clearingDetailMapper.listClientSettlementLog(params, new PageBounds(appQueryBean.getPage(), appQueryBean.getLimit(), Order.formString("report_date.desc"))); logs.forEach(log -> log.put("total_charge", log.getBigDecimal("total_charge").add(log.getBigDecimal("tax_amount")))); + logs.forEach(log -> log.put("padding", log.getBooleanValue("editable"))); JSONObject result = PageListUtils.buildPageListResult(logs); - if (appQueryBean.getPage() == 1 && !logs.isEmpty()) { - JSONObject clearingLog = clearingLogMapper.findById(logs.get(0).getIntValue("clearing_id")); - if (clearingLog.getBooleanValue("editable")) { - result.put("padding", true); - logs.get(0).put("padding", true); - } - } + result.put("padding", logs.stream().anyMatch(log -> log.getBooleanValue("editable"))); return result; } @@ -2236,7 +2231,7 @@ public class RetailAppServiceImp implements RetailAppService { String nationCode = phone.getString("nation_code").contains("+") ? phone.getString("nation_code").substring(1) : phone.getString("nation_code"); String phoneNumber = phone.getString("contact_phone"); try { - smsSender.sendAuthCodeMessage(nationCode.trim(), phoneNumber, Locale.ENGLISH, new AuthCodeMessage("绑定手机号", codeKeyValue, 1)); + smsSender.sendAuthCodeMessage(nationCode.trim(), phoneNumber, Locale.ENGLISH, new AuthCodeMessage("Binding mobile number", codeKeyValue, 1)); } catch (Exception e) { logger.error(e.getMessage(), e); throw new BadRequestException("Phone number is wrong.Please try again."); @@ -2256,7 +2251,7 @@ public class RetailAppServiceImp implements RetailAppService { String nationCode = client.getString("nation_code").contains("+") ? client.getString("nation_code").substring(1) : client.getString("nation_code"); String phoneNumber = client.getString("contact_phone"); try { - smsSender.sendAuthCodeMessage(nationCode.trim(), phoneNumber, Locale.ENGLISH, new AuthCodeMessage("解綁绑定手机号", codeKeyValue, 1)); + smsSender.sendAuthCodeMessage(nationCode.trim(), phoneNumber, Locale.ENGLISH, new AuthCodeMessage("Unbind mobile number", codeKeyValue, 1)); } catch (Exception e) { logger.error(e.getMessage(), e); throw new BadRequestException("Phone number is wrong.Please try again."); diff --git a/src/main/java/au/com/royalpay/payment/manage/dev/web/TestController.java b/src/main/java/au/com/royalpay/payment/manage/dev/web/TestController.java index 0034eebe2..c39d3e4bc 100644 --- a/src/main/java/au/com/royalpay/payment/manage/dev/web/TestController.java +++ b/src/main/java/au/com/royalpay/payment/manage/dev/web/TestController.java @@ -45,7 +45,6 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.lang3.time.DateUtils; import org.apache.http.util.TextUtils; -import org.apache.ibatis.annotations.Mapper; import org.joda.time.DateTime; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/CleanService.java b/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/CleanService.java index b4d478137..0581a03e7 100644 --- a/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/CleanService.java +++ b/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/CleanService.java @@ -56,6 +56,8 @@ public interface CleanService { void settlementAba(Date date, HttpServletResponse response) throws IOException; + void getCustomizedSettleABA(int logId, HttpServletResponse response); + void getSettlementFilesForBatch(String batchId, HttpServletResponse resp) throws IOException; List getCleanLogs(ClearingLogQuery query, JSONObject manager); 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 e6e295462..478b3ef5d 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 @@ -104,7 +104,7 @@ import static au.com.royalpay.payment.manage.permission.utils.OrgCheckUtils.chec */ @Service public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider, ApplicationEventPublisherAware { - private Logger logger = LoggerFactory.getLogger(getClass()); + private final Logger logger = LoggerFactory.getLogger(getClass()); @Resource private SettlementSupport settlementSupport; @Resource @@ -114,6 +114,8 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider @Resource private ClearingDetailMapper clearingDetailMapper; @Resource + private CustomizedSettleLogMapper customizedSettleLogMapper; + @Resource private ClearingDetailAnalysisMapper clearingDetailAnalysisMapper; @Resource private TaskManualSettleMapper taskManualSettleMapper; @@ -665,6 +667,33 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider } } + @Override + public void getCustomizedSettleABA(int logId, HttpServletResponse response) { + JSONObject log = customizedSettleLogMapper.find(logId); + if (log == null) { + throw new NotFoundException("Settle log not found"); + } + String bank = log.getString("settle_bank"); + BalanceGroup group = BalanceGroup.valueOf(log.getString("balance_group")); + JSONObject settle = new JSONObject(); + settle.put("settle_bank", bank); + settle.put("clearing_amount", log.getBigDecimal("amount")); + settle.put("client_id", log.getIntValue("client_id")); + settle.put("bsb_no", log.getString("bsb_no")); + settle.put("account_no", log.getString("account_no")); + settle.put("account_name", log.getString("account_name")); + settle.put("client_moniker", log.getString("client_moniker")); + ABAFile file = generateSettleAbaFile(bank, group, new Date(), Collections.singletonList(settle)); + response.setContentType("application/octet-stream;"); + response.addHeader("Content-Disposition", "attachment; filename=" + file.filename()); + try (OutputStream ous = response.getOutputStream()) { + ous.write(file.output(1)); + ous.flush(); + } catch (IOException e) { + throw new ServerErrorException("Output failed", e); + } + } + @Override public void getSettlementFilesForBatch(String batchId, HttpServletResponse resp) throws IOException { int clearingId = Integer.parseInt(batchId); @@ -1649,20 +1678,27 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider if (!log.getBooleanValue("editable")) { throw new ForbiddenException("Settlement log has been sent and unable to edit"); } - List details = clearingDetailMapper.listReportsOfSettlement(clearingId); - List detailsWithDistributedSurcharge = details.stream().filter(detail -> detail.getBigDecimal("distributed_surcharge").compareTo(BigDecimal.ZERO) > 0).collect(Collectors.toList()); - if (!detailsWithDistributedSurcharge.isEmpty()) { - for (JSONObject detail : detailsWithDistributedSurcharge) { - releaseDistributedSurcharge(detail); + if (!locker.lock("settle_task", 3600_000)) { + throw new ServerErrorException("Settle Task Running!"); + } + try { + List details = clearingDetailMapper.listReportsOfSettlement(clearingId); + List detailsWithDistributedSurcharge = details.stream().filter(detail -> detail.getBigDecimal("distributed_surcharge").compareTo(BigDecimal.ZERO) > 0).collect(Collectors.toList()); + if (!detailsWithDistributedSurcharge.isEmpty()) { + for (JSONObject detail : detailsWithDistributedSurcharge) { + releaseDistributedSurcharge(detail); + } } + transactionMapper.deleteSettlementTransaction(clearingId); + transactionMapper.removeSettleRemark(clearingId); + preSettleTaskMapper.resetClearStatus(clearingId); + clearingDetailAnalysisMapper.clearAnalysis(clearingId); + taskManualSettleMapper.rollbackExecutedTask(clearingId); + clearingDetailMapper.deleteSettleLogs(clearingId); + clearingLogMapper.deleteSettleLogs(clearingId); + } finally { + locker.unlock("settle_task"); } - transactionMapper.deleteSettlementTransaction(clearingId); - transactionMapper.removeSettleRemark(clearingId); - preSettleTaskMapper.resetClearStatus(clearingId); - clearingDetailAnalysisMapper.clearAnalysis(clearingId); - taskManualSettleMapper.rollbackExecutedTask(clearingId); - clearingDetailMapper.deleteSettleLogs(clearingId); - clearingLogMapper.deleteSettleLogs(clearingId); } @Override @@ -1724,7 +1760,7 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider public TransactionStatus getTransactionStatus(String transactionId) { TransactionStatus transactionStatus = transactionMapper.getTransactionStatusById(transactionId); if (transactionStatus == null) { - throw new ParamInvalidException("date","The transaction was not found"); + throw new ParamInvalidException("date", "The transaction was not found"); } return transactionStatus.toSet(); } diff --git a/src/main/java/au/com/royalpay/payment/manage/management/clearing/web/SettlementDevController.java b/src/main/java/au/com/royalpay/payment/manage/management/clearing/web/SettlementDevController.java index a0124f00c..f2ca28d44 100644 --- a/src/main/java/au/com/royalpay/payment/manage/management/clearing/web/SettlementDevController.java +++ b/src/main/java/au/com/royalpay/payment/manage/management/clearing/web/SettlementDevController.java @@ -30,8 +30,8 @@ import java.util.List; @RestController @ManagerMapping(value = "/sys/settlement", role = {ManagerRole.ADMIN, ManagerRole.OPERATOR, ManagerRole.FINANCIAL_STAFF}, method = RequestMethod.GET) public class SettlementDevController { - private DateFormat monthFormat = new SimpleDateFormat("yyyyMM"); - private DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + private final DateFormat monthFormat = new SimpleDateFormat("yyyyMM"); + private final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); @Resource private CleanService cleanService; @@ -170,6 +170,11 @@ public class SettlementDevController { } } + @GetMapping("/customized_settle/{logId}/aba_file") + public void getCustomizedSettleABAFile(@PathVariable int logId,HttpServletResponse response){ + cleanService.getCustomizedSettleABA(logId, response); + } + @GetMapping("/settle_batches/{batchId}/settle_files") public void getSettlementFilesForBatch(@PathVariable String batchId, HttpServletResponse resp) throws IOException { cleanService.getSettlementFilesForBatch(batchId, resp); diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/log/CustomizedSettleLogMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/log/CustomizedSettleLogMapper.java new file mode 100644 index 000000000..0d34da48e --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/log/CustomizedSettleLogMapper.java @@ -0,0 +1,14 @@ +package au.com.royalpay.payment.manage.mappers.log; + +import com.alibaba.fastjson.JSONObject; +import com.yixsoft.support.mybatis.autosql.annotations.AutoMapper; +import com.yixsoft.support.mybatis.autosql.annotations.AutoSql; +import com.yixsoft.support.mybatis.autosql.annotations.SqlType; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator; + +@AutoMapper(tablename = "log_settle_customized", pkName = "log_id", keyGenerator = Jdbc3KeyGenerator.class) +public interface CustomizedSettleLogMapper { + @AutoSql(SqlType.SELECT) + JSONObject find(@Param("log_id") int logId); +} 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 00d205680..3249041fa 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 @@ -4119,20 +4119,10 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } PageList logs = transactionMapper.listSettlementLog(params, new PageBounds(query.getPage(), query.getLimit(), Order.formString("clearing_time.desc"))); + logs.forEach(log -> log.put("padding", log.getBooleanValue("editable"))); JSONObject result = PageListUtils.buildPageListResult(logs); - if (query.getPage() == 1) { - if (!logs.isEmpty()) { - JSONObject clearingDetail = clearingDetailMapper.findByDetailId(logs.get(0).getIntValue("clear_detail_id")); - if (clearingDetail != null) { - JSONObject clearingLog = clearingLogMapper.findById(clearingDetail.getIntValue("clearing_id")); - if (clearingLog.getBooleanValue("editable")) { - result.put("padding", true); - logs.get(0).put("padding", true); - logger.info("##editable{}", clearingLog.getBooleanValue("editable")); - } - } - } - } + result.put("padding", logs.stream().anyMatch(log->log.getBooleanValue("editable"))); + logger.info("##editable{}", result.getBooleanValue("padding")); return result; } diff --git a/src/main/java/au/com/royalpay/payment/manage/signin/core/impls/SignInAccountServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/signin/core/impls/SignInAccountServiceImpl.java index c28390ea9..97c8f62c9 100644 --- a/src/main/java/au/com/royalpay/payment/manage/signin/core/impls/SignInAccountServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/signin/core/impls/SignInAccountServiceImpl.java @@ -571,7 +571,7 @@ public class SignInAccountServiceImpl implements SignInAccountService, Applicati }); break; case "phone": - smsSender.sendAuthCodeMessage(account.getString("nation_code").trim(), account.getString("contact_phone"), Locale.ENGLISH, new AuthCodeMessage("密码重置服务", codeKeyValue, 5)); + smsSender.sendAuthCodeMessage(account.getString("nation_code").trim(), account.getString("contact_phone"), Locale.ENGLISH, new AuthCodeMessage("Reset password", codeKeyValue, 5)); break; } stringRedisTemplate.boundValueOps(getResetClientAccountKey(accountId)).set(codeKeyValue, 5, TimeUnit.MINUTES); @@ -607,7 +607,7 @@ public class SignInAccountServiceImpl implements SignInAccountService, Applicati }); break; case "phone": - smsSender.sendAuthCodeMessage(account.getString("nation_code").trim(), account.getString("phone"), Locale.CHINESE, new AuthCodeMessage("密码重置服务",codeKeyValue,5)); + smsSender.sendAuthCodeMessage(account.getString("nation_code").trim(), account.getString("phone"), Locale.CHINESE, new AuthCodeMessage("密码重置服务", codeKeyValue,5)); break; } stringRedisTemplate.boundValueOps(getResetManagerAccountKey(managerId)).set(codeKeyValue, 5, TimeUnit.MINUTES); diff --git a/src/main/java/au/com/royalpay/payment/manage/support/sms/SmsSenderQcloudImpl.java b/src/main/java/au/com/royalpay/payment/manage/support/sms/SmsSenderQcloudImpl.java index 8730b4bf7..c2bbcc243 100644 --- a/src/main/java/au/com/royalpay/payment/manage/support/sms/SmsSenderQcloudImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/support/sms/SmsSenderQcloudImpl.java @@ -7,7 +7,6 @@ import au.com.royalpay.payment.tools.exceptions.ServerErrorException; import com.github.qcloudsms.SmsSingleSender; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.core.Ordered; import org.springframework.stereotype.Component; import java.util.Locale; diff --git a/src/main/java/au/com/royalpay/payment/manage/support/sms/daas/AuthCodeMessageTemplate.java b/src/main/java/au/com/royalpay/payment/manage/support/sms/daas/AuthCodeMessageTemplate.java index 82c3005ef..49ca1e630 100644 --- a/src/main/java/au/com/royalpay/payment/manage/support/sms/daas/AuthCodeMessageTemplate.java +++ b/src/main/java/au/com/royalpay/payment/manage/support/sms/daas/AuthCodeMessageTemplate.java @@ -6,7 +6,7 @@ import java.util.Locale; public class AuthCodeMessageTemplate implements DaasMessageTemplate { private static final String CN_TPL = "您正在申请%s,验证码为%s,%s分钟内有效,请勿向任何人提供此验证码"; - private static final String EN_TPL = "Your %s secret code is %s(valid for %s minutes). Do not provide this to anyone."; + private static final String EN_TPL = "%s secret code is %s (valid in %s min).No reveal to others"; private final Locale locale; private final AuthCodeMessage register; diff --git a/src/main/java/au/com/royalpay/payment/manage/support/sms/daas/DaasMessageTemplate.java b/src/main/java/au/com/royalpay/payment/manage/support/sms/daas/DaasMessageTemplate.java index d01811e03..c440c6dfd 100644 --- a/src/main/java/au/com/royalpay/payment/manage/support/sms/daas/DaasMessageTemplate.java +++ b/src/main/java/au/com/royalpay/payment/manage/support/sms/daas/DaasMessageTemplate.java @@ -1,7 +1,5 @@ package au.com.royalpay.payment.manage.support.sms.daas; -import org.springframework.util.MultiValueMap; - public interface DaasMessageTemplate { String getMessage(); diff --git a/src/main/java/au/com/royalpay/payment/manage/tradelog/core/impls/TradeLogServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/tradelog/core/impls/TradeLogServiceImpl.java index 25761287b..0ec3dff0f 100644 --- a/src/main/java/au/com/royalpay/payment/manage/tradelog/core/impls/TradeLogServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/tradelog/core/impls/TradeLogServiceImpl.java @@ -1425,21 +1425,10 @@ public class TradeLogServiceImpl implements TradeLogService { } PageList logs = transactionMapper.listSettlementLog(params, new PageBounds(query.getPage(), query.getLimit(), Order.formString("clearing_time.desc"))); + logs.forEach(log -> log.put("padding", log.getBooleanValue("editable"))); result.putAll(PageListUtils.buildPageListResult(logs)); - if (query.getPage() == 1) { - if (!logs.isEmpty()) { - JSONObject clearingDetail = clearingDetailMapper.findByDetailId(logs.get(0).getIntValue("clear_detail_id")); - if (clearingDetail != null) { - JSONObject clearingLog = clearingLogMapper.findById(clearingDetail.getIntValue("clearing_id")); - - if (clearingLog.getBooleanValue("editable")) { - result.put("padding", true); - logs.get(0).put("padding", true); - logger.info("##editable{}", clearingLog.getBooleanValue("editable")); - } - } - } - } + result.put("padding", logs.stream().anyMatch(log -> log.getBooleanValue("editable"))); + logger.info("##editable{}", result.getBooleanValue("padding")); return result; } diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/log/ClearingDetailMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/log/ClearingDetailMapper.xml index 8444788cb..31ff6d0d7 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/log/ClearingDetailMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/log/ClearingDetailMapper.xml @@ -91,11 +91,13 @@