| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- namespace addons\ElectronCoupon\backend\controllers;
- use addons\ElectronCoupon\common\services\SettingService;
- use common\models\common\PlatformSetting;
- use Yii;
- class SettingController extends BaseController
- {
- public $enableCsrfValidation = false;
- /**
- * 基础配置
- *
- * @author hpi
- * @return array|mixed
- */
- public function actionIndex()
- {
- $service = new SettingService(['mall_id' => $this->mall_id]);
- if (Yii::$app->request->isAjax) {
- if (Yii::$app->request->isPost) {
- $params = Yii::$app->request->post();
- $res = Yii::$app->services->validate->validate($params, [
- [['is_open', 'customize_name', 'receive_num', 'payed_url', 'is_payed_url', 'agreement', 'images'], 'safe'],
- [['is_allow_deal', 'source_transfer_permission', 'transfer_num', 'images', 'logo', 'is_notice', 'settlement_type'], 'safe'],
- [['center_url'], 'safe'],
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- return $service->setSetting($params)
- ? $this->success('操作成功')
- : $this->error('操作失败');
- } else {
- $setting = $service->getSetting();
- $platform_config = PlatformSetting::getConfByGroup('system', true);
- $config['web_url'] = $platform_config['h5_url']['value'];
- $config['mall_sign'] = $this->mall['mall_sign'];
- return $this->success('操作成功', compact('setting', 'config'));
- }
- }
- return $this->render('index');
- }
- }
|