presettle undo processing

master
yixian 5 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,15 +63,17 @@
SELECT count(1)
FROM pmt_transactions t
<if test="dev_id!=null or ">
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="
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
<foreach collection="channel" item="chan" open="(" close=")" separator=" or ">
o.channel=#{chan}
</foreach>
</if>
</where>)oo ON oo.order_id=t.order_id
<foreach collection="channel" item="chan" open="(" close=")" separator=" or ">
o.channel=#{chan}
</foreach>
</if>
</where>
)oo ON oo.order_id=t.order_id
</if>
<where>
@ -170,7 +174,7 @@
<if test="trans_type==2">and t.refund_id is NOT NULL</if>
<if test="trans_type==3">and t.transaction_type='Debit' and t.refund_id is NULL</if>
<if test="dev_id!=null">
and binary o.dev_id = #{dev_id}
and binary o.dev_id = #{dev_id}
</if>
<if test="channel!=null">
and
@ -241,7 +245,7 @@
<if test="trans_type==2">and t.refund_id is NOT NULL</if>
<if test="trans_type==3">and t.transaction_type='Debit' and t.refund_id is NULL</if>
<if test="dev_id!=null">
and binary o.dev_id = #{dev_id}
and binary o.dev_id = #{dev_id}
</if>
<if test="channel!=null">
and
@ -310,12 +314,12 @@
SELECT sc.client_id,
sc.client_moniker,
IFNULL(SUM(IF(pt.transaction_type = 'Credit', pt.clearing_amount, -pt.clearing_amount)), 0) amount,
IFNULL(MAX(pt.create_time), sc.approve_time) transation_time
FROM pmt_transactions pt,
sys_clients sc
WHERE clearing_status = 0
AND pt.client_id = sc.client_id
GROUP BY client_id
IFNULL(MAX(pt.create_time), sc.approve_time) transation_time
FROM pmt_transactions pt,
sys_clients sc
WHERE clearing_status = 0
AND pt.client_id = sc.client_id
GROUP BY client_id
HAVING amount &lt; 0
</select>
<select id="validAnalysis" resultType="com.alibaba.fastjson.JSONObject">
@ -439,17 +443,17 @@
FROM sys_clients c
]]>
INNER JOIN (select system_transaction_id,clearing_amount,client_id
from pmt_transactions
where channel='Settlement'
<if test="from!=null">and transaction_time &gt;= #{from}</if>
<if test="to!=null">and transaction_time &lt; #{to}</if>
) t ON t.client_id = c.client_id
from pmt_transactions
where channel='Settlement'
<if test="from!=null">and transaction_time &gt;= #{from}</if>
<if test="to!=null">and transaction_time &lt; #{to}</if>
) t ON t.client_id = c.client_id
<where>
<if test="client_moniker!=null">and c.client_moniker=#{client_moniker}</if>
<if test="org_id!=null and org_ids==null">and c.org_id = #{org_id}</if>
<if test="org_ids!=null">and c.org_id in
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
</if>
<if test="client_moniker!=null">and c.client_moniker=#{client_moniker}</if>
<if test="org_id!=null and org_ids==null">and c.org_id = #{org_id}</if>
<if test="org_ids!=null">and c.org_id in
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
</if>
</where>
GROUP BY c.client_id
</select>
@ -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
@ -744,13 +748,13 @@
if(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount) clearing_amount,
if(t.transaction_type = 'Credit', t.total_surcharge, -t.total_surcharge) total_surcharge,
if(t.transaction_type = 'Credit', t.channel_surcharge, -t.channel_surcharge) channel_surcharge,
if(t.transaction_type = 'Credit', t.settle_amount, -t.settle_amount) settle_amount,
if(t.transaction_type = 'Credit', t.settle_amount, -t.settle_amount) settle_amount,
t.order_id,
t.org_rate,
t.surcharge_cashback,
o.customer_surcharge
from pmt_transactions t
LEFT JOIN pmt_orders o on o.order_id = t.order_id
LEFT JOIN pmt_orders o on o.order_id = t.order_id
INNER JOIN sys_org so ON t.org_id = so.org_id AND so.is_valid = 1
AND so.type = 0
AND so.citypartner = 1 AND so.commission = 1
@ -763,7 +767,7 @@
<select id="listTransactionForCityPartnerAgentCommissionByDate" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
select t.org_id,
t.clearing_currency,
t.clearing_currency,
t.client_id,
t.channel,
t.surcharge_rate,
@ -771,13 +775,13 @@
if(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount) clearing_amount,
if(t.transaction_type = 'Credit', t.total_surcharge, -t.total_surcharge) total_surcharge,
if(t.transaction_type = 'Credit', t.channel_surcharge, -t.channel_surcharge) channel_surcharge,
if(t.transaction_type = 'Credit', t.settle_amount, -t.settle_amount) settle_amount,
if(t.transaction_type = 'Credit', t.settle_amount, -t.settle_amount) settle_amount,
t.order_id,
t.org_rate,
t.surcharge_cashback,
o.customer_surcharge
from pmt_transactions t
LEFT JOIN pmt_orders o on o.order_id = t.order_id
LEFT JOIN pmt_orders o on o.order_id = t.order_id
INNER JOIN sys_org so ON t.org_id = so.org_id AND so.is_valid = 1
AND so.type = 0
AND so.parent_org_id != ''
@ -951,7 +955,7 @@
<select id="listTransactionsOfClearingOrder" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
SELECT t.*,
IFNULL(t.incremental_surcharge, 0.00) incremental_surcharge_settle,
IFNULL(t.incremental_surcharge, 0.00) incremental_surcharge_settle,
o.display_amount,
o.client_order_id,
o.gateway,
@ -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">
@ -1145,10 +1149,10 @@
t.channel = 'Settlement'
]]>
<if test="client_ids!=null">
AND t.client_id IN
<foreach collection="client_ids" open="(" close=")" separator="," item="clientId">
#{clientId}
</foreach>
AND t.client_id IN
<foreach collection="client_ids" open="(" close=")" separator="," item="clientId">
#{clientId}
</foreach>
</if>
<if test="client_ids==null">
and t.client_id=#{client_id}
@ -1208,42 +1212,42 @@
</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,
channel
FROM pmt_transactions
WHERE channel!='Settlement'
AND channel!='System'
AND system_generate = 0
AND transaction_time >= #{datefrom}
AND transaction_time &lt; #{dateto}
GROUP BY channel
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'
AND system_generate = 0
AND transaction_time >= #{datefrom}
AND transaction_time &lt; #{dateto}
GROUP BY channel
</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,
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,
SUM(IF(transaction_type = 'Credit', clearing_amount, -clearing_amount)) AS net_trading,
SUM(IF(transaction_type = 'Credit', total_surcharge, -total_surcharge)) AS total_surcharge,
SUM(IF(transaction_type = 'Credit', royal_surcharge, -royal_surcharge)) AS royal_surcharge,
SUM(IF(transaction_type = 'Credit', channel_surcharge, -channel_surcharge)) AS channel_surcharge,
SUM(IF(transaction_type = 'Credit', tax_amount, -tax_amount)) AS tax_amount,
cashback_send_flag,
surcharge_cashback
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,
SUM(IF(transaction_type = 'Credit', clearing_amount, -clearing_amount)) AS net_trading,
SUM(IF(transaction_type = 'Credit', total_surcharge, -total_surcharge)) AS total_surcharge,
SUM(IF(transaction_type = 'Credit', royal_surcharge, -royal_surcharge)) AS royal_surcharge,
SUM(IF(transaction_type = 'Credit', channel_surcharge, -channel_surcharge)) AS channel_surcharge,
SUM(IF(transaction_type = 'Credit', tax_amount, -tax_amount)) AS tax_amount,
cashback_send_flag,
surcharge_cashback
FROM pmt_transactions
WHERE create_time >= #{beginTime}
AND create_time &lt; #{endTime}
AND channel != 'Settlement'
AND create_time &lt; #{endTime}
AND channel != 'Settlement'
GROUP BY channel
</select>
</mapper>

Loading…
Cancel
Save