fix clearing_detail

master
luoyang 6 years ago
parent 6929b209fa
commit 03274a4ee0

@ -31,6 +31,8 @@ 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,6 +248,70 @@ 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<>();
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");
int 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());
totalList = clearingDetailMapper.listRepostTotal(clearingId);
//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));
}
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,6 +42,16 @@ 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,6 +29,8 @@ 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);
@ -48,4 +50,7 @@ public interface ClearingDetailMapper {
@AutoSql(type = SqlType.DELETE)
void deleteSettleLogs(@Param("clearing_id") int clearingId);
List<JSONObject> listRepostTotal(@Param("clearing_id") int clearingId);
}

@ -25,7 +25,37 @@
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
@ -77,4 +107,11 @@
<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,6 +243,8 @@ 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;
@ -250,6 +252,9 @@ 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() {
return [
@ -266,7 +271,44 @@ 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)]);
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.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;
};
angular.forEach($scope.detail.details, function (settleItem) {
var settleDays = settleItem.clear_days;
@ -279,6 +321,10 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func
analysisItem.settleAmount = Decimal.add(analysisItem.settleAmount, settleItem.clearing_amount).toFixed(2, Decimal.ROUND_FLOOR);
}
});
t1Amount = $scope.settleAnalysis[0].settleAmount;
t2Amount = $scope.settleAnalysis[1].settleAmount;
t3Amount = $scope.settleAnalysis[2].settleAmount;
var nowStr = $filter('date')(new Date(), "yyyy-MM-dd");
$scope.datePattern = $stateParams.date;
if ($scope.datePattern == nowStr) {

@ -169,6 +169,13 @@
</ul>
</div>
</div>
<div class="box">
<div style="padding-left: 77%" 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+'']">
@ -217,6 +224,14 @@
</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>
</span>
<span class="small-box-footer cursor pull-right" ng-click="packup()" ng-hide="limitButton">
收起 <i class="fa fa-arrow-circle-up"></i>
</span>
</a>
</div>
</div>
</section>

Loading…
Cancel
Save