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 getClearDetails(Date dt, String managerId);
JSONObject getClearDetailsLimit20(Date dt, String managerId);
JSONObject getCleanLogTransactions(int detailId, JSONObject manager); JSONObject getCleanLogTransactions(int detailId, JSONObject manager);
Map<String,JSONObject> getDayAndChannelOfAnalysisMap(int detailId, String channel,JSONObject manager); Map<String,JSONObject> getDayAndChannelOfAnalysisMap(int detailId, String channel,JSONObject manager);

@ -248,69 +248,6 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
return total; 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) { private void addBigDecimal(JSONObject total, JSONObject log, String key) {
total.put(key, total.getBigDecimal(key).add(log.getBigDecimal(key))); total.put(key, total.getBigDecimal(key).add(log.getBigDecimal(key)));
} }

@ -42,16 +42,6 @@ public class SettlementDevController {
} }
@RequestMapping("/reports/{date}") @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) { public JSONObject settleReport(@PathVariable String date, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
try { try {
Date dt = dateFormat.parse(date); Date dt = dateFormat.parse(date);

@ -29,8 +29,6 @@ public interface ClearingDetailMapper {
List<JSONObject> listReportsOfSettlement(@Param("clearing_id") int clearingId); 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); JSONObject listReportsOfSettleCleanDay(@Param("clearing_id") int clearingId, @Param("client_ids") List<String> client_ids);
PageList<JSONObject> listReportsOfSettlementLogs(JSONObject params, PageBounds pagination); PageList<JSONObject> listReportsOfSettlementLogs(JSONObject params, PageBounds pagination);
@ -50,7 +48,4 @@ public interface ClearingDetailMapper {
@AutoSql(type = SqlType.DELETE) @AutoSql(type = SqlType.DELETE)
void deleteSettleLogs(@Param("clearing_id") int clearingId); 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 INNER JOIN sys_clients c ON c.client_id = d.client_id AND c.is_valid=1
WHERE d.clearing_id = #{clearing_id} WHERE d.clearing_id = #{clearing_id}
</select> </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 id="listReportsOfSettleCleanDay" resultType="com.alibaba.fastjson.JSONObject">
SELECT SUM(d.clearing_amount) total_amount SELECT SUM(d.clearing_amount) total_amount
FROM log_clearing_detail d FROM log_clearing_detail d
@ -107,11 +77,4 @@
<if test="end!=null">and report_date &lt;= #{end}</if> <if test="end!=null">and report_date &lt;= #{end}</if>
</where> </where>
</select> </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> </mapper>

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

@ -169,17 +169,9 @@
</ul> </ul>
</div> </div>
</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" <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]"> <div class="box-header" ng-click="pageCtrl.visible[group.settleDays]=!pageCtrl.visible[group.settleDays]">
T+{{group.settleDays}}: Clients:{{group.clients}} T+{{group.settleDays}}: Clients:{{group.clients}}
Amount:{{group.settleAmount|currency:''}} Amount:{{group.settleAmount|currency:''}}
@ -201,7 +193,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr ng-repeat="settleItem in group.settles"> <tr ng-repeat="settleItem in group.settles.slice(0, endIndexMap[key])">
<td> <td>
<img ng-src="/static/images/bank/{{settleItem.settle_bank|uppercase}}.png" class="bank-logo" title="{{settleItem.settle_bank}}"> <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> <span ng-bind="settleItem.client_moniker"></span>
@ -225,11 +217,17 @@
</tr> </tr>
</tbody> </tbody>
</table> </table>
<a style="cursor: pointer" class="list-group-item col-sm-12 col-xs-12 text-center" > <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="allClearing()" ng-hide="allButton"> <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>
&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> 全部 <i class="fa fa-arrow-circle-down"></i>
</span> </span>
<span class="small-box-footer cursor pull-right" ng-click="packup()" ng-hide="limitButton"> <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> 收起 <i class="fa fa-arrow-circle-up"></i>
</span> </span>
</a> </a>

Loading…
Cancel
Save