|
@@ -0,0 +1,131 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace refill;
|
|
|
+
|
|
|
+class rquery
|
|
|
+{
|
|
|
+ public $normal_cond = [];
|
|
|
+ public $time_cond = [];
|
|
|
+
|
|
|
+ public function __construct($input)
|
|
|
+ {
|
|
|
+ $this->ct_query_cond($input);
|
|
|
+ $this->ct_time_cond($input);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function ct_query_cond($input)
|
|
|
+ {
|
|
|
+ if (!empty($input['order_sn'])) {
|
|
|
+ $this->normal_cond['refill_order.order_sn'] = $input['order_sn'];
|
|
|
+ }
|
|
|
+ if (!empty($input['mch_order'])) {
|
|
|
+ $this->normal_cond['refill_order.mch_order'] = $input['mch_order'];
|
|
|
+ }
|
|
|
+ if (!empty($input['ch_trade_no'])) {
|
|
|
+ $this->normal_cond['refill_order.ch_trade_no'] = $input['ch_trade_no'];
|
|
|
+ }
|
|
|
+ if (!empty($input['card_no'])) {
|
|
|
+ $this->normal_cond['refill_order.card_no'] = $input['card_no'];
|
|
|
+ }
|
|
|
+ if (!empty($input['no_mchid'])) {
|
|
|
+ $no_mchid = explode(',', $input['no_mchid']);
|
|
|
+ $this->normal_cond['refill_order.mchid'] = ['not in', $no_mchid];
|
|
|
+ }
|
|
|
+ if (!empty($input['no_amount'])) {
|
|
|
+ $no_amount = explode(',', $input['no_amount']);
|
|
|
+ $this->normal_cond['refill_order.refill_amount'] = ['not in', $no_amount];
|
|
|
+ }
|
|
|
+ if (!empty($input['mchid'])) {
|
|
|
+ $this->normal_cond['refill_order.mchid'] = $input['mchid'];
|
|
|
+ }
|
|
|
+ if (!empty($input['store_id'])) {
|
|
|
+ $this->normal_cond['vr_order.store_id'] = $input['store_id'];
|
|
|
+ }
|
|
|
+ if (!empty($input['refill_amount'])) {
|
|
|
+ $this->normal_cond['refill_order.refill_amount'] = $input['refill_amount'];
|
|
|
+ }
|
|
|
+ if (!empty($input['quality'])) {
|
|
|
+ $this->normal_cond['refill_order.quality'] = $input['quality'];
|
|
|
+ }
|
|
|
+ if(!empty($input['official_status'])) {
|
|
|
+ if($input['official_status'] == 1) {
|
|
|
+ $this->normal_cond['official_sn'] = '';
|
|
|
+ } elseif ($input['official_status'] == 2) {
|
|
|
+ $this->normal_cond['official_sn'] = ['neq', ''];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!empty($input['card_type'])) {
|
|
|
+ if (in_array($input['card_type'], ['1', '2', '4', '5', '6', '7'])) {
|
|
|
+ $this->normal_cond['refill_order.card_type'] = intval($input['card_type']);
|
|
|
+ }
|
|
|
+ if ($input['card_type'] == 'oil') {
|
|
|
+ $this->normal_cond['refill_order.card_type'] = ['in', [1, 2]];
|
|
|
+ }
|
|
|
+ if ($input['card_type'] == 'phone') {
|
|
|
+ $this->normal_cond['refill_order.card_type'] = ['in', [4, 5, 6]];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(in_array($input['cardno_state'], ['0','1', '2', '4', '5'])) {
|
|
|
+ $this->normal_cond['refill_order.cardno_state'] = $input['cardno_state'];
|
|
|
+ }
|
|
|
+ if(in_array($input['is_transfer'], ['0','1'])) {
|
|
|
+ $this->normal_cond['refill_order.is_transfer'] = $input['is_transfer'];
|
|
|
+ }
|
|
|
+ if (in_array($input['order_state'], ['0', '10', '20', '30', '40']))
|
|
|
+ {
|
|
|
+ $this->normal_cond['vr_order.order_state'] = $input['order_state'];
|
|
|
+ }
|
|
|
+ if(!empty($input['card_nos'])) {
|
|
|
+ $card_nos = trim($input['card_nos'], ',');
|
|
|
+ $this->normal_cond['refill_order.card_no'] = ['in', $card_nos];
|
|
|
+ }
|
|
|
+ if (!empty($input['mch_orders'])) {
|
|
|
+ $mch_orders = rtrim($input['mch_orders'], ',');
|
|
|
+ $this->normal_cond['refill_order.mch_order'] = ['in', $mch_orders];
|
|
|
+ }
|
|
|
+ if(!empty($input['order_sns'])) {
|
|
|
+ $order_sns = trim($input['order_sns'], ',');
|
|
|
+ $this->normal_cond['refill_order.order_sn'] = ['in', $order_sns];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function ct_time_cond($input)
|
|
|
+ {
|
|
|
+ $start = intval(strtotime($input['query_start_time']));
|
|
|
+ $end = intval(strtotime($input['query_end_time']));
|
|
|
+
|
|
|
+ $today = strtotime(date('Y-m-d',time()));
|
|
|
+ $tomorrow = $today + 86400;
|
|
|
+
|
|
|
+ if($start <= 0) {
|
|
|
+ $start = $today;
|
|
|
+ }
|
|
|
+
|
|
|
+ $cur = time();
|
|
|
+ $cur = $cur - ($cur % 300) + 300;
|
|
|
+ if($end <= 0) {
|
|
|
+ $end = $cur;
|
|
|
+ }
|
|
|
+ $end_date = strtotime(date('Y-m-d',$end));
|
|
|
+
|
|
|
+ if ($end >= $start)
|
|
|
+ {
|
|
|
+ $add_end = $end_date + 86400 * 5;
|
|
|
+ if($add_end > $tomorrow) {
|
|
|
+ $add_end = $tomorrow;
|
|
|
+ }
|
|
|
+ $this->time_cond['refill_order.order_time'] = [['egt', $start], ['lt', $end], 'and'];
|
|
|
+ $this->time_cond['vr_order.add_time'] = [['egt', $start], ['elt', $add_end], 'and'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function normal_cond_result(): array
|
|
|
+ {
|
|
|
+ return $this->normal_cond;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function time_cond_result(): array
|
|
|
+ {
|
|
|
+ return $this->time_cond;
|
|
|
+ }
|
|
|
+}
|