request->get(); $query=BaseConfig::find()->where([ 'status'=>0 ]); $this->field=[ BaseConfig::class=>[ 'id','type','desc','content','change_at'=>function($m){ return date('Y-m-d H:i:s',$m->change_at); }, 'status','end', 'created_at'=>function($model){ return date('Y-m-d H:i:s',$model->created_at); } ] ]; return $this->create($query,$get); } /** * @doc-name 删除协议 * @doc-param int id 协议ID */ public function actionAgreeDel() { $get= \Yii::$app->request->get(); $this->requestValidate($get,[ ['id','required'] ]); $AgreeForm=new AgreeForm(); $AgreeForm->attributes=$get; return $AgreeForm->del(); } /** * @doc-name 编译协议及新增协议 * @doc-desc 传id即为编辑 * @doc-param int id 协议ID / optional * @doc-param string type 类型1服务协议2隐私政策3其他 * @doc-param string desc 描述 / optional * @doc-param string content 内容 */ public function actionAgreeSave() { $post = \Yii::$app->request->post(); $AgreeForm=new AgreeForm(); $AgreeForm->attributes=$post; return $AgreeForm->save(); } /** * @doc-name 西药包邮 * @doc-desc 传id即为编辑 * @doc-param string name name * @doc-param string rule 规则 * @doc-param string value 值 */ public function actionFreeShip() { $post = \Yii::$app->request->post(); $this->requestValidate($post,[ ['name','required'], ['rule','required'], ['value','required'], ]); $SystemConfig=SystemConfig::find()->where([ 'config_type'=>2, 'type'=>2 ])->one(); if (!$SystemConfig){ throw new Exception('西药包邮配置不存在'); } $SystemConfig->name=$post['name']; $SystemConfig->rule=$post['rule']; $SystemConfig->value=$post['value']; $SystemConfig->saveOrFail(); return ['设置成功']; } /** * 小程序版本 */ public function actionXcxVersion(){ $SystemConfig=SystemConfig::find()->where([ 'config_type'=>3, ])->one(); if (!$SystemConfig){ throw new Exception('小程序版本配置不存在'); } return $SystemConfig; } /** * 小程序版本设置 */ public function actionXcxVersionSet(){ $post = \Yii::$app->request->post(); $this->requestValidate($post,[ ['value','required'], ]); $SystemConfig=SystemConfig::find()->where([ 'config_type'=>3, ])->one(); if (!$SystemConfig){ throw new Exception('小程序版本配置不存在'); } $SystemConfig->value=$post['value']; $SystemConfig->saveOrFail(); return ['设置成功']; } }