feat(settle ui): 清算发送勾选发送批次,取消每日一次发送邮件限制,取消验证码

master
yixian 5 years ago
parent 2b921b92c3
commit 7ee7ababe1

@ -52,32 +52,33 @@ public class PartnerCardDashboardServiceImp implements PartnerCardDashboardServi
private LogSettleMailMapper logSettleMailMapper; private LogSettleMailMapper logSettleMailMapper;
@Resource @Resource
private PaymentApi paymentApi; private PaymentApi paymentApi;
@Override @Override
public JSONObject getCommonAnalysis(String client_moniker) { public JSONObject getCommonAnalysis(String client_moniker) {
JSONObject client = clientManager.getClientInfoByMoniker(client_moniker); JSONObject client = clientManager.getClientInfoByMoniker(client_moniker);
client.putAll(clientConfigService.find(client.getIntValue("client_id"))); client.putAll(clientConfigService.find(client.getIntValue("client_id")));
JSONObject earlistOrder = transactionAnalysisMapper.getEarliestOrder(client.getIntValue("client_id")); JSONObject earlistOrder = transactionAnalysisMapper.getEarliestOrder(client.getIntValue("client_id"));
Date data = new Date(); Date data = new Date();
if (earlistOrder != null){ if (earlistOrder != null) {
client.put("transaction_time", DateFormatUtils.format(earlistOrder.getDate("transaction_time"),"yyyy-MM-dd")); client.put("transaction_time", DateFormatUtils.format(earlistOrder.getDate("transaction_time"), "yyyy-MM-dd"));
} }
JSONObject res = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), data,"Wechat"); JSONObject res = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), data, "Wechat");
JSONObject best_pay = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), data,"Bestpay"); JSONObject best_pay = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), data, "Bestpay");
JSONObject ali_pay = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), data,"Alipay"); JSONObject ali_pay = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), data, "Alipay");
JSONObject rate_value = new JSONObject(); JSONObject rate_value = new JSONObject();
if (res!= null){ if (res != null) {
rate_value.put("wechat_rate_value",res.getBigDecimal("rate_value").setScale(1, BigDecimal.ROUND_DOWN)); rate_value.put("wechat_rate_value", res.getBigDecimal("rate_value").setScale(1, BigDecimal.ROUND_DOWN));
if (res.getInteger("clean_days") != null) { if (res.getInteger("clean_days") != null) {
client.put("clean_days", res.getIntValue("clean_days")); client.put("clean_days", res.getIntValue("clean_days"));
} }
} }
if(best_pay != null){ if (best_pay != null) {
rate_value.put("best_rate_value",best_pay.getBigDecimal("rate_value").setScale(1, BigDecimal.ROUND_DOWN)); rate_value.put("best_rate_value", best_pay.getBigDecimal("rate_value").setScale(1, BigDecimal.ROUND_DOWN));
} }
if(ali_pay != null){ if (ali_pay != null) {
rate_value.put("ali_rate_value",ali_pay.getBigDecimal("rate_value").setScale(1, BigDecimal.ROUND_DOWN)); rate_value.put("ali_rate_value", ali_pay.getBigDecimal("rate_value").setScale(1, BigDecimal.ROUND_DOWN));
} }
client.put("rate_value",rate_value); client.put("rate_value", rate_value);
return client; return client;
} }
@ -86,7 +87,7 @@ public class PartnerCardDashboardServiceImp implements PartnerCardDashboardServi
JSONObject client = clientManager.getClientInfoByMoniker(client_moniker); JSONObject client = clientManager.getClientInfoByMoniker(client_moniker);
Assert.notNull(client); Assert.notNull(client);
JSONObject params = new JSONObject(); JSONObject params = new JSONObject();
params.put("client_id",client.getIntValue("client_id")); params.put("client_id", client.getIntValue("client_id"));
return transactionAnalysisMapper.getTransactionCommonAnalysis(params); return transactionAnalysisMapper.getTransactionCommonAnalysis(params);
} }
@ -95,7 +96,7 @@ public class PartnerCardDashboardServiceImp implements PartnerCardDashboardServi
JSONObject client = clientManager.getClientInfoByMoniker(client_moniker); JSONObject client = clientManager.getClientInfoByMoniker(client_moniker);
Assert.notNull(client); Assert.notNull(client);
JSONObject params = new JSONObject(); JSONObject params = new JSONObject();
params.put("client_id",client.getIntValue("client_id")); params.put("client_id", client.getIntValue("client_id"));
return customerAndOrdersStatisticsMapper.getPartnerCustomerAndOrderStatistics(params); return customerAndOrdersStatisticsMapper.getPartnerCustomerAndOrderStatistics(params);
} }
@ -104,16 +105,16 @@ public class PartnerCardDashboardServiceImp implements PartnerCardDashboardServi
JSONObject client = clientManager.getClientInfoByMoniker(client_moniker); JSONObject client = clientManager.getClientInfoByMoniker(client_moniker);
Assert.notNull(client); Assert.notNull(client);
JSONObject params = new JSONObject(); JSONObject params = new JSONObject();
params.put("client_id",client.getIntValue("client_id")); params.put("client_id", client.getIntValue("client_id"));
return dashboardService.getTradeInTypes(params); return dashboardService.getTradeInTypes(params);
} }
@Override @Override
public JSONObject getOrderAndCustomerPerDay(String client_moniker){ public JSONObject getOrderAndCustomerPerDay(String client_moniker) {
JSONObject client = clientManager.getClientInfoByMoniker(client_moniker); JSONObject client = clientManager.getClientInfoByMoniker(client_moniker);
Assert.notNull(client); Assert.notNull(client);
JSONObject params = new JSONObject(); JSONObject params = new JSONObject();
params.put("client_id",client.getIntValue("client_id")); params.put("client_id", client.getIntValue("client_id"));
return customerAndOrdersStatisticsMapper.getAvgOrderAndCustomerStatistics(params); return customerAndOrdersStatisticsMapper.getAvgOrderAndCustomerStatistics(params);
} }
@ -124,38 +125,38 @@ public class PartnerCardDashboardServiceImp implements PartnerCardDashboardServi
JSONObject earlistOrder = transactionAnalysisMapper.getEarliestOrder(client.getIntValue("client_id")); JSONObject earlistOrder = transactionAnalysisMapper.getEarliestOrder(client.getIntValue("client_id"));
String timezone = client.getString("timezone"); String timezone = client.getString("timezone");
AnalysisBean analysisBean = new AnalysisBean(); AnalysisBean analysisBean = new AnalysisBean();
if (earlistOrder != null){ if (earlistOrder != null) {
analysisBean.setBegin(DateFormatUtils.format(earlistOrder.getDate("transaction_time"),"yyyyMMdd")); analysisBean.setBegin(DateFormatUtils.format(earlistOrder.getDate("transaction_time"), "yyyyMMdd"));
} }
analysisBean.setEnd(DateFormatUtils.format(new Date(),"yyyyMMdd")); analysisBean.setEnd(DateFormatUtils.format(new Date(), "yyyyMMdd"));
JSONObject params = analysisBean.toParams(timezone); JSONObject params = analysisBean.toParams(timezone);
params.put("client_id",client.getIntValue("client_id")); params.put("client_id", client.getIntValue("client_id"));
return dashboardService.getTradeAnalysisInHours(params); return dashboardService.getTradeAnalysisInHours(params);
} }
@Override @Override
public JSONObject getSettlementLog(String client_moniker,TradeLogQuery query) { public JSONObject getSettlementLog(String client_moniker, TradeLogQuery query) {
JSONObject client = clientManager.getClientInfoByMoniker(client_moniker); JSONObject client = clientManager.getClientInfoByMoniker(client_moniker);
Assert.notNull(client); Assert.notNull(client);
int client_id = client.getIntValue("client_id"); int client_id = client.getIntValue("client_id");
String timezone = client.getString("timezone"); String timezone = client.getString("timezone");
JSONObject earlistOrder = transactionAnalysisMapper.getEarliestOrder(client_id); JSONObject earlistOrder = transactionAnalysisMapper.getEarliestOrder(client_id);
if (earlistOrder!= null){ if (earlistOrder != null) {
query.setDatefrom(DateFormatUtils.format(earlistOrder.getDate("transaction_time"),"yyyyMMdd")); query.setDatefrom(DateFormatUtils.format(earlistOrder.getDate("transaction_time"), "yyyyMMdd"));
} }
query.setDateto(DateFormatUtils.format(new Date(),"yyyyMMdd")); query.setDateto(DateFormatUtils.format(new Date(), "yyyyMMdd"));
JSONObject params = query.toParams(timezone); JSONObject params = query.toParams(timezone);
params.put("client_id", client_id); params.put("client_id", client_id);
PageList<JSONObject> logs = transactionMapper.listSettlementLog(params, new PageBounds(query.getPage(), query.getLimit(), Order.formString("clearing_time.desc"))); PageList<JSONObject> logs = transactionMapper.listSettlementLog(params, new PageBounds(query.getPage(), query.getLimit(), Order.formString("clearing_time.desc")));
JSONObject result = PageListUtils.buildPageListResult(logs); JSONObject result = PageListUtils.buildPageListResult(logs);
if (query.getPage()==1){ if (query.getPage() == 1) {
if (!logs.isEmpty() && logs.size()>0){ if (!logs.isEmpty()) {
JSONObject sendMailLog = logSettleMailMapper.findByDate(logs.get(0).getDate("clearing_time")); List<JSONObject> sendMailLogs = logSettleMailMapper.findByDate(logs.get(0).getDate("clearing_time"));
if (sendMailLog == null) { if (sendMailLogs.isEmpty()) {
result.put("padding",true); result.put("padding", true);
} }
if (sendMailLog!=null && sendMailLog.getIntValue("mail_status") != 1) { if (!sendMailLogs.isEmpty() && sendMailLogs.stream().anyMatch(mail -> mail.getIntValue("mail_status") != 1)) {
result.put("padding",true); result.put("padding", true);
} }
} }
} }

@ -43,9 +43,9 @@ public interface CleanService {
void settlementXlsx(Date date, HttpServletResponse response) throws IOException; void settlementXlsx(Date date, HttpServletResponse response) throws IOException;
List<JSONObject> getXlsx(Date dt, String bank) throws IOException; List<JSONObject> getXlsx(Date dt, String bank, List<String> clearIds) throws IOException;
List<ABAFile> getAba(Date dt, String bank) throws IOException; List<ABAFile> getAba(Date dt, String bank, List<String> clearIds) throws IOException;
void settlementAba(Date date, HttpServletResponse response) throws IOException; void settlementAba(Date date, HttpServletResponse response) throws IOException;
@ -79,11 +79,11 @@ public interface CleanService {
void getTodaySettlementLogs(); void getTodaySettlementLogs();
JSONObject sendSettlementMail(Date date, String checkCode); JSONObject sendSettlementMail(Date date, List<String> clearIds);
void sendCheckCode(Date date, JSONObject manager); void sendCheckCode(Date date, JSONObject manager);
JSONObject findLogSettleByDate(Date date); List<JSONObject> findLogSettleByDate(Date date);
JSONObject validTransactions(Date date, boolean fix, boolean b, boolean b1); JSONObject validTransactions(Date date, boolean fix, boolean b, boolean b1);

@ -64,7 +64,6 @@ import org.springframework.format.number.CurrencyStyleFormatter;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.thymeleaf.context.Context; import org.thymeleaf.context.Context;
import org.thymeleaf.spring5.SpringTemplateEngine; import org.thymeleaf.spring5.SpringTemplateEngine;
@ -256,6 +255,12 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
return data; return data;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
log.put("bank_statistics", bankStatistics); log.put("bank_statistics", bankStatistics);
if (StringUtils.isNotEmpty(log.getString("plan_detail"))) {
try {
log.put("plan_detail", JSON.parseObject(log.getString("plan_detail")));
} catch (JSONException ignore) {
}
}
log.put("editable", DateUtils.isSameDay(log.getDate("settle_date"), new Date()) && log.getBooleanValue("editable")); log.put("editable", DateUtils.isSameDay(log.getDate("settle_date"), new Date()) && log.getBooleanValue("editable"));
log.put("channel_analysis", clearingDetailAnalysisMapper.analysisChannelReport(clearingId)); log.put("channel_analysis", clearingDetailAnalysisMapper.analysisChannelReport(clearingId));
} }
@ -390,9 +395,11 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
} }
@Override @Override
public List<JSONObject> getXlsx(Date dt, String bank) throws IOException { public List<JSONObject> getXlsx(Date dt, String bank, List<String> clearIds) throws IOException {
List<JSONObject> logs = clearingLogMapper.findByDate(dt); List<JSONObject> logs = clearingLogMapper.findByDate(dt);
logs = logs.stream().filter(log -> log.getBooleanValue("editable")).collect(Collectors.toList()); logs = logs.stream().filter(log -> log.getBooleanValue("editable"))
.filter(log -> clearIds.isEmpty() || clearIds.contains(log.getString("clearing_id")))
.collect(Collectors.toList());
if (logs.isEmpty()) { if (logs.isEmpty()) {
throw new NotFoundException(); throw new NotFoundException();
} }
@ -486,9 +493,11 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
} }
@Override @Override
public List<ABAFile> getAba(Date dt, String bank) { public List<ABAFile> getAba(Date dt, String bank, List<String> clearIds) {
List<JSONObject> logs = clearingLogMapper.findByDate(dt); List<JSONObject> logs = clearingLogMapper.findByDate(dt);
logs = logs.stream().filter(log -> log.getBooleanValue("editable")).collect(Collectors.toList()); logs = logs.stream().filter(log -> log.getBooleanValue("editable"))
.filter(log -> clearIds.isEmpty() || clearIds.contains(log.getString("clearing_id")))
.collect(Collectors.toList());
if (logs.isEmpty()) { if (logs.isEmpty()) {
throw new NotFoundException(); throw new NotFoundException();
} }
@ -496,11 +505,19 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
for (JSONObject log : logs) { for (JSONObject log : logs) {
List<JSONObject> details = clearingDetailMapper.listReportsOfSettlement(log.getIntValue("clearing_id")); List<JSONObject> details = clearingDetailMapper.listReportsOfSettlement(log.getIntValue("clearing_id"));
details = mergeBatchSettleClients(details); details = mergeBatchSettleClients(details);
files.addAll(generateSettleAbaFiles(dt, details, log.getDate("operate_time"))); String remark = extractSettleRemark(log);
files.addAll(generateSettleAbaFiles(dt, details, log.getDate("operate_time"), remark));
} }
return files.stream().filter(file -> bank.equals(file.bank())).collect(Collectors.toList()); return files.stream().filter(file -> bank.equals(file.bank())).collect(Collectors.toList());
} }
public String extractSettleRemark(JSONObject log) {
return Optional.ofNullable(StringUtils.defaultIfEmpty(log.getString("plan_detail"), null))
.map(JSON::parseObject)
.map(plan -> StringUtils.defaultIfEmpty(plan.getString("remark"), plan.getString("plan_id")))
.orElse("");
}
private byte[] generateSettleXlsxFile(Date dt, List<JSONObject> settlements, String bank) throws IOException { private byte[] generateSettleXlsxFile(Date dt, List<JSONObject> settlements, String bank) throws IOException {
try (Workbook wb = new XSSFWorkbook()) { try (Workbook wb = new XSSFWorkbook()) {
Sheet sheet = wb.createSheet("Merchant_Settlement_Info_" + DateFormatUtils.format(dt, "yyyyMMdd")); Sheet sheet = wb.createSheet("Merchant_Settlement_Info_" + DateFormatUtils.format(dt, "yyyyMMdd"));
@ -536,7 +553,7 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
for (JSONObject log : logs) { for (JSONObject log : logs) {
List<JSONObject> details = clearingDetailMapper.listReportsOfSettlement(log.getIntValue("clearing_id")); List<JSONObject> details = clearingDetailMapper.listReportsOfSettlement(log.getIntValue("clearing_id"));
details = mergeBatchSettleClients(details); details = mergeBatchSettleClients(details);
files.addAll(generateSettleAbaFiles(dt, details, log.getDate("operate_time"))); files.addAll(generateSettleAbaFiles(dt, details, log.getDate("operate_time"), extractSettleRemark(log)));
} }
OutputStream ous = resp.getOutputStream(); OutputStream ous = resp.getOutputStream();
if (files.size() == 1) { if (files.size() == 1) {
@ -580,7 +597,7 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
resp.addHeader("Content-Disposition", "attachment; filename=" + zipName); resp.addHeader("Content-Disposition", "attachment; filename=" + zipName);
OutputStream ous = resp.getOutputStream(); OutputStream ous = resp.getOutputStream();
List<ABAFile> abaFiles = generateSettleAbaFiles(settleDate, details, opTime); List<ABAFile> abaFiles = generateSettleAbaFiles(settleDate, details, opTime, extractSettleRemark(clearing));
try (ZipOutputStream zos = new ZipOutputStream(ous)) { try (ZipOutputStream zos = new ZipOutputStream(ous)) {
for (ABAFile aba : abaFiles) { for (ABAFile aba : abaFiles) {
zos.putNextEntry(new ZipEntry(aba.filename())); zos.putNextEntry(new ZipEntry(aba.filename()));
@ -591,9 +608,12 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
} }
} }
private List<ABAFile> generateSettleAbaFiles(Date dt, List<JSONObject> settlements, Date operateTime) { private List<ABAFile> generateSettleAbaFiles(Date dt, List<JSONObject> settlements, Date operateTime, String remark) {
List<String> banks = settlements.stream().map(detail -> detail.getString("settle_bank")).distinct().collect(Collectors.toList()); List<String> banks = settlements.stream().map(detail -> detail.getString("settle_bank")).distinct().collect(Collectors.toList());
return banks.stream().map(bank -> generateSettleAbaFile(bank, dt, settlements)).peek(file -> file.setOperateTime(operateTime)).collect(Collectors.toList()); return banks.stream().map(bank -> generateSettleAbaFile(bank, dt, settlements))
.peek(file -> file.setOperateTime(operateTime))
.peek(file -> file.setRemark(remark))
.collect(Collectors.toList());
} }
private ABAFile generateSettleAbaFile(String bank, Date dt, List<JSONObject> settlements) { private ABAFile generateSettleAbaFile(String bank, Date dt, List<JSONObject> settlements) {
@ -1092,28 +1112,8 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
} }
@Override @Override
public JSONObject sendSettlementMail(Date date, String checkCode) { public JSONObject sendSettlementMail(Date date, List<String> clearIds) {
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
String redisCode = stringRedisTemplate.boundValueOps(reidsCheckCodeKey).get();
if (StringUtils.isEmpty(redisCode)) {
result.put("result", 1);
result.put("msg", "The verification code has expired Please send the verification code again");
return result;
}
if (!redisCode.equals(checkCode)) {
result.put("result", 1);
result.put("msg", "The verification code is incorrect");
return result;
}
JSONObject settleMail = logSettleMailMapper.findByDate(date);
if (settleMail != null) {
List<JSONObject> emailStatus = mailService.checkEmailStatus(settleMail.getString("email_id"));
if (!CollectionUtils.isEmpty(emailStatus) && emailStatus.get(0).getIntValue("status") == 1 && settleMail.getIntValue("mail_status") == 1) {
result.put("result", 0);
result.put("msg", "Excel has been sent");
return result;
}
}
try { try {
String title = "Royalpay Settlement File " + DateFormatUtils.format(date, "yyyyMMdd"); String title = "Royalpay Settlement File " + DateFormatUtils.format(date, "yyyyMMdd");
JSONObject model = new JSONObject(); JSONObject model = new JSONObject();
@ -1121,7 +1121,7 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
String fileName1 = "Merchant_Settlement_Info_xlsx_" + DateFormatUtils.format(date, "yyyyMMdd"); String fileName1 = "Merchant_Settlement_Info_xlsx_" + DateFormatUtils.format(date, "yyyyMMdd");
List<JSONObject> attachList = new ArrayList<>(); List<JSONObject> attachList = new ArrayList<>();
JSONObject attach1 = new JSONObject(); JSONObject attach1 = new JSONObject();
List<JSONObject> xlsxFileList = getXlsx(date, "CBA"); List<JSONObject> xlsxFileList = getXlsx(date, "CBA", clearIds);
if (xlsxFileList.size() > 1) { if (xlsxFileList.size() > 1) {
fileName1 += ".zip"; fileName1 += ".zip";
attach1.put("content", Base64.encodeBase64String(getZipByteArr(xlsxFileList))); attach1.put("content", Base64.encodeBase64String(getZipByteArr(xlsxFileList)));
@ -1133,7 +1133,7 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
attachList.add(attach1); attachList.add(attach1);
JSONObject attach2 = new JSONObject(); JSONObject attach2 = new JSONObject();
List<ABAFile> abaFileList = getAba(date, "CBA"); List<ABAFile> abaFileList = getAba(date, "CBA", clearIds);
String fileName2 = "Merchant_Settlement_Info_aba_" + DateFormatUtils.format(date, "yyyyMMdd"); String fileName2 = "Merchant_Settlement_Info_aba_" + DateFormatUtils.format(date, "yyyyMMdd");
if (abaFileList.size() > 1) { if (abaFileList.size() > 1) {
fileName2 += ".zip"; fileName2 += ".zip";
@ -1157,6 +1157,7 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
Context ctx = new Context(); Context ctx = new Context();
ctx.setVariable("date", DateFormatUtils.format(date, "dd-MM-yyyy")); ctx.setVariable("date", DateFormatUtils.format(date, "dd-MM-yyyy"));
ctx.setVariable("abaFiles", abaFileList); ctx.setVariable("abaFiles", abaFileList);
ctx.setVariable("totalAmount", abaFileList.stream().map(ABAFile::getTotalSettleAmount).reduce(BigDecimal::add));
final String content = thymeleaf.process("mail/settlement_mail", ctx); final String content = thymeleaf.process("mail/settlement_mail", ctx);
// 测试用地址 // 测试用地址
// String mailId = mailService.sendEmail(title, "164851225@qq.com", "1029811920@qq.com", content, // String mailId = mailService.sendEmail(title, "164851225@qq.com", "1029811920@qq.com", content,
@ -1164,35 +1165,21 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
JSONObject config = sysConfigManager.getSysConfig(); JSONObject config = sysConfigManager.getSysConfig();
String mailId = mailService.sendEmail(title, config.getString("settle_mail_to"), config.getString("settle_mail_cc"), content, attachList); String mailId = mailService.sendEmail(title, config.getString("settle_mail_to"), config.getString("settle_mail_cc"), content, attachList);
if (settleMail == null) { JSONObject settleMailRecord = new JSONObject();
JSONObject settleMailRecord = new JSONObject(); settleMailRecord.put("send_date", new Date());
settleMailRecord.put("send_date", new Date()); settleMailRecord.put("clearing_date", date);
settleMailRecord.put("clearing_date", date); settleMailRecord.put("email_id", mailId);
settleMailRecord.put("email_id", mailId); if (StringUtils.isEmpty(mailId)) {
if (StringUtils.isEmpty(mailId)) { result.put("result", 1);
result.put("result", 1); result.put("msg", "System error");
result.put("msg", "System error"); settleMailRecord.put("mail_status", 0);
settleMailRecord.put("mail_status", 0); settleMailRecord.put("notice_status", 0);
settleMailRecord.put("notice_status", 0); logSettleMailMapper.save(settleMailRecord);
logSettleMailMapper.save(settleMailRecord); return result;
return result;
} else {
settleMailRecord.put("mail_status", 1);
settleMailRecord.put("notice_status", 0);
logSettleMailMapper.save(settleMailRecord);
}
} else { } else {
if (!StringUtils.isEmpty(mailId)) { settleMailRecord.put("mail_status", 1);
JSONObject updateRecord = new JSONObject(); settleMailRecord.put("notice_status", 0);
updateRecord.put("id", settleMail.getString("id")); logSettleMailMapper.save(settleMailRecord);
updateRecord.put("mail_status", 1);
updateRecord.put("email_id", mailId);
logSettleMailMapper.update(updateRecord);
} else {
result.put("result", 0);
result.put("msg", "System error");
return result;
}
} }
sendTaskFinishMessages(ManagerRole.FINANCIAL_STAFF, "清算文件已发送清算方", "发送清算通知"); sendTaskFinishMessages(ManagerRole.FINANCIAL_STAFF, "清算文件已发送清算方", "发送清算通知");
clearingLogMapper.lockSettlements(date); clearingLogMapper.lockSettlements(date);
@ -1246,7 +1233,7 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
} }
@Override @Override
public JSONObject findLogSettleByDate(Date date) { public List<JSONObject> findLogSettleByDate(Date date) {
return logSettleMailMapper.findByDate(date); return logSettleMailMapper.findByDate(date);
} }

@ -121,14 +121,15 @@ public class SettlementDevController {
} }
} }
@ManagerMapping(value = "/reports/{date}/send_settlement_xlsx/{checkCode}", role = {ManagerRole.FINANCIAL_STAFF}) @ManagerMapping(value = "/reports/{date}/send_settlement_xlsx", role = {ManagerRole.FINANCIAL_STAFF}, method = RequestMethod.POST)
public JSONObject sendSettlementMail(@PathVariable("date") String date, @PathVariable("checkCode") String checkCode) { public JSONObject sendSettlementMail(@PathVariable("date") String date, @RequestBody JSONObject data) {
Date dt = null; Date dt = null;
try { try {
dt = dateFormat.parse(date); dt = dateFormat.parse(date);
} catch (ParseException e) { } catch (ParseException e) {
} }
return cleanService.sendSettlementMail(dt, checkCode); List<String> clearIds = data.getJSONArray("clearing_ids").toJavaList(String.class);
return cleanService.sendSettlementMail(dt, clearIds);
} }
@ManagerMapping(value = "/reports/send_checkcode", role = {ManagerRole.FINANCIAL_STAFF}) @ManagerMapping(value = "/reports/send_checkcode", role = {ManagerRole.FINANCIAL_STAFF})
@ -137,7 +138,7 @@ public class SettlementDevController {
} }
@RequestMapping(value = "/reports/{date}/send_status") @RequestMapping(value = "/reports/{date}/send_status")
public JSONObject sendStatus(@PathVariable String date) { public List<JSONObject> sendStatus(@PathVariable String date) {
Date dt = null; Date dt = null;
try { try {
dt = dateFormat.parse(date); dt = dateFormat.parse(date);

@ -6,6 +6,7 @@ import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
* Created by davep on 2016-09-04. * Created by davep on 2016-09-04.
@ -16,7 +17,7 @@ public interface LogSettleMailMapper {
@AutoSql(type = SqlType.INSERT) @AutoSql(type = SqlType.INSERT)
void save(JSONObject clearingLog); void save(JSONObject clearingLog);
JSONObject findByDate(Date date); List<JSONObject> findByDate(Date date);
@AutoSql(type = SqlType.UPDATE) @AutoSql(type = SqlType.UPDATE)
void update(JSONObject update); void update(JSONObject update);

@ -21,6 +21,7 @@ public class ABAFile {
private List<SettleMerchantInfo> settlements; private List<SettleMerchantInfo> settlements;
private BigDecimal totalSettleAmount; private BigDecimal totalSettleAmount;
private Date operateTime; private Date operateTime;
private String remark;
public ABAFile(ABAConfig.ABABase base, Date settleDate) { public ABAFile(ABAConfig.ABABase base, Date settleDate) {
this.base = base; this.base = base;
@ -34,6 +35,15 @@ public class ABAFile {
totalSettleAmount = totalSettleAmount.add(settleAmount); totalSettleAmount = totalSettleAmount.add(settleAmount);
} }
public String getRemark() {
return remark;
}
public ABAFile setRemark(String remark) {
this.remark = remark;
return this;
}
public boolean manualSending() { public boolean manualSending() {
return base.isManualSending(); return base.isManualSending();
} }
@ -62,6 +72,10 @@ public class ABAFile {
return format.format(totalSettleAmount); return format.format(totalSettleAmount);
} }
public BigDecimal getTotalSettleAmount(){
return totalSettleAmount;
}
private String generateFinalLine() { private String generateFinalLine() {
StringBuilder lineBuilder = new StringBuilder(baseLine); StringBuilder lineBuilder = new StringBuilder(baseLine);
lineBuilder.replace(0, 1, "7"); lineBuilder.replace(0, 1, "7");

@ -5,11 +5,12 @@
<br> <br>
<br> <br>
<p>Please find the attached settlement files data up to <span th:text="${date}"></span></p> <p>Please find the attached settlement files data up to <span th:text="${date}"></span></p>
<p th:text="|Total Amount: ${totalAmount}|"></p>
<p></p> <p></p>
<p>File Validation:</p> <p>File Validation:</p>
<p> <p>
<ul> <ul>
<li th:each="aba : ${abaFiles}" th:text="|${aba.filename()} : ${aba.getTotalSettleAmountStr()}|"></li> <li th:each="aba : ${abaFiles}" th:text="|${aba.filename()}(${aba.getRemark()}) : ${aba.getTotalSettleAmountStr()}|"></li>
</ul> </ul>
</p> </p>
<br> <br>

@ -323,11 +323,16 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func
if ($scope.datePattern == nowStr) { if ($scope.datePattern == nowStr) {
$scope.sendNotice = true; $scope.sendNotice = true;
} }
$scope.displaySendCheckCode = function () { $scope.displaySendCheck = function () {
$uibModal.open({ $uibModal.open({
templateUrl: '/static/analysis/templates/settlement_send_check_code.html', templateUrl: '/static/analysis/templates/settlement_send_check_code.html',
controller: 'settlementSendCheckCodeCtrl', controller: 'settlementSendCheckCodeCtrl',
size: 'sm' size: 'sm',
resolve: {
settleLogs: function () {
return $scope.detail.logs.filter(log => log.editable);
}
}
}); });
}; };
@ -348,15 +353,6 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func
})[0]; })[0];
}; };
$http.get('/sys/settlement/reports/' + $stateParams.date + '/send_status/').then(function (resp) {
if (resp.data != null && resp.data.mail_status == 1) {
$scope.hasSentMail = true;
}
});
$scope.$on("sendMailSuccess",
function (event, msg) {
$scope.hasSentMail = true;
});
$scope.confirmSendSettlementMail = function () { $scope.confirmSendSettlementMail = function () {
commonDialog.confirm({ commonDialog.confirm({
@ -497,7 +493,18 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func
}; };
}]); }]);
app.controller('settlementSendCheckCodeCtrl', ['$scope', '$http', '$rootScope', '$stateParams', function ($scope, $http, $rootScope, $stateParams) { app.controller('settlementSendCheckCodeCtrl', ['$scope', '$http', '$rootScope', '$stateParams', 'settleLogs', function ($scope, $http, $rootScope, $stateParams, settleLogs) {
$scope.settleLogs = settleLogs.map(log => {
let info = {
'id': log.clearing_id,
'remark': log.plan_detail.remark || log.plan_detail.plan_id,
'send': false
};
return info
});
$scope.switchSendFlag=function(info){
info.send=!info.send
};
$scope.sendCheckCodeButton = false; $scope.sendCheckCodeButton = false;
$scope.sendMailButton = false; $scope.sendMailButton = false;
$scope.check_code = ''; $scope.check_code = '';
@ -510,12 +517,9 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func
$scope.sendSettlementMail = function () { $scope.sendSettlementMail = function () {
$scope.error_msg = '正在发送,请稍后。'; $scope.error_msg = '正在发送,请稍后。';
if ($scope.check_code == '' || $scope.check_code == null) {
$scope.error_msg = '请输入验证码';
return;
}
$scope.sendMailButton = true; $scope.sendMailButton = true;
$http.get('/sys/settlement/reports/' + $stateParams.date + '/send_settlement_xlsx/' + $scope.check_code).then(function (resp) { $http.post('/sys/settlement/reports/' + $stateParams.date + '/send_settlement_xlsx',
{clearing_ids:$scope.settleLogs.filter(log=>log.send).map(log=>log.clearing_id)}).then(function (resp) {
$scope.error_msg = resp.data.msg; $scope.error_msg = resp.data.msg;
$scope.sendMailButton = false; $scope.sendMailButton = false;
if (resp.data.result == 0) { if (resp.data.result == 0) {

@ -29,7 +29,7 @@
<i class="fa fa-download"></i> Settlement.aba <i class="fa fa-download"></i> Settlement.aba
</a> </a>
<button type="button" class="btn btn-warning " ng-if="(('1000'|withRole) && !hasSentMail)&&sendNotice" <button type="button" class="btn btn-warning " ng-if="(('1000'|withRole) && !hasSentMail)&&sendNotice"
data-toggle="modal" ng-click="displaySendCheckCode()"> data-toggle="modal" ng-click="displaySendCheck()">
Send Settlement Mail Send Settlement Mail
</button> </button>
<button class="btn btn-success" ng-if="hasSentMail" disabled="true"> <button class="btn btn-success" ng-if="hasSentMail" disabled="true">
@ -60,7 +60,7 @@
ng-click="switchSettleBatch(log)" ng-click="switchSettleBatch(log)"
ng-class="{active:analysisFilter.clearing_id==log.clearing_id}"> ng-class="{active:analysisFilter.clearing_id==log.clearing_id}">
<i class="fa fa-lock" ng-if="!log.editable"></i> <i class="fa fa-lock" ng-if="!log.editable"></i>
<span ng-bind="log.operate_time"></span> <span ng-bind="'['+(log.plan_detail.remark||log.plan_detail.plan_id)+']'+log.operate_time"></span>
</button> </button>
</div> </div>
</div> </div>

@ -4,10 +4,9 @@
<div class="modal-body" style="height: 300px"> <div class="modal-body" style="height: 300px">
<div class="text-center" > <div class="text-center" >
<div class="col-sm-12"> <div class="col-sm-12">
<input type="text" ng-model="check_code" class="col-sm-6" style="margin-right:7px" required> <ul class="list-group">
<button type="button" class="btn btn-default col-sm-5" data-dismiss="modal" <li class="list-group-item" ng-repeat="log in settleLogs" ng-class="{'active':log.send}" ng-click="switchSendFlag(log)">[{{log.remark}}]log.clearing_id</li>
ng-click="sendCheckCode()" ng-disabled="sendCheckCodeButton">发送验证码 </ul>
</button>
</div> </div>
<div class="col-sm-12"> <div class="col-sm-12">
<button type="button" class="btn btn-primary" style="width: 100%; margin-top: 30px" data-dismiss="modal" <button type="button" class="btn btn-primary" style="width: 100%; margin-top: 30px" data-dismiss="modal"

@ -14,6 +14,7 @@ import org.thymeleaf.spring5.SpringTemplateEngine;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -33,7 +34,7 @@ public class SettleMailTest {
@Test @Test
public void parse() throws IOException { public void parse() throws IOException {
Date date = DateUtils.truncate(new Date(), Calendar.DATE); Date date = DateUtils.truncate(new Date(), Calendar.DATE);
List<ABAFile> abaFileList = cleanService.getAba(date, "CBA"); List<ABAFile> abaFileList = cleanService.getAba(date, "CBA", new ArrayList<>());
Context ctx = new Context(); Context ctx = new Context();
ctx.setVariable("date", DateFormatUtils.format(date, "dd-MM-yyyy")); ctx.setVariable("date", DateFormatUtils.format(date, "dd-MM-yyyy"));

Loading…
Cancel
Save