'submit'], ]; } public function attributeLabels() { return [ 'cx_mch_id' => '平台商户ID', 'cat_id' => '分类ID', 'contact' => '联系方式:QQ|手机号', 'content' => '反馈内容', 'pic_list' => '反馈图片', ]; } public function save() { if(!$this->validate()){ return $this->getModelError(); } if(!empty($this->cat_id)){ $cat = Cat::findOne([ 'type' => Cat::TYPE_FEEDBACK, 'id' => $this->cat_id, 'is_delete' => 0, 'status' => 1, ]); if($cat == null){ return $this->apiReturnError("反馈分类不存在"); } } $pic_list = json_decode($this->pic_list); if(!is_array($pic_list)){ return $this->apiReturnError("反馈图片列表无效数据格式"); } if(count($pic_list) == 0){ return $this->apiReturnError("反馈图片不能为空"); } foreach ($pic_list as $index => $pic){ $pic_list[$index] = SiteHelper::getRelativeUrl($pic); } $this->pic_list = json_encode($pic_list,JSON_UNESCAPED_UNICODE); $model = new Feedback(); $model->attributes = $this->attributes; $model->review_user_id = 0; $model->review_status = Feedback::REVIEW_STATUS_WAITTING; $model->review_time = 0; if(!$model->save()){ return $this->getModelError($model); } return $this->apiReturnSuccess("反馈提交成功"); } public function search() { if(!$this->validate()){ return $this->getModelError(); } $cat_list = Cat::find() ->where([ 'cx_mch_id' => $this->cx_mch_id, 'is_delete' => 0, 'type' => Cat::TYPE_FEEDBACK, ]) ->orderBy(['sort' => SORT_ASC, 'created_at' => SORT_DESC]) ->select('id,name,img_url')->asArray()->all(); foreach($cat_list as $index => $item){ $item['img_url'] = SiteHelper::getFullUrl($item['img_url']); $cat_list[$index] = $item; } return $this->apiReturnSuccess("ok", ['cat_list' => $cat_list]); } }