|
@@ -18,7 +18,6 @@ class merchant_orderControl extends mbMerchantControl
|
|
|
|
|
|
$cond['mchid'] = $this->mchid();
|
|
|
$cond['inner_status'] = 0;
|
|
|
- $fSingle = false;
|
|
|
if (!empty($_GET['card_type'])) {
|
|
|
if(in_array($_GET['card_type'] , ['1' , '2' , '4' , '5' , '6'])) {
|
|
|
$cond['refill_order.card_type'] = $_GET['card_type'];
|
|
@@ -31,18 +30,15 @@ class merchant_orderControl extends mbMerchantControl
|
|
|
}
|
|
|
}
|
|
|
if (!empty($_GET['card_no'])) {
|
|
|
- $fSingle = true;
|
|
|
$cond['refill_order.card_no'] = $_GET['card_no'];
|
|
|
}
|
|
|
if (!empty($_GET['refill_amount'])) {
|
|
|
$cond['refill_order.refill_amount'] = $_GET['refill_amount'];
|
|
|
}
|
|
|
if (!empty($_GET['mch_order'])) {
|
|
|
- $fSingle = true;
|
|
|
$cond['refill_order.mch_order'] = $_GET['mch_order'];
|
|
|
}
|
|
|
if (!empty($_GET['order_sn'])) {
|
|
|
- $fSingle = true;
|
|
|
$cond['refill_order.order_sn'] = $_GET['order_sn'];
|
|
|
}
|
|
|
if (!empty($_GET['quality'])) {
|
|
@@ -53,31 +49,26 @@ class merchant_orderControl extends mbMerchantControl
|
|
|
$end_date = strtotime(date('Y-m-d',$cur_time));
|
|
|
$add_end = $end_date + 86400 * 5;
|
|
|
|
|
|
- if($fSingle)
|
|
|
- {
|
|
|
- $start = intval($_GET['start_time']);
|
|
|
- $end = intval($_GET['end_time']);
|
|
|
+ $start = intval($_GET['start_time']);
|
|
|
+ $end = intval($_GET['end_time']);
|
|
|
|
|
|
- if($start <= 0) {
|
|
|
- $start = $cur_time - 3600;
|
|
|
- }
|
|
|
- if($end <= 0) {
|
|
|
- $end = $cur_time;
|
|
|
- }
|
|
|
+ if($start <= 0) {
|
|
|
+ $start = $cur_time - 86400 * 2;
|
|
|
}
|
|
|
- else{
|
|
|
- $start = $cur_time - 3600;
|
|
|
+ if($end <= 0) {
|
|
|
$end = $cur_time;
|
|
|
}
|
|
|
+
|
|
|
$cond['refill_order.order_time'] = [['egt', $start], ['lt', $end], 'and'];
|
|
|
$cond['vr_order.add_time'] = [['egt', $start], ['elt', $add_end], 'and'];
|
|
|
|
|
|
if (in_array($_GET['order_state'], ['0', '30', '40']))
|
|
|
{
|
|
|
$cond['vr_order.order_state'] = $_GET['order_state'];
|
|
|
- if ($_GET['order_state'] == 30 && $_GET['time'] == 1) {
|
|
|
- $cond['refill_order.order_time'] = ['lt', (time() - 3600)];
|
|
|
- }
|
|
|
+ }
|
|
|
+ if ($_GET['stat']) {
|
|
|
+ $stat = $this->orderStatsHour($cond);
|
|
|
+ return self::outsuccess($stat);
|
|
|
}
|
|
|
|
|
|
$fields = 'refill_order.*,vr_order.order_state';
|
|
@@ -105,6 +96,52 @@ class merchant_orderControl extends mbMerchantControl
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+ private function orderStatsHour($cond)
|
|
|
+ {
|
|
|
+ $stats = Model('')->table('refill_order,vr_order')->join('inner')
|
|
|
+ ->on('refill_order.order_id=vr_order.order_id')
|
|
|
+ ->field("FROM_UNIXTIME(order_time,'%d-%H') as hour, count(*) as order_count, sum(refill_amount) as refill_amounts, sum(mch_amount) as mch_amounts, order_state")
|
|
|
+ ->where($cond)->group('hour, order_state')->select();
|
|
|
+
|
|
|
+ $cond['refill_order.channel_name'] = '';
|
|
|
+ $excp_stats = Model('')->table('refill_order,vr_order')->join('inner')
|
|
|
+ ->on('refill_order.order_id=vr_order.order_id')
|
|
|
+ ->field("FROM_UNIXTIME(order_time,'%d-%H') as hour, count(*) as order_count")
|
|
|
+ ->where($cond)->group('hour')->select();
|
|
|
+
|
|
|
+ $data = [];
|
|
|
+ $except = [];
|
|
|
+ if(!empty($excp_stats)) {
|
|
|
+ foreach ($excp_stats as $value) {
|
|
|
+ $except[$value['hour']] = $value['order_count'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!empty($stats)) {
|
|
|
+ $init = [
|
|
|
+ 'order_count' => 0, 'refill_amounts' => 0, 'mch_amounts' => 0
|
|
|
+ ];
|
|
|
+ $sending = $success = $cancel = $init;
|
|
|
+ foreach ($stats as $stat) {
|
|
|
+ $hour = $stat['hour'];
|
|
|
+ if ($stat['order_state'] == ORDER_STATE_SEND) {
|
|
|
+ $sending = $stat;
|
|
|
+ } elseif ($stat['order_state'] == ORDER_STATE_SUCCESS) {
|
|
|
+ $success = $stat;
|
|
|
+ } elseif ($stat['order_state'] == ORDER_STATE_CANCEL) {
|
|
|
+ $cancel = $stat;
|
|
|
+ }
|
|
|
+ $data[$hour] = ['sending' => $sending, 'success' => $success, 'cancel' => $cancel];
|
|
|
+ if(array_key_exists($hour, $except)) {
|
|
|
+ $data[$hour]['except_count'] = $except[$hour];
|
|
|
+ }else{
|
|
|
+ $data[$hour]['except_count'] = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
+
|
|
|
public function OrderStatsOp()
|
|
|
{
|
|
|
if(empty($_GET['time_type']) || empty($_GET['start_time']) || empty($_GET['end_time'])) {
|