|
|
|
@ -241,65 +241,119 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}]);
|
|
|
|
|
app.controller('settlementDetailCtrl', ['$scope', '$stateParams', '$http','$uibModal','$filter','detail','commonDialog', function ($scope, $stateParams,$http,$uibModal,$filter, detail,commonDialog) {
|
|
|
|
|
$scope.detail = detail.data;
|
|
|
|
|
$scope.hasSentMail = false;
|
|
|
|
|
$scope.sendNotice = false;
|
|
|
|
|
$scope.noticeResend = false;
|
|
|
|
|
app.controller('settlementDetailCtrl', ['$scope', '$stateParams', '$http', '$uibModal', '$filter', '$state', 'detail', 'commonDialog',
|
|
|
|
|
function ($scope, $stateParams, $http, $uibModal, $filter, $state, detail, commonDialog) {
|
|
|
|
|
$scope.detail = detail.data;
|
|
|
|
|
$scope.hasSentMail = false;
|
|
|
|
|
$scope.sendNotice = false;
|
|
|
|
|
$scope.noticeResend = false;
|
|
|
|
|
$scope.analysisFilter = {};
|
|
|
|
|
$scope.currentAnalysis = $scope.detail;
|
|
|
|
|
|
|
|
|
|
$scope.settleAnalysis = [
|
|
|
|
|
{settleDays: 1, clients: 0, settleAmount: 0, settles: []},
|
|
|
|
|
{settleDays: 2, clients: 0, settleAmount: 0, settles: []},
|
|
|
|
|
{settleDays: 3, clients: 0, settleAmount: 0, settles: []}
|
|
|
|
|
];
|
|
|
|
|
angular.forEach($scope.detail.details, function (settleItem) {
|
|
|
|
|
var settleDays = settleItem.clear_days;
|
|
|
|
|
var analysisItem = $scope.settleAnalysis[Math.min(settleDays - 1, 2)];
|
|
|
|
|
analysisItem.settles.push(settleItem);
|
|
|
|
|
analysisItem.clients++;
|
|
|
|
|
analysisItem.settleAmount = Decimal.add(analysisItem.settleAmount, settleItem.clearing_amount).toFixed(2, Decimal.ROUND_FLOOR)
|
|
|
|
|
});
|
|
|
|
|
var nowStr = $filter('date')(new Date(), "yyyy-MM-dd");
|
|
|
|
|
$scope.datePattern = $stateParams.date;
|
|
|
|
|
if($scope.datePattern == nowStr){
|
|
|
|
|
$scope.sendNotice = true;
|
|
|
|
|
}
|
|
|
|
|
$scope.displaySendCheckCode = function () {
|
|
|
|
|
$uibModal.open({
|
|
|
|
|
templateUrl: '/static/analysis/templates/settlement_send_check_code.html',
|
|
|
|
|
controller: 'settlementSendCheckCodeCtrl',
|
|
|
|
|
size: 'sm'
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
function getAnalysisTemplate() {
|
|
|
|
|
return [
|
|
|
|
|
{settleDays: 1, clients: 0, settleAmount: 0, settles: []},
|
|
|
|
|
{settleDays: 2, clients: 0, settleAmount: 0, settles: []},
|
|
|
|
|
{settleDays: 3, clients: 0, settleAmount: 0, settles: []}
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$http.get('/sys/settlement/reports/'+$stateParams.date+'/send_status/').then(function (resp) {
|
|
|
|
|
if(resp.data!=null && resp.data.mail_status ==1){
|
|
|
|
|
$scope.hasSentMail = true;
|
|
|
|
|
$scope.settleAnalysis = getAnalysisTemplate();
|
|
|
|
|
|
|
|
|
|
$scope.batchAnalysis = {
|
|
|
|
|
'All': $scope.settleAnalysis
|
|
|
|
|
};
|
|
|
|
|
angular.forEach($scope.detail.logs, function (batch) {
|
|
|
|
|
$scope.batchAnalysis[batch.clearing_id+''] = getAnalysisTemplate();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
angular.forEach($scope.detail.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);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
var nowStr = $filter('date')(new Date(), "yyyy-MM-dd");
|
|
|
|
|
$scope.datePattern = $stateParams.date;
|
|
|
|
|
if ($scope.datePattern == nowStr) {
|
|
|
|
|
$scope.sendNotice = true;
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
$scope.$on("sendMailSuccess",
|
|
|
|
|
function (event, msg) {
|
|
|
|
|
$scope.hasSentMail = true;
|
|
|
|
|
});
|
|
|
|
|
$scope.displaySendCheckCode = function () {
|
|
|
|
|
$uibModal.open({
|
|
|
|
|
templateUrl: '/static/analysis/templates/settlement_send_check_code.html',
|
|
|
|
|
controller: 'settlementSendCheckCodeCtrl',
|
|
|
|
|
size: 'sm'
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$scope.switchSettleBatch = function (batch) {
|
|
|
|
|
if (batch == null) {
|
|
|
|
|
$scope.currentAnalysis = $scope.detail;
|
|
|
|
|
$scope.analysisFilter.clearing_id = null;
|
|
|
|
|
} else {
|
|
|
|
|
$scope.analysisFilter.clearing_id = batch.clearing_id;
|
|
|
|
|
$scope.currentAnalysis = batch;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$scope.confirmSendSettlementMail = function () {
|
|
|
|
|
commonDialog.confirm({
|
|
|
|
|
title: 'Confirm to send notice',
|
|
|
|
|
content: '请确认账户已扣款后再发送清算通知',
|
|
|
|
|
choises : [{label: 'Send', className: 'btn-success', key: '1'},
|
|
|
|
|
{label: 'Cancel', className: 'btn-danger', key: '2', dismiss: true}]
|
|
|
|
|
}).then(function () {
|
|
|
|
|
$scope.noticeResend=true;
|
|
|
|
|
$http.post('/sys/settlement/settlement_notice').then(function () {
|
|
|
|
|
commonDialog.alert({title: 'Success', content: '发送成功', type: 'success'});
|
|
|
|
|
$scope.noticeResend=false;
|
|
|
|
|
},function (resp) {
|
|
|
|
|
commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'});
|
|
|
|
|
$scope.noticeResend=false;
|
|
|
|
|
$scope.getCurrentLog = function () {
|
|
|
|
|
return $scope.detail.logs.filter(function (log) {
|
|
|
|
|
return log.clearing_id === $scope.analysisFilter.clearing_id
|
|
|
|
|
})[0];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$http.get('/sys/settlement/reports/' + $stateParams.date + '/send_status/').then(function (resp) {
|
|
|
|
|
if (resp.data != null && resp.data.mail_status == 1) {
|
|
|
|
|
$scope.hasSentMail = true;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
$scope.$on("sendMailSuccess",
|
|
|
|
|
function (event, msg) {
|
|
|
|
|
$scope.hasSentMail = true;
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
};
|
|
|
|
|
}]);
|
|
|
|
|
|
|
|
|
|
$scope.confirmSendSettlementMail = function () {
|
|
|
|
|
commonDialog.confirm({
|
|
|
|
|
title: 'Confirm to send notice',
|
|
|
|
|
content: '请确认账户已扣款后再发送清算通知',
|
|
|
|
|
choises: [{label: 'Send', className: 'btn-success', key: '1'},
|
|
|
|
|
{label: 'Cancel', className: 'btn-danger', key: '2', dismiss: true}]
|
|
|
|
|
}).then(function () {
|
|
|
|
|
$scope.noticeResend = true;
|
|
|
|
|
$http.post('/sys/settlement/settlement_notice').then(function () {
|
|
|
|
|
commonDialog.alert({title: 'Success', content: '发送成功', type: 'success'});
|
|
|
|
|
$scope.noticeResend = false;
|
|
|
|
|
}, function (resp) {
|
|
|
|
|
commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'});
|
|
|
|
|
$scope.noticeResend = false;
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$scope.lockSettleLog = function (clearingId) {
|
|
|
|
|
commonDialog.confirm({title: '确认操作', content: '当前操作将标记本批次清算已发送,无法撤回,确认操作?'}).then(function () {
|
|
|
|
|
$http.put('/sys/settlement/reports/' + $stateParams.date + '/clearings/' + clearingId + '/lock').then(function () {
|
|
|
|
|
$scope.detail.logs.filter(function (log) {
|
|
|
|
|
return log.clearing_id === clearingId
|
|
|
|
|
}).forEach(function (log) {
|
|
|
|
|
log.editable = 0
|
|
|
|
|
});
|
|
|
|
|
commonDialog.alert({title: 'Success', content: 'Operation success', type: 'success'});
|
|
|
|
|
}, function (resp) {
|
|
|
|
|
commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'});
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$scope.distributeBankDialog = function () {
|
|
|
|
|
var log = $scope.getCurrentLog();
|
|
|
|
|
}
|
|
|
|
|
}]);
|
|
|
|
|
app.controller('settlementTransactionsCtrl', ['$scope', '$stateParams', 'detail', function ($scope, $stateParams, detail) {
|
|
|
|
|
$scope.ctrl = {channel: null};
|
|
|
|
|
$scope.report = detail.data;
|
|
|
|
@ -341,7 +395,7 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}]);
|
|
|
|
|
app.controller('settlementSendCheckCodeCtrl',['$scope', '$http','$rootScope','$stateParams', function ($scope, $http,$rootScope,$stateParams) {
|
|
|
|
|
app.controller('settlementSendCheckCodeCtrl', ['$scope', '$http', '$rootScope', '$stateParams', function ($scope, $http, $rootScope, $stateParams) {
|
|
|
|
|
$scope.sendCheckCodeButton = false;
|
|
|
|
|
$scope.sendMailButton = false;
|
|
|
|
|
$scope.check_code = '';
|
|
|
|
@ -354,15 +408,15 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func
|
|
|
|
|
|
|
|
|
|
$scope.sendSettlementMail = function () {
|
|
|
|
|
$scope.error_msg = '正在发送,请稍后。';
|
|
|
|
|
if($scope.check_code =='' || $scope.check_code == null){
|
|
|
|
|
if ($scope.check_code == '' || $scope.check_code == null) {
|
|
|
|
|
$scope.error_msg = '请输入验证码';
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$scope.sendMailButton= true;
|
|
|
|
|
$http.get('/sys/settlement/reports/'+$stateParams.date+'/send_settlement_xlsx/'+$scope.check_code).then(function (resp) {
|
|
|
|
|
$scope.error_msg =resp.data.msg;
|
|
|
|
|
$scope.sendMailButton= false;
|
|
|
|
|
if(resp.data.result==0){
|
|
|
|
|
$scope.sendMailButton = true;
|
|
|
|
|
$http.get('/sys/settlement/reports/' + $stateParams.date + '/send_settlement_xlsx/' + $scope.check_code).then(function (resp) {
|
|
|
|
|
$scope.error_msg = resp.data.msg;
|
|
|
|
|
$scope.sendMailButton = false;
|
|
|
|
|
if (resp.data.result == 0) {
|
|
|
|
|
$scope.sendMailButton = true;
|
|
|
|
|
$rootScope.$broadcast("sendMailSuccess", '123');
|
|
|
|
|
}
|
|
|
|
|