Merge branch 'develop'

master
Tayl0r 7 years ago
commit 25416d5478

@ -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<String, Date> settleDate = new HashMap<>();
@ -95,6 +102,7 @@ public class PlatformClearAnalysisServiceImpl implements PlatformClearService {
// deleteSettleLogs();
generateWechatSettleLogs();
generateAlipaySettleLogs();
generateAlipayOnlineSettleLogs();
}
@Transactional
@ -124,9 +132,35 @@ public class PlatformClearAnalysisServiceImpl implements PlatformClearService {
}
public void generateAlipayOnlineSettleLogs() {
try {
List<Date> 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.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 +172,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 +247,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 +273,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,67 +292,30 @@ 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 {
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();

@ -32,7 +32,7 @@ public interface PlatformSettlementMapper {
PageList<JSONObject> 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);

@ -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<JSONObject> listGroupBds = financialBDConfigMapper.listGroupBds(bdConfig.getString("bd_group"));
List<Integer> 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;

@ -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 @@
<select id="calculateRmbCharge" resultType="decimal">
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 channel_surcharge)
WHEN 'Debit' THEN -channel_surcharge)
ELSE 0 END),
0.00) ali_charge_amount
FROM pmt_transactions

@ -69,6 +69,13 @@
</if>
</if>
<where>
<if test="bd_group!=null">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&lt;=now() and (b.end_date is null or b.end_date &gt;= now())
AND (fb.bd_group=#{bd_group} or fb.manager_id=#{bd_group})
)
</if>
<if test="client_moniker !=null">c.client_moniker=#{client_moniker}</if>
<if test="sub_merchant_id!=null">and c.sub_merchant_id=#{sub_merchant_id}</if>
<if test="business_structure!=null">

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