shop_id=$this->storeId?:Store::getMainStore($this->wqData['uniacid'])['id']; $this->shop_id=$this->shop_id?:0; } //运营资讯 public function actionGetInformationList(){ $result=axios_request(); $page=Yii::$app->request->get('page')?Yii::$app->request->get('page'):1; $num=($page-1)*10; $limit=10; $type=Yii::$app->request->get('type'); $storeId=$result['storeId']?:$this->shop_id; $where=['deleteAt'=>0,'uniacid'=>$this->wqData['uniacid'],'storeId'=>$storeId]; // if($type){ // $where['type']=$type; // } $table= (new \yii\db\Query()) ->from('{{%ybwm_information}}') ->where($where); $data=$table->orderBy('sort asc,id desc') ->offset($num) ->limit($limit) ->all(); foreach ($data as $k=>$v){ $data[$k]['createdAt']=date('Y-m-d H:i:s',$v['createdAt']); } $count=$table->count(); //dd($data);die; return $this->result(1,'成功',$data,$count); } public function actionInformationSave(){ $request = Yii::$app->request; $result=axios_request(); $storeId=$result['storeId']?:$this->shop_id; if($request->isGet){ $info=(new \yii\db\Query()) ->from('{{%ybwm_information}}') ->where('id=:id',[':id'=>$result['id']])->one(); return $this->result(1,'成功',$info); } $data=array( 'sort'=>$result['sort'], 'title'=>$result['title'], 'body'=>$result['body'], 'icon'=>$result['icon'], 'introduction'=>$result['introduction'], 'type'=>1, ); //if($result['type']==1){ $data['storeId']=$storeId; //} if(!$result['title']){ return $this->result(2,'标题不能为空'); } if($result['id']){ $data['changeAt']=time(); $re = YII::$app->db->createCommand()->update('{{%ybwm_information}}', $data, ['id'=>$result['id']])->execute(); }else{ $data['createdAt']=time(); $data['uniacid']=$this->wqData['uniacid']; //dd($data);die; $re = YII::$app->db->createCommand()->insert('{{%ybwm_information}}', $data)->execute(); } if($re){ return $this->result(1,'成功'); }else{ return $this->result(2,'失败'); } } public function actionChangeInformation(){ $request = Yii::$app->request; if($request->isPost){ $result=axios_request(); $id=$result['id']; if(is_array($id)){ $re = YII::$app->db->createCommand()->update('{{%ybwm_information}}', ['display'=>$result['display']], ['in','id',$id])->execute(); }else{ $re = YII::$app->db->createCommand()->update('{{%ybwm_information}}', ['display'=>$result['display']], ['id'=>$id])->execute(); } return $this->result(1,'成功'); } } public function actionInformationDel(){ $request = Yii::$app->request; if($request->isPost){ $id=axios_request()['id']; if(is_array($id)){ $re = YII::$app->db->createCommand()->update('{{%ybwm_information}}', ['deleteAt'=>time()], ['in','id',$id])->execute(); }else{ $re = YII::$app->db->createCommand()->update('{{%ybwm_information}}', ['deleteAt'=>time()], ['id'=>$id])->execute(); } return $this->result(1,'成功'); } } }