Config.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\controller\store\system;
  12. use app\controller\store\AuthController;
  13. use app\services\store\StoreConfigServices;
  14. use app\services\system\config\SystemConfigServices;
  15. use app\services\system\config\SystemConfigTabServices;
  16. use think\facade\App;
  17. use app\Request;
  18. /**
  19. * Class Config
  20. * @package app\controller\store\system
  21. */
  22. class Config extends AuthController
  23. {
  24. /**
  25. * Config constructor.
  26. * @param App $app
  27. * @param SystemConfigServices $services
  28. */
  29. public function __construct(App $app, SystemConfigServices $services)
  30. {
  31. parent::__construct($app);
  32. $this->services = $services;
  33. }
  34. /**
  35. * 获取门店配置
  36. * @param $type
  37. * @param StoreConfigServices $services
  38. * @return mixed
  39. */
  40. public function getConfig($type, StoreConfigServices $services)
  41. {
  42. if (!isset(StoreConfigServices::CONFIG_TYPE[$type])) {
  43. return $this->fail('类型不正确');
  44. }
  45. return $this->success($services->getConfigAll(StoreConfigServices::CONFIG_TYPE[$type], 1, (int)$this->storeId));
  46. }
  47. /**
  48. * 保存数据
  49. * @param StoreConfigServices $services
  50. * @return mixed
  51. */
  52. public function save(StoreConfigServices $services)
  53. {
  54. $data = $this->request->post();
  55. $services->saveConfig($data,1, (int)$this->storeId);
  56. \crmeb\services\SystemConfigService::clear();
  57. return $this->success('修改成功');
  58. }
  59. /**
  60. * 基础配置
  61. * @param Request $request
  62. * @param StoreConfigServices $services
  63. * @return mixed
  64. * @throws \think\db\exception\DataNotFoundException
  65. * @throws \think\db\exception\DbException
  66. * @throws \think\db\exception\ModelNotFoundException
  67. */
  68. public function edit_basics(Request $request, StoreConfigServices $services)
  69. {
  70. $name = $this->request->param('name', '');
  71. if (!$name) {
  72. return $this->fail('参数错误');
  73. }
  74. $store_id = $this->storeId;
  75. return $this->success($services->getFormBuildRule($name, 1, $store_id));
  76. }
  77. /**
  78. * @param string $type
  79. * @return mixed
  80. */
  81. public function getFormBuild(StoreConfigServices $services, string $type)
  82. {
  83. $store_id = (int)$this->storeId;
  84. return $this->success($services->getFormBuildRule($type, 1, $store_id));
  85. }
  86. }