apply interceptor

master
yixian 6 years ago
parent 40f3e9368a
commit ac75df6ead

@ -943,9 +943,6 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
model.put("date", DateFormatUtils.format(date, "dd-MM-yyyy"));
// todo themeleaf
Context ctx = new Context();
ctx.setVariable("date", DateFormatUtils.format(date, "dd-MM-yyyy"));
final String content = thymeleaf.process("mail/settlement_mail", ctx);
// final String content = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine,
// "mail/settlement_mail.vm", "utf-8", model);
@ -984,6 +981,11 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
}
attach2.put("name", fileName2);
attachList.add(attach2);
Context ctx = new Context();
ctx.setVariable("date", DateFormatUtils.format(date, "dd-MM-yyyy"));
ctx.setVariable("abaFiles", abaFileList);
final String content = thymeleaf.process("mail/settlement_mail", ctx);
// 测试用地址
// String mailId = mailService.sendEmail(title, "164851225@qq.com", "1029811920@qq.com", content,
// attachList);

@ -9,6 +9,7 @@ import org.springframework.util.Assert;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -56,6 +57,11 @@ public class ABAFile {
return out.toString().getBytes();
}
public String getTotalSettleAmountStr() {
DecimalFormat format = new DecimalFormat("#.##0.00");
return format.format(totalSettleAmount);
}
private String generateFinalLine() {
StringBuilder lineBuilder = new StringBuilder(baseLine);
lineBuilder.replace(0, 1, "7");

@ -1,22 +1,29 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="zh">
<div style="color: #000000">
<p>Dear Flexewallet,</p>
<br>
<br>
<p>Please find the attached settlement files data up to <span th:text="${date}"></span></p>
<br>
<br>
<p>Best Regards,</p>
<p style="border-bottom: 45px; font-weight: 900;">RoyalPay Finance team</p>
<p style="margin: initial;">Tunnel Show Pty Ltd trading as RoyalPay</p>
<p style="margin: initial;">Representative of AFS Licensee 448066</p>
<p style="margin: initial;">------------------------------</p>
<p style="margin: initial;">Lv.11,15 William Street Melbourne 3000 </p>
<p style="margin: initial;">Lv.14, 383 Kent Street, Sydney, NSW 2000 </p>
<p style="margin: initial;">P: 1300 1077 50</p>
<p style="margin: initial;">E: settlement@royalpay.com.au</p>
<p style="margin: initial;">www.royalpay.com.au</p>
<p>Dear Flexewallet,</p>
<br>
<br>
<p>Please find the attached settlement files data up to <span th:text="${date}"></span></p>
<p></p>
<p>File Validation:</p>
<p>
<ul>
<li th:each="aba : ${abaList}">${aba.filename()} : ${aba.getTotalSettleAmountStr()}</li>
</ul>
</p>
<br>
<br>
<p>Best Regards,</p>
<p style="border-bottom: 45px; font-weight: 900;">RoyalPay Finance team</p>
<p style="margin: initial;">Tunnel Show Pty Ltd trading as RoyalPay</p>
<p style="margin: initial;">Representative of AFS Licensee 448066</p>
<p style="margin: initial;">------------------------------</p>
<p style="margin: initial;">Lv.11,15 William Street Melbourne 3000 </p>
<p style="margin: initial;">Lv.14, 383 Kent Street, Sydney, NSW 2000 </p>
<p style="margin: initial;">P: 1300 1077 50</p>
<p style="margin: initial;">E: settlement@royalpay.com.au</p>
<p style="margin: initial;">www.royalpay.com.au</p>
</div>
</html>

@ -0,0 +1,94 @@
package au.com.royalpay.payment.manage.process.alipay;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.*;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.Optional;
/**
* Create by yixian at 2018-08-14 21:41
*/
@SpringBootTest
@ActiveProfiles({"proxy"})
@RunWith(SpringRunner.class)
public class FixAlipayData {
@Resource
private JdbcTemplate jdbcTemplate;
private String fileLocation = "C:\\Users\\yixian\\Documents\\royalpay\\2018\\alipayfix\\2088721525235246_20180815110000000032102003900557154_result - 副本.xls";
private String fileTarget = "C:\\Users\\yixian\\Documents\\royalpay\\2018\\alipayfix\\fixed_2088721525235246_20180815110000000032102003900557154_result.xls";
private Logger logger = LoggerFactory.getLogger(getClass());
@Test
public void fix() throws IOException, InvalidFormatException {
Workbook wb = WorkbookFactory.create(new File(fileLocation));
Sheet sheet = wb.getSheetAt(0);
final int startRow = 6;
int rowNum = startRow;
String compName;
while ((compName = mchCompName(sheet, rowNum)) != null) {
logger.info("row:" + rowNum + ",company name=" + compName);
final String corpName = compName;
Row row = sheet.getRow(rowNum++);
String shortName = row.getCell(2).getStringCellValue();
List<Map<String, Object>> clients = jdbcTemplate.queryForList("select c.company_name,c.short_name,c.ali_sub_merchant_id,c.alipayindustry,c.country,c.address,c.state,l.latitude,l.longitude from sys_clients c" +
" left join sys_clients_locations l on l.client_id=c.client_id where c.short_name=?", shortName);
if (clients.isEmpty()) {
clients = jdbcTemplate.queryForList("select c.company_name,c.short_name,c.ali_sub_merchant_id,c.alipayindustry,c.country,c.address,c.state,l.latitude,l.longitude from sys_clients c" +
" left join sys_clients_locations l on l.client_id=c.client_id where c.company_name=?", corpName);
if (clients.isEmpty()) {
continue;
}
}
Optional<Map<String, Object>> cliOpts = clients.stream()
.filter(cli -> new JSONObject(cli).getString("company_name").equals(corpName))
.findFirst();
JSONObject client = new JSONObject(cliOpts.isPresent() ? cliOpts.get() : clients.get(0));
String moniker = client.getString("ali_sub_merchant_id");
logger.info("updating to xlsx:" + moniker);
row.getCell(4).setCellValue(moniker);
row.getCell(5).setCellValue(moniker);
String mcc = client.getString("alipayindustry");
row.getCell(7).setCellValue(StringUtils.isEmpty(mcc) ? "5311" : mcc);
row.getCell(8).setCellValue("Australia");
if (StringUtils.isNoneEmpty(client.getString("address"), client.getString("state"))) {
row.getCell(9).setCellValue(client.getString("address") + "," + client.getString("state"));
}
if (client.getString("latitude") != null) {
row.getCell(29).setCellValue(client.getBigDecimal("latitude").setScale(8, BigDecimal.ROUND_DOWN).toPlainString());
row.getCell(30).setCellValue(client.getBigDecimal("longitude").setScale(8, BigDecimal.ROUND_DOWN).toPlainString());
}
logger.info("finished update row:" + (rowNum - 1));
}
wb.write(new FileOutputStream(fileTarget));
}
private String mchCompName(Sheet sheet, int rowNum) {
Row row = sheet.getRow(rowNum);
if (row == null) {
return null;
}
Cell cell = row.getCell(1);
if (cell == null) {
return null;
}
return cell.getStringCellValue();
}
}

@ -0,0 +1,54 @@
package au.com.royalpay.payment.manage.process.custom;
import au.com.royalpay.payment.channels.alipay.runtime.impls.AlipayCustomDeclaringTaskProcessor;
import au.com.royalpay.payment.core.mappers.PmtCustomReportsDetailMapper;
import au.com.royalpay.payment.core.mappers.PmtCustomReportsMapper;
import au.com.royalpay.payment.core.mappers.PmtOrderMapper;
import au.com.royalpay.payment.manage.mappers.custom.CustomReportDetailsMapper;
import au.com.royalpay.payment.manage.mappers.custom.CustomReportsMapper;
import com.alibaba.fastjson.JSONObject;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.util.List;
/**
* Create by yixian at 2018-08-14 20:28
*/
@SpringBootTest
@ActiveProfiles({"proxy", "alipay"})
@TestPropertySource(properties = {"spring.datasource.username=root", "spring.datasource.password=ZOIBhellor0yalpay"})
@RunWith(SpringRunner.class)
public class ManualReportCustom {
@Autowired
private AlipayCustomDeclaringTaskProcessor processor;
@Resource
private PmtCustomReportsMapper pmtCustomReportsMapper;
@Resource
private PmtOrderMapper pmtOrderMapper;
@Resource
private PmtCustomReportsDetailMapper pmtCustomReportsDetailMapper;
@Test
public void test() {
String reportId = "05482201808142036430702208";
List<JSONObject> customs = pmtCustomReportsMapper.findReport(reportId);
List<JSONObject> sub = pmtCustomReportsDetailMapper.listSubReports(reportId);
JSONObject order = pmtOrderMapper.find(reportId);
JSONObject task = new JSONObject();
task.put("channel", order.getString("channel"));
task.put("merchant_id", order.getString("merchant_id"));
task.put("sub_orders", sub);
task.put("report", customs.stream().filter(rep -> rep.getIntValue("report_status") == 2)
.findFirst().orElseThrow(() -> new RuntimeException("No Failure Reports")));
processor.process(task);
}
}
Loading…
Cancel
Save