add 手动清算增加统计功能

master
luoyang 5 years ago
parent 4997d6ff11
commit 1a3fa95ddd

@ -9,7 +9,7 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>manage</artifactId>
<version>1.4.21</version>
<version>1.4.22</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jib-maven-plugin.version>1.8.0</jib-maven-plugin.version>

@ -5,6 +5,8 @@ import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -29,7 +31,9 @@ public interface TaskManualSettleMapper {
@AutoSql(type = SqlType.UPDATE)
void update(JSONObject task);
List<JSONObject> getEveryLatestRecord();
PageList<JSONObject> getEveryLatestRecord(PageBounds pagination);
JSONObject getManualSettleAnalysis();
void rollbackExecutedTask(@Param("clearing_id") int clearingId);

@ -3,7 +3,6 @@ package au.com.royalpay.payment.manage.settlement.core;
import com.alibaba.fastjson.JSONObject;
import java.util.Date;
import java.util.List;
/**
* Create by yixian at 2018-03-20 17:42
@ -14,5 +13,7 @@ public interface ManualSettleSupport {
JSONObject findCurrentSettle(int clientId, boolean includingUnsettleData);
List<JSONObject> listWithClearInfo();
JSONObject listWithClearInfo(int page);
JSONObject getWithManualSettleAnalysis();
}

@ -1,5 +1,6 @@
package au.com.royalpay.payment.manage.settlement.core.impls;
import au.com.royalpay.payment.manage.analysis.mappers.ClientAnalysisMapper;
import au.com.royalpay.payment.manage.mappers.log.ClearingLogMapper;
import au.com.royalpay.payment.manage.mappers.payment.TaskManualSettleMapper;
import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper;
@ -13,14 +14,17 @@ import au.com.royalpay.payment.tools.locale.LocaleSupport;
import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider;
import au.com.royalpay.payment.tools.permission.enums.PartnerRole;
import au.com.royalpay.payment.tools.utils.CurrencyAmountUtils;
import au.com.royalpay.payment.tools.utils.PageListUtils;
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.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
@ -45,6 +49,8 @@ public class ManualSettleSupportImpl implements ManualSettleSupport {
private CalendarMapper calendarMapper;
@Resource
private ClientManager clientManager;
@Resource
private ClientAnalysisMapper clientAnalysisMapper;
@Override
public JSONObject requestManualSettle(Date settleTo, String accountId) {
@ -138,22 +144,19 @@ public class ManualSettleSupportImpl implements ManualSettleSupport {
}
@Override
public List<JSONObject> listWithClearInfo() {
List<JSONObject> manuals = taskManualSettleMapper.getEveryLatestRecord();
List<Integer> client_ids = new ArrayList<>(manuals.size());
manuals.parallelStream().forEach(p -> {
client_ids.add(p.getInteger("client_id"));
});
List<JSONObject> clientUnsettle = transactionMapper.getClientsUnClearedAmount(client_ids);
for (JSONObject manual : manuals) {
for (JSONObject settle : clientUnsettle) {
if (manual.getIntValue("client_id") == settle.getIntValue("client_id")) {
manual.put("unsettle", settle.getBigDecimal("clearing_amount"));
break;
}
}
}
public JSONObject listWithClearInfo(int page) {
PageList<JSONObject> manuals = taskManualSettleMapper.getEveryLatestRecord(
new PageBounds(page, 20, Order.formString("unsettle.desc")));
return PageListUtils.buildPageListResult(manuals);
}
return manuals;
@Override
public JSONObject getWithManualSettleAnalysis() {
JSONObject params = new JSONObject();
params.put("end", new Date());
JSONObject analysis = taskManualSettleMapper.getManualSettleAnalysis();
analysis.put("total_partners", clientAnalysisMapper.countClientsAll(params));
return analysis;
}
}

@ -4,17 +4,13 @@ import au.com.royalpay.payment.manage.permission.manager.ManagerMapping;
import au.com.royalpay.payment.manage.pos.datasource.ReadOnlyConnection;
import au.com.royalpay.payment.manage.settlement.core.ManualSettleSupport;
import au.com.royalpay.payment.manage.system.core.ClientContractService;
import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import javax.annotation.Resource;
@RestController
@ -41,7 +37,13 @@ public class contractController {
@ManagerMapping(value = "/manualSettle/list", method = RequestMethod.GET)
@ReadOnlyConnection
public List<JSONObject> manualList() {
return manualSettleSupport.listWithClearInfo();
public JSONObject manualList(@RequestParam(defaultValue = "1") int page) {
return manualSettleSupport.listWithClearInfo(page);
}
@ManagerMapping(value = "/manualSettle/analysis", method = RequestMethod.GET)
@ReadOnlyConnection
public JSONObject manualSettleAnalysis() {
return manualSettleSupport.getWithManualSettleAnalysis();
}
}

@ -9,16 +9,38 @@
</update>
<select id="getEveryLatestRecord" resultType="com.alibaba.fastjson.JSONObject">
SELECT
s.request_time,
c.client_id,
c.client_moniker
s.request_time,
cc.client_id,
cc.client_moniker,
ifnull(sum(if(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount)), 0) as unsettle
FROM
task_client_manual_settle s
right join sys_clients c on s.client_id = c.client_id
inner join sys_client_config cc on cc.client_id = c.client_id
where (s.request_time = (select max(B.request_time)
from task_client_manual_settle B
where s.client_id = B.client_id) or s.request_time is null)
and cc.manual_settle = 1
task_client_manual_settle s
RIGHT JOIN sys_client_config cc ON cc.client_id = s.client_id
LEFT JOIN pmt_transactions t on cc.client_id = t.client_id
and t.clearing_status = 0
WHERE
(
s.request_time = ( SELECT max( B.request_time ) FROM task_client_manual_settle B WHERE s.client_id = B.client_id )
OR s.request_time IS NULL
)
AND cc.manual_settle = 1
group by cc.client_id
</select>
</mapper>
<select id="getManualSettleAnalysis" resultType="com.alibaba.fastjson.JSONObject">
SELECT
count(distinct cc.client_id) as manual_settle_clients,
ifnull(sum(if(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount)), 0) as unsettle
FROM
task_client_manual_settle s
RIGHT JOIN sys_client_config cc ON cc.client_id = s.client_id
LEFT JOIN pmt_transactions t on cc.client_id = t.client_id
and t.clearing_status = 0
WHERE
(
s.request_time = ( SELECT max( B.request_time ) FROM task_client_manual_settle B WHERE s.client_id = B.client_id )
OR s.request_time IS NULL
)
AND cc.manual_settle = 1
</select>
</mapper>

@ -65,13 +65,21 @@ define(['angular'], function (angular) {
}]);
app.controller('manualSettleCtrl', ['$scope', '$http', '$state', '$filter', 'commonDialog', function ($scope, $http, $state, $filter, commonDialog) {
$scope.getManualSettleAnalysis = function () {
$http.get('/manage/common/analysis/manualSettle/list').then(function (resp) {
$scope.manual_settle_analysis = resp.data;
$scope.pagination = {};
$scope.getManualSettleAnalysis = function (page) {
var params = {};
params.page = page || $scope.pagination.page || 1;
$http.get('/manage/common/analysis/manualSettle/list', {params: params}).then(function (resp) {
$scope.manual_settle_analysis = resp.data.data;
$scope.pagination = resp.data.pagination;
});
};
$scope.getManualSettleAnalysis();
$scope.getManualSettleAnalysis(1);
$http.get('/manage/common/analysis/manualSettle/analysis').then(function (resp) {
$scope.manual_dashboard_analysis = resp.data;
});
}]);
return app;
});
});

@ -17,6 +17,36 @@
</li>
</ul>-->
<div class="modal-body">
<div class="row">
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="info-box">
<span class="info-box-icon bg-aqua"><i class="ion ion-social-usd"></i></span>
<div class="info-box-content">
<span class="info-box-text">未清算交易额</span>
<span class="info-box-number" ng-bind="manual_dashboard_analysis.unsettle|currency:'AUD '"></span>
</div>
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="info-box">
<span class="info-box-icon bg-red"><i class="ion ion-person-add"></i></span>
<div class="info-box-content">
<span class="info-box-text">开通手动清算商户数</span>
<span class="info-box-number" ng-bind="manual_dashboard_analysis.manual_settle_clients"></span>
</div>
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="info-box">
<span class="info-box-icon bg-green"><i class="ion ion-ios-people"></i></span>
<div class="info-box-content">
<span class="info-box-text">总商户数</span>
<span class="info-box-number" ng-bind="manual_dashboard_analysis.total_partners"></span>
</div>
</div>
</div>
</div>
<div class="box box-danger">
<div class="box-header">商户</div>
<div class="box-body table-responsive">
@ -37,5 +67,23 @@
</tbody>
</table>
</div>
<div class="box-body" ng-if="manual_settle_analysis.length">
<uib-pagination class="pagination"
total-items="pagination.totalCount"
boundary-links="true"
ng-model="pagination.page"
items-per-page="pagination.limit"
max-size="10"
ng-change="getManualSettleAnalysis()"
previous-text="&lsaquo;"
next-text="&rsaquo;"
first-text="&laquo;"
last-text="&raquo;"></uib-pagination>
<div class="row">
<div class="col-xs-12">Total Records:{{pagination.totalCount}};Total
Pages:{{pagination.totalPages}}
</div>
</div>
</div>
</div>
</div>
</div>

Loading…
Cancel
Save