commit
cb99428bcc
@ -0,0 +1,66 @@
|
|||||||
|
package au.com.royalpay.payment.manage.management.clearing.web;
|
||||||
|
|
||||||
|
import au.com.royalpay.payment.manage.mappers.log.ValidationLogMapper;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import netscape.javascript.JSObject;
|
||||||
|
import org.apache.commons.lang3.time.DateUtils;
|
||||||
|
import org.apache.xerces.impl.validation.ValidationManager;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description:
|
||||||
|
* @Author: lujian
|
||||||
|
* @Date: 2019/1/30 13:50
|
||||||
|
*/
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/sys/financial")
|
||||||
|
public class ArrivalNoticeController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ValidationLogMapper validationLogMapper;
|
||||||
|
|
||||||
|
@GetMapping("/notice")
|
||||||
|
public String noticePage(HashMap<String, Object> map,
|
||||||
|
@RequestParam("date") String date) throws ParseException {
|
||||||
|
|
||||||
|
JSONArray reports = new JSONArray();
|
||||||
|
Date dt = DateUtils.parseDate(date, new String[]{"yyyyMMdd"});
|
||||||
|
JSONObject reportItem = validationLogMapper.findByDate(dt);
|
||||||
|
if (reportItem != null) {
|
||||||
|
JSONObject result = JSON.parseObject(reportItem.getString("result"));
|
||||||
|
reports = result.getJSONArray("channel_details");
|
||||||
|
for (int i = 0; i < reports.size(); i++) {
|
||||||
|
JSONObject channelItem = reports.getJSONObject(i);
|
||||||
|
String channel = channelItem.getString("channel");
|
||||||
|
if (channel.equals("Wechat") && result.containsKey("wechat_analysis")) {
|
||||||
|
JSONObject wechatAnalysis = result.getJSONObject("wechat_analysis");
|
||||||
|
List<JSONObject> analysis = new ArrayList<>();
|
||||||
|
for (Map.Entry<String, Object> entry : wechatAnalysis.entrySet()) {
|
||||||
|
JSONObject oneMerchant = new JSONObject();
|
||||||
|
oneMerchant.put("merchant_id", entry.getKey());
|
||||||
|
oneMerchant.put("order_amount", ((JSONObject) JSON.toJSON(entry.getValue())).getJSONObject("wechat_analysis").getBigDecimal("order_amount"));
|
||||||
|
analysis.add(oneMerchant);
|
||||||
|
}
|
||||||
|
channelItem.put("analysis", analysis);
|
||||||
|
}
|
||||||
|
if (channel.equals("Bestpay") && result.containsKey("bestpay_valid_analysis")) {
|
||||||
|
List<JSONObject> analysis = new ArrayList<>();
|
||||||
|
analysis.add(result.getJSONObject("bestpay_valid_analysis"));
|
||||||
|
reports.getJSONObject(i).put("analysis", analysis);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
map.put("reports", reports);
|
||||||
|
map.put("title", "到账提醒");
|
||||||
|
return "reports/arrival_notice";
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns:th="http://www.thymeleaf.org" lang="zh">
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
|
||||||
|
<meta http-equiv="cache-control" content="max-age=0">
|
||||||
|
<meta http-equiv="cache-control" content="no-cache">
|
||||||
|
<meta http-equiv="expires" content="0">
|
||||||
|
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT">
|
||||||
|
<meta http-equiv="pragma" content="no-cache">
|
||||||
|
<title th:text="${title}"></title>
|
||||||
|
<link rel="stylesheet" href="https://pay.unifpay.com/static/lib/weui/weui_new.css">
|
||||||
|
<link rel="stylesheet" href="https://pay.unifpay.com/static/lib/weui/example.css">
|
||||||
|
<script type="text/javascript" src="https://pay.unifpay.com/static/lib/jquery/jquery-2.1.4.min.js"></script>
|
||||||
|
<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
|
||||||
|
<style type="text/css">
|
||||||
|
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="page__bd" th:each="report : ${reports}">
|
||||||
|
<div class="weui-form-preview">
|
||||||
|
<div class="weui-form-preview__hd">
|
||||||
|
<div class="weui-form-preview__item">
|
||||||
|
<em class="weui-form-preview__value" th:text="${report.channel}" style="text-align: center;"></em>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="weui-form-preview__bd">
|
||||||
|
<div class="weui-form-preview__item">
|
||||||
|
<label class="weui-form-preview__label">对账状态</label>
|
||||||
|
<span class="weui-form-preview__value" th:text="${report.success} ? '成功' : '失败'" th:style="'color: ' + (${report.success} ? 'green' : 'red')"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="weui-form-preview__bd" th:each="item : ${report['analysis']}">
|
||||||
|
<div class="weui-form-preview__item">
|
||||||
|
<label class="weui-form-preview__label" th:text="${item['merchant_id']} ? ${item['merchant_id']} : 'order_amount'"></label>
|
||||||
|
<span class="weui-form-preview__value" th:text="${item.order_amount}"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,66 @@
|
|||||||
|
package au.com.royalpay.payment.manage.process;
|
||||||
|
|
||||||
|
import au.com.royalpay.payment.manage.support.abafile.ABAConfig;
|
||||||
|
import au.com.royalpay.payment.manage.support.abafile.ABAFile;
|
||||||
|
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
|
||||||
|
import org.apache.commons.csv.CSVFormat;
|
||||||
|
import org.apache.commons.csv.CSVParser;
|
||||||
|
import org.apache.commons.csv.CSVRecord;
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.test.util.ReflectionTestUtils;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create by yixian at 2019-01-17 12:47
|
||||||
|
*/
|
||||||
|
public class ABAGenerator {
|
||||||
|
private ABAConfig.ABABase config;
|
||||||
|
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||||
|
private String csvFile = "C:\\Users\\yixian\\Documents\\royalpay\\2019\\cemtexaba-template-csv.csv";
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void prepareEnv() {
|
||||||
|
PlatformEnvironment env = new PlatformEnvironment();
|
||||||
|
env.afterInitialize();
|
||||||
|
ReflectionTestUtils.setField(env, "foreignCurrency", "AUD");
|
||||||
|
config = new ABAConfig.ABABase()
|
||||||
|
.setBank("CBA")
|
||||||
|
.setApca("301500")
|
||||||
|
.setBsb("063109")
|
||||||
|
.setAccountNo("11505847")
|
||||||
|
.setAccountName("Tunnel Show Pty Ltd");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void generate() {
|
||||||
|
ABAFile file = config.initFile(new Date());
|
||||||
|
try (FileReader reader = new FileReader(csvFile)) {
|
||||||
|
CSVParser parser = new CSVParser(reader, CSVFormat.newFormat(','));
|
||||||
|
List<CSVRecord> records = parser.getRecords();
|
||||||
|
for (CSVRecord record : records) {
|
||||||
|
logger.debug("reading record:{}", record.toString());
|
||||||
|
String bsb = record.get(0).replace("-", "");
|
||||||
|
String accountNo = record.get(1);
|
||||||
|
String accountName = record.get(2);
|
||||||
|
BigDecimal amount = new BigDecimal(record.get(3));
|
||||||
|
String remark = record.get(4);
|
||||||
|
file.addSettleMerchant(bsb, accountNo, accountName, amount, remark);
|
||||||
|
}
|
||||||
|
byte[] bytes = file.output(0);
|
||||||
|
FileUtils.writeByteArrayToFile(new File("C:\\Users\\yixian\\Documents\\royalpay\\2019\\cemtexaba-template.aba"), bytes);
|
||||||
|
logger.info("output done");
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue