Setting.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2021 https://www.thinkphp.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
  8. // +----------------------------------------------------------------------
  9. // | Author: thinkphp <admin@yiovo.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types = 1);
  12. namespace app\api\controller;
  13. use app\api\service\Payment;
  14. use app\api\service\Setting as SettingService;
  15. use app\store\model\Setting as SettingModel;
  16. /**
  17. * 商城设置控制器
  18. * Class Setting
  19. * @package app\store\controller
  20. */
  21. class Setting extends Controller
  22. {
  23. /**
  24. * 商城公共设置(仅展示可公开的信息)
  25. * @return array|\think\response\Json
  26. * @throws \think\db\exception\DataNotFoundException
  27. * @throws \think\db\exception\DbException
  28. * @throws \think\db\exception\ModelNotFoundException
  29. */
  30. public function data()
  31. {
  32. $service = new SettingService;
  33. $setting = $service->getPublic();
  34. return $this->renderSuccess(compact('setting'));
  35. }
  36. /**
  37. * @return \think\response\Json
  38. * @throws \app\common\exception\BaseException
  39. * @throws \think\db\exception\DataNotFoundException
  40. * @throws \think\db\exception\DbException
  41. * @throws \think\db\exception\ModelNotFoundException
  42. */
  43. public function payment()
  44. {
  45. $payment = Payment::getPaySetting();
  46. $platform = SettingModel::getItem('platform');
  47. $platform['locked'] = isset($platform['locked'])? $platform['locked'] : ['locked_cost'=>0];
  48. $platform['books'] = isset($platform['books'])? $platform['books'] : ['book_cost'=>0,'book_limit'=>0,'fields'=>[]];
  49. return $this->renderSuccess(compact('payment','platform'));
  50. }
  51. }