1], [['limit'], 'default','value' => 10], [['status'], 'default','value' => 1] ]; } /** * @return array */ public function detail() { if (!$this->validate()) { return [ 'code' => 1, 'msg' => $this->getErrorSummary(false)[0], ]; } $list = UserCard::findOne([ 'store_id' => $this->store_id, 'user_id' => $this->user_id, 'id' => $this->user_card_id, 'is_delete' => 0, ]); return [ 'code'=>0, 'msg'=> '', 'data'=> [ 'list' => $list, ] ]; } /** * @return array */ public function search() { if (!$this->validate()) { return [ 'code' => 1, 'msg' => $this->getErrorSummary(false)[0], ]; } $query = UserCard::find()->where([ 'store_id' => $this->store_id, 'user_id' => $this->user_id, 'is_delete' => 0]); if ($this->status == 1) { $query->andWhere(['is_use' => 0]); } if ($this->status == 2) { $query->andWhere(['is_use' => 1]); } $count = $query->count(); $p = new Pagination(['totalCount' => $count,'pageSize' => $this->limit]); $list = $query->limit($p->limit)->offset($p->offset)->orderBy(['created_at' => SORT_DESC])->asArray()->all(); foreach ($list as $k => $v) { $list[$k]['clerk_time'] = date('Y-m-d H:i:s', $v['clerk_time']); } return [ 'code'=>0, 'msg'=>'', 'data'=>[ 'list' => $list, 'page_count' => $p->pageCount, 'row_count' => $count ] ]; } }