|
@@ -148,6 +148,49 @@ class ordersendlistControl extends SystemControl
|
|
|
Tpl::showpage('refill.order.send.index');
|
|
|
}
|
|
|
|
|
|
+ private function extra_stats($base_cond, $timeout_type,$cur_time): array
|
|
|
+ {
|
|
|
+ $stat_order = function ($cond)
|
|
|
+ {
|
|
|
+ $stat = Model('')->table('refill_order,vr_order')->join('inner')
|
|
|
+ ->on('refill_order.order_id=vr_order.order_id')
|
|
|
+ ->field('count(*) as order_count ')
|
|
|
+ ->where($cond)->find();
|
|
|
+
|
|
|
+ return $stat['order_count'];
|
|
|
+ };
|
|
|
+
|
|
|
+ $result = [];
|
|
|
+
|
|
|
+ $start_day = strtotime("-5 days",$cur_time);
|
|
|
+ $extra_conds = [
|
|
|
+ ['between', [$cur_time - 3600, $cur_time - 1800]],
|
|
|
+ ['between', [$start_day, $cur_time - 3600]]
|
|
|
+ ];
|
|
|
+
|
|
|
+ if (array_key_exists($timeout_type, $this->mTimeouts)) {
|
|
|
+ $time_out = $this->mTimeouts[$timeout_type];
|
|
|
+ $extra_conds[] = ['_multi' => true,
|
|
|
+ ['egt', $start_day],
|
|
|
+ ['lt', $cur_time - $time_out]];
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach ($extra_conds as $stat_cond)
|
|
|
+ {
|
|
|
+ if (!empty($time_out)) {
|
|
|
+ $base_cond['vr_order.add_time&vr_order.add_time'] = $stat_cond;
|
|
|
+ $base_cond['refill_order.order_time&refill_order.order_time'] = $stat_cond;
|
|
|
+ } else {
|
|
|
+ $base_cond['refill_order.order_time'] = $stat_cond;
|
|
|
+ $base_cond['vr_order.add_time'] = $stat_cond;
|
|
|
+ }
|
|
|
+
|
|
|
+ $result[] = $stat_order($base_cond);
|
|
|
+ }
|
|
|
+
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
+
|
|
|
private function notify_time($cur_time,$period)
|
|
|
{
|
|
|
$start_day = strtotime("-5 days",$cur_time);
|
|
@@ -221,27 +264,25 @@ class ordersendlistControl extends SystemControl
|
|
|
$this->RefillOrderExport($orders_cond, 'time_out_order');
|
|
|
return;
|
|
|
}
|
|
|
+ $merchant_list = $this->merchants();
|
|
|
+ $provider_list = $this->providers();
|
|
|
|
|
|
//耗时
|
|
|
$fields = "refill_order.*,vr_order.order_state";
|
|
|
$order_by = "({$cur_time} - refill_order.commit_time) desc";
|
|
|
- $order_stat = Model('')->table('refill_order,vr_order,merchant')
|
|
|
- ->join('inner,inner')
|
|
|
- ->on('refill_order.order_id=vr_order.order_id,refill_order.mchid=merchant.mchid')
|
|
|
+ $order_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($orders_cond)->find();
|
|
|
$order_list = $model_refill_order->getMerchantTimeOut($orders_cond, 200, $order_stat['order_count'],$fields, $order_by);
|
|
|
-
|
|
|
-
|
|
|
- $special_stat = $this->extra_stats($base_cond, $timeout_type,$cur_time);
|
|
|
- $merchant_list = $this->merchants();
|
|
|
-
|
|
|
if(!empty($order_list)) {
|
|
|
$order_list = $this->orderFormat($order_list, $merchant_list);
|
|
|
}
|
|
|
- $provider_list = $this->providers();
|
|
|
+ $special_stat = $this->provider_timeout_stats($orders_cond, $provider_list);
|
|
|
+
|
|
|
Tpl::output('stat', $order_stat);
|
|
|
- Tpl::output('count', $special_stat);
|
|
|
+ Tpl::output('special_stat', $special_stat);
|
|
|
Tpl::output('order_list', $order_list);
|
|
|
Tpl::output('merchant_list', $merchant_list);
|
|
|
Tpl::output('provider_list', $provider_list);
|
|
@@ -249,47 +290,29 @@ class ordersendlistControl extends SystemControl
|
|
|
Tpl::showpage('refill.order.monitor.notify');
|
|
|
}
|
|
|
|
|
|
- private function extra_stats($base_cond, $timeout_type,$cur_time): array
|
|
|
+ private function provider_timeout_stats($cond, $provider_list)
|
|
|
{
|
|
|
- $stat_order = function ($cond)
|
|
|
- {
|
|
|
- $stat = Model('')->table('refill_order,vr_order')->join('inner')
|
|
|
- ->on('refill_order.order_id=vr_order.order_id')
|
|
|
- ->field('count(*) as order_count ')
|
|
|
- ->where($cond)->find();
|
|
|
-
|
|
|
- return $stat['order_count'];
|
|
|
- };
|
|
|
-
|
|
|
- $result = [];
|
|
|
-
|
|
|
- $start_day = strtotime("-5 days",$cur_time);
|
|
|
- $extra_conds = [
|
|
|
- ['between', [$cur_time - 3600, $cur_time - 1800]],
|
|
|
- ['between', [$start_day, $cur_time - 3600]]
|
|
|
- ];
|
|
|
-
|
|
|
- if (array_key_exists($timeout_type, $this->mTimeouts)) {
|
|
|
- $time_out = $this->mTimeouts[$timeout_type];
|
|
|
- $extra_conds[] = ['_multi' => true,
|
|
|
- ['egt', $start_day],
|
|
|
- ['lt', $cur_time - $time_out]];
|
|
|
- }
|
|
|
-
|
|
|
- foreach ($extra_conds as $stat_cond)
|
|
|
- {
|
|
|
- if (!empty($time_out)) {
|
|
|
- $base_cond['vr_order.add_time&vr_order.add_time'] = $stat_cond;
|
|
|
- $base_cond['refill_order.order_time&refill_order.order_time'] = $stat_cond;
|
|
|
- } else {
|
|
|
- $base_cond['refill_order.order_time'] = $stat_cond;
|
|
|
- $base_cond['vr_order.add_time'] = $stat_cond;
|
|
|
- }
|
|
|
-
|
|
|
- $result[] = $stat_order($base_cond);
|
|
|
- }
|
|
|
-
|
|
|
- return $result;
|
|
|
+ unset($cond['vr_order.store_id']);
|
|
|
+ $order_stat = Model('')->table('refill_order,vr_order')
|
|
|
+ ->join('inner')
|
|
|
+ ->on('refill_order.order_id=vr_order.order_id')
|
|
|
+ ->field('count(*) as order_count, store_id')
|
|
|
+ ->where($cond)
|
|
|
+ ->group('vr_order.store_id')
|
|
|
+ ->order('order_count desc')
|
|
|
+ ->select();
|
|
|
+ if(empty($order_stat)) return [];
|
|
|
+
|
|
|
+ foreach ($provider_list as $provider) {
|
|
|
+ $providers[$provider['provider_id']] = $provider;
|
|
|
+ }
|
|
|
+ ksort($providers);
|
|
|
+ foreach ($order_stat as $key => $stat) {
|
|
|
+ $store_id = intval($stat['store_id']);
|
|
|
+ $order_stat[$key]['store_name'] = $providers[$store_id]['store_name'];
|
|
|
+ $order_stat[$key]['opened'] = $providers[$store_id]['opened'];
|
|
|
+ }
|
|
|
+ return $order_stat;
|
|
|
}
|
|
|
|
|
|
private function RefillOrderExport($cond,$type='order')
|
|
@@ -366,11 +389,17 @@ class ordersendlistControl extends SystemControl
|
|
|
$this->RefillOrderExport($condition);
|
|
|
return;
|
|
|
}
|
|
|
- $order_list = $model_refill_order->getMerchantOrderList($condition, 200, 0,'refill_order.*,vr_order.order_state', 'refill_order.order_time asc');
|
|
|
+ $order_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();
|
|
|
+ $order_list = $model_refill_order->getMerchantOrderList($condition, 200, $order_stat['order_count'],'refill_order.*,vr_order.order_state', 'refill_order.order_time asc');
|
|
|
$merchant_list = Model('')->table('merchant')->limit(1000)->order('name asc')->select();
|
|
|
$order_list = $this->orderFormat($order_list, $merchant_list);
|
|
|
|
|
|
$provider_list = $this->providers();
|
|
|
+ Tpl::output('stat', $order_stat);
|
|
|
Tpl::output('provider_list', $provider_list);
|
|
|
Tpl::output('order_list', $order_list);
|
|
|
Tpl::output('show_page', $model_refill_order->showpage());
|