123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- <?php
- class refill_evidenceControl extends SystemControl
- {
- public function __construct()
- {
- parent::__construct();
- }
- /**
- * 充值申请列表
- */
- public function indexOp()
- {
- $model_merchant = Model('merchant');
- $condition = [];
- if (trim($_GET['mchid']) != '') {
- $condition['mchid'] = $_GET['mchid'];
- }
- $state_sel = intval($_REQUEST['state_sel']);
- if ($state_sel == 1) {
- $condition['check_time'] = 0;
- $condition['status'] = 1;
- } elseif ($state_sel == 2) {
- $condition['check_time'] = ['gt', 0];
- $condition['status'] = 2;
- } elseif ($state_sel == 3) {
- $condition['check_time'] = ['gt', 0];
- $condition['status'] = 3;
- } else {
- }
- if (!empty($_GET['add_type'])) {
- $condition['add_type'] = intval($_GET['add_type']);
- }
- if (!empty($_GET['is_bank'])) {
- $condition['is_bank'] = intval($_GET['is_bank']);
- }
- if (!empty($_GET['receive_bank'])) {
- $condition['receive_bank'] = intval($_GET['receive_bank']);
- }
- $export = $_GET['export'] ?? 0;
- $start_unixtime = intval(strtotime($_GET['query_start_time']));
- $end_unixtime = intval(strtotime($_GET['query_end_time']));
- if ($start_unixtime > 0 && $end_unixtime > $start_unixtime) {
- $condition['add_time'] = [['egt', $start_unixtime], ['lt', $end_unixtime], 'and'];
- } elseif ($start_unixtime > 0) {
- $condition['add_time'] = ['egt', $start_unixtime];
- } elseif ($end_unixtime > 0) {
- $condition['add_time'] = ['lt', $end_unixtime];
- }
- //充值申请列表
- if(!empty($export)) {
- $evidence_list = $this->GetExportData($condition);
- } else {
- $evidence_list = $model_merchant->getRefillEvidence($condition, 20, 'refill_evidence.*,member.available_predeposit', 'refill_evidence.add_time desc', '', true);
- }
- $evidence_list = $this->formatData($evidence_list);
- $counts = Model('')->table('refill_evidence')
- ->field('sum(amount) as amounts,status,add_type')
- ->where($condition)
- ->group('status,add_type')
- ->select();
- $success_amount = $send_amount = $cancel_amount = $mch_amount = $system_amount = $system_edit_amount = 0;
- foreach ($counts as $count) {
- if($count['status'] == 1) {
- $send_amount += $count['amounts'];
- }elseif ($count['status'] == 2) {
- $success_amount += $count['amounts'];
- if($count['add_type'] == 1) {
- $mch_amount += $count['amounts'];
- }elseif ($count['add_type'] == 2) {
- $system_amount += $count['amounts'];
- }elseif ($count['add_type'] == 3) {
- $system_edit_amount += $count['amounts'];
- }
- }elseif ($count['status'] == 3) {
- $cancel_amount += $count['amounts'];
- }
- }
- $stats['send_amount'] = $send_amount;
- $stats['success_amount'] = $success_amount;
- $stats['cancel_amount'] = $cancel_amount;
- $stats['mch_amount'] = $mch_amount;
- $stats['system_amount'] = $system_amount;
- $stats['system_edit_amount'] = $system_edit_amount;
- if(!empty($export)) {
- $result['data'] = $evidence_list;
- $result['stats'] = $stats;
- echo(json_encode($result));
- exit;
- }
- global $config;
- $receive_bank_text = $config['receive_bank'][COMPANY_NAME];
- $merchant_list = $this->merchants();
- Tpl::output('merchant_list', $merchant_list);
- Tpl::output('stats', $stats);
- Tpl::output('receive_bank_text', $receive_bank_text);
- Tpl::output('evidence_list', $evidence_list);
- Tpl::output('page', $model_merchant->showpage());
- Tpl::showpage('merchant.refill.evidence_list');
- }
- public function formatData($data)
- {
- $status_text = ['申请中', '已通过', '已驳回'];
- $operation_text = ['未预存', '已预存'];
- $add_type_text = ['商户预存','后台手动预存','后台手动调款'];
- $is_bank_text = ['否','是'];
- foreach ($data as $key => $value) {
- $data[$key]['add_time'] = date('Y-m-d H:i', $value['add_time']);
- $data[$key]['check_time'] = date('Y-m-d H:i', $value['check_time']);
- $data[$key]['status_text'] = $status_text[$value['status']-1];
- $data[$key]['operation_text'] = $operation_text[$value['is_operation']-1];
- $data[$key]['add_type_text'] = $add_type_text[$value['add_type']-1];
- $data[$key]['is_bank_text'] = $is_bank_text[$value['is_bank']];
- }
- return $data;
- }
- private function GetExportData($condition): array
- {
- $i = 0;
- $result = [];
- while (true) {
- $start = $i * 1000;
- $list = Model('')->table('refill_evidence,member')->join('inner')->on('member.member_id=refill_evidence.member_id')
- ->field('refill_evidence.*,member.available_predeposit')->where($condition)->limit("{$start},1000")->master(true)->select();
- if (empty($list)) {
- break;
- }
- $i++;
- foreach ($list as $value) {
- $result[] = $value;
- }
- }
- return $result;
- }
- }
|