SettingController.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace addons\Alitopay\backend\controllers;
  3. use addons\Alitopay\common\services\SettingService;
  4. /**
  5. * 代付设置
  6. * @package addons\Alitopay\backend\controllers
  7. */
  8. class SettingController extends BaseController
  9. {
  10. public $enableCsrfValidation = false;
  11. /**
  12. * @var SettingService
  13. */
  14. private $service;
  15. public function init()
  16. {
  17. parent::init();
  18. $this->service = new SettingService($this->mall_id);
  19. }
  20. /**
  21. * 设置页面
  22. *
  23. * @return void
  24. */
  25. public function actionIndex()
  26. {
  27. if ($this->request->isPost) {
  28. $data = $this->request->post();
  29. unset($data['_csrf']);
  30. return $this->service->setSetting($data)
  31. ? $this->success('ok')
  32. : $this->error($this->service->getErrorMsg());
  33. }
  34. return $this->render('index');
  35. }
  36. /**
  37. * 获取配置
  38. *
  39. * @return void
  40. */
  41. public function actionRead()
  42. {
  43. return $this->success(
  44. 'ok',
  45. ['setting' => $this->service->getSetting()]
  46. );
  47. }
  48. }