diff --git a/Application/Admin/Controller/PresidentDepositController.class.php b/Application/Admin/Controller/PresidentDepositController.class.php index fa91bb84e..e0ae9920f 100644 --- a/Application/Admin/Controller/PresidentDepositController.class.php +++ b/Application/Admin/Controller/PresidentDepositController.class.php @@ -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 (!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('pay_confirm_time_end', '') != '') { + $depositStrWhere .= ' and pay_confirm_time<=' . strtotime(I('pay_confirm_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('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 (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))]); - } - $promotes = []; + $query = M('promote_company', 'tab_')->where($where); + $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 '
';
-        var_dump($promotes);
-        echo '
'; - 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); diff --git a/Application/Admin/View/PresidentDeposit/records.html b/Application/Admin/View/PresidentDeposit/records.html index a9ba13742..4dbfa30f5 100644 --- a/Application/Admin/View/PresidentDeposit/records.html +++ b/Application/Admin/View/PresidentDeposit/records.html @@ -67,10 +67,10 @@
@@ -92,7 +92,7 @@
- 所属推广公司 - 会长账号 - 工会类型 + 推广公司 + 公会类型 退押金账户名 付款方式 退押金账号 @@ -188,7 +187,6 @@ {$data.company_name} - {$data.account} {$data.company_belong_text} {$data.payer} {$data.pay_way_text} diff --git a/Application/Admin/View/PromoteCompany/add.html b/Application/Admin/View/PromoteCompany/add.html index 1aa543176..f19fd33b9 100644 --- a/Application/Admin/View/PromoteCompany/add.html +++ b/Application/Admin/View/PromoteCompany/add.html @@ -413,7 +413,7 @@ - 是否有打款流程: + 是否支付宝打款: