DefaultController.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace addons\StarChain\backend\controllers;
  3. use addons\StarChain\common\services\SettingService;
  4. use Yii;
  5. /**
  6. * 默认控制器
  7. *
  8. * Class DefaultController
  9. * @package addons\StarChain\backend\controllers
  10. */
  11. class DefaultController extends BaseController
  12. {
  13. /**
  14. * 设置
  15. *
  16. * @return string
  17. */
  18. public function actionIndex()
  19. {
  20. if ($this->request->isAjax) {
  21. $service = new SettingService(['mall_id' => $this->mall_id]);
  22. return $this->success('ok', $service->getBackendSetting());
  23. }
  24. return $this->render('index');
  25. }
  26. /**
  27. * 保存更改
  28. *
  29. * @return string
  30. */
  31. public function actionEdit()
  32. {
  33. if ($this->request->isAjax) {
  34. $data = $this->request->getBodyParam('setting');
  35. $service = new SettingService(['mall_id' => $this->mall_id]);
  36. unset($data['callback_url']);
  37. return $service->setSetting($data)
  38. ? $this->success('ok')
  39. : $this->error($service->error);
  40. }
  41. }
  42. }