| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- namespace addons\ScoreMall\backend\controllers;
- use addons\ScoreMall\common\enums\ScoreMallEnum;
- use common\enums\StatusEnum;
- class SettingController extends BaseController
- {
- public $enableCsrfValidation = false;
- /**
- * 基础设置
- * @return mixed|string|null
- */
- public function actionIndex()
- {
- $retuest = \Yii::$app->request;
- if ($retuest->isAjax) {
- $mall_id = $this->mall_id;
- if ($retuest->isPost) {
- try{
- $params = \Yii::$app->request->post();
- $res = \Yii::$app->services->validate->validate($params, [
- [['is_limit_address', ], 'integer'],
- [['is_limit_address'], 'number'],
- ]);
- if ($res === false) throw new \Exception(\Yii::$app->services->validate->getErrorMessage());
- \Yii::$app->services->setting->addons->set($mall_id, ScoreMallEnum::ADDONS_NAME, ['base' => $params]);
- return $this->success('保存成功');
- }catch (\Exception $e){
- return $this->error($e->getMessage());
- }
- }else{
- $config = \Yii::$app->services->setting->addons->get($mall_id, ScoreMallEnum::ADDONS_NAME, 'base');
- return $this->success('获取成功', $config);
- }
- }
- return $this->render('index');
- }
- }
|