ConfigSetting.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
  8. // +----------------------------------------------------------------------
  9. // | Author: 萤火科技 <admin@yiovo.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types = 1);
  12. namespace app\store\controller;
  13. use app\store\model\ConfigPercent;
  14. use think\facade\Log;
  15. /**
  16. * 分佣设置
  17. * Class Setting
  18. * @package app\store\controller
  19. */
  20. class ConfigSetting extends Controller
  21. {
  22. /**
  23. * 获取设置项
  24. * @return array
  25. * @throws \think\db\exception\DataNotFoundException
  26. * @throws \think\db\exception\DbException
  27. * @throws \think\db\exception\ModelNotFoundException
  28. */
  29. public function detail()
  30. {
  31. $model = new ConfigPercent();
  32. $values = $model->detail();
  33. return $this->renderSuccess($values);
  34. }
  35. /**
  36. * 更新系统设置
  37. * @param string $key
  38. * @return array
  39. * @throws \think\db\exception\DataNotFoundException
  40. * @throws \think\db\exception\DbException
  41. * @throws \think\db\exception\ModelNotFoundException
  42. */
  43. public function update()
  44. {
  45. //{"form":{"staff_percent":"15","manager_percent":"35","boss_percent":"50"}}
  46. // 保存分佣设置
  47. $model = new ConfigPercent();
  48. if ($model->edit($this->postForm())) {
  49. return $this->renderSuccess('操作成功');
  50. }
  51. return $this->renderError($model->getError() ?: '操作失败');
  52. }
  53. public function updatePlat(){
  54. //{"form":{"ticket_rate":"15","platform_rate":"35"}}
  55. $model = new ConfigPercent();
  56. Log::error("plat::".json_encode($this->postForm()));
  57. if ($model->editPlat($this->postForm())) {
  58. return $this->renderSuccess('操作成功');
  59. }
  60. return $this->renderError($model->getError() ?: '操作失败');
  61. }
  62. }