| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
- /**
- * Created by PhpStorm.
- * User: wniu
- * Date: 2022/5/31
- * Time: 10:08 下午
- */
- namespace addons\Coupon\backend\controllers;
- use addons\Coupon\common\enums\AddonsCouponEnum;
- use addons\Coupon\common\services\SettingService;
- use common\enums\AddonsEnum;
- use common\models\common\PlatformSetting;
- use common\helpers\ApiCode;
- class SettingController extends BaseController
- {
- public $enableCsrfValidation = false;
- /**
- * 首页
- *
- * @return string
- */
- public function actionIndex()
- {
- $retuest = \Yii::$app->request;
- $settingService = new SettingService(['mall_id' => $this->mall_id]);
- if ($retuest->isAjax) {
- if ($retuest->isPost) {
- $params = \Yii::$app->request->post();
- $res = \Yii::$app->services->validate->validate($params,[
- [['give_type', 'is_effective_coupon_give'], 'safe'],
- ]);
- if($res === false) return $this->error(\Yii::$app->services->validate->getErrorMessage());
- $config = $settingService->setSetting($params);
- $this->success('保存成功', $config);
- } else {
- // 获取配置
- $config = $settingService->getSetting();
- $this->success('获取成功',$config,ApiCode::CODE_SUCCESS,0);
- }
- }
- return $this->render($this->action->id);
- }
- public function actionSmsDetail()
- {
- $params = \Yii::$app->request->get();
- $mall_id = $this->mall_id;
- $one = PkSms::find()->where(['sms_key' => $params['sms_key'], 'mall_id' => $mall_id])->one();
- if (!$one) {
- $one = PkSms::def();
- }
- return $this->success('success', $one);
- }
- public function actionSmsEdit()
- {
- $params = \Yii::$app->request->post();
- $params['mall_id'] = $this->mall_id;
- $model = PkSms::setData($params);
- return $this->success('success', $model);
- }
- }
|