fix clearing

master
luoyang 6 years ago
parent c6f214559d
commit b10b343679

@ -31,8 +31,6 @@ public interface CleanService {
JSONObject getClearDetails(Date dt, String managerId);
JSONObject getClearDetailsLimit20(Date dt, String managerId);
JSONObject getCleanLogTransactions(int detailId, JSONObject manager);
Map<String,JSONObject> getDayAndChannelOfAnalysisMap(int detailId, String channel,JSONObject manager);

@ -248,69 +248,6 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
return total;
}
@Override
public JSONObject getClearDetailsLimit20(Date settleDate, String managerId) {
List<JSONObject> logs = clearingLogMapper.findByDate(settleDate);
if (logs.isEmpty()) {
throw new NotFoundException();
}
JSONObject total = new JSONObject();
total.put("settle_date", settleDate);
total.put("total_credit", 0);
total.put("total_debit", 0);
total.put("gross_amount", 0);
total.put("wechat_charge", 0);
total.put("royalpay_charge", 0);
total.put("net_amount", 0);
total.put("total_charge", 0);
total.put("tax_amount", 0);
total.put("charge_cashback", 0);
List<JSONObject> details = new ArrayList<>();
List<JSONObject> totalList = new ArrayList<>();
int clearingId = 0;
for (JSONObject log : logs) {
addBigDecimal(total, log, "total_credit");
addBigDecimal(total, log, "total_debit");
addBigDecimal(total, log, "gross_amount");
addBigDecimal(total, log, "wechat_charge");
addBigDecimal(total, log, "royalpay_charge");
addBigDecimal(total, log, "net_amount");
addBigDecimal(total, log, "total_charge");
addBigDecimal(total, log, "charge_cashback");
addBigDecimal(total, log, "tax_amount");
clearingId = log.getIntValue("clearing_id");
List<JSONObject> logDetails = clearingDetailMapper.listReportsOfSettlementLimit20(clearingId);
details.addAll(logDetails);
List<String> banks = logDetails.stream().map(detail -> detail.getString("settle_bank")).distinct().collect(Collectors.toList());
List<JSONObject> bankStatistics = banks.stream().map(bank -> {
JSONObject data = new JSONObject();
data.put("bank", bank);
data.put("total_settle", logDetails.stream()
.filter(detail -> bank.equals(detail.getString("settle_bank")))
.map(detail -> detail.getBigDecimal("clearing_amount"))
.reduce(BigDecimal::add)
);
data.put("clients", logDetails.stream()
.filter(detail -> bank.equals(detail.getString("settle_bank")))
.count());
return data;
}).collect(Collectors.toList());
//bankStatistics.put()
log.put("bank_statistics", bankStatistics);
log.put("editable", DateUtils.isSameDay(log.getDate("settle_date"), new Date()) && log.getBooleanValue("editable"));
log.put("channel_analysis", clearingDetailAnalysisMapper.analysisChannelReport(clearingId));
}
totalList = clearingDetailMapper.listRepostTotal(clearingId);
total.put("totalList", totalList);
total.put("logs", logs);
total.put("details", details);
List<JSONObject> channels = clearingDetailAnalysisMapper.analysisChannelReportDaily(settleDate);
total.put("channel_analysis", channels);
return total;
}
private void addBigDecimal(JSONObject total, JSONObject log, String key) {
total.put(key, total.getBigDecimal(key).add(log.getBigDecimal(key)));
}

@ -42,16 +42,6 @@ public class SettlementDevController {
}
@RequestMapping("/reports/{date}")
public JSONObject settleReportLimit20(@PathVariable String date,@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
try {
Date dt = dateFormat.parse(date);
return cleanService.getClearDetailsLimit20(dt, manager.getString("manager_id"));
} catch (ParseException e) {
throw new BadRequestException("error.payment.valid.invalid_date_format");
}
}
@RequestMapping("/reports/{date}/all")
public JSONObject settleReport(@PathVariable String date, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
try {
Date dt = dateFormat.parse(date);

@ -29,8 +29,6 @@ public interface ClearingDetailMapper {
List<JSONObject> listReportsOfSettlement(@Param("clearing_id") int clearingId);
List<JSONObject> listReportsOfSettlementLimit20(@Param("clearing_id") int clearingId);
JSONObject listReportsOfSettleCleanDay(@Param("clearing_id") int clearingId, @Param("client_ids") List<String> client_ids);
PageList<JSONObject> listReportsOfSettlementLogs(JSONObject params, PageBounds pagination);
@ -50,7 +48,4 @@ public interface ClearingDetailMapper {
@AutoSql(type = SqlType.DELETE)
void deleteSettleLogs(@Param("clearing_id") int clearingId);
List<JSONObject> listRepostTotal(@Param("clearing_id") int clearingId);
}

@ -25,37 +25,7 @@
INNER JOIN sys_clients c ON c.client_id = d.client_id AND c.is_valid=1
WHERE d.clearing_id = #{clearing_id}
</select>
<select id="listReportsOfSettlementLimit20" resultType="com.alibaba.fastjson.JSONObject">
(SELECT
d.*,DATE_FORMAT(d.report_date,'%y-%m-%d')clear_date,DATE_FORMAT(d.settle_date_from,'%m-%d')settle_from,DATE_FORMAT(d.settle_date_to,'%m-%d')settle_to,
c.client_id as cid,
c.client_moniker,
c.parent_client_id
FROM log_clearing_detail d
INNER JOIN sys_clients c ON c.client_id = d.client_id AND c.is_valid=1
WHERE d.clearing_id = #{clearing_id} and clear_days='1' limit 20
) UNION All
( SELECT
d.*,DATE_FORMAT(d.report_date,'%y-%m-%d')clear_date,DATE_FORMAT(d.settle_date_from,'%m-%d')settle_from,DATE_FORMAT(d.settle_date_to,'%m-%d')settle_to,
c.client_id as cid,
c.client_moniker,
c.parent_client_id
FROM log_clearing_detail d
INNER JOIN sys_clients c ON c.client_id = d.client_id AND c.is_valid=1
WHERE d.clearing_id = #{clearing_id} and clear_days='2' limit 20
)
UNION All
( SELECT
d.*,DATE_FORMAT(d.report_date,'%y-%m-%d')clear_date,DATE_FORMAT(d.settle_date_from,'%m-%d')settle_from,DATE_FORMAT(d.settle_date_to,'%m-%d')settle_to,
c.client_id as cid,
c.client_moniker,
c.parent_client_id
FROM log_clearing_detail d
INNER JOIN sys_clients c ON c.client_id = d.client_id AND c.is_valid=1
WHERE d.clearing_id = #{clearing_id} and clear_days='3' limit 20
)
</select>
<select id="listReportsOfSettleCleanDay" resultType="com.alibaba.fastjson.JSONObject">
SELECT SUM(d.clearing_amount) total_amount
FROM log_clearing_detail d
@ -107,11 +77,4 @@
<if test="end!=null">and report_date &lt;= #{end}</if>
</where>
</select>
<select id="listRepostTotal" resultType="com.alibaba.fastjson.JSONObject">
select count(*) as clients,SUM(clearing_amount) as total_settle,settle_bank as bank,clear_days from log_clearing_detail where clearing_id=#{clearing_id}
GROUP BY
clear_days
</select>
</mapper>

@ -243,8 +243,6 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func
}]);
app.controller('settlementDetailCtrl', ['$scope', '$stateParams', '$http', '$uibModal', '$filter', '$state', 'detail', 'commonDialog',
function ($scope, $stateParams, $http, $uibModal, $filter, $state, detail, commonDialog) {
$scope.allButton = false;
$scope.limitButton = true;
$scope.detail = detail.data;
$scope.hasSentMail = false;
$scope.sendNotice = false;
@ -252,11 +250,8 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func
$scope.analysisFilter = {};
$scope.currentAnalysis = $scope.detail;
$scope.pageCtrl = {visible:{}};
var t1Amount =0;
var t2Amount =0;
var t3Amount =0;
function getAnalysisTemplate() {
function getAnalysisTemplate() {
return [
{settleDays: 1, clients: 0, settleAmount: 0, settles: []},
{settleDays: 2, clients: 0, settleAmount: 0, settles: []},
@ -271,45 +266,35 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func
};
angular.forEach($scope.detail.logs, function (batch) {
$scope.batchAnalysis[batch.clearing_id + ''] = getAnalysisTemplate();
});
$scope.allClearing = function() {
$http.get('/sys/settlement/reports/' + $stateParams.date + '/all').then(function (resp) {
angular.forEach($scope.settleAnalysis, function (list) {
list.settles.splice(0, list.settles.length);
list.clients = 0;
list.settleAmount = 0;
});
angular.forEach(resp.data.details, function (settleItem) {
var settleDays = settleItem.clear_days;
attachAnalysis($scope.settleAnalysis[Math.min(settleDays - 1, 2)]);
attachAnalysis($scope.batchAnalysis[settleItem.clearing_id + ''][Math.min(settleDays - 1, 2)]);
$scope.endIndexMap = {};
$scope.initEndIndex = 20;
function attachAnalysis(analysisItem) {
analysisItem.settles.push(settleItem);
analysisItem.clients++;
analysisItem.settleAmount = Decimal.add(analysisItem.settleAmount, settleItem.clearing_amount).toFixed(2, Decimal.ROUND_FLOOR);
}
});
$scope.allButton = true;
$scope.limitButton = false;
});
};
$scope.more = function(key) {
$scope.packup = function() {
angular.forEach($scope.settleAnalysis, function (list) {
list.settles.splice(20, list.settles.length);
list.clients = 20;
});
$scope.settleAnalysis[0].settleAmount = t1Amount;
$scope.settleAnalysis[1].settleAmount = t2Amount;
$scope.settleAnalysis[2].settleAmount = t3Amount;
$scope.allButton = false;
$scope.limitButton = true;
var endIndex = $scope.endIndexMap[key] + $scope.initEndIndex;
$scope.endIndexMap[key] = endIndex;
if (endIndex > $scope.clientsMap[key].clients) {
$scope.endIndexMap[key] = $scope.clientsMap[key].clients;
}
};
$scope.packup = function(key) {
$scope.endIndexMap[key] = $scope.initEndIndex;
var length = $scope.clientsMap[key];
if (length <= $scope.initEndIndex)
$scope.endIndexMap[key] = length;
};
$scope.displayAll = function (key) {
var length = $scope.clientsMap[key].clients;
$scope.endIndexMap[key] = length;
};
angular.forEach($scope.detail.details, function (settleItem) {
var settleDays = settleItem.clear_days;
attachAnalysis($scope.settleAnalysis[Math.min(settleDays - 1, 2)]);
@ -322,9 +307,16 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func
}
});
t1Amount = $scope.settleAnalysis[0].settleAmount;
t2Amount = $scope.settleAnalysis[1].settleAmount;
t3Amount = $scope.settleAnalysis[2].settleAmount;
$scope.clientsMap = $scope.settleAnalysis;
for (var key in $scope.clientsMap) {
$scope.endIndexMap[key] = $scope.initEndIndex;
var length = $scope.clientsMap[key].clients;
if (length <= $scope.initEndIndex)
$scope.endIndexMap[key] = length;
}
var nowStr = $filter('date')(new Date(), "yyyy-MM-dd");
$scope.datePattern = $stateParams.date;
if ($scope.datePattern == nowStr) {

@ -169,17 +169,9 @@
</ul>
</div>
</div>
<div class="box ">
<div class="box-header" ><span >Total Amount:</span></div>
<div style="padding-left: 2%" ng-repeat="clearingTotal in detail.totalList" >
<span ng-bind="'T+' + clearingTotal.clear_days"></span>
<span ng-bind="'Clients:' + clearingTotal.clients"></span> &nbsp Amounts:
<span ng-bind="+clearingTotal.total_settle |currency:''"></span>
</div>
</div>
<div class="box box-success settle-result-box"
ng-repeat="group in batchAnalysis[analysisFilter.clearing_id==null?'All':analysisFilter.clearing_id+'']">
ng-repeat=" (key, group) in batchAnalysis[analysisFilter.clearing_id==null?'All':analysisFilter.clearing_id+'']">
<div class="box-header" ng-click="pageCtrl.visible[group.settleDays]=!pageCtrl.visible[group.settleDays]">
T+{{group.settleDays}}: Clients:{{group.clients}}
Amount:{{group.settleAmount|currency:''}}
@ -201,7 +193,7 @@
</tr>
</thead>
<tbody>
<tr ng-repeat="settleItem in group.settles">
<tr ng-repeat="settleItem in group.settles.slice(0, endIndexMap[key])">
<td>
<img ng-src="/static/images/bank/{{settleItem.settle_bank|uppercase}}.png" class="bank-logo" title="{{settleItem.settle_bank}}">
<span ng-bind="settleItem.client_moniker"></span>
@ -225,13 +217,19 @@
</tr>
</tbody>
</table>
<a style="cursor: pointer" class="list-group-item col-sm-12 col-xs-12 text-center" >
<span class="small-box-footer cursor" ng-click="allClearing()" ng-hide="allButton">
全部 <i class="fa fa-arrow-circle-down"></i>
<a ng-if="group.clients > initEndIndex" class="list-group-item col-sm-12 col-xs-12 text-center" >
<span class="small-box-footer cursor" ng-click="more(key)" ng-if="endIndexMap[key]< group.clients">
更多 <i class="fa fa-arrow-circle-down"></i>
</span>
<span class="small-box-footer cursor pull-right" ng-click="packup()" ng-hide="limitButton">
收起 <i class="fa fa-arrow-circle-up"></i>
&nbsp;&nbsp;&nbsp;
<span class="small-box-footer cursor" ng-click="displayAll(key)" ng-if="endIndexMap[key]< group.clients">
全部 <i class="fa fa-arrow-circle-down"></i>
</span>
<span class="small-box-footer cursor pull-right"
ng-click="packup(key)"
ng-if="endIndexMap[key] > initEndIndex">
收起 <i class="fa fa-arrow-circle-up"></i>
</span>
</a>
</div>
</div>

Loading…
Cancel
Save