Config.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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\supplier\system;
  12. use app\controller\supplier\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\supplier\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], 2, (int)$this->supplierId));
  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,2, (int)$this->supplierId);
  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. $supplier_id = (int)$this->supplierId;
  75. return $this->success($services->getFormBuildRule($name, 2, $supplier_id));
  76. }
  77. /**
  78. * @param string $type
  79. * @return mixed
  80. */
  81. public function getFormBuild(StoreConfigServices $services, string $type)
  82. {
  83. $supplier_id = (int)$this->supplierId;
  84. return $this->success($services->getFormBuildRule($type, 2, $supplier_id));
  85. }
  86. }