Setting.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. $trade = SettingModel::getItem('trade');
  47. $trade = [
  48. 'locked'=>isset($trade['locked'])? $trade['locked'] : ['locked_cost'=>0],
  49. 'books'=>isset($trade['books'])? $trade['books'] : ['book_cost'=>0,'book_limit'=>0,'fields'=>[]],
  50. ];
  51. return $this->renderSuccess(compact('payment','trade'));
  52. }
  53. }