shish 3 years ago
parent
commit
1b8640eba6
1 changed files with 51 additions and 17 deletions
  1. 51 17
      biz-ghs/stat/classes/StatSaleClass.php

+ 51 - 17
biz-ghs/stat/classes/StatSaleClass.php

@@ -57,24 +57,58 @@ class StatSaleClass extends BaseClass
     public static function OrderClear($mainId)
     {
         $get = Yii::$app->request->get();
-        $where = [];
-        $where['mainId'] = $mainId;
-        $searchTime = isset($get['searchTime']) && !empty($get['searchTime']) ? $get['searchTime'] : 'today';
-
-        $startTime = $get['startTime'] ?? '';
-        $endTime = $get['endTime'] ?? '';
-        $period = dateUtil::formatTime($searchTime, $startTime, $endTime, true);
-        $start = $period['startTime'];
-        $end = $period['endTime'];
-        $where['time'] = ['between', [$start, $end]];
-
-        $currentStartDate = date('Y-m-d', strtotime($start));
-        $currentEndDate = date('Y-m-d', strtotime($end));
-        $currentStartTime = $currentStartDate . ' 00:00:00';
-        $currentEndTime = $currentEndDate . ' 23:59:59';
-
         $where = ['mainId' => $mainId, 'status' => ['in', [OrderClass::ORDER_STATUS_UN_SEND, OrderClass::ORDER_STATUS_SENDING, OrderClass::ORDER_STATUS_COMPLETE]]];
-        $where['payTime'] = ['between', [$currentStartTime, $currentEndTime]];
+
+        if (isset($get['payTime']) && !empty($get['payTime'])) {
+            $payTime = $get['payTime'];
+
+            $startTime = $get['startTime'] ?? '';
+            $endTime = $get['endTime'] ?? '';
+            $period = dateUtil::formatTime($payTime, $startTime, $endTime, true);
+            $start = $period['startTime'];
+            $end = $period['endTime'];
+            $currentStartDate = date('Y-m-d', strtotime($start));
+            $currentEndDate = date('Y-m-d', strtotime($end));
+            $currentStartTime = $currentStartDate . ' 00:00:00';
+            $currentEndTime = $currentEndDate . ' 23:59:59';
+            $where['payTime'] = ['between', [$currentStartTime, $currentEndTime]];
+
+        } elseif (isset($get['clearTime']) && !empty($get['clearTime'])) {
+            $clearTime = $get['clearTime'];
+
+            $startTime = $get['startTime'] ?? '';
+            $endTime = $get['endTime'] ?? '';
+            $period = dateUtil::formatTime($clearTime, $startTime, $endTime, true);
+            $start = $period['startTime'];
+            $end = $period['endTime'];
+            $currentStartDate = date('Y-m-d', strtotime($start));
+            $currentEndDate = date('Y-m-d', strtotime($end));
+            $currentStartTime = $currentStartDate . ' 00:00:00';
+            $currentEndTime = $currentEndDate . ' 23:59:59';
+            $where['clearTime'] = ['between', [$currentStartTime, $currentEndTime]];
+
+        } else {
+            $payTime = 'today';
+
+            $startTime = $get['startTime'] ?? '';
+            $endTime = $get['endTime'] ?? '';
+            $period = dateUtil::formatTime($payTime, $startTime, $endTime, true);
+            $start = $period['startTime'];
+            $end = $period['endTime'];
+            $currentStartDate = date('Y-m-d', strtotime($start));
+            $currentEndDate = date('Y-m-d', strtotime($end));
+            $currentStartTime = $currentStartDate . ' 00:00:00';
+            $currentEndTime = $currentEndDate . ' 23:59:59';
+            $where['payTime'] = ['between', [$currentStartTime, $currentEndTime]];
+        }
+        $customId = $get['customId'] ?? 0;
+        if (!empty($customId)) {
+            $where['customId'] = $customId;
+        }
+        $unClear = $get['unClear'] ?? 0;
+        if ($unClear == 1) {
+            $where['clearId'] = 0;
+        }
         $ghsOrderList = OrderClass::getAllByCondition($where, null, '*');
         return ['list' => $ghsOrderList];
     }