feat(settle ui): 清算发送勾选发送是否标记已发送

master
yixian 5 years ago
parent e51f7e8407
commit 381e68467d

@ -43,9 +43,9 @@ public interface CleanService {
void settlementXlsx(Date date, HttpServletResponse response) throws IOException;
List<JSONObject> getXlsx(Date dt, String bank, List<String> clearIds) throws IOException;
List<JSONObject> getXlsx(Date dt, String bank, List<JSONObject> logs) throws IOException;
List<ABAFile> getAba(Date dt, String bank, List<String> clearIds) throws IOException;
List<ABAFile> getAba(Date dt, String bank, List<JSONObject> logs) throws IOException;
void settlementAba(Date date, HttpServletResponse response) throws IOException;
@ -79,7 +79,7 @@ public interface CleanService {
void getTodaySettlementLogs();
JSONObject sendSettlementMail(Date date, List<String> clearIds);
JSONObject sendSettlementMail(Date date, List<String> clearIds, boolean autoMarkSent);
void sendCheckCode(Date date, JSONObject manager);

@ -395,14 +395,7 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
}
@Override
public List<JSONObject> getXlsx(Date dt, String bank, List<String> clearIds) throws IOException {
List<JSONObject> logs = clearingLogMapper.findByDate(dt);
logs = logs.stream().filter(log -> log.getBooleanValue("editable"))
.filter(log -> clearIds.isEmpty() || clearIds.contains(log.getString("clearing_id")))
.collect(Collectors.toList());
if (logs.isEmpty()) {
throw new NotFoundException();
}
public List<JSONObject> getXlsx(Date dt, String bank, List<JSONObject> logs) throws IOException {
List<JSONObject> result = new ArrayList<>();
int fileIndex = 1;
if (logs.size() > 1) {
@ -431,6 +424,17 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
return result;
}
public List<JSONObject> getSettleLogs(Date dt, List<String> clearIds) {
List<JSONObject> logs = clearingLogMapper.findByDate(dt);
logs = logs.stream().filter(log -> log.getBooleanValue("editable"))
.filter(log -> clearIds.isEmpty() || clearIds.contains(log.getString("clearing_id")))
.collect(Collectors.toList());
if (logs.isEmpty()) {
throw new NotFoundException();
}
return logs;
}
private List<JSONObject> mergeBatchSettleClients(List<JSONObject> details) {
Map<String, List<JSONObject>> sameBankDetails = details.stream()
.filter(this::detailEnabledMergeSettle)
@ -493,14 +497,7 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
}
@Override
public List<ABAFile> getAba(Date dt, String bank, List<String> clearIds) {
List<JSONObject> logs = clearingLogMapper.findByDate(dt);
logs = logs.stream().filter(log -> log.getBooleanValue("editable"))
.filter(log -> clearIds.isEmpty() || clearIds.contains(log.getString("clearing_id")))
.collect(Collectors.toList());
if (logs.isEmpty()) {
throw new NotFoundException();
}
public List<ABAFile> getAba(Date dt, String bank, List<JSONObject> logs) {
List<ABAFile> files = new ArrayList<>();
for (JSONObject log : logs) {
List<JSONObject> details = clearingDetailMapper.listReportsOfSettlement(log.getIntValue("clearing_id"));
@ -1112,7 +1109,7 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
}
@Override
public JSONObject sendSettlementMail(Date date, List<String> clearIds) {
public JSONObject sendSettlementMail(Date date, List<String> clearIds, boolean autoMarkSent) {
JSONObject result = new JSONObject();
try {
String title = "Royalpay Settlement File " + DateFormatUtils.format(date, "yyyyMMdd");
@ -1121,7 +1118,8 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
String fileName1 = "Merchant_Settlement_Info_xlsx_" + DateFormatUtils.format(date, "yyyyMMdd");
List<JSONObject> attachList = new ArrayList<>();
JSONObject attach1 = new JSONObject();
List<JSONObject> xlsxFileList = getXlsx(date, "CBA", clearIds);
List<JSONObject> clearLogs = getSettleLogs(date, clearIds);
List<JSONObject> xlsxFileList = getXlsx(date, "CBA", clearLogs);
if (xlsxFileList.size() > 1) {
fileName1 += ".zip";
attach1.put("content", Base64.encodeBase64String(getZipByteArr(xlsxFileList)));
@ -1133,7 +1131,7 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
attachList.add(attach1);
JSONObject attach2 = new JSONObject();
List<ABAFile> abaFileList = getAba(date, "CBA", clearIds);
List<ABAFile> abaFileList = getAba(date, "CBA", clearLogs);
String fileName2 = "Merchant_Settlement_Info_aba_" + DateFormatUtils.format(date, "yyyyMMdd");
if (abaFileList.size() > 1) {
fileName2 += ".zip";
@ -1182,7 +1180,13 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
logSettleMailMapper.save(settleMailRecord);
}
sendTaskFinishMessages(ManagerRole.FINANCIAL_STAFF, "清算文件已发送清算方", "发送清算通知");
clearingLogMapper.lockSettlements(date);
if (autoMarkSent) {
if (!clearIds.isEmpty()) {
clearingLogMapper.lockSettlementsById(clearLogs.stream().map(log->log.getString("clearing_id")).collect(Collectors.toList()));
} else {
clearingLogMapper.lockSettlements(date);
}
}
} catch (IOException e) {
logger.error("生成excel字节数组发生错误");
} catch (URISyntaxException e) {

@ -129,7 +129,8 @@ public class SettlementDevController {
} catch (ParseException e) {
}
List<String> clearIds = data.getJSONArray("clearing_ids").toJavaList(String.class);
return cleanService.sendSettlementMail(dt, clearIds);
boolean autoMarkSent = data.getBooleanValue("mark_sent");
return cleanService.sendSettlementMail(dt, clearIds, autoMarkSent);
}
@ManagerMapping(value = "/reports/send_checkcode", role = {ManagerRole.FINANCIAL_STAFF})

@ -42,6 +42,8 @@ public interface ClearingLogMapper {
void lockSettlements(@Param("date") Date date);
void lockSettlementsById(@Param("clearing_ids") List<String> clearingIds);
@AutoSql(type = SqlType.SELECT)
JSONObject findById(@Param("clearing_id") int clearingId);

@ -2,7 +2,16 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="au.com.royalpay.payment.manage.mappers.log.ClearingLogMapper">
<update id="lockSettlements">
update log_clearing set editable=0 where settle_date=#{date}
update log_clearing
set editable=0
where settle_date = #{date}
</update>
<update id="lockSettlementsById">
update log_clearing set editable=0
where clearing_id in
<foreach collection="clearing_ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</update>
<select id="findByDate" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
@ -15,7 +24,8 @@
<![CDATA[
SELECT settle_date
FROM log_clearing
WHERE year(settle_date) = year(#{month}) AND month(settle_date) = month(#{month})
WHERE year(settle_date) = year(#{month})
AND month(settle_date) = month(#{month})
]]>
</select>
<select id="listLatestSettleDates" resultType="java.util.Date">
@ -28,28 +38,33 @@
</select>
<select id="getSettlementMonthReport" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
SELECT
settle_date,
gross_amount,
gross_amount - wechat_charge wechat_settlement,
net_amount,
royalpay_charge
SELECT settle_date,
gross_amount,
gross_amount - wechat_charge wechat_settlement,
net_amount,
royalpay_charge
FROM log_clearing
WHERE year(settle_date) = #{year} AND month(settle_date) = #{month}
WHERE year(settle_date) = #{year}
AND month(settle_date) = #{month}
ORDER BY settle_date ASC
]]>
</select>
<select id="getSettlementChannelsMonthReport" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
select sum(a.royalpay_charge) charge,a.channel channel from log_clearing_detail_analysis a left join log_clearing_detail d on d.clear_detail_id = a.clearing_detail_id and a.channel !='System'
WHERE year(d.report_date) = #{year} AND month(d.report_date) = #{month}
select sum(a.royalpay_charge) charge, a.channel channel
from log_clearing_detail_analysis a
left join log_clearing_detail d on d.clear_detail_id = a.clearing_detail_id and a.channel != 'System'
WHERE year(d.report_date) = #{year}
AND month(d.report_date) = #{month}
group by a.channel
]]>
</select>
<select id="getSettlementChannelsDailyReport" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
select sum(a.royalpay_charge) charge,a.channel channel from log_clearing_detail_analysis a left join log_clearing_detail d on d.clear_detail_id = a.clearing_detail_id and a.channel !='System'
select sum(a.royalpay_charge) charge, a.channel channel
from log_clearing_detail_analysis a
left join log_clearing_detail d on d.clear_detail_id = a.clearing_detail_id and a.channel != 'System'
WHERE d.report_date = #{date}
group by a.channel
]]>
@ -57,17 +72,21 @@
<select id="getTotalPlatformCharge" resultType="com.alibaba.fastjson.JSONObject">
SELECT SUM(royalpay_charge) royalpay_charge
FROM log_clearing
WHERE year(settle_date) = #{year}
AND month(settle_date) = #{month}
FROM log_clearing
WHERE year(settle_date) = #{year}
AND month(settle_date) = #{month}
</select>
<select id="getMondayClearing" resultType="com.alibaba.fastjson.JSONObject">
select DATE_FORMAT(operate_time,'%Y%m%d') operate_time,net_amount from log_clearing
where operate_time &gt; #{begin} and operate_time &lt; #{end} and dayofweek(operate_time)=2
select DATE_FORMAT(operate_time, '%Y%m%d') operate_time, net_amount
from log_clearing
where operate_time &gt; #{begin}
and operate_time &lt; #{end}
and dayofweek(operate_time) = 2
</select>
<select id="getSettleDataDailyReport" resultType="com.alibaba.fastjson.JSONObject">
select ifnull(sum(net_amount),0) net_amount,ifnull(sum(royalpay_charge),0) royalpay_charge
FROM log_clearing WHERE settle_date = date(#{date})
select ifnull(sum(net_amount), 0) net_amount, ifnull(sum(royalpay_charge), 0) royalpay_charge
FROM log_clearing
WHERE settle_date = date(#{date})
</select>
</mapper>

@ -504,6 +504,7 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func
};
return info
});
$scope.config = {mark_sent: true};
$scope.switchSendFlag=function(info){
info.send=!info.send
};
@ -514,7 +515,7 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func
$scope.error_msg = '正在发送,请稍后。';
$scope.sendMailButton = true;
$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) {
{clearing_ids:$scope.settleLogs.filter(log=>log.send).map(log=>log.clearing_id),mark_sent:$scope.config.mark_sent}).then(function (resp) {
$scope.error_msg = resp.data.msg;
$scope.sendMailButton = false;
if (resp.data.result == 0) {

@ -11,6 +11,12 @@
</li>
</ul>
</div>
<div class="col-sm-12">
<label class="checkbox-inline">
<input type="checkbox" name="mark_sent" ng-value="config.mark_sent" class="checkbox">
同时标记为已发送
</label>
</div>
<div class="col-sm-12">
<button type="button" class="btn btn-primary" style="width: 100%; margin-top: 30px" data-dismiss="modal"
ng-click="sendSettlementMail()" ng-disabled="sendMailButton">发送清算邮件

@ -34,7 +34,8 @@ public class SettleMailTest {
@Test
public void parse() throws IOException {
Date date = DateUtils.truncate(new Date(), Calendar.DATE);
List<ABAFile> abaFileList = cleanService.getAba(date, "CBA", new ArrayList<>());
final ArrayList<String> clearIds = new ArrayList<>();
List<ABAFile> abaFileList = cleanService.getAba(date, "CBA", cleanService.getSettleLogs(date, clearIds));
Context ctx = new Context();
ctx.setVariable("date", DateFormatUtils.format(date, "dd-MM-yyyy"));

Loading…
Cancel
Save