Store.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2024 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\api\service;
  13. use app\api\model\Store as StoreModel;
  14. use app\api\service\Client as ClientService;
  15. use app\api\service\Setting as SettingService;
  16. use app\common\service\BaseService;
  17. /**
  18. * 商城基础信息
  19. * Class Store
  20. * @package app\api\service
  21. */
  22. class Store extends BaseService
  23. {
  24. /**
  25. * 获取商城基础信息
  26. * @return array
  27. * @throws \think\db\exception\DataNotFoundException
  28. * @throws \think\db\exception\DbException
  29. * @throws \think\db\exception\ModelNotFoundException
  30. */
  31. public function data(): array
  32. {
  33. return [
  34. // 店铺基本信息
  35. 'storeInfo' => $this->storeInfo(),
  36. // 当前客户端名称
  37. 'client' => \getPlatform(),
  38. // 商城设置
  39. 'setting' => $this->setting(),
  40. // 客户端设置
  41. 'clientData' => $this->getClientData(),
  42. ];
  43. }
  44. /**
  45. * 客户端公共数据
  46. * @return array
  47. * @throws \think\db\exception\DataNotFoundException
  48. * @throws \think\db\exception\DbException
  49. * @throws \think\db\exception\ModelNotFoundException
  50. */
  51. private function getClientData(): array
  52. {
  53. $service = new ClientService;
  54. return $service->getPublic();
  55. }
  56. /**
  57. * 商城设置
  58. * @return array
  59. * @throws \think\db\exception\DataNotFoundException
  60. * @throws \think\db\exception\DbException
  61. * @throws \think\db\exception\ModelNotFoundException
  62. */
  63. private function setting(): array
  64. {
  65. $service = new SettingService;
  66. return $service->getPublic();
  67. }
  68. /**
  69. * 店铺基本信息(名称、简介、logo)
  70. * @return StoreModel|array|null
  71. */
  72. private function storeInfo()
  73. {
  74. return StoreModel::getInfo();
  75. }
  76. }