From 9b9a477f787f9c63f79ef8a84fa509ac8812f81e Mon Sep 17 00:00:00 2001 From: yuan <1551130722@qq.com> Date: Thu, 22 Feb 2018 18:37:53 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=95=86=E6=88=B7=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0bd=E5=88=86=E7=BB=84=E7=AD=9B=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/impls/ClientManagerImpl.java | 33 +++++++++++++++---- .../manage/mappers/system/ClientMapper.xml | 7 ++++ 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java index 5d649523e..43bb2774a 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java @@ -11,6 +11,7 @@ import au.com.royalpay.payment.core.exceptions.InvalidShortIdException; import au.com.royalpay.payment.core.utils.OrderExpiryRuleResolver; import au.com.royalpay.payment.manage.analysis.mappers.TransactionAnalysisMapper; import au.com.royalpay.payment.manage.appclient.beans.AppClientBean; +import au.com.royalpay.payment.manage.mappers.financial.FinancialBDConfigMapper; import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper; import au.com.royalpay.payment.manage.mappers.redpack.ActClientInvitationCodeMapper; import au.com.royalpay.payment.manage.mappers.system.*; @@ -164,6 +165,9 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid @Resource private SpringTemplateEngine thymeleaf; + @Resource + private FinancialBDConfigMapper financialBDConfigMapper; + private static final String SOURCE_AGREE_FILE = "source_agree_file"; private static final String CLIENT_BANK_FILE = "client_bank_file"; private static final String CLIENT_ID_FILE = "client_id_file"; @@ -309,12 +313,6 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid @Override public JSONObject listClients(JSONObject manager, PartnerQuery query) { JSONObject params = query.toJsonParam(); - if (ManagerRole.BD_USER.hasRole(manager.getIntValue("role"))) { - if (query.getOnlyMe()) { - params.put("bd_user", manager.getString("manager_id")); - } - } - if(params.getString("org_id") != null){ if(params.getString("org_ids") == null){ orgIds(params,Integer.parseInt(params.getString("org_id"))); @@ -346,6 +344,29 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid params.remove("org_ids"); } } + if (ManagerRole.BD_USER.hasRole(manager.getIntValue("role"))) { + JSONObject bdConfig = financialBDConfigMapper.getBdConfig(manager.getString("manager_id")); + if (bdConfig != null) { + params.put("bd_group", bdConfig.getString("bd_group")); + List listGroupBds = financialBDConfigMapper.listGroupBds(bdConfig.getString("bd_group")); + List bdUserId = listGroupBds.stream().map(groupBd->groupBd.getIntValue("manager_id")).collect(Collectors.toList()); + if(params.containsKey("bd_user")){ + if(!bdUserId.contains(params.getIntValue("bd_user"))){ + params.remove("bd_user"); + } + } + if(params.containsKey("org_ids")){ + params.remove("org_ids"); + } + if(params.containsKey("org_id")){ + params.remove("org_id"); + } + } + + if (query.getOnlyMe()) { + params.put("bd_user", manager.getString("manager_id")); + } + } String tempSubMchId = sysConfigManager.getSysConfig().getString("temp_sub_mch_id"); String tempSubMchSource = sysConfigManager.getSysConfig().getString("temp_sub_mch_id_source"); tempSubMchSource = tempSubMchSource == null ? "" : tempSubMchSource; diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMapper.xml index 7995aa37b..980a4ffa0 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMapper.xml @@ -69,6 +69,13 @@ + and c.client_id in + (SELECT b.client_id FROM sys_client_bd b + INNER JOIN financial_bd_config fb ON fb.manager_id=b.bd_id + where b.is_valid=1 and b.start_date<=now() and (b.end_date is null or b.end_date >= now()) + AND (fb.bd_group=#{bd_group} or fb.manager_id=#{bd_group}) + ) + c.client_moniker=#{client_moniker} and c.sub_merchant_id=#{sub_merchant_id} From eb5fdb48df76eb0bf2bf4511612b281ffce58c16 Mon Sep 17 00:00:00 2001 From: Tayl0r <519104047@qq.com> Date: Thu, 22 Feb 2018 19:28:20 +0800 Subject: [PATCH 2/3] =?UTF-8?q?[Y]=20=E6=96=B0=E5=A2=9EAlipayOnline?= =?UTF-8?q?=E5=AF=B9=E8=B4=A6=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PlatformClearAnalysisServiceImpl.java | 90 +++++++++++------- .../config/platformrevenue/platformrevenue.js | 13 +++ .../templates/platform_settle_logs.html | 91 ++++++++++++++++++- 3 files changed, 155 insertions(+), 39 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 667f6632e..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 @@ -95,6 +95,7 @@ public class PlatformClearAnalysisServiceImpl implements PlatformClearService { // deleteSettleLogs(); generateWechatSettleLogs(); generateAlipaySettleLogs(); + generateAlipayOnlineSettleLogs(); } @Transactional @@ -124,9 +125,35 @@ public class PlatformClearAnalysisServiceImpl implements PlatformClearService { } + public void generateAlipayOnlineSettleLogs() { + 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); + } + + } + @Transactional public void doVerifyAlipaySettleLog(Date dateStr) throws Exception { JSONObject aliSettleLog = alipayClient.downloadRetailSettlements(dateStr); + saveAlipaySettleLog(dateStr, aliSettleLog, "Alipay"); + } + + @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); JSONObject params = new JSONObject(); @@ -138,17 +165,17 @@ public class PlatformClearAnalysisServiceImpl implements PlatformClearService { 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", "Alipay"); + params.put("channel", channel); params.put("last_update_date", new Date()); - JSONObject sysClearData = getSystemClearingAmount(dateStr,null,"Alipay"); - if(sysClearData!=null && sysClearData.size()>0){ - 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")); + JSONObject sysClearData = getSystemClearingAmount(dateStr, null, channel); + if (sysClearData != null && sysClearData.size() > 0) { + 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")); } - JSONObject check = platformSettlementMapper.findByDateMerchant(sdfClear.format(dateStr), "Alipay", "All"); + JSONObject check = platformSettlementMapper.findByDateMerchant(sdfClear.format(dateStr), channel, "All"); if (check != null) { params.put("log_id", check.getString("log_id")); platformSettlementMapper.update(params); @@ -213,14 +240,20 @@ public class PlatformClearAnalysisServiceImpl implements PlatformClearService { JSONArray payments = aliSettleLog.getJSONArray("payments"); BigDecimal credit = new BigDecimal(0.00); - BigDecimal creditFee = new BigDecimal(0.00); - BigDecimal creditSettle = new BigDecimal(0.00); + BigDecimal creditFee = new BigDecimal(0.00); + BigDecimal creditSettle = new BigDecimal(0.00); if (payments != null) { for (int i = 0; i < payments.size(); i++) { JSONObject json = payments.getJSONObject(i); - credit = credit.add(json.getBigDecimal("transaction_amount")); - creditFee = creditFee.add(json.getBigDecimal("charge_fee")); - creditSettle = creditSettle.add(json.getBigDecimal("settle_amount")); + 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)); + } } } alipaySettleLog.put("credit", credit); @@ -233,9 +266,15 @@ public class PlatformClearAnalysisServiceImpl implements PlatformClearService { if (refunds != null) { for (int i = 0; i < refunds.size(); i++) { JSONObject json = refunds.getJSONObject(i); - debit = debit.add(json.getBigDecimal("transaction_amount")); - debitFee = debitFee.add(json.getBigDecimal("charge_fee")); - debitSettle = debitSettle.add(json.getBigDecimal("settle_amount")); + 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); @@ -246,23 +285,6 @@ public class PlatformClearAnalysisServiceImpl implements PlatformClearService { return alipaySettleLog; } - - public void deleteSettleLogs() { - try { - List dateList = TimeZoneUtils.getStatetime(); - for (Date dateStr : dateList) { - List logs = platformSettlementMapper.findByDate(DateFormatUtils.format(dateStr, "yyyy-MM-dd")); - if (logs != null) { - for (JSONObject log : logs) { - platformSettlementMapper.delete(log); - } - } - } - } catch (Exception e) { - - } - } - 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(); diff --git a/src/main/ui/static/config/platformrevenue/platformrevenue.js b/src/main/ui/static/config/platformrevenue/platformrevenue.js index 9c2c3fe6b..5b3f3d1ec 100644 --- a/src/main/ui/static/config/platformrevenue/platformrevenue.js +++ b/src/main/ui/static/config/platformrevenue/platformrevenue.js @@ -42,6 +42,18 @@ define(['angular', 'decimal', 'uiRouter', 'angularEcharts', '../../analysis/repo }); } $scope.loadAliLogs(1); + $scope.aliOnlinePagination = {}; + $scope.loadAliOnlineLogs = function (page) { + var params = $scope.queryParams || {}; + params.page = page || $scope.aliOnlinePagination.page || 1; + params.limit = 20; + params.channel = 'AlipayOnline'; + $http.get('/platform/analysis/settle/log', {params: params}).then(function (resp) { + $scope.aliOnlineLogs = resp.data.data; + $scope.aliOnlinePagination = resp.data.pagination; + }); + } + $scope.loadAliOnlineLogs(1); $scope.loadBestpayLog = function () { $http.get('/platform/analysis/settle/Bestpay').then(function (resp) { $scope.bestpayLogs = resp.data; @@ -51,6 +63,7 @@ define(['angular', 'decimal', 'uiRouter', 'angularEcharts', '../../analysis/repo $scope.verifySettleLog = function(log){ $http.get('/platform/analysis/settle/verify',{params:log}).then(function () { $scope.loadAliLogs(1); + $scope.loadAliOnlineLogs(1); $scope.loadWechatLogs(1); commonDialog.alert({ title: 'Success', diff --git a/src/main/ui/static/config/platformrevenue/templates/platform_settle_logs.html b/src/main/ui/static/config/platformrevenue/templates/platform_settle_logs.html index d30bb82e2..8dbb01f0a 100644 --- a/src/main/ui/static/config/platformrevenue/templates/platform_settle_logs.html +++ b/src/main/ui/static/config/platformrevenue/templates/platform_settle_logs.html @@ -55,9 +55,11 @@   (System:{{log.sys_settlement_fee}}) - - @@ -117,7 +119,6 @@ -

Alipay Logs

@@ -163,9 +164,11 @@   (System:{{log.sys_settlement_fee}})   (System:{{log.sys_settlement_fee}}) - - @@ -191,4 +194,82 @@
+ + + +
+
+

AlipayOnline Logs

+
+
+

No Data

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Date StartDate EndSettle DatePay FeeRefund FeeNet FeePoundageSettlement FeeValidation
{{log.pay_fee}} +   (System:{{log.sys_pay_fee}}) +   (System:{{log.sys_pay_fee}}) + {{log.refund_fee}} +   (System:{{log.sys_refund_fee}}) +   (System:{{log.sys_refund_fee}}) + {{log.net_fee}} +   (System:{{log.sys_net_fee}}) +   (System:{{log.sys_net_fee}}) + {{log.surcharge}} +   (System:{{log.sys_surcharge}}) +   (System:{{log.sys_surcharge}}) + {{log.settlement_fee}} +   (System:{{log.sys_settlement_fee}}) +   (System:{{log.sys_settlement_fee}}) +
+ +
+
\ No newline at end of file From ae589d563a0fd3d9402e37cf6aec3eec917872bf Mon Sep 17 00:00:00 2001 From: Tayl0r <519104047@qq.com> Date: Thu, 22 Feb 2018 20:02:21 +0800 Subject: [PATCH 3/3] ignore --- .../PlatformClearAnalysisServiceImpl.java | 53 +++++++------------ .../mappers/log/PlatformSettlementMapper.java | 2 +- .../mappers/log/PlatformSettlementMapper.xml | 6 +-- 3 files changed, 24 insertions(+), 37 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 f130f3606..2e66a8311 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,6 +76,13 @@ 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<>(); @@ -130,13 +137,13 @@ public class PlatformClearAnalysisServiceImpl implements PlatformClearService { List dateList = TimeZoneUtils.getStatetime(); for (Date dateStr : dateList) { try { - doVerifyAlipaySettleLog(dateStr); + doVerifyAlipayOnlineSettleLog(dateStr); } catch (Exception e) { - logger.error("获取" + dateStr + "Alipay清算记录失败", e); + logger.error("获取" + dateStr + "AlipayOnline清算记录失败", e); } } } catch (Exception e) { - logger.error("获取Alipay清算记录时间失败", e); + logger.error("获取AlipayOnline清算记录时间失败", e); } } @@ -285,50 +292,30 @@ public class PlatformClearAnalysisServiceImpl implements PlatformClearService { return alipaySettleLog; } - public JSONObject getSystemClearingAmount(Date settle_date, SettlementLog settlementLog, String channel) throws Exception { + public JSONObject getSystemClearingAmount(Date settle_date, SettlementLog settlementLog, String channel){ 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("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)) { + 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); + 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"); + 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); } - try { - JSONObject creditLogs = platformSettlementMapper.calculateSysSettleLog(start_date, end_date, channel, "Credit", wechat_rate); + JSONObject creditLogs = platformSettlementMapper.calculateSysSettleLog(start_date, end_date, 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(start_date, end_date, 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)); - }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"))); 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 0b87546ba..aca42f88b 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, @Param("wechat_rate") BigDecimal wechat_rate); + JSONObject calculateSysSettleLog(@Param("start_date") String start_date, @Param("end_date") String end_date, @Param("channel") String channel, @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); 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 77bc52413..d368a32bf 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(clearing_amount * #{wechat_rate},2)),0.00) charge_amount + ifnull(sum(ROUND(channel_surcharge)),0.00) charge_amount FROM pmt_transactions WHERE @@ -28,8 +28,8 @@