SettingController.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: wniu
  5. * Date: 2022/5/31
  6. * Time: 10:08 下午
  7. */
  8. namespace addons\Pk\backend\controllers;
  9. use addons\OperatingNote\common\enums\NoteEnum;
  10. use addons\Pk\common\enums\PkEnum;
  11. use addons\Pk\common\models\PkSms;
  12. use common\models\common\PlatformSetting;
  13. class SettingController extends BaseController
  14. {
  15. public $enableCsrfValidation = false;
  16. /**
  17. * 首页
  18. *
  19. * @return string
  20. */
  21. public function actionIndex()
  22. {
  23. $retuest = \Yii::$app->request;
  24. if ($retuest->isAjax) {
  25. if ($retuest->isPost) {
  26. $params = \Yii::$app->request->post();
  27. $res = \Yii::$app->services->validate->validate($params,[
  28. [['not_allow_apply_hour','is_no_restrictions','person',], 'safe'],
  29. [['bg_img','page','is_enable','type'],'safe'],
  30. ]);
  31. if($res === false) return $this->error(\Yii::$app->services->validate->getErrorMessage());
  32. $config = \Yii::$app->services->setting->addons->set($this->mall_id, PkEnum::ADDONS_NAME, ['basic' => $params]);
  33. $this->success('保存成功', $config);
  34. } else {
  35. // 获取配置
  36. $config = \Yii::$app->services->setting->addons->get($this->mall_id, PkEnum::ADDONS_NAME, 'basic');
  37. $Platform_config = PlatformSetting::getConfByGroup( 'system', true);
  38. $config['web_url'] = $Platform_config['h5_url']['value'].'/#/plugins2/Pk/index?sign='.$this->mall['mall_sign'];
  39. $this->success('获取成功',$config);
  40. }
  41. }
  42. return $this->render($this->action->id);
  43. }
  44. public function actionSmsDetail()
  45. {
  46. $params = \Yii::$app->request->get();
  47. $mall_id = $this->mall_id;
  48. $one = PkSms::find()->where(['sms_key' => $params['sms_key'], 'mall_id' => $mall_id])->one();
  49. if (!$one) {
  50. $one = PkSms::def();
  51. }
  52. return $this->success('success', $one);
  53. }
  54. public function actionSmsEdit()
  55. {
  56. $params = \Yii::$app->request->post();
  57. $params['mall_id'] = $this->mall_id;
  58. $model = PkSms::setData($params);
  59. return $this->success('success', $model);
  60. }
  61. }