优化押金

master
ELF 5 years ago
parent 50755b89c5
commit 42547128d4

@ -17,154 +17,81 @@ class PresidentDepositController extends ThinkController
$companyType = I('company_type');
$payType = I('pay_type');
$status = I('status');
$promoteId = I('promote_id');
$companyId = I('company_id', 0);
$query = M('promote', 'tab_')->where(['level' => 1])->where(['company_belong' => ['in', [1, 2]]]);
$idStrWhere = [];
if ($promoteId !== '') {
$idStrWhere[] = 'id = ' . $promoteId;
$where = [
'_string' => '1=1',
'company_belong' => ['in', [1, 2]]
];
if ($companyId != '') {
$where['id'] = $companyId;
}
if ($companyType !== '') {
$query->where(['company_belong' => $companyType]);
$where['_string'] .= ' and company_belong=' . $companyType;
}
$promoteIds = [];
$depositWhere = [];
$depositStrWhere = '1=1';
if ($status !== '') {
if ($status == '-1') { // 市场待审核
$tempPromoteIds = M('president_deposit', 'tab_')->getField('promote_id', true);
if (count($tempPromoteIds) > 0) {
$idStrWhere[] = 'id not in (' . implode(',', $tempPromoteIds) . ')';
if ($status == '-1') {
$companyIds = M('president_deposit', 'tab_')->getField('company_id', true);
if (count($companyIds) > 0) {
$depositStrWhere .= ' and company_id not in (' . implode(',', $companyIds) . ')';
}
} else {
$tempPromoteIds = M('president_deposit', 'tab_')->where(['status' => $status])->getField('promote_id', true);
if (count($tempPromoteIds) > 0) {
$idStrWhere[] = 'id in (' . implode(',', $tempPromoteIds) . ')';
} else {
$idStrWhere[] = '1<>1';
}
$depositWhere['status'] = $status;
}
}
if (!empty(I('pay_confirm_time_start')) && empty(I('pay_confirm_time_end'))) {
$startTime = strtotime(I('pay_confirm_time_start'));
$endTime = strtotime(I('pay_confirm_time_end')) + 86400;
$tempPromoteIds = M('president_deposit', 'tab_')->where("pay_confirm_time >= {$startTime}")->getField('promote_id', true);
if (count($tempPromoteIds) > 0) {
$idStrWhere[] = 'id in (' . implode(',', $tempPromoteIds) . ')';
} else {
$idStrWhere[] = '1<>1';
}
} else if (empty(I('pay_confirm_time_start')) && !empty(I('pay_confirm_time_end'))) {
$startTime = strtotime(I('pay_confirm_time_start'));
$endTime = strtotime(I('pay_confirm_time_end')) + 86400;
$tempPromoteIds = M('president_deposit', 'tab_')->where("pay_confirm_time <= {$endTime}")->getField('promote_id', true);
if (count($tempPromoteIds) > 0) {
$idStrWhere[] = 'id in (' . implode(',', $tempPromoteIds) . ')';
} else {
$idStrWhere[] = '1<>1';
}
} else if (!empty(I('pay_confirm_time_start')) && !empty(I('pay_confirm_time_end'))) {
$startTime = strtotime(I('pay_confirm_time_start'));
$endTime = strtotime(I('pay_confirm_time_end')) + 86400;
$tempPromoteIds = M('president_deposit', 'tab_')->where("pay_confirm_time >= {$startTime} and pay_confirm_time <= {$endTime}")->getField('promote_id', true);
if (count($tempPromoteIds) > 0) {
$idStrWhere[] = 'id in (' . implode(',', $tempPromoteIds) . ')';
} else {
$idStrWhere[] = '1<>1';
if (I('pay_confirm_time_start', '') != '') {
$depositStrWhere .= ' and pay_confirm_time>=' . strtotime(I('pay_confirm_time_start') . ' 00:00:00');
}
if (I('pay_confirm_time_end', '') != '') {
$depositStrWhere .= ' and pay_confirm_time<=' . strtotime(I('pay_confirm_time_end') . ' 23:59:59');
}
if (!empty(I('refund_time_start')) && empty(I('refund_time_end'))) {
$startTime = strtotime(I('refund_time_start'));
$endTime = strtotime(I('refund_time_end')) + 86400;
$tempPromoteIds = M('president_deposit', 'tab_')->where("refund_time >= {$startTime}")->getField('promote_id', true);
if (count($tempPromoteIds) > 0) {
$idStrWhere[] = 'id in (' . implode(',', $tempPromoteIds) . ')';
} else {
$idStrWhere[] = '1<>1';
}
} else if (empty(I('refund_time_start')) && !empty(I('refund_time_end'))) {
$startTime = strtotime(I('refund_time_start'));
$endTime = strtotime(I('refund_time_end'))+ 86400;
$tempPromoteIds = M('president_deposit', 'tab_')->where("refund_time <= {$endTime}")->getField('promote_id', true);
if (count($tempPromoteIds) > 0) {
$idStrWhere[] = 'id in (' . implode(',', $tempPromoteIds) . ')';
} else {
$idStrWhere[] = '1<>1';
}
} else if (!empty(I('refund_time_start')) && !empty(I('refund_time_end'))) {
$startTime = strtotime(I('refund_time_start'));
$endTime = strtotime(I('refund_time_end'))+ 86400;
$tempPromoteIds = M('president_deposit', 'tab_')->where("refund_time >= {$startTime} and refund_time <= {$endTime}")->getField('promote_id', true);
if (count($tempPromoteIds) > 0) {
$idStrWhere[] = 'id in (' . implode(',', $tempPromoteIds) . ')';
} else {
$idStrWhere[] = '1<>1';
if (I('refund_time_start', '') != '') {
$depositStrWhere .= ' and refund_time>=' . strtotime(I('refund_time_start') . ' 00:00:00');
}
if (I('refund_time_end', '') != '') {
$depositStrWhere .= ' and refund_time<=' . strtotime(I('refund_time_end') . ' 23:59:59');
}
if (!empty(I('pay_accept_time_start')) && empty(I('pay_accept_time_end'))) {
$startTime = strtotime(I('pay_accept_time_start'));
$endTime = strtotime(I('pay_accept_time_end'))+ 86400;
$tempPromoteIds = M('president_deposit', 'tab_')->where("pay_accept_time >= {$startTime}")->getField('promote_id', true);
if (count($tempPromoteIds) > 0) {
$idStrWhere[] = 'id in (' . implode(',', $tempPromoteIds) . ')';
} else {
$idStrWhere[] = '1<>1';
}
} else if (empty(I('pay_accept_time_start')) && !empty(I('pay_accept_time_end'))) {
$startTime = strtotime(I('pay_accept_time_start'));
$endTime = strtotime(I('pay_accept_time_end'))+ 86400;
$tempPromoteIds = M('president_deposit', 'tab_')->where("pay_accept_time <= {$endTime}")->getField('promote_id', true);
if (count($tempPromoteIds) > 0) {
$idStrWhere[] = 'id in (' . implode(',', $tempPromoteIds) . ')';
} else {
$idStrWhere[] = '1<>1';
}
} else if (!empty(I('pay_accept_time_start')) && !empty(I('pay_accept_time_end'))) {
$startTime = strtotime(I('pay_accept_time_start'));
$endTime = strtotime(I('pay_accept_time_end'))+ 86400;
$tempPromoteIds = M('president_deposit', 'tab_')->where("pay_accept_time >= {$startTime} and pay_accept_time <= {$endTime}")->getField('promote_id', true);
if (count($tempPromoteIds) > 0) {
$idStrWhere[] = 'id in (' . implode(',', $tempPromoteIds) . ')';
} else {
$idStrWhere[] = '1<>1';
if (I('pay_accept_time_start', '') != '') {
$depositStrWhere .= ' and pay_accept_time>=' . strtotime(I('pay_accept_time_start') . ' 00:00:00');
}
if (I('pay_accept_time_end', '') != '') {
$depositStrWhere .= ' and pay_accept_time<=' . strtotime(I('pay_accept_time_end') . ' 23:59:59');
}
if ($payType !== '') {
$tempPromoteIds = M('president_deposit', 'tab_')->where(['pay_type' => $payType])->getField('promote_id', true);
if (count($tempPromoteIds) > 0) {
$idStrWhere[] = 'id in (' . implode(',', $tempPromoteIds) . ')';
} else {
$idStrWhere[] = '1<>1';
}
$depositWhere['pay_type'] = $payType;
}
$subSql = M('president_deposit', 'tab_')->field('company_id')->where($depositWhere)->select(false);
$where['_string'] .= ' and id in (' . $subSql . ')';
if (!empty(I('admin_id', 0))) {
$query->where(['admin_id' => I('admin_id', 0)]);
}
if (count($idStrWhere) > 0) {
$query->where(['_string' => implode(' and ', array_unique($idStrWhere))]);
}
$query = M('promote_company', 'tab_')->where($where);
$promotes = [];
$count = 0;
$totalQuery = clone $query;
$companies = [];
if (I('export', 0) == 1 || $row == 'all') {
$promotes = $query->select();
$companies = $query->select();
$count = count($promotes);
} else {
$countQuery = clone $query;
$promotes = $query->page($page, $row)->select();
$companies = $query->page($page, $row)->select();
$count = $countQuery->count();
}
// 汇总金额
if (count($promotes) > 0 || (isset($count) && $count > 0)) {
if (count($companies) > 0 || (isset($count) && $count > 0)) {
$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();
$total = [
'totalamount' => $total['totalamount'] ?? 0, 'confirmedamount' => $total['confirmedamount'] ?? 0, 'refundedamount' => $total['refundedamount'] ?? 0
@ -175,17 +102,9 @@ class PresidentDepositController extends ThinkController
];
}
$relationQuery = M('promote_company', 'tab_')->field(['id', 'company_name']);
$promotes = $this->mergeOneReletions('company', $promotes, $relationQuery, 'company_id', 'id');
$relationQuery = M('president_deposit', 'tab_');
$promotes = $this->mergeOneReletions('presidentDeposit', $promotes, $relationQuery, 'id', 'promote_id');
$relationQuery = M('promote_belong', 'tab_')->field(['verify_time', 'promote_id']);
$promotes = $this->mergeOneReletions('promoteBelong', $promotes, $relationQuery, 'id', 'promote_id');
/*echo '<pre>';
var_dump($promotes);
echo '</pre>';
die();*/
$companies = $this->mergeOneReletions('presidentDeposit', $companies, $relationQuery, 'id', 'company_id');
$companyTypes = [
1 => '外团',
2 => '外团-分发联盟',
@ -195,17 +114,15 @@ class PresidentDepositController extends ThinkController
$statusList = PresidentDepositService::$statusList;
$records = [];
if (count($promotes) > 0) {
foreach ($promotes as $promote) {
if (count($companies) > 0) {
foreach ($companies as $company) {
$record = [
'id' => $promote['id'],
'company_name' => $promote['company'] ? $promote['company']['company_name'] : '',
'account' => $promote['account'],
'company_belong_text' => $companyTypes[$promote['company_belong']],
'id' => $company['id'],
'company_name' => $company['company_name'],
'company_belong_text' => $companyTypes[$company['company_belong']],
];
if ($promote['presidentDeposit']) {
$presidentDeposit = $promote['presidentDeposit'];
$promoteBelong = $promote['promoteBelong'];
if ($presidentDeposit['pay_type'] == PresidentDepositService::PAY_TYPE_NONE) {
$record['payer'] = '--';
$record['pay_account'] = '--';
@ -218,7 +135,7 @@ class PresidentDepositController extends ThinkController
$record['pay_type_text'] = $payTypes[$presidentDeposit['pay_type']];
$record['pay_way_text'] = $payWays[$presidentDeposit['pay_way']] ?? '--';
$record['create_time'] = $presidentDeposit['create_time'] == 0 ? '--' : date('Y-m-d H:i:s', $presidentDeposit['create_time']);
$record['verify_time'] = $promoteBelong && $promoteBelong['verify_time'] != 0 ? date('Y-m-d H:i:s', $promoteBelong['verify_time']) : '--';
$record['verify_time'] = $company['create_time'] != 0 ? date('Y-m-d H:i:s', $company['create_time']) : '--';
$record['pay_confirm_time'] = $presidentDeposit['pay_confirm_time'] == 0 ? '--' : date('Y-m-d', $presidentDeposit['pay_confirm_time']);
$record['refund_time'] = $presidentDeposit['refund_time'] == 0 ? '--' : date('Y-m-d', $presidentDeposit['refund_time']);
$record['pay_accept_time'] = $presidentDeposit['pay_accept_time'] == 0 ? '--' : date('Y-m-d', $presidentDeposit['pay_accept_time']);
@ -271,10 +188,13 @@ class PresidentDepositController extends ThinkController
$this->checkListOrCountAuthRestMap($map,[]);
$total['unconfirmedamount'] = $total['totalamount'] - $total['confirmedamount'] - $total['refundedamount'];
$page = set_pagination($count, $row == 'all' ? 99999999 : $row);
//dd($row == 'all' ? 99999999 : $row);
$allCompanies = M('promote_company', 'tab_')->field(['id', 'company_name'])->where(['company_belong' => ['in', [1, 2]]])->select();
if($page) {
$this->assign('_page', $page);
}
$this->assign('allCompanies', $allCompanies);
$this->assign('total', $total);
$this->assign('payWays', $payWays);
$this->assign('payTypes', $payTypes);

@ -67,10 +67,10 @@
</div>
<div class="input-list input-list-promote search_label_rehab">
<select id="promote_id" name="promote_id" class="select_gallery" style="width:120px;">
<option value="">会长账号</option>
<volist name=":get_promote_list_by_id()" id="vo">
<option value="{$vo.id}">{$vo.account}</option>
</volist>
<option value="0">推广公司</option>
<?php foreach($allCompanies as $company):?>
<option value="<?=$company['id']?>"><?=$company['id']?></option>
<?php endforeach;?>
</select>
</div>
<div class="input-list input-list-promote search_label_rehab">
@ -92,7 +92,7 @@
</div>
<div class="input-list input-list-promote search_label_rehab">
<select id="company_type" name="company_type" class="select_gallery" style="width:120px;">
<option value="">会类型</option>
<option value="">会类型</option>
<?php foreach($companyTypes as $key => $name):?>
<option value="<?=$key?>"><?=$name?></option>
<?php endforeach;?>
@ -155,9 +155,8 @@
<th>
<input class="check-all" type="checkbox">
</th>
<th>所属推广公司</th>
<th>会长账号</th>
<th>工会类型</th>
<th>推广公司</th>
<th>公会类型</th>
<th>退押金账户名</th>
<th>付款方式</th>
<th>退押金账号</th>
@ -188,7 +187,6 @@
<?php endif;?>
</td>
<td>{$data.company_name}</td>
<td>{$data.account}</td>
<td>{$data.company_belong_text}</td>
<td>{$data.payer}</td>
<td>{$data.pay_way_text}</td>

@ -413,7 +413,7 @@
</td>
</tr>
<tr>
<td class="l">是否有打款流程:</td>
<td class="l">是否支付宝打款:</td>
<td class="r table_radio">
<span class="form_radio table_btn">
<label>

@ -417,7 +417,7 @@
</td>
</tr>
<tr>
<td class="l">是否有打款流程:</td>
<td class="l">是否支付宝打款:</td>
<td class="r table_radio">
<span class="form_radio table_btn">
<label>

@ -428,7 +428,7 @@
</td>
</tr>
<tr>
<td class="l">是否有打款流程:</td>
<td class="l">是否支付宝打款:</td>
<td class="r table_radio">
<span class="form_radio table_btn">
<label>

Loading…
Cancel
Save