presettle undo processing

master
yixian 6 years ago
parent 073df7b0ee
commit d19bc70a16

@ -11,7 +11,6 @@ import au.com.royalpay.payment.core.PaymentApi;
import au.com.royalpay.payment.core.exceptions.InvalidShortIdException;
import au.com.royalpay.payment.core.exceptions.OrderNotExistsException;
import au.com.royalpay.payment.core.mappers.PmtCustomReportMapper;
import au.com.royalpay.payment.manage.analysis.core.ATOReportService;
import au.com.royalpay.payment.manage.analysis.core.DashboardService;
import au.com.royalpay.payment.manage.analysis.core.PlatformClearService;
import au.com.royalpay.payment.manage.appclient.core.RetailAppService;
@ -28,7 +27,6 @@ import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
import au.com.royalpay.payment.manage.mappers.system.SysClientLegalPersonMapper;
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import au.com.royalpay.payment.manage.permission.manager.ManagerMapping;
import au.com.royalpay.payment.manage.pos.datasource.ReadOnlyConnection;
import au.com.royalpay.payment.manage.system.core.TradeSecureService;
import au.com.royalpay.payment.manage.tradelog.core.TradeLogService;
import au.com.royalpay.payment.tools.CommonConsts;
@ -38,6 +36,7 @@ import au.com.royalpay.payment.tools.defines.TradeType;
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
import au.com.royalpay.payment.tools.env.SysConfigManager;
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.exceptions.NotFoundException;
import au.com.royalpay.payment.tools.http.HttpUtils;
import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
@ -62,7 +61,6 @@ import org.springframework.util.Assert;
import org.springframework.validation.Errors;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import au.com.royalpay.payment.tools.exceptions.NotFoundException;
import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;

@ -102,6 +102,8 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
@Resource
private TaskManualSettleMapper taskManualSettleMapper;
@Resource
private PreSettleTaskMapper preSettleTaskMapper;
@Resource
private ValidationLogMapper validationLogMapper;
@Resource
private ManagerMapper managerMapper;
@ -732,7 +734,7 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
new PageBounds(Order.formString("order_id.asc")));
for (JSONObject transaction : transactions) {
transaction.put("rate_value",StringUtils.defaultString(clientIncrementalMapper.findByChannelAndClientId(transaction.getIntValue("client_id"),transaction.getString("source")) ,"0"));
transaction.put("rate_value", StringUtils.defaultString(clientIncrementalMapper.findByChannelAndClientId(transaction.getIntValue("client_id"), transaction.getString("source")), "0"));
}
String timezone_client = client.getString("timezone");
if (timezone_client != null) {
@ -838,7 +840,7 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
int rowNum = 0;
Row row = sheet.createRow(rowNum);
String[] title = {"order Id", "Client Order Id", "Transaction Time", "Channel", "Gateway", "Exchange Rate", "Transaction Type", "Currency",
"Input Amount", "Total Amount", "Clearing Amount(AUD)", "Sruchange Rate", "Surcharge(AUD)", "GST(AUD)", "Settle Amount(AUD)", "Remark", "Dev No","Dev Remark"};
"Input Amount", "Total Amount", "Clearing Amount(AUD)", "Sruchange Rate", "Surcharge(AUD)", "GST(AUD)", "Settle Amount(AUD)", "Remark", "Dev No", "Dev Remark"};
String[] analysis = {"Total Credit(AUD)", "Total Debit(AUD)", "Gross Amount(AUD)", "Total GST(AUD)", "Total Charge(AUD)", "Net Amount(AUD)"};
for (int i = 0; i < title.length; i++) {
row.createCell(i, Cell.CELL_TYPE_STRING).setCellValue(title[i]);
@ -864,26 +866,26 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
row.createCell(5, Cell.CELL_TYPE_STRING).setCellValue(settle.getBigDecimal("exchange_rate").setScale(5, BigDecimal.ROUND_DOWN).toPlainString());
cell = row.createCell(6, Cell.CELL_TYPE_STRING);
cell.setCellValue(settle.getString("transaction_type"));
cell.setCellStyle(!"Credit".equals(settle.getString("transaction_type"))?analysisStyle2:null);
cell.setCellStyle(!"Credit".equals(settle.getString("transaction_type")) ? analysisStyle2 : null);
row.createCell(7, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("transaction_currency"));
cell = row.createCell(8, Cell.CELL_TYPE_STRING);
cell.setCellValue(settle.getBigDecimal("display_amount") == null ? ""
: "Credit".equals(settle.getString("transaction_type"))?
settle.getBigDecimal("display_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString():
"-"+settle.getBigDecimal("display_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString());
cell.setCellStyle(!"Credit".equals(settle.getString("transaction_type"))?analysisStyle2:null);
: "Credit".equals(settle.getString("transaction_type")) ?
settle.getBigDecimal("display_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString() :
"-" + settle.getBigDecimal("display_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString());
cell.setCellStyle(!"Credit".equals(settle.getString("transaction_type")) ? analysisStyle2 : null);
cell = row.createCell(9, Cell.CELL_TYPE_STRING);
cell.setCellValue(settle.getBigDecimal("transaction_amount") == null ? ""
: "Credit".equals(settle.getString("transaction_type"))?
settle.getBigDecimal("transaction_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString():
"-"+settle.getBigDecimal("transaction_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString());
cell.setCellStyle(!"Credit".equals(settle.getString("transaction_type"))?analysisStyle2:null);
: "Credit".equals(settle.getString("transaction_type")) ?
settle.getBigDecimal("transaction_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString() :
"-" + settle.getBigDecimal("transaction_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString());
cell.setCellStyle(!"Credit".equals(settle.getString("transaction_type")) ? analysisStyle2 : null);
cell = row.createCell(10, Cell.CELL_TYPE_STRING);
cell.setCellValue(settle.getBigDecimal("clearing_amount") == null ? ""
: "Credit".equals(settle.getString("transaction_type"))?
settle.getBigDecimal("clearing_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString():
"-"+settle.getBigDecimal("clearing_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString());
cell.setCellStyle(!"Credit".equals(settle.getString("transaction_type"))?analysisStyle2:null);
: "Credit".equals(settle.getString("transaction_type")) ?
settle.getBigDecimal("clearing_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString() :
"-" + settle.getBigDecimal("clearing_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString());
cell.setCellStyle(!"Credit".equals(settle.getString("transaction_type")) ? analysisStyle2 : null);
row.createCell(11, Cell.CELL_TYPE_STRING).setCellValue(channels.getString(settle.getString("channel")) == null ? ""
: channels.getJSONObject(settle.getString("channel")).getBigDecimal("rate").toPlainString() + "%");
//手续费 + gst
@ -1283,6 +1285,7 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
}
transactionMapper.deleteSettlementTransaction(clearingId);
transactionMapper.removeSettleRemark(clearingId);
preSettleTaskMapper.resetClearStatus(clearingId);
clearingDetailAnalysisMapper.clearAnalysis(clearingId);
taskManualSettleMapper.rollbackExecutedTask(clearingId);
clearingDetailMapper.deleteSettleLogs(clearingId);

@ -0,0 +1,13 @@
package au.com.royalpay.payment.manage.mappers.log;
import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
import org.apache.ibatis.annotations.Param;
/**
* Create by davep at 2020-02-04 11:40
*/
@AutoMapper(tablename = "log_presettle_task",pkName = "task_id")
public interface PreSettleTaskMapper {
void resetClearStatus(@Param("clearing_id") int clearingId);
}

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!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.PreSettleTaskMapper">
<update id="resetClearStatus">
update log_presettle_task p
inner join log_clearing_detail cd on cd.clear_detail_id = p.clear_detail_id
set p.clear_detail_id=null,
p.finish_flag=0
where cd.clearing_id = #{clearing_id}
</update>
</mapper>

@ -4,7 +4,9 @@
<update id="removeSettleRemark">
UPDATE pmt_transactions AS t
INNER JOIN log_clearing_detail d ON d.clear_detail_id = t.clearing_order
SET clearing_status = 0,
SET clearing_status = if(
(select count(task_id) from log_presettle_task p where p.clear_detail_id = d.clear_detail_id) >
0, 4, 0),
clearing_order = NULL,
clearing_time = NULL
WHERE d.clearing_id = #{clearing_id}
@ -61,7 +63,8 @@
SELECT count(1)
FROM pmt_transactions t
<if test="dev_id!=null or ">
INNER JOIN (select o.order_id from pmt_orders o<where>
INNER JOIN (select o.order_id from pmt_orders o
<where>
<if test="dev_id!=null">and o.dev_id = #{dev_id}</if>
<if test="
channel!=null">and
@ -69,7 +72,8 @@
o.channel=#{chan}
</foreach>
</if>
</where>)oo ON oo.order_id=t.order_id
</where>
)oo ON oo.order_id=t.order_id
</if>
<where>
@ -628,7 +632,7 @@
select sum(if(temp.transaction_type = 'Credit', temp.clearing_amount * d.proportion,
-temp.clearing_amount * d.proportion))
total
FROM (SELECT l.client_id,l.clearing_amount,l.refund_id,l.transaction_type,o.create_time
FROM (SELECT l.client_id, l.clearing_amount, l.refund_id, l.transaction_type, o.create_time
FROM pmt_transactions l
INNER JOIN pmt_orders o
ON o.order_id = l.order_id
@ -1073,7 +1077,7 @@
and t.clearing_status = 1
and t.transaction_time between #{from} and #{to}
and t.channel != 'Settlement'
group by cd.bsb_no,cd.account_no
group by cd.bsb_no, cd.account_no
order by period_start
</select>
<select id="listCreditTransactionsForSecure" resultType="com.alibaba.fastjson.JSONObject">
@ -1208,13 +1212,13 @@
</select>
<select id="getLastDaytransAmount" resultType="com.alibaba.fastjson.JSONObject">
SELECT ifnull(SUM(IF(transaction_type='Credit',clearing_amount,-clearing_amount)),0) clearing_amount,
ifnull(SUM(IF(transaction_type='Credit',total_surcharge,-total_surcharge)),0) total_surcharge,
ifnull(SUM(IF(transaction_type='Credit',channel_surcharge,-channel_surcharge)),0) channel_surcharge,
SELECT ifnull(SUM(IF(transaction_type = 'Credit', clearing_amount, -clearing_amount)), 0) clearing_amount,
ifnull(SUM(IF(transaction_type = 'Credit', total_surcharge, -total_surcharge)), 0) total_surcharge,
ifnull(SUM(IF(transaction_type = 'Credit', channel_surcharge, -channel_surcharge)), 0) channel_surcharge,
channel
FROM pmt_transactions
WHERE channel!='Settlement'
AND channel!='System'
WHERE channel != 'Settlement'
AND channel != 'System'
AND system_generate = 0
AND transaction_time >= #{datefrom}
AND transaction_time &lt; #{dateto}
@ -1222,14 +1226,14 @@
</select>
<select id="useAlipayOnlineClients" resultType="java.lang.Integer">
SELECT DISTINCT client_id FROM pmt_transactions
WHERE order_channel='AlipayOnline'
and create_time>='2019-01-01 00:00:00'
SELECT DISTINCT client_id
FROM pmt_transactions
WHERE order_channel = 'AlipayOnline'
and create_time >= '2019-01-01 00:00:00'
</select>
<select id="getSettleDataDailyReport" resultType="com.alibaba.fastjson.JSONObject">
SELECT
channel,
SELECT channel,
SUM(IF(transaction_type = 'Credit', settle_amount, -settle_amount)) AS settle_amount,
SUM(IF(transaction_type = 'Credit', clearing_amount, 0)) AS credit_amount,
SUM(IF(transaction_type = 'Credit', 0, -clearing_amount)) AS debit_amount,

Loading…
Cancel
Save