| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- namespace addons\WechatVideoShop\backend\controllers;
- use addons\WechatVideoShop\common\service\SettingService;
- use addons\WechatVideoShop\common\service\ShopService;
- use Yii;
- use common\controllers\AddonsController;
- use yii\helpers\Json;
- /**
- * 默认控制器
- *
- * Class DefaultController
- * @package addons\WechatVideoShop\backend\controllers
- */
- class SettingController extends BaseController
- {
- public $enableCsrfValidation = false;
- /**
- * 首页
- *
- * @return string
- */
- public function actionIndex()
- {
- if (Yii::$app->request->isAjax) {
- $service = (new SettingService());
- if (Yii::$app->request->isPost) {
- $data = Yii::$app->request->post();
- $valid = Yii::$app->services->validate->validate($data, [
- [['is_enable', 'settlement_type', 'compute_type', 'is_open_level_limit',
- 'reward_commission_type', 'reward_score_type', 'is_show_at_center', 'sharer_default_apply_shop_id'], 'integer'],
- [['reward_commission', 'reward_score'], 'number'],
- ]);
- if ($valid === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- return $service->save($this->mall_id, $data) ? $this->success("保存成功", $data) : $this->error('保存失败');
- } else {
- $ret = $service->get($this->mall_id);
- return $this->success('success', $ret);
- }
- }
- $shop = (new ShopService())->ShopArr($this->mall_id, false);
- return $this->render('index',['shop' => Json::encode($shop)]);
- }
- }
|