1], [['limit'], 'default', 'value' => 20], [['cx_mch_id'], 'required'] ]; } public function search() { if(!$this->validate()){ return $this->getModelError(); } $query = PaymentConfig::find() ->where([ 'cx_mch_id' => $this->cx_mch_id, 'is_delete' => 0 ]) ->andFilterWhere([ 'OR', ['LIKE', 'name', $this->keywords], ['LIKE', 'remark', $this->keywords], ]) ->andFilterWhere([ 'pay_type' => $this->pay_type, 'status' => $this->status ]) ->select('id,name,status,remark,pay_type,created_at,updated_at'); $count_query = clone $query; $count = $count_query->count(); $pagination = new Pagination(['pageSize' => $this->limit, 'totalCount' => $count, 'page' => $this->page - 1]); $list = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['created_at' => SORT_DESC])->asArray()->all(); foreach ($list as $index => $item){ $item['created_at_cn'] = date('Y-m-d H:i:s',$item['created_at']); $item['updated_at_cn'] = date('Y-m-d H:i:s',$item['created_at']); $item['status_cn'] = PaymentConfig::getStatus($item['status']); $item['pay_type_cn'] = PaymentTypes::getPayType(PaymentTypes::payTypeKeyToId($item['pay_type'])); $list[$index] = $item; } //是否已经全部加载 $end_flag = $this->page > $pagination->pageCount ? true : false; return [ 'code' => 0, 'msg' => 'ok', 'data' => $list, 'count' => $count, 'page_size' => $this->limit, 'page_count' => $pagination->pageCount, 'page_no' => $this->page, 'end_flag' => $end_flag ]; } }