[Y] 新增AlipayOnline对账查询

master
Tayl0r 7 years ago
parent 9b9a477f78
commit eb5fdb48df

@ -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<Date> 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<Date> dateList = TimeZoneUtils.getStatetime();
for (Date dateStr : dateList) {
List<JSONObject> 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();

@ -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',

@ -55,9 +55,11 @@
<span ng-if="log.sys_settlement_fee!=log.settlement_fee" style="color: crimson">&nbsp;&nbsp;(System:{{log.sys_settlement_fee}})</span>
</td>
<td ng-bind="log.unsettle_fee"></td>
<td ng-if="log.sys_settlement_fee==log.settlement_fee" style="font-size:25px;text-align: center;"><a role="button" ng-click="verifySettleLog(log)"><i
<td ng-if="log.sys_settlement_fee==log.settlement_fee" style="font-size:25px;text-align: center;"><a
role="button" ng-click="verifySettleLog(log)"><i
class="fa fa-check-circle text-green" uib-tooltip="校验通过"></i></a></td>
<td ng-if="log.sys_settlement_fee!=log.settlement_fee" style="font-size:25px;text-align: center;"><a role="button" ng-click="verifySettleLog(log)"><i
<td ng-if="log.sys_settlement_fee!=log.settlement_fee" style="font-size:25px;text-align: center;"><a
role="button" ng-click="verifySettleLog(log)"><i
class="fa fa-exclamation-circle text-red" uib-tooltip="校验未通过:点击重新验证"></i></a></td>
</tr>
</tbody>
@ -117,7 +119,6 @@
</div>
<div class="box box-warning">
<div class="box-header">
<h4 class="text-blue">Alipay Logs</h4>
@ -163,9 +164,11 @@
<span ng-if="log.sys_settlement_fee==log.settlement_fee" style="color: #0BB20C">&nbsp;&nbsp;(System:{{log.sys_settlement_fee}})</span>
<span ng-if="log.sys_settlement_fee!=log.settlement_fee" style="color: crimson">&nbsp;&nbsp;(System:{{log.sys_settlement_fee}})</span>
</td>
<td ng-if="log.sys_settlement_fee==log.settlement_fee" style="font-size:25px;text-align: center;"><a role="button" ng-click="verifySettleLog(log)"><i
<td ng-if="log.sys_settlement_fee==log.settlement_fee" style="font-size:25px;text-align: center;"><a
role="button" ng-click="verifySettleLog(log)"><i
class="fa fa-check-circle text-green" uib-tooltip="校验通过"></i></a></td>
<td ng-if="log.sys_settlement_fee!=log.settlement_fee" style="font-size:25px;text-align: center;"><a role="button" ng-click="verifySettleLog(log)"><i
<td ng-if="log.sys_settlement_fee!=log.settlement_fee" style="font-size:25px;text-align: center;"><a
role="button" ng-click="verifySettleLog(log)"><i
class="fa fa-exclamation-circle text-red" uib-tooltip="校验未通过:点击重新验证"></i></a></td>
</tr>
</tbody>
@ -191,4 +194,82 @@
</div>
</div>
</div>
<div class="box box-warning">
<div class="box-header">
<h4 class="text-blue">AlipayOnline Logs</h4>
</div>
<div class="box-body table-responsive">
<p ng-if="!aliLogs.length">No Data</p>
<table class="table table-hover table-striped" ng-if="aliLogs.length">
<thead>
<tr>
<th>Date Start</th>
<th>Date End</th>
<th>Settle Date</th>
<th>Pay Fee</th>
<th>Refund Fee</th>
<th>Net Fee</th>
<th>Poundage</th>
<th>Settlement Fee</th>
<th style="text-align: center;">Validation</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="log in aliOnlineLogs">
<td ng-bind="log.start_date.substr(0,10)"></td>
<td ng-bind="log.end_date.substr(0,10)"></td>
<td ng-bind="log.settle_date.substr(0,10)"></td>
<td>{{log.pay_fee}}
<span ng-if="log.sys_pay_fee==log.pay_fee" style="color: #0BB20C">&nbsp;&nbsp;(System:{{log.sys_pay_fee}})</span>
<span ng-if="log.sys_pay_fee!=log.pay_fee" style="color: crimson">&nbsp;&nbsp;(System:{{log.sys_pay_fee}})</span>
</td>
<td>{{log.refund_fee}}
<span ng-if="log.sys_refund_fee==log.refund_fee" style="color: #0BB20C">&nbsp;&nbsp;(System:{{log.sys_refund_fee}})</span>
<span ng-if="log.sys_refund_fee!=log.refund_fee" style="color: crimson">&nbsp;&nbsp;(System:{{log.sys_refund_fee}})</span>
</td>
<td>{{log.net_fee}}
<span ng-if="log.sys_net_fee==log.net_fee" style="color: #0BB20C">&nbsp;&nbsp;(System:{{log.sys_net_fee}})</span>
<span ng-if="log.sys_net_fee!=log.net_fee" style="color: crimson">&nbsp;&nbsp;(System:{{log.sys_net_fee}})</span>
</td>
<td>{{log.surcharge}}
<span ng-if="log.sys_surcharge==log.surcharge" style="color: #0BB20C">&nbsp;&nbsp;(System:{{log.sys_surcharge}})</span>
<span ng-if="log.sys_surcharge!=log.surcharge" style="color: crimson">&nbsp;&nbsp;(System:{{log.sys_surcharge}})</span>
</td>
<td>{{log.settlement_fee}}
<span ng-if="log.sys_settlement_fee==log.settlement_fee" style="color: #0BB20C">&nbsp;&nbsp;(System:{{log.sys_settlement_fee}})</span>
<span ng-if="log.sys_settlement_fee!=log.settlement_fee" style="color: crimson">&nbsp;&nbsp;(System:{{log.sys_settlement_fee}})</span>
</td>
<td ng-if="log.sys_settlement_fee==log.settlement_fee" style="font-size:25px;text-align: center;"><a
role="button" ng-click="verifySettleLog(log)"><i
class="fa fa-check-circle text-green" uib-tooltip="校验通过"></i></a></td>
<td ng-if="log.sys_settlement_fee!=log.settlement_fee" style="font-size:25px;text-align: center;"><a
role="button" ng-click="verifySettleLog(log)"><i
class="fa fa-exclamation-circle text-red" uib-tooltip="校验未通过:点击重新验证"></i></a></td>
</tr>
</tbody>
</table>
<div class="panel-footer">
<div class="row">
<uib-pagination ng-if="aliOnlieLogs.length"
class="pagination"
total-items="aliOnlinePagination.totalCount"
boundary-links="true"
ng-model="aliOnlinePagination.page"
items-per-page="aliOnlinePagination.limit"
max-size="10"
ng-change="loadAliOnlineLogs()"
previous-text="&lsaquo;"
next-text="&rsaquo;"
first-text="&laquo;"
last-text="&raquo;"></uib-pagination>
<div class="col-xs-12">Total Records:{{aliOnlinePagination.totalCount}};Total
Pages:{{aliOnliePagination.totalPages}}
</div>
</div>
</div>
</div>
</div>
</div>
Loading…
Cancel
Save