| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- namespace addons\Seckill\backend\controllers;
- use addons\Seckill\common\enums\SeckillEnum;
- use common\enums\StatusEnum;
- use common\models\goods\Goods;
- use addons\Seckill\common\models\SeckillActivity;
- use Yii;
- /**
- * 系统设置控制器
- *
- * Class ActivityController
- * @package addons\Seckill\backend\controllers
- */
- class SettingController extends BaseController
- {
- public $enableCsrfValidation = false;
- /**
- * 首页
- *
- * @return string
- */
- public function actionIndex()
- {
- if (\Yii::$app->request->isAjax) {
- $config = \Yii::$app->services->setting->addons->get($this->mall_id, SeckillEnum::ADDONS_NAME, 'basic');
- $this->success('获取成功', $config);
- }
- return $this->render('index');
- }
- /**
- * 保存设置
- * @return mixed|void
- */
- public function actionSaveSetting()
- {
- $post = \Yii::$app->request->post();
- $check = \Yii::$app->services->validate
- ->validate(
- $post,
- [
- [['status', 'order_cancel_time'], 'required'],
- [['status','order_cancel_time'], 'integer'],
- ]
- );
- if ($check === false) {
- return $this->error(\Yii::$app->services->validate->getErrorMessage());
- }
- if($post['order_cancel_time'] <= 0 ){
- return $this->error('超时取消时间需大于0');
- }
- $res = \Yii::$app->services->setting->addons->set($this->mall_id, SeckillEnum::ADDONS_NAME, ['basic' => $post]);
- if($res){
- return $this->success('操作成功');
- }
- return $this->error('保存失败');
- }
- }
|