| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- namespace addons\RandFee\backend\controllers;
- use addons\RandFee\common\enums\Order;
- use addons\RandFee\common\service\SettingService;
- use Yii;
- use common\controllers\AddonsController;
- use common\enums\StatusEnum;
- use common\models\user\UserLevel;
- /**
- * 设置控制器
- *
- * Class SettingController
- * @package addons\RandFee\backend\controllers
- */
- class SettingController extends BaseController
- {
- public $enableCsrfValidation = false;
- /**
- * 设置首页
- *
- * @return void
- */
- public function actionIndex()
- {
- if ($this->request->isAjax) {
- // 获取设置
- $service = new SettingService(['mall_id' => $this->mall_id]);
- $conf = $service->getSetting();
- // 等级
- $level = UserLevel::getUserLevel([
- ['=', 'mall_id', $this->mall_id],
- ['=', 'status', StatusEnum::ENABLED],
- ], [], true, 'level, name', 'level asc');
- // 订单
- $order = Order::getTypes();
- return $this->success('ok', compact('conf', 'level', 'order'));
- }
- return $this->render('index');
- }
- /**
- * 保存设置
- *
- * @return void
- */
- public function actionSubmit()
- {
- if ($this->request->isPost) {
- // 数据提交
- $post = $this->request->post();
- $service = new SettingService(['mall_id' => $this->mall_id]);
- if ($service->saveSetting($post)) {
- return $this->success('保存成功');
- }
- return $this->error('保存失败');
- }
- }
- }
|