Setting.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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\api\service;
  13. use app\common\library\helper;
  14. use app\common\service\BaseService;
  15. use app\api\model\Setting as SettingModel;
  16. use app\common\enum\Setting as SettingEnum;
  17. /**
  18. * 服务类:商城设置
  19. * Class Setting
  20. * @package app\api\service
  21. */
  22. class Setting extends BaseService
  23. {
  24. /**
  25. * 商城公共设置
  26. * 这里的商城设置仅暴露可公开的设置项 例如分类页模板、积分名称
  27. * @return array
  28. * @throws \think\db\exception\DataNotFoundException
  29. * @throws \think\db\exception\DbException
  30. * @throws \think\db\exception\ModelNotFoundException
  31. */
  32. public function getPublic()
  33. {
  34. $data = [];
  35. //分类页模板设置
  36. // $data[SettingEnum::PAGE_CATEGORY_TEMPLATE] = $this->getCatTplStyle();
  37. // 积分设置
  38. // $data[SettingEnum::POINTS] = $this->getPoints();
  39. // 充值设置
  40. // $data[SettingEnum::RECHARGE] = $this->getRecharge();
  41. // 品牌文化
  42. $data[SettingEnum::BRAND_CULTURE] = $this->getBrandCulture();
  43. return $data;
  44. }
  45. /**
  46. * 积分设置 (积分名称、积分描述)
  47. * @return array
  48. * @throws \think\db\exception\DataNotFoundException
  49. * @throws \think\db\exception\DbException
  50. * @throws \think\db\exception\ModelNotFoundException
  51. */
  52. private function getPoints()
  53. {
  54. $values = SettingModel::getItem(SettingEnum::POINTS);
  55. return helper::pick($values, ['points_name', 'describe']);
  56. }
  57. /**
  58. * 积分设置 (积分名称、积分描述)
  59. * @return array
  60. * @throws \think\db\exception\DataNotFoundException
  61. * @throws \think\db\exception\DbException
  62. * @throws \think\db\exception\ModelNotFoundException
  63. */
  64. private function getRecharge()
  65. {
  66. $values = SettingModel::getItem(SettingEnum::RECHARGE);
  67. return helper::pick($values, ['is_entrance', 'is_custom', 'describe']);
  68. }
  69. /**
  70. * 品牌文化
  71. * @return array|mixed
  72. * @throws \think\db\exception\DataNotFoundException
  73. * @throws \think\db\exception\DbException
  74. * @throws \think\db\exception\ModelNotFoundException
  75. */
  76. private function getBrandCulture()
  77. {
  78. $values = SettingModel::getItem(SettingEnum::BRAND_CULTURE);
  79. return $values;
  80. }
  81. /**
  82. * 获取分类页模板设置
  83. * @return array|mixed
  84. * @throws \think\db\exception\DataNotFoundException
  85. * @throws \think\db\exception\DbException
  86. * @throws \think\db\exception\ModelNotFoundException
  87. */
  88. private function getCatTplStyle()
  89. {
  90. return SettingModel::getItem(SettingEnum::PAGE_CATEGORY_TEMPLATE);
  91. }
  92. }