DefaultController.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace addons\Sicpay\backend\controllers;
  3. use addons\Sicpay\common\services\ConfigService;
  4. use Yii;
  5. use common\controllers\AddonsController;
  6. /**
  7. * 默认控制器
  8. *
  9. * Class DefaultController
  10. * @package addons\Sicpay\backend\controllers
  11. */
  12. class DefaultController extends BaseController
  13. {
  14. public $enableCsrfValidation = false;
  15. public $service;
  16. public function __construct ($id, $module, $config = [])
  17. {
  18. parent::__construct($id, $module, $config);
  19. $this->service = new ConfigService(['mall_id'=>$this->mall_id]);
  20. }
  21. /**
  22. * 首页
  23. *
  24. * @return string
  25. */
  26. public function actionIndex()
  27. {
  28. if(!$this->request->isAjax){
  29. return $this->render('index');
  30. }
  31. }
  32. public function actionGetConfig(){
  33. $config = $this->service->getConfig($this->mall_id);
  34. return $this->success('',empty($config) ? '' : $config);
  35. }
  36. public function actionSave(){
  37. $data = $this->request->post();
  38. $data['mall_id'] = $this->mall_id;
  39. $res = $this->service->save($data);
  40. return $res ? $this->success("操作成功") : $this->error($this->service->error);
  41. }
  42. }