|
@@ -458,74 +458,6 @@ class merchantControl extends SystemControl
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 充值申请列表
|
|
|
- */
|
|
|
- public function refill_evidenceOp()
|
|
|
- {
|
|
|
- $model_merchant = Model('merchant');
|
|
|
- $condition = [];
|
|
|
- if (trim($_GET['mch_name']) != '') {
|
|
|
- $condition['mch_name'] = ['like', '%' . $_GET['mch_name'] . '%'];
|
|
|
- Tpl::output('mch_name', $_GET['mch_name']);
|
|
|
- }
|
|
|
- $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 {
|
|
|
- }
|
|
|
-
|
|
|
- $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];
|
|
|
- }
|
|
|
-
|
|
|
- //充值申请列表
|
|
|
- $evidence_list = $model_merchant->getRefillEvidence($condition, 20, '*,member.available_predeposit', 'refill_evidence.add_time desc');
|
|
|
- $status_text = ['申请中', '已通过', '已驳回'];
|
|
|
- $operation_text = ['未预存', '已预存'];
|
|
|
- $add_type_text = ['商户预存','后台手动预存'];
|
|
|
-
|
|
|
- $counts = Model('')->table('refill_evidence')
|
|
|
- ->field('sum(amount) as amounts,status')
|
|
|
- ->where($condition)
|
|
|
- ->group('status')
|
|
|
- ->select();
|
|
|
- $success_amount = $send_amount = $cancel_amount = 0;
|
|
|
- foreach ($counts as $count) {
|
|
|
- if($count['status'] == 1) {
|
|
|
- $send_amount += $count['amounts'];
|
|
|
- }elseif ($count['status'] == 2) {
|
|
|
- $success_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;
|
|
|
- Tpl::output('stats', $stats);
|
|
|
- Tpl::output('evidence_list', $evidence_list);
|
|
|
- Tpl::output('status_text', $status_text);
|
|
|
- Tpl::output('operation_text', $operation_text);
|
|
|
- Tpl::output('add_type_text', $add_type_text);
|
|
|
- Tpl::output('page', $model_merchant->showpage('2'));
|
|
|
- Tpl::showpage('merchant.refill.evidence_list');
|
|
|
- }
|
|
|
-
|
|
|
public function check_evidenceOp()
|
|
|
{
|
|
|
$status = $_GET['status'];
|
|
@@ -545,7 +477,7 @@ class merchantControl extends SystemControl
|
|
|
|
|
|
}
|
|
|
}
|
|
|
- showMessage(L('nc_common_save_succ'), urlAdmin('merchant', 'refill_evidence'));
|
|
|
+ showMessage(L('nc_common_save_succ'), urlAdmin('refill_evidence', 'index'));
|
|
|
}
|
|
|
|
|
|
public function rechargeOp()
|
|
@@ -561,7 +493,7 @@ class merchantControl extends SystemControl
|
|
|
$caches[$mchid] = ['last_time' => 0, 'send_count' => 0];
|
|
|
wcache("merchant-notify", ['data' => serialize($caches)], 'refill-');
|
|
|
}
|
|
|
- showMessage('操作成功', 'index.php?act=merchant&op=refill_evidence');
|
|
|
+ showMessage('操作成功', 'index.php?act=refill_evidence&op=index');
|
|
|
} else {
|
|
|
$apply_id = $_GET['apply_id'];
|
|
|
if (!empty($apply_id)) {
|
|
@@ -647,10 +579,10 @@ class merchantControl extends SystemControl
|
|
|
$caches[$mchid] = ['last_time' => 0, 'send_count' => 0];
|
|
|
wcache("merchant-notify", ['data' => serialize($caches)], 'refill-');
|
|
|
}
|
|
|
- showMessage('操作成功', 'index.php?act=merchant&op=refill_evidence');
|
|
|
+ showMessage('操作成功', 'index.php?act=refill_evidence&op=index');
|
|
|
} catch (Exception $e) {
|
|
|
$trans->rollback();
|
|
|
- showMessage('操作失败', 'index.php?act=merchant&op=refill_evidence');
|
|
|
+ showMessage('操作失败', 'index.php?act=refill_evidence&op=index');
|
|
|
}
|
|
|
} else {
|
|
|
$page = "recharge.manual.{$type}";
|
|
@@ -742,7 +674,7 @@ class merchantControl extends SystemControl
|
|
|
$log_msg = "管理员【" . $admininfo['name'] . "】操作会员【" . $member_info['member_name'] . "】预存款【减少】,金额为" . $money . ",编号为" . $order_sn;
|
|
|
break;
|
|
|
default:
|
|
|
- showMessage('操作失败', 'index.php?act=merchant&op=refill_evidence');
|
|
|
+ showMessage('操作失败', 'index.php?act=refill_evidence&op=index');
|
|
|
break;
|
|
|
}
|
|
|
try {
|
|
@@ -768,7 +700,7 @@ class merchantControl extends SystemControl
|
|
|
} catch (Exception $e) {
|
|
|
$trans->rollback();
|
|
|
$this->log($log_msg, 0);
|
|
|
- showMessage($e->getMessage(), 'index.php?act=merchant&op=refill_evidence', 'html', 'error');
|
|
|
+ showMessage($e->getMessage(), 'index.php?act=refill_evidence&op=index', 'html', 'error');
|
|
|
exit;
|
|
|
}
|
|
|
}
|
|
@@ -800,7 +732,7 @@ class merchantControl extends SystemControl
|
|
|
QueueClient::push("QueryRefillState", ['order_id' => $order_id]);
|
|
|
}
|
|
|
}
|
|
|
- showMessage('操作成功', 'index.php?act=merchant&op=refill_order');
|
|
|
+ showMessage('操作成功', 'index.php?act=refill_order&op=index');
|
|
|
}
|
|
|
|
|
|
public function mch_notifyOp()
|
|
@@ -820,207 +752,9 @@ class merchantControl extends SystemControl
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- showMessage('操作成功', 'index.php?act=merchant&op=refill_order');
|
|
|
- }
|
|
|
-
|
|
|
- public function refill_orderOp()
|
|
|
- {
|
|
|
- $fShowStat = $_GET['fShowStat'];
|
|
|
- $this->refill_order($fShowStat==1);
|
|
|
- }
|
|
|
-
|
|
|
- public function refill_order($fShowStat = false)
|
|
|
- {
|
|
|
- $model_refill_order = Model('refill_order');
|
|
|
- $condition['inner_status'] = 0;
|
|
|
-
|
|
|
- $fSingle = false;
|
|
|
- if (!empty($_GET['order_sn'])) {
|
|
|
- $condition['refill_order.order_sn'] = $_GET['order_sn'];
|
|
|
- $fSingle = true;
|
|
|
- }
|
|
|
- if (!empty($_GET['mch_order'])) {
|
|
|
- $condition['refill_order.mch_order'] = $_GET['mch_order'];
|
|
|
- $fSingle = true;
|
|
|
- }
|
|
|
- if (!empty($_GET['ch_trade_no'])) {
|
|
|
- $condition['refill_order.ch_trade_no'] = $_GET['ch_trade_no'];
|
|
|
- $fSingle = true;
|
|
|
- }
|
|
|
- if (!empty($_GET['card_no'])) {
|
|
|
- $condition['refill_order.card_no'] = $_GET['card_no'];
|
|
|
- $fSingle = true;
|
|
|
- }
|
|
|
-
|
|
|
- if (!empty($_GET['mchid'])) {
|
|
|
- $condition['refill_order.mchid'] = $_GET['mchid'];
|
|
|
- }
|
|
|
- if (!empty($_GET['channel_name'])) {
|
|
|
- $condition['refill_order.channel_name'] = $_GET['channel_name'];
|
|
|
- }
|
|
|
- if (!empty($_GET['store_id'])) {
|
|
|
- $condition['vr_order.store_id'] = $_GET['store_id'];
|
|
|
- }
|
|
|
- if (!empty($_GET['refill_amount'])) {
|
|
|
- $condition['refill_order.refill_amount'] = $_GET['refill_amount'];
|
|
|
- }
|
|
|
- if (!empty($_GET['quality'])) {
|
|
|
- $condition['refill_order.quality'] = $_GET['quality'];
|
|
|
- }
|
|
|
-
|
|
|
- if (!empty($_GET['card_type'])) {
|
|
|
- if (in_array($_GET['card_type'], ['1', '2', '4', '5', '6'])) {
|
|
|
- $condition['refill_order.card_type'] = intval($_GET['card_type']);
|
|
|
- }
|
|
|
- if ($_GET['card_type'] == 'oil') {
|
|
|
- $condition['refill_order.card_type'] = ['in', [1, 2]];
|
|
|
- }
|
|
|
- if ($_GET['card_type'] == 'phone') {
|
|
|
- $condition['refill_order.card_type'] = ['in', [4, 5, 6]];
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- $fToday = false;
|
|
|
- if (!$fSingle)
|
|
|
- {
|
|
|
- $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['refill_order.order_time'] = [['egt', $start_unixtime], ['lt', $end_unixtime], 'and'];
|
|
|
- } elseif ($start_unixtime > 0) {
|
|
|
- $condition['refill_order.order_time'] = ['egt', $start_unixtime];
|
|
|
- } elseif ($end_unixtime > 0) {
|
|
|
- $condition['refill_order.order_time'] = ['lt', $end_unixtime];
|
|
|
- } else {
|
|
|
- $start = strtotime(date('Y-m-d', time()));
|
|
|
- $condition['refill_order.order_time'] = ['egt', $start];
|
|
|
- $fToday = true;
|
|
|
- }
|
|
|
-
|
|
|
- if (in_array($_GET['order_state'], ['0', '10', '20', '30', '40'])) {
|
|
|
- $condition['vr_order.order_state'] = $_GET['order_state'];
|
|
|
- if ($_GET['order_state'] == ORDER_STATE_SEND) {
|
|
|
- if ($_GET['time'] == 1) {
|
|
|
- $condition['refill_order.order_time'] = ['between', [(time() - 3600), (time() - 1800)]];
|
|
|
- }
|
|
|
- if ($_GET['time'] == 2) {
|
|
|
- $condition['refill_order.order_time'] = ['lt', (time() - 3600)];
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if(!empty($_GET['export'])) {
|
|
|
- $this->RefillOrderExport($condition);
|
|
|
- }
|
|
|
- $merchants = [];
|
|
|
- $merchant_list = Model('')->table('merchant')->limit(1000)->select();
|
|
|
- foreach ($merchant_list as $key => $value) {
|
|
|
- $merchants[$value['mchid']] = $value;
|
|
|
- }
|
|
|
- $order_list = $model_refill_order->getMerchantOrderList($condition, 50, 'refill_order.*,vr_order.order_state', 'refill_order.order_time desc');
|
|
|
-
|
|
|
- foreach ($order_list as $order_id => $order_info) {
|
|
|
- $order_list[$order_id]['card_type_text'] = $this->scard_type($order_info['card_type']);
|
|
|
- $order_list[$order_id]['mch_name'] = $merchants[$order_info['mchid']]['company_name'];
|
|
|
- if ($order_info['notify_time'] > 0) {
|
|
|
- $diff_time = $order_info['notify_time'] - $order_info['order_time'];
|
|
|
- } else {
|
|
|
- $diff_time = time() - $order_info['order_time'];
|
|
|
- }
|
|
|
- $order_list[$order_id]['diff_time_text'] = $this->elapse_time($diff_time);
|
|
|
- $order_list[$order_id]['diff_time'] = $diff_time;
|
|
|
- $order_list[$order_id]['quality_text'] = $this->quality_format($order_info['quality']);
|
|
|
- $order_list[$order_id]['org_quality_text'] = $this->quality_format($order_info['org_quality']);
|
|
|
- }
|
|
|
-
|
|
|
- $provider_list = Model('')->table('refill_provider,store')
|
|
|
- ->field('refill_provider.*,store.store_name')
|
|
|
- ->join('inner')
|
|
|
- ->on('store.store_id=refill_provider.store_id')
|
|
|
- ->order('opened asc, provider_id desc')
|
|
|
- ->limit(1000)
|
|
|
- ->select();
|
|
|
-
|
|
|
- if ($fShowStat) {
|
|
|
- $stat = $this->all_order_state_stat($condition);
|
|
|
- Tpl::output('stat', $stat);
|
|
|
- }
|
|
|
-
|
|
|
- Tpl::output('ftoday', $fToday);
|
|
|
- Tpl::output('order_list', $order_list);
|
|
|
- Tpl::output('provider_list', $provider_list);
|
|
|
- Tpl::output('merchant_list', $merchant_list);
|
|
|
- Tpl::output('show_page', $model_refill_order->showpage());
|
|
|
- Tpl::showpage('refill.order.index');
|
|
|
+ showMessage('操作成功', 'index.php?act=refill_order&op=index');
|
|
|
}
|
|
|
|
|
|
- private function RefillOrderExport($condition)
|
|
|
- {
|
|
|
- $i = 0;
|
|
|
- $result = [];
|
|
|
- while (true)
|
|
|
- {
|
|
|
- $start = $i * 1000;
|
|
|
- $order_list = Model('')->table('refill_order,vr_order')->field('refill_order.*,vr_order.order_state')
|
|
|
- ->where($condition)->join('inner')->on('refill_order.order_id=vr_order.order_id')->order('refill_order.order_time desc')->limit("{$start},1000")->select();
|
|
|
- if(empty($order_list)) {
|
|
|
- break;
|
|
|
- }
|
|
|
- $i++;
|
|
|
- foreach ($order_list as $order) {
|
|
|
- $result[] = $order;
|
|
|
- }
|
|
|
- }
|
|
|
- $this->createExcel($result);
|
|
|
- }
|
|
|
-
|
|
|
- private function createExcel($data = array()){
|
|
|
- Language::read('export');
|
|
|
- import('libraries.excel');
|
|
|
- $excel_obj = new Excel();
|
|
|
- $excel_data = array();
|
|
|
- //设置样式
|
|
|
- $excel_obj->setStyle(array('id'=>'s_title','Font'=>array('FontName'=>'宋体','Size'=>'12','Bold'=>'1')));
|
|
|
- //header
|
|
|
- $excel_data[0][] = array('styleid'=>'s_title','data'=> '商户号');
|
|
|
- $excel_data[0][] = array('styleid'=>'s_title','data'=> '客户订单号');
|
|
|
- $excel_data[0][] = array('styleid'=>'s_title','data'=> '平台单号');
|
|
|
- $excel_data[0][] = array('styleid'=>'s_title','data'=> '面额');
|
|
|
- $excel_data[0][] = array('styleid'=>'s_title','data'=> '充值卡号');
|
|
|
- $excel_data[0][] = array('styleid'=>'s_title','data'=> '充值卡类型');
|
|
|
- $excel_data[0][] = array('styleid'=>'s_title','data'=> '下单日期');
|
|
|
- $excel_data[0][] = array('styleid'=>'s_title','data'=> '完成日期');
|
|
|
- $excel_data[0][] = array('styleid'=>'s_title','data'=> '官方流水号');
|
|
|
- $excel_data[0][] = array('styleid'=>'s_title','data'=> '订单状态');
|
|
|
- $excel_data[0][] = array('styleid'=>'s_title','data'=> '扣款金额');
|
|
|
- //data
|
|
|
- foreach ((array)$data as $k=>$v){
|
|
|
- $tmp = array();
|
|
|
- $tmp[] = array('data'=>$v['mchid']);
|
|
|
- $tmp[] = array('data'=>$v['mch_order']);
|
|
|
- $tmp[] = array('data'=>$v['order_sn']);
|
|
|
- $tmp[] = array('data'=>$v['refill_amount']);
|
|
|
- $tmp[] = array('data'=>$v['card_no']);
|
|
|
- $tmp[] = array('data'=>$this->scard_type($v['card_type']));
|
|
|
- $tmp[] = array('data'=>date('Y-m-d H:i:s',$v['order_time']));
|
|
|
- if(empty($v['notify_time'])) {
|
|
|
- $tmp[] = array('data'=>'');
|
|
|
- }else{
|
|
|
- $tmp[] = array('data'=>date('Y-m-d H:i:s',$v['notify_time']));
|
|
|
- }
|
|
|
-
|
|
|
- $tmp[] = array('data'=>$v['official_sn']);
|
|
|
- $tmp[] = array('data'=>orderState($v));
|
|
|
- $tmp[] = array('data'=>$v['mch_amount']);
|
|
|
- $excel_data[] = $tmp;
|
|
|
- }
|
|
|
- $excel_data = $excel_obj->charset($excel_data,CHARSET);
|
|
|
- $excel_obj->addArray($excel_data);
|
|
|
- $excel_obj->addWorksheet($excel_obj->charset(L('exp_od_order'),CHARSET));
|
|
|
- $excel_obj->generateXML($excel_obj->charset(L('exp_od_order'),CHARSET).date('Y-m-d-H',time()));
|
|
|
- exit;
|
|
|
- }
|
|
|
|
|
|
public function notify_merchantOp()
|
|
|
{
|
|
@@ -1044,7 +778,7 @@ class merchantControl extends SystemControl
|
|
|
$order_info = $mod_order->getOrderInfo(['order_id' => $order_id]);
|
|
|
|
|
|
if ((time() - $order_info['order_time']) < 3600) {
|
|
|
- showMessage('订单时间未超过1小时', 'index.php?act=merchant&op=refill_order');
|
|
|
+ showMessage('订单时间未超过1小时', 'index.php?act=refill_order&op=index');
|
|
|
}
|
|
|
|
|
|
if ($type == 'success') {
|
|
@@ -1052,7 +786,7 @@ class merchantControl extends SystemControl
|
|
|
} elseif ($type == 'cancel') {
|
|
|
refill\util::manual_cancel($order_id);
|
|
|
} else {
|
|
|
- showMessage('手动操作类型错误', 'index.php?act=merchant&op=refill_order');
|
|
|
+ showMessage('手动操作类型错误', 'index.php?act=refill_order&op=index');
|
|
|
}
|
|
|
|
|
|
showMessage('操作成功', '');
|
|
@@ -1072,40 +806,6 @@ class merchantControl extends SystemControl
|
|
|
Tpl::showpage('provider.stats');
|
|
|
}
|
|
|
|
|
|
- public function providerOp()
|
|
|
- {
|
|
|
- $this->sync_cfgs();
|
|
|
- $provider_model = Model('refill_provider');
|
|
|
- $condition = [];
|
|
|
- if (trim($_GET['name']) != '') {
|
|
|
- $condition['name'] = ['like', '%' . $_GET['name'] . '%'];
|
|
|
- Tpl::output('name', $_GET['name']);
|
|
|
- }
|
|
|
- if (in_array($_GET['type'], [1, 2])) {
|
|
|
- $condition['type'] = $_GET['type'];
|
|
|
- }
|
|
|
- $store_list = Model('store')->getStoreList(['store_id' => ['gt',0]], '', '', 'store_id,store_name');
|
|
|
- foreach ($store_list as $store) {
|
|
|
- $stores[$store['store_id']] = $store['store_name'];
|
|
|
- }
|
|
|
- $provider_list = $provider_model->getProviderList($condition, 100);
|
|
|
- foreach ($provider_list as $key => $provider) {
|
|
|
- if (!empty($provider['start_period']) && !empty($provider['end_period'])) {
|
|
|
- $provider_list[$key]['period'] = $provider['start_period'] . '~' . $provider['end_period'];
|
|
|
- } else {
|
|
|
- $provider_list[$key]['period'] = '全时间段';
|
|
|
- }
|
|
|
- $provider_list[$key]['store_name'] = $stores[$provider['store_id']];
|
|
|
- }
|
|
|
- $opened_text = ['使用中', '已禁用'];
|
|
|
- $type_text = ['油卡', '手机充值卡', '三方增值业务'];
|
|
|
- Tpl::output('opened_text', $opened_text);
|
|
|
- Tpl::output('type_text', $type_text);
|
|
|
- Tpl::output('provider_list', $provider_list);
|
|
|
- Tpl::output('show_page', $provider_model->showpage());
|
|
|
- Tpl::showpage('provider.index');
|
|
|
- }
|
|
|
-
|
|
|
public function provider_provinceOp()
|
|
|
{
|
|
|
$provider_model = Model('refill_provider');
|
|
@@ -1128,7 +828,7 @@ class merchantControl extends SystemControl
|
|
|
}
|
|
|
$resp = $provider_model->editProvider(['provinces' => serialize($updata)], ['provider_id' => $provider_id]);
|
|
|
if ($resp) {
|
|
|
- showMessage('编辑成功', 'index.php?act=merchant&op=provider');
|
|
|
+ showMessage('编辑成功', 'index.php?act=provider&op=index');
|
|
|
} else {
|
|
|
showMessage('编辑失败', "index.php?act=merchant&op=provider_province&id={$provider_id}");
|
|
|
}
|
|
@@ -1152,80 +852,6 @@ class merchantControl extends SystemControl
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public function sync_cfgs()
|
|
|
- {
|
|
|
- $name_val = function ($items) {
|
|
|
- $result = [];
|
|
|
- foreach ($items as $item) {
|
|
|
- $name = $item['name'];
|
|
|
- $result[$name] = $item;
|
|
|
- }
|
|
|
- return $result;
|
|
|
- };
|
|
|
-
|
|
|
- $match = function ($all, $cur) {
|
|
|
- $inserts = $updates = [];
|
|
|
- foreach ($all as $key => $value) {
|
|
|
- if (!array_key_exists($key, $cur)) {
|
|
|
- $insert['name'] = $key;
|
|
|
- $insert['store_id'] = $value['cfg']['store_id'];
|
|
|
- $insert['qualitys'] = $value['cfg']['qualitys'];
|
|
|
- $inserts[] = $insert;
|
|
|
- } elseif ($value['cfg']['qualitys'] != $cur[$key]['qualitys']) {
|
|
|
- $update['provider_id'] = $cur[$key]['provider_id'];
|
|
|
- $update['qualitys'] = $value['cfg']['qualitys'];
|
|
|
- $updates[] = $update;
|
|
|
- }
|
|
|
- }
|
|
|
- return [$inserts, $updates];
|
|
|
- };
|
|
|
-
|
|
|
- $updater = function ($mod, $updates) {
|
|
|
- if (empty($updates)) return;
|
|
|
- foreach ($updates as $update) {
|
|
|
- $provider_id = $update['provider_id'];
|
|
|
-
|
|
|
- $data = ['qualitys' => $update['qualitys']];
|
|
|
- $mod->editProvider($data, ['provider_id' => $provider_id]);
|
|
|
- }
|
|
|
- };
|
|
|
- $inserter = function ($mod, $type, $names) {
|
|
|
- foreach ($names as $name) {
|
|
|
- $data = ['name' => $name['name'], 'type' => $type, 'store_id' => $name['store_id'], 'qualitys' => $name['qualitys'], 'opened' => 2];
|
|
|
- $mod->insert($data);
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- global $config;
|
|
|
- $oil_configs = $config['oil_providers'];
|
|
|
- $pho_configs = $config['phone_providers'];
|
|
|
- $third_configs = $config['third_providers'];
|
|
|
- $oils = $name_val($oil_configs);
|
|
|
- $phones = $name_val($pho_configs);
|
|
|
- $third = $name_val($third_configs);
|
|
|
-
|
|
|
- $mod_prov = Model('refill_provider');
|
|
|
-
|
|
|
- $oil_items = $mod_prov->getProviderList(['type' => 1]);
|
|
|
- $oil_items = $name_val($oil_items);
|
|
|
- [$oil_inserts, $oil_updates] = $match($oils, $oil_items);
|
|
|
-
|
|
|
- $phone_items = $mod_prov->getProviderList(['type' => 2]);
|
|
|
- $phone_items = $name_val($phone_items);
|
|
|
- [$phone_inserts, $phone_updates] = $match($phones, $phone_items);
|
|
|
-
|
|
|
- $third_items = $mod_prov->getProviderList(['type' => 3]);
|
|
|
- $third_items = $name_val($third_items);
|
|
|
- [$third_inserts, $third_updates] = $match($third, $third_items);
|
|
|
-
|
|
|
- $inserter($mod_prov, 1, $oil_inserts);
|
|
|
- $inserter($mod_prov, 2, $phone_inserts);
|
|
|
- $inserter($mod_prov, 3, $third_inserts);
|
|
|
- $updater($mod_prov, $oil_updates);
|
|
|
- $updater($mod_prov, $phone_updates);
|
|
|
- $updater($mod_prov, $third_updates);
|
|
|
- }
|
|
|
-
|
|
|
public function changeProviderStateOp()
|
|
|
{
|
|
|
$provider_id = intval($_GET['id']);
|
|
@@ -1233,13 +859,13 @@ class merchantControl extends SystemControl
|
|
|
$provider_model = Model('refill_provider');
|
|
|
$provider_info = $provider_model->getProviderInfo(['provider_id' => $provider_id]);
|
|
|
if (empty($provider_info) || !in_array($state, [1, 2])) {
|
|
|
- showMessage('操作成功', 'index.php?act=merchant&op=provider');
|
|
|
+ showMessage('操作成功', 'index.php?act=provider&op=index');
|
|
|
}
|
|
|
$resp = $provider_model->editProvider(['opened' => $state], ['provider_id' => $provider_id]);
|
|
|
if (!$resp) {
|
|
|
- showMessage('操作失败', 'index.php?act=merchant&op=provider', 'html', 'error');
|
|
|
+ showMessage('操作失败', 'index.php?act=provider&op=index', 'html', 'error');
|
|
|
}
|
|
|
- showMessage('操作成功', 'index.php?act=merchant&op=provider');
|
|
|
+ showMessage('操作成功', 'index.php?act=provider&op=index');
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1255,7 +881,7 @@ class merchantControl extends SystemControl
|
|
|
if ($result) {
|
|
|
$url = [
|
|
|
[
|
|
|
- 'url' => 'index.php?act=merchant&op=provider',
|
|
|
+ 'url' => 'index.php?act=provider&op=index',
|
|
|
'msg' => '返回通道列表',
|
|
|
],
|
|
|
[
|
|
@@ -1284,12 +910,12 @@ class merchantControl extends SystemControl
|
|
|
$params = $_POST;
|
|
|
unset($params['form_submit']);
|
|
|
if (empty($params)) {
|
|
|
- showMessage('通道编辑成功', 'index.php?act=merchant&op=provider');
|
|
|
+ showMessage('通道编辑成功', 'index.php?act=provider&op=index');
|
|
|
}
|
|
|
$result = $provider_model->editProvider($params, ['provider_id' => $provider_id]);
|
|
|
if ($result) {
|
|
|
$this->log('编辑通道:' . '[ ' . $provider['name'] . ']', 1);
|
|
|
- showMessage('通道编辑成功', 'index.php?act=merchant&op=provider');
|
|
|
+ showMessage('通道编辑成功', 'index.php?act=provider&op=index');
|
|
|
} else {
|
|
|
showMessage('通道编辑失败', "index.php?act=merchant&op=provider_edit&id={$provider_id}");
|
|
|
}
|
|
@@ -1316,9 +942,9 @@ class merchantControl extends SystemControl
|
|
|
$result = $provider_model->delProvider(['provider_id' => $provider_id]);
|
|
|
if ($result) {
|
|
|
$this->log('删除通道:' . '[ ' . $provider['name'] . ']', 1);
|
|
|
- showMessage('通道删除成功', 'index.php?act=merchant&op=provider');
|
|
|
+ showMessage('通道删除成功', 'index.php?act=provider&op=index');
|
|
|
} else {
|
|
|
- showMessage('通道删除失败', "index.php?act=merchant&op=provider");
|
|
|
+ showMessage('通道删除失败', "index.php?act=provider&op=index");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1354,7 +980,7 @@ class merchantControl extends SystemControl
|
|
|
$result[$index][] = $data;
|
|
|
}
|
|
|
wcache($rkey, ['data' => serialize($result)], 'provider-');
|
|
|
- showMessage('编辑成功', 'index.php?act=merchant&op=provider');
|
|
|
+ showMessage('编辑成功', 'index.php?act=provider&op=index');
|
|
|
} else {
|
|
|
$speed_limit = rcache($rkey, 'provider-');
|
|
|
if (empty($speed_limit)) {
|
|
@@ -1380,7 +1006,7 @@ class merchantControl extends SystemControl
|
|
|
->order('opened asc , provider_id desc')
|
|
|
->select();
|
|
|
if (empty($providers)) {
|
|
|
- showMessage('暂无相关通道', 'index.php?act=merchant&op=provider');
|
|
|
+ showMessage('暂无相关通道', 'index.php?act=provider&op=index');
|
|
|
}
|
|
|
$formData = $this->formData($type, $form);
|
|
|
|
|
@@ -1424,7 +1050,7 @@ class merchantControl extends SystemControl
|
|
|
$datas[$pid] = $result;
|
|
|
}
|
|
|
if (empty($datas)) {
|
|
|
- showMessage('暂无相关通道配置', 'index.php?act=merchant&op=provider');
|
|
|
+ showMessage('暂无相关通道配置', 'index.php?act=provider&op=index');
|
|
|
}
|
|
|
Tpl::output('form', $formData);
|
|
|
Tpl::output('datas', $datas);
|
|
@@ -1440,7 +1066,7 @@ class merchantControl extends SystemControl
|
|
|
} elseif ($type == 2) {
|
|
|
$rkey = "channel-ctl-phone-{$form}-limit";
|
|
|
} else {
|
|
|
- showMessage('类型有误', "index.php?act=merchant&op=provider");
|
|
|
+ showMessage('类型有误', "index.php?act=provider&op=index");
|
|
|
}
|
|
|
Log::record($rkey, Log::DEBUG);
|
|
|
return $rkey;
|
|
@@ -1546,195 +1172,6 @@ class merchantControl extends SystemControl
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
- private function refill_stat($condition, $times)
|
|
|
- {
|
|
|
- $stat_order = function ($condition) {
|
|
|
- $stat = Model('')->table('refill_order,vr_order')->join('inner')
|
|
|
- ->on('refill_order.order_id=vr_order.order_id')
|
|
|
- ->field('count(*) as order_count ')
|
|
|
- ->where($condition)->find();
|
|
|
-
|
|
|
- return $stat['order_count'];
|
|
|
- };
|
|
|
- $result = [];
|
|
|
- $condition['order_state'] = ORDER_STATE_SEND;
|
|
|
- foreach ($times as $time) {
|
|
|
- $condition['refill_order.order_time'] = $time;
|
|
|
- $result[] = $stat_order($condition);
|
|
|
- }
|
|
|
- return $result;
|
|
|
- }
|
|
|
-
|
|
|
- private function all_order_state_stat($condition)
|
|
|
- {
|
|
|
- $counts = Model('')->table('refill_order,vr_order')->join('inner')
|
|
|
- ->on('refill_order.order_id=vr_order.order_id')
|
|
|
- ->field('count(*) as order_count, sum(refill_amount) as refill_amounts, sum(channel_amount) as channel_amounts, sum(mch_amount) as mch_amounts, order_state')
|
|
|
- ->where($condition)
|
|
|
- ->group('order_state')
|
|
|
- ->select();
|
|
|
-
|
|
|
- $all = [];
|
|
|
- $data['order_count'] = $data['refill_amounts'] = $data['channel_amounts'] = $data['mch_amounts'] = 0;
|
|
|
- $sending = $success = $cancel = $data;
|
|
|
- foreach ($counts as $count) {
|
|
|
- if ($count['order_state'] == ORDER_STATE_SEND) {
|
|
|
- $sending = $count;
|
|
|
- } elseif ($count['order_state'] == ORDER_STATE_SUCCESS) {
|
|
|
- $success = $count;
|
|
|
- } elseif ($count['order_state'] == ORDER_STATE_CANCEL) {
|
|
|
- $cancel = $count;
|
|
|
- }
|
|
|
-
|
|
|
- $all['order_count'] += $count['order_count'];
|
|
|
- $all['refill_amounts'] += ncPriceFormat($count['refill_amounts']);
|
|
|
- $all['channel_amounts'] += ncPriceFormat($count['channel_amounts']);
|
|
|
- $all['mch_amounts'] += ncPriceFormat($count['mch_amounts']);
|
|
|
- }
|
|
|
-
|
|
|
- return ['all' => $all, 'sending' => $sending, 'success' => $success, 'cancel' => $cancel];
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- public function OrderSendListOp()
|
|
|
- {
|
|
|
- $model_refill_order = Model('refill_order');
|
|
|
- $condition['refill_order.inner_status'] = 0;
|
|
|
- $condition['vr_order.order_state'] = ORDER_STATE_SEND;
|
|
|
-
|
|
|
- $condition['refill_order.order_time'] = ['lt', (time() - 1800)];
|
|
|
- if (!empty($_GET['mchid'])) {
|
|
|
- $condition['refill_order.mchid'] = $_GET['mchid'];
|
|
|
- }
|
|
|
- if (!empty($_GET['store_id'])) {
|
|
|
- $condition['vr_order.store_id'] = $_GET['store_id'];
|
|
|
- }
|
|
|
- $time_cond = [
|
|
|
- ['between', [(time() - 3600), (time() - 1800)]],
|
|
|
- ['lt', (time() - 3600)]];
|
|
|
- if ($_GET['time'] == 1) {
|
|
|
- $condition['refill_order.order_time'] = ['between', [(time() - 3600), (time() - 1800)]];
|
|
|
- }
|
|
|
- if ($_GET['time'] == 2) {
|
|
|
- $condition['refill_order.order_time'] = ['lt', (time() - 3600)];
|
|
|
- }
|
|
|
- $time_out_order = function($time_out, $condition){
|
|
|
- $mchids = Model('')->table('merchant')->where(['time_out' => ['elt', $time_out]])->field('mchid')->select();
|
|
|
- $mchids = array_column($mchids, 'mchid');
|
|
|
- $mchids = implode(',', $mchids);
|
|
|
-
|
|
|
- $condition['refill_order.order_time'] = ['lt', (time() - $time_out)];
|
|
|
- $condition['refill_order.mchid'] = ['in',$mchids];
|
|
|
- return $condition;
|
|
|
- };
|
|
|
- if ($_GET['time'] == 3) {
|
|
|
- $condition = $time_out_order(300, $condition);
|
|
|
- $time_cond[] = ['lt', (time() - 300)];
|
|
|
- }
|
|
|
- if ($_GET['time'] == 4) {
|
|
|
- $condition = $time_out_order(900, $condition);
|
|
|
- $time_cond[] = ['lt', (time() - 900)];
|
|
|
- }
|
|
|
- if (!empty($_GET['card_type'])) {
|
|
|
- if (in_array($_GET['card_type'], ['1', '2', '4', '5', '6'])) {
|
|
|
- $condition['refill_order.card_type'] = $_GET['card_type'];
|
|
|
- }
|
|
|
- if ($_GET['card_type'] == 'oil') {
|
|
|
- $condition['refill_order.card_type'] = ['in', ['1', '2']];
|
|
|
- }
|
|
|
- if ($_GET['card_type'] == 'phone') {
|
|
|
- $condition['refill_order.card_type'] = ['in', ['4', '5', '6']];
|
|
|
- }
|
|
|
- }
|
|
|
- if (!empty($_GET['quality'])) {
|
|
|
- $condition['refill_order.quality'] = $_GET['quality'];
|
|
|
- }
|
|
|
-
|
|
|
- $order_list = $model_refill_order->getMerchantOrderList($condition, 50, 'refill_order.*,vr_order.order_state', 'refill_order.order_time desc');
|
|
|
-
|
|
|
- $stat = Model('')->table('refill_order,vr_order')->join('inner')
|
|
|
- ->on('refill_order.order_id=vr_order.order_id')
|
|
|
- ->field('count(*) as order_count ,sum(refill_amount) as refill_amounts, sum(channel_amount) as channel_amounts, sum(mch_amount) as mch_amounts')
|
|
|
- ->where($condition)->find();
|
|
|
- $count = $this->refill_stat($condition,$time_cond);
|
|
|
-
|
|
|
- $merchant_list = Model('')->table('merchant')->limit(1000)->select();
|
|
|
- foreach ($merchant_list as $key => $value) {
|
|
|
- $merchants[$value['mchid']] = $value;
|
|
|
- }
|
|
|
- foreach ($order_list as $order_id => $order_info) {
|
|
|
- $order_list[$order_id]['card_type_text'] = $this->scard_type($order_info['card_type']);
|
|
|
- $order_list[$order_id]['mch_name'] = $merchants[$order_info['mchid']]['company_name'];
|
|
|
- $order_list[$order_id]['diff_time_text'] = $this->elapse_time(time() - $order_info['order_time']);
|
|
|
- $order_list[$order_id]['diff_time'] = time() - $order_info['order_time'];
|
|
|
- $order_list[$order_id]['quality_text'] = $this->quality_format($order_info['quality']);
|
|
|
- }
|
|
|
- $provider_list = Model('')->table('refill_provider,store')
|
|
|
- ->field('refill_provider.*,store.store_name')
|
|
|
- ->join('inner')
|
|
|
- ->on('store.store_id=refill_provider.store_id')
|
|
|
- ->order('opened asc, provider_id desc')
|
|
|
- ->limit(1000)
|
|
|
- ->select();
|
|
|
- Tpl::output('stat', $stat);
|
|
|
- Tpl::output('count', $count);
|
|
|
- Tpl::output('order_list', $order_list);
|
|
|
- Tpl::output('merchant_list', $merchant_list);
|
|
|
- Tpl::output('provider_list', $provider_list);
|
|
|
- Tpl::output('show_page', $model_refill_order->showpage());
|
|
|
- Tpl::showpage('refill.order.send.index');
|
|
|
- }
|
|
|
-
|
|
|
- public function OrderStatsOp()
|
|
|
- {
|
|
|
- $type = $_GET['type'] ? $_GET['type'] : 'system';
|
|
|
- $page = "{$type}.order.stats";
|
|
|
- $model_refill_order = Model('refill_order');
|
|
|
- $condition['type'] = $type;
|
|
|
- if (!empty($_GET['cid'])) {
|
|
|
- $condition['cid'] = $_GET['cid'];
|
|
|
- }
|
|
|
- $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['time_stamp'] = [['egt', $start_unixtime], ['lt', $end_unixtime], 'and'];
|
|
|
- } elseif ($start_unixtime > 0) {
|
|
|
- $condition['time_stamp'] = ['egt', $start_unixtime];
|
|
|
- } elseif ($end_unixtime > 0) {
|
|
|
- $condition['time_stamp'] = ['lt', $end_unixtime];
|
|
|
- }
|
|
|
-
|
|
|
- $stats_list = $model_refill_order->getOrderStatsList($condition);
|
|
|
-
|
|
|
- if ($type == 'provider') {
|
|
|
- $provider_list = Model('')->table('refill_provider,store')->field('refill_provider.store_id,store.store_name')->join('inner')
|
|
|
- ->on('store.store_id=refill_provider.store_id')->limit(1000)->select();
|
|
|
- Tpl::output('provider_list', $provider_list);
|
|
|
- } elseif ($type == 'merchant') {
|
|
|
- $merchant_list = Model('')->table('merchant')->limit(1000)->select();
|
|
|
- Tpl::output('merchant_list', $merchant_list);
|
|
|
- }
|
|
|
- $success_count_total = $success_refill_amounts_total = $success_mch_amounts_toatl = $success_channel_amounts_total = 0;
|
|
|
- foreach ($stats_list as $stats) {
|
|
|
- $success_count_total += $stats['success_count'];
|
|
|
- $success_refill_amounts_total += $stats['success_refill_amounts'];
|
|
|
- $success_mch_amounts_toatl += $stats['success_mch_amounts'];
|
|
|
- $success_channel_amounts_total += $stats['success_channel_amounts'];
|
|
|
- }
|
|
|
- $total_stats = [
|
|
|
- 'success_count_total' => $success_count_total,
|
|
|
- 'success_refill_amounts_total' => $success_refill_amounts_total,
|
|
|
- 'success_mch_amounts_toatl' => $success_mch_amounts_toatl,
|
|
|
- 'success_channel_amounts_total' => $success_channel_amounts_total
|
|
|
- ];
|
|
|
- $check_text = ['未编辑', '匹配', '不匹配'];
|
|
|
- Tpl::output('total_stats', $total_stats);
|
|
|
- Tpl::output('stats_list', $stats_list);
|
|
|
- Tpl::output('check_text', $check_text);
|
|
|
- Tpl::output('show_page', $model_refill_order->showpage());
|
|
|
- Tpl::showpage($page);
|
|
|
- }
|
|
|
-
|
|
|
public function OrderStatsCheckOp()
|
|
|
{
|
|
|
$stat_id = $_GET['stat_id'] ?? $_POST['stat_id'];
|
|
@@ -1756,7 +1193,7 @@ class merchantControl extends SystemControl
|
|
|
$gap_order_count = $stats_data['success_count'] - $corder_success_count;
|
|
|
$gap_success_amounts = $stats_data['success_channel_amounts'] - $corder_success_amounts;
|
|
|
}else{
|
|
|
- showMessage('对账数据类型错误', 'index.php?act=merchant&op=OrderStats');
|
|
|
+ showMessage('对账数据类型错误', 'index.php?act=OrderStats&op=index');
|
|
|
}
|
|
|
|
|
|
$updata['corder_success_count'] = $corder_success_count;
|
|
@@ -1772,7 +1209,7 @@ class merchantControl extends SystemControl
|
|
|
$res = $mod_stat->edit($stat_id, $updata);
|
|
|
|
|
|
if ($res) {
|
|
|
- showMessage('操作成功',"index.php?act=merchant&op=OrderStats&type={$type}");
|
|
|
+ showMessage('操作成功',"index.php?act=OrderStats&op=index&type={$type}");
|
|
|
} else {
|
|
|
showMessage('操作失败');
|
|
|
}
|