feature/desposit

master
yulingwei 5 years ago
parent 20ac65f12a
commit eaa25ebcda

@ -141,17 +141,18 @@ class PresidentDepositController extends ThinkController
$promotes = []; $promotes = [];
$count = 0; $count = 0;
if (I('export', 0) == 1) { $totalQuery = clone $query;
if (I('export', 0) == 1 || $row == 'all') {
$promotes = $query->select(); $promotes = $query->select();
} else { } else {
$totalQuery = clone $query;
$countQuery = clone $query; $countQuery = clone $query;
$promotes = $query->page($page, $row)->select(); $promotes = $query->page($page, $row)->select();
// 汇总金额
$total = M('president_deposit', 'tab_')->where(['promote_id'=>['in', $totalQuery->getField('id', true)]])->field('sum(amount) as totalAmount, sum(if(status = 1, amount, 0)) as confirmedAmount, sum(if(status = 2, amount, 0)) as refundedAmount')->find();
$count = $countQuery->count(); $count = $countQuery->count();
} }
// 汇总金额
$total = M('president_deposit', 'tab_')->where(['promote_id'=>['in', $totalQuery->getField('id', true)]])->field('sum(amount) as totalAmount, sum(if(status = 1, amount, 0)) as confirmedAmount, sum(if(status = 2, amount, 0)) as refundedAmount')->find();
$relationQuery = M('promote_company', 'tab_')->field(['id', 'company_name']); $relationQuery = M('promote_company', 'tab_')->field(['id', 'company_name']);
$promotes = $this->mergeOneReletions('company', $promotes, $relationQuery, 'company_id', 'id'); $promotes = $this->mergeOneReletions('company', $promotes, $relationQuery, 'company_id', 'id');
$relationQuery = M('president_deposit', 'tab_'); $relationQuery = M('president_deposit', 'tab_');
@ -213,7 +214,7 @@ class PresidentDepositController extends ThinkController
$record['pay_confirm_time'] = '--'; $record['pay_confirm_time'] = '--';
$record['refund_time'] = '--'; $record['refund_time'] = '--';
$record['pay_accept_time'] = '--'; $record['pay_accept_time'] = '--';
$record['status_text'] = '--'; $record['status_text'] = '市场待确认';
$record['has_record'] = false; $record['has_record'] = false;
$record['status'] = 0; $record['status'] = 0;
$record['pay_type'] = 0; $record['pay_type'] = 0;
@ -246,7 +247,7 @@ class PresidentDepositController extends ThinkController
} }
$this->checkListOrCountAuthRestMap($map,[]); $this->checkListOrCountAuthRestMap($map,[]);
$total['unconfirmedamount'] = $total['totalamount'] - $total['confirmedamount'] - $total['refundedamount']; $total['unconfirmedamount'] = $total['totalamount'] - $total['confirmedamount'] - $total['refundedamount'];
$page = set_pagination($count, $row); $page = set_pagination($count, $row == 'all' ? 1 : $row);
if($page) { if($page) {
$this->assign('_page', $page); $this->assign('_page', $page);
} }
@ -528,12 +529,12 @@ class PresidentDepositController extends ThinkController
break; break;
} }
// 如果不是无需押金,并且没有填写收到押金时间 // 如果不是无需押金,并且没有填写收到押金时间
if ($record['pay_type'] != PresidentDepositService::PAY_TYPE_NONE && empty($record['pay_accept_time'])) { // if ($record['pay_type'] != PresidentDepositService::PAY_TYPE_NONE && empty($record['pay_accept_time'])) {
$this->ajaxReturn([ // $this->ajaxReturn([
'status' => 0, // 'status' => 0,
'message' => '含有待确认收到押金时间记录,不可批量操作' // 'message' => '含有待确认收到押金时间记录,不可批量操作'
]); // ]);
} // }
} }
if (!$checkStatus) { if (!$checkStatus) {
$this->ajaxReturn([ $this->ajaxReturn([
@ -560,7 +561,8 @@ class PresidentDepositController extends ThinkController
M('president_deposit', 'tab_')->where(['promote_id' => ['in', $promoteIds]])->save([ M('president_deposit', 'tab_')->where(['promote_id' => ['in', $promoteIds]])->save([
'status' => 1, 'status' => 1,
'pay_confirm_time' => time(), 'pay_confirm_time' => time(),
'update_time' => time() 'update_time' => time(),
'pay_accept_time' => strtotime(I('accept_time'))
]); ]);
$this->ajaxReturn([ $this->ajaxReturn([
'status' => 1, 'status' => 1,

@ -257,6 +257,14 @@
//导航高亮 //导航高亮
highlight_subnav('{:U('PresidentDeposit/records')}'); highlight_subnav('{:U('PresidentDeposit/records')}');
$(function(){ $(function(){
// 添加全部选项
if ('all' == "{:I('row', 0)}") {
$("#pagechange").append("<option value='all' selected>全部</option>");
} else {
$("#pagechange").append("<option value='all'>全部</option>");
}
$('.time-select').each(function(){ $('.time-select').each(function(){
laydate.render({ laydate.render({
elem: this, elem: this,
@ -358,22 +366,46 @@
$('#pay-confirm-btn').on({ $('#pay-confirm-btn').on({
click: function() { click: function() {
var ids = getIds(); var ids = getIds();
$.ajax({ var accept_time = '';
url: '{:U("payConfirm")}',
type: 'post', layer.open({
dataType: 'json', title : '押金收到时间确认',
data: {ids: ids}, content : `<input type="text" readonly id="deposit_recept_time" value=""placeholder="押金收到时间"/>`,
success: function(result) { success : function() {
if (result.status == 1) { laydate.render({
layer.msg(result.message) elem: '#deposit_recept_time',
setTimeout(function() { type: 'datetime',
window.location.href = window.location.href value: new Date()
}, 200) });
} else { },
layer.msg(result.message) yes : function(index, layero) {
accept_time = $('#deposit_recept_time').val();
if (!accept_time) {
layer.msg('请选择押金收到时间');
return true;
} }
$.ajax({
url: '{:U("payConfirm")}',
type: 'post',
dataType: 'json',
data: {ids: ids, accept_time : accept_time},
success: function(result) {
if (result.status == 1) {
layer.msg(result.message)
setTimeout(function() {
window.location.href = window.location.href
}, 200)
} else {
layer.msg(result.message)
layer.close(index);
}
}
})
return true;
} }
}) });
} }
}) })
function getIds() { function getIds() {

@ -27,7 +27,7 @@ class PresidentDepositService
]; ];
public static $statusList = [ public static $statusList = [
0 => '待确认', 0 => '财务待确认',
1 => '已收到', 1 => '已收到',
2 => '已退款', 2 => '已退款',
]; ];

Loading…
Cancel
Save