From 3310ade433bb2209c2a1321707b21b65ed284e7a Mon Sep 17 00:00:00 2001 From: yixian Date: Mon, 27 Sep 2021 17:34:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=A0=E9=81=93=E6=B8=85=E7=AE=97=E5=AF=B9?= =?UTF-8?q?=E8=B4=A6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../analysis/core/PlatformClearService.java | 3 +- .../PlatformClearAnalysisServiceImpl.java | 360 +++++------------- .../mappers/log/PlatformSettlementMapper.java | 10 +- .../manage/task/SettleEstimateTaskManger.java | 4 - .../mappers/log/PlatformSettlementMapper.xml | 47 +-- 5 files changed, 114 insertions(+), 310 deletions(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/analysis/core/PlatformClearService.java b/src/main/java/au/com/royalpay/payment/manage/analysis/core/PlatformClearService.java index 748c33efa..232339e9f 100644 --- a/src/main/java/au/com/royalpay/payment/manage/analysis/core/PlatformClearService.java +++ b/src/main/java/au/com/royalpay/payment/manage/analysis/core/PlatformClearService.java @@ -10,10 +10,9 @@ public interface PlatformClearService { JSONObject getChannelSettleLog(String channel); - void verifySettleLogByDate(String start_date, String end_date, String channel) throws ParseException; + void verifySettleLogByDate(String startDate, String endDate, String channel) throws ParseException; void generateSettleLogs(); - void generateAliPaySettleLogs(); } diff --git a/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/PlatformClearAnalysisServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/PlatformClearAnalysisServiceImpl.java index bad33c583..c68b25b11 100644 --- a/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/PlatformClearAnalysisServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/PlatformClearAnalysisServiceImpl.java @@ -1,34 +1,30 @@ package au.com.royalpay.payment.manage.analysis.core.impls; -import au.com.royalpay.payment.channels.alipay.runtime.AlipayClient; -import au.com.royalpay.payment.channels.wechat.config.WeChatPayConfig; -import au.com.royalpay.payment.channels.wechat.config.WechatPayEnvironment; -import au.com.royalpay.payment.channels.wechat.runtime.MpPaymentApi; -import au.com.royalpay.payment.channels.wechat.runtime.beans.SettlementLog; -import au.com.royalpay.payment.core.exceptions.ChannelNetworkException; +import au.com.royalpay.payment.core.ChannelSettleVerify; +import au.com.royalpay.payment.core.beans.SettlementLog; import au.com.royalpay.payment.manage.analysis.core.PlatformClearService; -import au.com.royalpay.payment.manage.analysis.mappers.EstimateAnalysisMapper; import au.com.royalpay.payment.manage.mappers.log.PlatformSettlementMapper; -import au.com.royalpay.payment.tools.connections.attachment.core.AttachmentClient; +import au.com.royalpay.payment.tools.defines.PayChannel; +import au.com.royalpay.payment.tools.exceptions.BadRequestException; import au.com.royalpay.payment.tools.utils.PageListUtils; import au.com.royalpay.payment.tools.utils.TimeZoneUtils; -import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.github.miemiedev.mybatis.paginator.domain.Order; import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageList; -import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateUtils; +import org.joda.time.DateTime; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; -import java.math.BigDecimal; import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.*; +import java.util.Arrays; +import java.util.Date; +import java.util.List; @Service public class PlatformClearAnalysisServiceImpl implements PlatformClearService { @@ -37,16 +33,10 @@ public class PlatformClearAnalysisServiceImpl implements PlatformClearService { public static final SimpleDateFormat sdfClear = new SimpleDateFormat("yyyy-MM-dd"); public static final SimpleDateFormat sdfNormal = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - @Resource - private MpPaymentApi mpPaymentApi; - @Resource - private AlipayClient alipayClient; + @Autowired(required = false) + private ChannelSettleVerify[] channelSettleVerifys; @Resource private PlatformSettlementMapper platformSettlementMapper; - @Resource - private EstimateAnalysisMapper estimateAnalysisMapper; - @Resource - private AttachmentClient attachmentClient; @Override public JSONObject getPlatformSettleLog(String channel, int page, int limit) { @@ -58,10 +48,11 @@ public class PlatformClearAnalysisServiceImpl implements PlatformClearService { @Override public JSONObject getChannelSettleLog(String channel) { JSONObject sysLogs = new JSONObject(); - JSONObject creditLogs = platformSettlementMapper.calculateSysSettleLog5("2018-04-05 02:00:00", sdfNormal.format(new Date()), channel, "Credit"); + Date fromDate = DateTime.parse("2018-04-05T02:00:00+10:00").toDate(); + JSONObject creditLogs = platformSettlementMapper.calculateChannelSysSettleLog(fromDate, new Date(), channel, "Credit"); sysLogs.put("sys_pay_fee", creditLogs.getBigDecimal("rmb_amount")); - JSONObject debitLogs = platformSettlementMapper.calculateSysSettleLog5("2018-04-05 02:00:00", sdfNormal.format(new Date()), channel, "Debit"); + JSONObject debitLogs = platformSettlementMapper.calculateChannelSysSettleLog(fromDate, new Date(), channel, "Debit"); sysLogs.put("sys_refund_fee", debitLogs.getBigDecimal("rmb_amount")); sysLogs.put("surcharge", creditLogs.getBigDecimal("charge_amount").subtract(debitLogs.getBigDecimal("charge_amount"))); @@ -74,121 +65,41 @@ public class PlatformClearAnalysisServiceImpl implements PlatformClearService { } @Override - public void verifySettleLogByDate(String start_date, String end_date, String channel) { - if (StringUtils.equals("Alipay", channel)) { - try { - doVerifyAlipaySettleLog(sdfClear.parse(end_date)); - } catch (Exception e) { - logger.error("PlatformClearAnalysisServiceImpl.verifySettleLogByDate ==> 校验" + end_date + "支付宝到账失败:", e); - } - } - if (StringUtils.equals("AlipayOnline", channel)) { - try { - doVerifyAlipayOnlineSettleLog(sdfClear.parse(end_date)); - } catch (Exception e) { - logger.error("PlatformClearAnalysisServiceImpl.verifySettleLogByDate ==> 校验" + end_date + "支付宝Online到账失败:", e); - throw new ChannelNetworkException("校验失败:", e); - } - } - if (StringUtils.equals("Wechat", channel)) { - try { - Map settleDate = new HashMap<>(); - settleDate.put("from", sdfClear.parse(start_date)); - settleDate.put("to", sdfClear.parse(end_date)); - doVerifyWechatSettleLog(settleDate); - } catch (Exception e) { - logger.error("PlatformClearAnalysisServiceImpl.verifySettleLogByDate ==> 校验" + end_date + "微信到账失败:", e); - } - - } - } - - @Override - // @Transactional - public void generateSettleLogs() { - // deleteSettleLogs(); - generateWechatSettleLogs(); - generateAlipaySettleLogs(); - generateAlipayOnlineSettleLogs(); - } - - @Override - @Transactional - public void generateAliPaySettleLogs() { - generateAlipaySettleLogs(); - generateAlipayOnlineSettleLogs(); - } - - @Transactional - public void generateWechatSettleLogs() { - try { - Map settleDate = TimeZoneUtils.getStatetimeDays(); - logger.info("开始查询" + settleDate.get("from") + "到" + settleDate.get("to") + "的微信清算记录"); - doVerifyWechatSettleLog(settleDate); - } catch (ParseException e) { - e.printStackTrace(); + public void verifySettleLogByDate(String startDate, String endDate, String channel) { + if (channelSettleVerifys == null) { + return; } - } - - private void generateAlipaySettleLogs() { - try { - List dateList = TimeZoneUtils.getStatetime(); - for (Date dateStr : dateList) { - try { - doVerifyAlipaySettleLog(dateStr); - } catch (Exception e) { - logger.error("获取" + dateStr + "Alipay清算记录失败", e); - } - } - } catch (Exception e) { - logger.error("获取Alipay清算记录时间失败", e); - } - - } - - private void generateAlipayOnlineSettleLogs() { - try { - List dateList = TimeZoneUtils.getStatetime(); - for (Date dateStr : dateList) { - try { - doVerifyAlipayOnlineSettleLog(dateStr); - } catch (Exception e) { - logger.error("获取" + dateStr + "AlipayOnline清算记录失败", e); - } - } - } catch (Exception e) { - logger.error("获取AlipayOnline清算记录时间失败", e); - } - - } - - @Transactional - public void doVerifyAlipaySettleLog(Date dateStr) throws Exception { - JSONObject aliSettleLog = alipayClient.oldDownloadRetailSettlements(dateStr); - saveAlipaySettleLog(dateStr, aliSettleLog, "Alipay"); - } + Arrays.stream(channelSettleVerifys).filter(verify -> verify.payChannel().getChannelCode().equalsIgnoreCase(channel)) + .findFirst().ifPresent(verify -> { + try { + Date currentDate = sdfClear.parse(startDate); + Date end = sdfClear.parse(endDate); + while (!end.before(currentDate)) { + saveVerifyResults(currentDate, verify); + currentDate = DateUtils.addDays(currentDate, 1); + } + } catch (ParseException e) { + throw new BadRequestException("Invalid Date Format"); + } - @Transactional - public void doVerifyAlipayOnlineSettleLog(Date dateStr) throws Exception { - JSONObject aliOnlineSettleLog = alipayClient.downloadOnlineSettlements(dateStr); - saveAlipaySettleLog(dateStr, aliOnlineSettleLog, "AlipayOnline"); + }); } - private void saveAlipaySettleLog(Date dateStr, JSONObject aliSettleLog, String channel) throws Exception { - if (aliSettleLog != null) { - JSONObject settleFee = getAliSettle(aliSettleLog); + private void saveVerifyResults(Date date, ChannelSettleVerify verify) { + logger.info("starting verify for channel {} on {}", verify.payChannel(), date); + List logs = verify.verifyResults(date); + logger.info("loaded {} settle logs for channel {} on {}", logs.size(), verify.payChannel(), date); + for (SettlementLog settle : logs) { JSONObject params = new JSONObject(); - params.put("settle_date", dateStr); - params.put("start_date", dateStr); - params.put("end_date", dateStr); - params.put("pay_fee", settleFee.getBigDecimal("credit")); - params.put("refund_fee", settleFee.getBigDecimal("debit")); - params.put("net_fee", settleFee.getBigDecimal("net_fee")); - params.put("surcharge", settleFee.getBigDecimal("surcharge")); - params.put("settlement_fee", settleFee.getBigDecimal("settlement_fee")); - params.put("channel", channel); + params.put("settle_date", settle.getSettlementDate()); + params.put("start_date", TimeZoneUtils.formatTime(settle.getStart(), TimeZoneUtils.PATTERN_NORMAL, "Asia/Shanghai")); + params.put("end_date", TimeZoneUtils.formatTime(settle.getEnd(), TimeZoneUtils.PATTERN_NORMAL, "Asia/Shanghai")); + if (verify.payChannel() == PayChannel.WECHAT) { + params.put("settle_date", TimeZoneUtils.formatTime(settle.getSettlementDate(), TimeZoneUtils.PATTERN_NORMAL, "Asia/Shanghai")); + } + params.put("channel", verify.payChannel().getChannelCode()); params.put("last_update_date", new Date()); - JSONObject sysClearData = getSystemClearingAmount(dateStr, aliSettleLog, channel); + JSONObject sysClearData = getSystemClearingAmount(settle, verify.payChannel().getChannelCode()); if (sysClearData != null && !sysClearData.isEmpty()) { params.put("sys_pay_fee", sysClearData.getBigDecimal("sys_pay_fee")); params.put("sys_refund_fee", sysClearData.getBigDecimal("sys_refund_fee")); @@ -196,173 +107,74 @@ public class PlatformClearAnalysisServiceImpl implements PlatformClearService { params.put("sys_surcharge", sysClearData.getBigDecimal("sys_surcharge")); params.put("sys_settlement_fee", sysClearData.getBigDecimal("sys_settle_fee")); } - JSONObject check = platformSettlementMapper.findByDateMerchant(sdfClear.format(dateStr), channel, "All"); - if (check != null) { - params.put("log_id", check.getString("log_id")); - platformSettlementMapper.update(params); - } else { - platformSettlementMapper.save(params); + params.put("merchants", settle.getMerchantId()); + params.put("pay_fee", settle.getPayFee()); + params.put("refund_fee", settle.getRefundFee()); + params.put("net_fee", settle.getPayNetFee()); + if (verify.payChannel() != PayChannel.WECHAT) { + params.put("net_fee", settle.getPayFee().subtract(settle.getRefundFee())); } - } - } - - public void doVerifyWechatSettleLog(Map settleDate) { - List tencentSettle = new ArrayList<>(); - for (WeChatPayConfig.Merchant mch : WechatPayEnvironment.getEnv().getWechatMerchantConfigs()) { + params.put("settlement_fee", settle.getSettlementFee()); + params.put("surcharge", settle.getPoundageFee()); + params.put("unsettle_fee", settle.getUnsettlementFee()); try { - tencentSettle = mpPaymentApi.settlementLogs(settleDate.get("from"), settleDate.get("to"), mch.getMerchantId()); - if (tencentSettle == null) { - logger.info("【{}】下没有清算记录", mch.getMerchantId()); + if (("1500474722".equals(settle.getMerchantId()) && settle.getSettlementDate().before(DateTime.parse("2018-06-02").toDate())) || + ("1492874492".equals(settle.getMerchantId()) && settle.getSettlementDate().after(DateTime.parse("2018-06-05").toDate()))) { + return; + } + JSONObject check = platformSettlementMapper.findByDateMerchant(verify.payChannel() == PayChannel.WECHAT ? TimeZoneUtils.formatTime(settle.getSettlementDate(), TimeZoneUtils.PATTERN_NORMAL, "Asia/Shanghai") : sdfClear.format(settle.getSettlementDate()), verify.payChannel().getChannelCode(), settle.getMerchantId()); + if (check != null) { + params.put("log_id", check.getString("log_id")); + platformSettlementMapper.update(params); } else { - for (SettlementLog settle : tencentSettle) { - JSONObject params = new JSONObject(); - params.put("settle_date", settle.getSettlementDate()); - params.put("start_date", settle.getStart()); - params.put("end_date", settle.getEnd()); - params.put("channel", "Wechat"); - params.put("last_update_date", new Date()); - JSONObject sysClearData = getSystemClearingAmount(null, settle, "Wechat"); - if (sysClearData != null && !sysClearData.isEmpty()) { - params.put("sys_pay_fee", sysClearData.getBigDecimal("sys_pay_fee")); - params.put("sys_refund_fee", sysClearData.getBigDecimal("sys_refund_fee")); - params.put("sys_net_fee", sysClearData.getBigDecimal("sys_net_fee")); - params.put("sys_surcharge", sysClearData.getBigDecimal("sys_surcharge")); - params.put("sys_settlement_fee", sysClearData.getBigDecimal("sys_settle_fee")); - } - params.put("merchants", mch.getMerchantId()); - params.put("pay_fee", settle.getPayFee()); - params.put("refund_fee", settle.getRefundFee()); - params.put("net_fee", settle.getPayNetFee()); - params.put("settlement_fee", settle.getSettlementFee()); - params.put("surcharge", settle.getPoundageFee()); - params.put("unsettle_fee", settle.getUnsettlementFee()); - - JSONObject check = platformSettlementMapper.findByDateMerchant(sdfClear.format(settle.getSettlementDate()), "Wechat", - mch.getMerchantId()); - if (check != null) { - params.put("log_id", check.getString("log_id")); - platformSettlementMapper.update(params); - } else { - platformSettlementMapper.save(params); - } - params.clear(); - logger.info("{}的微信清算记录查询完成", mch.getMerchantId()); - } + platformSettlementMapper.save(params); } + params.clear(); } catch (Exception e) { - logger.error("【{}】下没有清算记录", mch.getMerchantId(), e); + logger.error(e.getMessage(), e); } } } - public JSONObject getAliSettle(JSONObject aliSettleLog) { - JSONObject alipaySettleLog = new JSONObject(); - JSONArray payments = aliSettleLog.getJSONArray("payments"); - BigDecimal credit = BigDecimal.ZERO; - BigDecimal creditFee = BigDecimal.ZERO; - BigDecimal creditSettle = BigDecimal.ZERO; - if (payments != null) { - for (int i = 0; i < payments.size(); i++) { - JSONObject json = payments.getJSONObject(i); - BigDecimal transactionAmount = json.getBigDecimal("transaction_amount"); - BigDecimal chargeFee = json.getBigDecimal("charge_fee"); - credit = credit.add(transactionAmount); - creditFee = creditFee.add(chargeFee); - if (json.containsKey("settle_amount")) { - creditSettle = creditSettle.add(json.getBigDecimal("settle_amount")); - } else { - creditSettle = creditSettle.add(transactionAmount.subtract(chargeFee)); + @Override + // @Transactional + public void generateSettleLogs() { + if (channelSettleVerifys != null) { + try { + List dateList = TimeZoneUtils.getStatetime(); + for (Date date : dateList) { + for (ChannelSettleVerify verify : channelSettleVerifys) { + try { + saveVerifyResults(date, verify); + } catch (Exception e) { + logger.error("[{}]{} failed to download settle file", date, verify.payChannel(), e); + } + } } + } catch (ParseException ignored) { } - } - alipaySettleLog.put("credit", credit); - JSONArray refunds = aliSettleLog.getJSONArray("refunds"); - logger.info("alipay的refunds清算总信息" + refunds.toJSONString()); - BigDecimal debit = BigDecimal.ZERO; - BigDecimal debitFee = BigDecimal.ZERO; - BigDecimal debitSettle = BigDecimal.ZERO; - for (int i = 0; i < refunds.size(); i++) { - JSONObject json = refunds.getJSONObject(i); - BigDecimal transactionAmount = json.getBigDecimal("transaction_amount"); - BigDecimal chargeFee = json.getBigDecimal("charge_fee"); - debit = debit.add(transactionAmount); - debitFee = debitFee.add(chargeFee); - if (json.containsKey("settle_amount")) { - debitSettle = debitSettle.add(json.getBigDecimal("settle_amount")); - } else { - debitSettle = debitSettle.add(transactionAmount.subtract(chargeFee)); - } } - alipaySettleLog.put("debit", debit); - alipaySettleLog.put("net_fee", credit.subtract(debit)); - alipaySettleLog.put("surcharge", creditFee.subtract(debitFee)); - alipaySettleLog.put("settlement_fee", creditSettle.subtract(debitSettle)); - logger.info("阿里清算日志:" + alipaySettleLog.toJSONString()); - return alipaySettleLog; } - public JSONObject getSystemClearingAmount(Date settle_date, Object settlementLog, String channel) throws Exception { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd 02:00:00"); + private JSONObject getSystemClearingAmount(SettlementLog settlementLog, String channel) { JSONObject sysLogs = new JSONObject(); - String start_date = null; - String end_date = null; - if (StringUtils.equals("Alipay", channel)) { - JSONObject lastClearDay = estimateAnalysisMapper.findLastCleanDays(sdfClear.format(settle_date), 1); - start_date = sdf.format(lastClearDay.getDate("date_str")); - end_date = sdf.format(settle_date); - logger.info("Alipay System Settle Logs:" + start_date + "<====>" + end_date); - } else if (StringUtils.equals("Wechat", channel)) { - SettlementLog wechatSettleLog = (SettlementLog) settlementLog; - start_date = sdf.format(wechatSettleLog.getStart()); - end_date = sdf.format(wechatSettleLog.getEnd()); - logger.info("Wechat System Settle Logs:" + start_date + "<====>" + end_date); - } else if (StringUtils.equals("AlipayOnline", channel)) { - JSONObject alipayOnlineSettleLog = (JSONObject) settlementLog; - logger.info("AlipayOnline System Settle Logs:" + alipayOnlineSettleLog.getDate("min_time") + "<====>" + alipayOnlineSettleLog.getDate("max_time")); - start_date = sdf.format(alipayOnlineSettleLog.getDate("min_time")); - end_date = sdf.format(DateUtils.addDays(alipayOnlineSettleLog.getDate("max_time"), 1)); - } else { - return null; - } - - // 2017-11-01后微信手续费0.5 - BigDecimal wechat_rate; - if (end_date.compareTo("2017-11-01 03:00:00") <= 0) { - wechat_rate = new BigDecimal("0.006"); - } else { - wechat_rate = new BigDecimal("0.005"); - } - - // 2018-09-01后Alipay_Online手续费0.006 - BigDecimal alipay_online_rate; - if (end_date.compareTo("2018-09-01 02:00:00") <= 0) { - alipay_online_rate = new BigDecimal("0.018"); - } else { - alipay_online_rate = new BigDecimal("0.006"); - } + logger.info("{} System Settle Logs:{}<====>{}", channel, settlementLog.getStart(), settlementLog.getEnd()); try { - JSONObject creditLogs = platformSettlementMapper.calculateSysSettleLog(start_date, end_date, channel, "Credit", wechat_rate); + JSONObject creditLogs = platformSettlementMapper.calculateSysSettleLog(settlementLog.getStart(), settlementLog.getEnd(), settlementLog.getMerchantId(), channel, "Credit"); sysLogs.put("sys_pay_fee", creditLogs.getBigDecimal("aud_amount")); - - JSONObject debitLogs = platformSettlementMapper.calculateSysSettleLog(start_date, end_date, channel, "Debit", wechat_rate); + JSONObject debitLogs = platformSettlementMapper.calculateSysSettleLog(settlementLog.getStart(), settlementLog.getEnd(), settlementLog.getMerchantId(), channel, "Debit"); sysLogs.put("sys_refund_fee", debitLogs.getBigDecimal("aud_amount")); - sysLogs.put("sys_net_fee", creditLogs.getBigDecimal("aud_amount").subtract(debitLogs.getBigDecimal("aud_amount"))); - if (StringUtils.equals("Alipay", channel)) { - sysLogs.put("sys_surcharge", platformSettlementMapper.calculateRmbCharge(start_date, end_date, channel, BigDecimal.valueOf(0.006))); - } else if (StringUtils.equals("AlipayOnline", channel)) { - sysLogs.put("sys_surcharge", platformSettlementMapper.calculateRmbCharge(start_date, end_date, channel, alipay_online_rate)); - } else { - sysLogs.put("sys_surcharge", creditLogs.getBigDecimal("charge_amount").subtract(debitLogs.getBigDecimal("charge_amount"))); - } + sysLogs.put("sys_surcharge", creditLogs.getBigDecimal("charge_amount").subtract(debitLogs.getBigDecimal("charge_amount"))); sysLogs.put("sys_settle_fee", sysLogs.getBigDecimal("sys_net_fee").subtract(sysLogs.getBigDecimal("sys_surcharge"))); + logger.info("calculated system result[{}|{}~{}]:{}", channel, settlementLog.getStart(), settlementLog.getEnd(), sysLogs); return sysLogs; } catch (Exception e) { - // do nothing - e.printStackTrace(); + //do nothing + logger.error("Error caught on analysising {}", channel, e); } return null; } diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/log/PlatformSettlementMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/log/PlatformSettlementMapper.java index f609a7fa1..bc3b6ae69 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/log/PlatformSettlementMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/log/PlatformSettlementMapper.java @@ -32,12 +32,14 @@ public interface PlatformSettlementMapper { PageList findSettleLogsAllMerchant(@Param("channel") String channel, PageBounds pageBounds); - JSONObject calculateSysSettleLog(@Param("start_date") String start_date, @Param("end_date") String end_date, @Param("channel") String channel, @Param("transaction_type") String type, @Param("wechat_rate") BigDecimal wechat_rate); + JSONObject calculateSysSettleLog(@Param("start_date") Date startDate, @Param("end_date") Date endDate, @Param("channel") String channel, + @Param("pid") String pid, @Param("transaction_type") String type); - JSONObject calculateSysSettleLog5(@Param("start_date") String start_date, @Param("end_date") String end_date, @Param("channel") String channel, @Param("transaction_type") String type); - - BigDecimal calculateRmbCharge(@Param("start_date") String start_date, @Param("end_date") String end_date, @Param("channel") String channel,@Param("ali_rate") BigDecimal ali_rate); + BigDecimal calculateRmbCharge(@Param("start_date") Date start_date, @Param("end_date") Date end_date, @Param("channel") String channel); @AutoSql(SqlType.DELETE) void delete(JSONObject params); + + JSONObject calculateChannelSysSettleLog(@Param("start_date") Date startDate, @Param("end_date") Date endDate, @Param("channel") String channel, + @Param("transaction_type") String type); } diff --git a/src/main/java/au/com/royalpay/payment/manage/task/SettleEstimateTaskManger.java b/src/main/java/au/com/royalpay/payment/manage/task/SettleEstimateTaskManger.java index d1b69b508..802553c7e 100644 --- a/src/main/java/au/com/royalpay/payment/manage/task/SettleEstimateTaskManger.java +++ b/src/main/java/au/com/royalpay/payment/manage/task/SettleEstimateTaskManger.java @@ -40,8 +40,4 @@ public class SettleEstimateTaskManger { synchronizedScheduler.executeProcess("manage_task:genSettleLog", 120_000, () -> platformClearService.generateSettleLogs()); } - @Scheduled(cron = "0 0 10 * * ?") - public void generateSettleLogs2() { - synchronizedScheduler.executeProcess("manage_task:generateAliPaySettleLog", 120_000, () -> platformClearService.generateAliPaySettleLogs()); - } } diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/log/PlatformSettlementMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/log/PlatformSettlementMapper.xml index 98529f116..a9ed6893d 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/log/PlatformSettlementMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/log/PlatformSettlementMapper.xml @@ -11,18 +11,17 @@ - - + SELECT sum(t.cny_amount) rmb_amount, + ifnull(sum(t.clearing_amount), 0.00) aud_amount, + ifnull(sum(t.channel_surcharge), 0.00) charge_amount + FROM pmt_transactions t + WHERE order_channel = #{channel} + AND transaction_type = #{transaction_type} + AND transaction_time >= #{start_date} + AND #{end_date} > transaction_time + and system_generate = 0 \ No newline at end of file