count(); $ing = FreeShipping::where('status', FreeShippingEnum::ING)->count(); $end = FreeShipping::where('status', FreeShippingEnum::END)->count(); return [ 'all' => $all, 'wait' => $wait, 'ing' => $ing, 'end' => $end, ]; } /** * @notes 附加搜索条件 */ public function setSearch() { if (isset($this->params['status']) && trim($this->params['status']) != '') { $this->searchWhere[] = ['status', '=', $this->params['status']]; } if (isset($this->params['name']) && !empty($this->params['name'])) { $this->searchWhere[] = ['name', 'like', '%' . trim($this->params['name']) . '%']; } if (isset($this->params['start_time']) && isset($this->params['end_time']) && !empty($this->params['start_time']) && !empty($this->params['end_time'])) { $this->searchWhere[] = ['start_time', '<=', strtotime($this->params['start_time'])]; $this->searchWhere[] = ['end_time', '>=', strtotime($this->params['end_time'])]; } } /** * @notes 列表 */ public function lists(): array { $this->setSearch(); $field = [ 'id', 'name', 'start_time', 'end_time', 'status', 'create_time', ]; $lists = FreeShipping::field($field) ->append(['order_num', 'order_amount','btn']) ->where($this->searchWhere) ->order('id', 'desc') ->limit($this->limitOffset, $this->limitLength) ->select() ->toArray(); return $lists; } /** * @notes 总记录数 */ public function count(): int { $this->setSearch(); $count = FreeShipping::where($this->searchWhere)->count(); return $count; } }