gorden 1 сар өмнө
parent
commit
63d157501d

+ 14 - 0
app/admin/controller/coupon/CouponPacketSequenceController.php

@@ -41,6 +41,13 @@ class CouponPacketSequenceController extends Curd
 
             $where['coupon_packet_sequence_addtimes'] = $addTimes;
         }
+        $usedTime = $request->get('coupon_packet_sequence_used_datetime', []);
+        if (!empty($usedTime)) {
+            $usedTime[0] = isset($usedTime[0]) ? strtotime($usedTime[0]) : time();
+            $usedTime[1] = isset($usedTime[1]) ? strtotime($usedTime[1]) : time();
+
+            $where['coupon_packet_sequence_used_datetime'] = $usedTime;
+        }
 
         $query = $this->doSelect($where, $field, $order);
         return $this->doFormat($query, $format, $limit);
@@ -48,6 +55,10 @@ class CouponPacketSequenceController extends Curd
 
     protected function doSelect(array $where, string $field = null, string $order = 'desc')
     {
+        if (!empty($where['coupon_packet_sequence_used_datetime'])) {
+            $usedTime = $where['coupon_packet_sequence_used_datetime'];
+            unset($where['coupon_packet_sequence_used_datetime']);
+        }
         $model = $this->model->with([
             'packet' => function ($query) {
                 $query->select('coupon_packet_id', 'coupon_packet_name');
@@ -91,6 +102,9 @@ class CouponPacketSequenceController extends Curd
                 $model = $model->where($column, $value);
             }
         }
+        if (!empty($usedTime)) {
+            $model = $model->whereRaw("UNIX_TIMESTAMP(coupon_packet_sequence_used_datetime) >= ? AND UNIX_TIMESTAMP(coupon_packet_sequence_used_datetime) <= ?", [$usedTime[0], $usedTime[1]]);
+        }
 //        $model = $model->selectRaw('join_detail_coupon_id,join_coupon_detail_member_id,MAX(coupon_detail_addtimes) as coupon_detail_addtimes,COUNT(*) as total');
 //        $model = $model->groupBy('join_coupon_detail_member_id', 'join_detail_coupon_id');
         if ($field) {