From 81fa3ef96c94346416da9044ac9adddab2425380 Mon Sep 17 00:00:00 2001 From: Tayl0r <519104047@qq.com> Date: Thu, 22 Feb 2018 20:26:12 +0800 Subject: [PATCH 1/2] Revert "ignore" This reverts commit ae589d5 --- .../PlatformClearAnalysisServiceImpl.java | 53 ++++++++++++------- .../mappers/log/PlatformSettlementMapper.java | 2 +- .../mappers/log/PlatformSettlementMapper.xml | 6 +-- 3 files changed, 37 insertions(+), 24 deletions(-) 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 2e66a8311..f130f3606 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 @@ -76,13 +76,6 @@ public class PlatformClearAnalysisServiceImpl implements PlatformClearService { 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); - } - } if (StringUtils.equals("Wechat", channel)) { try { Map settleDate = new HashMap<>(); @@ -137,13 +130,13 @@ public class PlatformClearAnalysisServiceImpl implements PlatformClearService { List dateList = TimeZoneUtils.getStatetime(); for (Date dateStr : dateList) { try { - doVerifyAlipayOnlineSettleLog(dateStr); + doVerifyAlipaySettleLog(dateStr); } catch (Exception e) { - logger.error("获取" + dateStr + "AlipayOnline清算记录失败", e); + logger.error("获取" + dateStr + "Alipay清算记录失败", e); } } } catch (Exception e) { - logger.error("获取AlipayOnline清算记录时间失败", e); + logger.error("获取Alipay清算记录时间失败", e); } } @@ -292,30 +285,50 @@ public class PlatformClearAnalysisServiceImpl implements PlatformClearService { return alipaySettleLog; } - public JSONObject getSystemClearingAmount(Date settle_date, SettlementLog settlementLog, String channel){ + public JSONObject getSystemClearingAmount(Date settle_date, SettlementLog settlementLog, String channel) throws Exception { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd 02:00:00"); JSONObject sysLogs = new JSONObject(); String start_date = null; String end_date = null; - if (StringUtils.equals("Wechat", channel)) { - start_date = sdf.format(settlementLog.getStart()); - end_date = sdf.format(settlementLog.getEnd()); - logger.info("Wechat System Settle Logs:" + start_date + "<====>" + end_date); - } else { + 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); + logger.info("Alipay System Settle Logs:"+start_date+"<====>" +end_date); + + } else if (StringUtils.equals("Wechat", channel)) { + start_date = sdf.format(settlementLog.getStart()); + end_date = sdf.format(settlementLog.getEnd()); + logger.info("Wechat System Settle Logs:"+start_date+"<====>" +end_date); + } 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"); } + try { - JSONObject creditLogs = platformSettlementMapper.calculateSysSettleLog(start_date, end_date, channel, "Credit"); + JSONObject creditLogs = platformSettlementMapper.calculateSysSettleLog(start_date, end_date, channel, "Credit", wechat_rate); sysLogs.put("sys_pay_fee", creditLogs.getBigDecimal("aud_amount")); - JSONObject debitLogs = platformSettlementMapper.calculateSysSettleLog(start_date, end_date, channel, "Debit"); + + JSONObject debitLogs = platformSettlementMapper.calculateSysSettleLog(start_date, end_date, channel, "Debit", wechat_rate); sysLogs.put("sys_refund_fee", debitLogs.getBigDecimal("aud_amount")); + sysLogs.put("sys_net_fee", creditLogs.getBigDecimal("aud_amount").subtract(debitLogs.getBigDecimal("aud_amount"))); - sysLogs.put("sys_surcharge", creditLogs.getBigDecimal("charge_amount").subtract(debitLogs.getBigDecimal("charge_amount"))); + if(StringUtils.equals("Alipay",channel)){ + sysLogs.put("sys_surcharge",platformSettlementMapper.calculateRmbCharge(start_date, end_date, channel)); + }else { + 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"))); return sysLogs; + } catch (Exception e) { //do nothing e.printStackTrace(); 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 aca42f88b..0b87546ba 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,7 +32,7 @@ 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); + 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 calculateSysSettleLog5(@Param("start_date") String start_date, @Param("end_date") String end_date, @Param("channel") String channel, @Param("transaction_type") String type); 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 d368a32bf..77bc52413 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 @@ -14,7 +14,7 @@ SELECT sum(cny_amount) rmb_amount, ifnull(sum(clearing_amount),0.00) aud_amount, - ifnull(sum(ROUND(channel_surcharge)),0.00) charge_amount + ifnull(sum(ROUND(clearing_amount * #{wechat_rate},2)),0.00) charge_amount FROM pmt_transactions WHERE @@ -28,8 +28,8 @@ SELECT IFNULL( - SUM(CASE transaction_type WHEN 'Credit' THEN ROUND(ROUND(cny_amount * 0.006, 2) / exchange_rate,2) - WHEN 'Debit' THEN -ROUND(ROUND(cny_amount * 0.006, 2) / exchange_rate,2) + SUM(CASE transaction_type WHEN 'Credit' THEN ROUND(ROUND(cny_amount * #{ali_rate}, 2) / exchange_rate,2) + WHEN 'Debit' THEN -ROUND(ROUND(cny_amount * #{ali_rate}, 2) / exchange_rate,2) ELSE 0 END), 0.00) ali_charge_amount FROM pmt_transactions