123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- <?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;
- }
- 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];
- }
- $merchant_list = $this->merchants();
- //充值申请列表
- 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, $merchant_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'] == merchantModel::status_applying) {
- $send_amount += $count['amounts'];
- }elseif ($count['status'] == merchantModel::status_passed) {
- $success_amount += $count['amounts'];
- if($count['add_type'] == merchantModel::type_mch_deposit) {
- $mch_amount += $count['amounts'];
- }elseif ($count['add_type'] == merchantModel::type_adm_deposit) {
- $system_amount += $count['amounts'];
- }elseif ($count['add_type'] == merchantModel::type_adm_adjust) {
- $system_edit_amount += $count['amounts'];
- }
- }elseif ($count['status'] == merchantModel::status_denied) {
- $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));
- return;
- }
- global $config;
- $receive_bank_text = $config['receive_bank'][COMPANY_NAME];
- 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, $merchant_list)
- {
- $status_text = [merchantModel::status_applying =>'申请中', merchantModel::status_passed => '已通过', merchantModel::status_denied => '已驳回'];
- $operation_text = [merchantModel::oper_undeposited => '未预存', merchantModel::oper_deposited => '已预存'];
- $add_type_text = self::ADD_TYPE_TEXT;
- $is_bank_text = ['否','是'];
- $merchants = [];
- foreach ($merchant_list as $value) {
- $merchants[$value['mchid']] = $value;
- }
- foreach ($data as $key => $value) {
- $data[$key]['add_time'] = date('Y-m-d H:i', $value['add_time']);
- $data[$key]['check_time'] = !empty($value['check_time']) ? date('Y-m-d H:i', $value['check_time']) : '/';
- $data[$key]['status_text'] = $status_text[$value['status']];
- $data[$key]['operation_text'] = $operation_text[$value['is_operation']];
- $data[$key]['add_type_text'] = $add_type_text[$value['add_type']];
- $data[$key]['is_bank_text'] = $is_bank_text[$value['is_bank']];
- $data[$key]['company_name'] = $merchants[$value['mchid']]['company_name'] ?? $merchants[$value['mchid']]['name'];
- }
- 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;
- }
- public function refill_evidence_editOp()
- {
- $apply_id = $_GET['apply_id'] ?? $_POST['apply_id'];
- $model_merchant = Model('merchant');
- if(chksubmit())
- {
- $data = [];
- if(!empty($_POST['bz'])) {
- $data['bz'] = $_POST['bz'];
- }
- if(!empty($_POST['add_type'])) {
- $data['add_type'] = $_POST['add_type'];
- }
- if (empty($data)) {
- showMessage('编辑成功', 'index.php?act=refill_evidence&op=index');
- }
- $resp = $model_merchant->editRefillEvidence(['apply_id' => $apply_id], $data);
- if ($resp) {
- showMessage('编辑成功', 'index.php?act=refill_evidence&op=index');
- } else {
- showMessage('编辑失败', "index.php?act=refill_evidence&op=refill_evidence_edit&apply_id={$apply_id}");
- }
- }
- else
- {
- $merchant_list = $this->merchants();
- $evidence_info = $model_merchant->getRefillEvidence(['apply_id' => $apply_id], 20, 'refill_evidence.*', 'refill_evidence.add_time desc', '', true);
- $evidence_info = $this->formatData($evidence_info, $merchant_list);
- if (empty($evidence_info)) {
- showMessage('充值申请不存在', 'index.php?act=refill_evidence&op=index');
- }
- Tpl::output('evidence_info', $evidence_info[0]);
- Tpl::showpage('refill.evidence.edit');
- }
- }
- }
|