Config.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2015-2025 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. * @author : niuteam
  10. */
  11. namespace app\api\controller;
  12. use app\model\express\Config as ExpressConfig;
  13. use app\model\goods\Cart as CartModel;
  14. use app\model\system\Promotion as PrmotionModel;
  15. use app\model\system\Servicer;
  16. use app\model\web\Config as ConfigModel;
  17. class Config extends BaseApi
  18. {
  19. /**
  20. * 详情信息
  21. */
  22. public function defaultimg()
  23. {
  24. $upload_config_model = new ConfigModel();
  25. $res = $upload_config_model->getDefaultImg($this->site_id, 'shop');
  26. if (!empty($res[ 'data' ][ 'value' ])) {
  27. return $this->response($this->success($res[ 'data' ][ 'value' ]));
  28. } else {
  29. return $this->response($this->error());
  30. }
  31. }
  32. /**
  33. * 版权信息
  34. */
  35. public function copyright()
  36. {
  37. $config_model = new ConfigModel();
  38. $res = $config_model->getCopyright($this->site_id, 'shop');
  39. return $this->response($this->success($res[ 'data' ][ 'value' ]));
  40. }
  41. /**
  42. * 获取当前时间戳
  43. * @return false|string
  44. */
  45. public function time()
  46. {
  47. $time = time();
  48. return $this->response($this->success($time));
  49. }
  50. /**
  51. * 获取验证码配置
  52. */
  53. public function getCaptchaConfig()
  54. {
  55. $config_model = new ConfigModel();
  56. $info = $config_model->getCaptchaConfig();
  57. return $this->response($this->success($info));
  58. }
  59. /**
  60. * 客服配置
  61. */
  62. public function servicer()
  63. {
  64. $servicer_model = new Servicer();
  65. $result = $servicer_model->getServicerConfig()[ 'data' ] ?? [];
  66. return $this->response($this->success($result[ 'value' ] ?? []));
  67. }
  68. public function init()
  69. {
  70. $cart_count = 0;
  71. $token = $this->checkToken();
  72. if ($token[ 'code' ] >= 0) {
  73. // 购物车数量
  74. $cart = new CartModel();
  75. $condition = [
  76. [ 'gc.member_id', '=', $token[ 'data' ][ 'member_id' ] ],
  77. [ 'gc.site_id', '=', $this->site_id ],
  78. [ 'gs.goods_state', '=', 1 ],
  79. [ 'gs.is_delete', '=', 0 ]
  80. ];
  81. $list = $cart->getCartList($condition, 'gc.num');
  82. $list = $list[ 'data' ];
  83. $count = 0;
  84. foreach ($list as $k => $v) {
  85. $count += $v[ 'num' ];
  86. }
  87. }
  88. // 商城风格
  89. $diy_view_api = new Diyview();
  90. $diy_style = json_decode($diy_view_api->style(), true)[ 'data' ][ 'value' ];
  91. // 底部导航
  92. $diy_bottom_nav = json_decode($diy_view_api->bottomNav(), true)[ 'data' ][ 'value' ];
  93. // 插件存在性
  94. $addon_api = new Addon();
  95. $addon_is_exist = json_decode($addon_api->addonIsExit(), true)[ 'data' ];
  96. // 默认图
  97. $config_model = new ConfigModel();
  98. $default_img = $config_model->getDefaultImg($this->site_id, 'shop')[ 'data' ][ 'value' ];
  99. // 版权信息
  100. $copyright = $config_model->getCopyright($this->site_id, 'shop')[ 'data' ][ 'value' ];
  101. $site_api = new Site();
  102. $site_info = json_decode($site_api->info(), true)[ 'data' ];
  103. $servicer = json_decode($this->servicer(), true)[ 'data' ];
  104. $this->initStoreData();
  105. $res = [
  106. 'cart_count' => $cart_count,
  107. 'style_theme' => $diy_style,
  108. 'diy_bottom_nav' => $diy_bottom_nav,
  109. 'addon_is_exist' => $addon_is_exist,
  110. 'default_img' => $default_img,
  111. 'copyright' => $copyright,
  112. 'site_info' => $site_info,
  113. 'servicer' => $servicer,
  114. 'store_config' => $this->store_data[ 'config' ]
  115. ];
  116. if (!empty($this->store_data[ 'store_info' ])) {
  117. $res[ 'store_info' ] = $this->store_data[ 'store_info' ];
  118. }
  119. return $this->response($this->success($res));
  120. }
  121. /**
  122. * 获取pc首页商品分类配置
  123. * @return false|string
  124. */
  125. public function categoryconfig()
  126. {
  127. $config_model = new ConfigModel();
  128. $config_info = $config_model->getCategoryConfig($this->site_id);
  129. return $this->response($this->success($config_info[ 'data' ][ 'value' ]));
  130. }
  131. /**
  132. *
  133. * @return false|string
  134. */
  135. public function enabledExpressType()
  136. {
  137. $express_type = ( new ExpressConfig() )->getEnabledExpressType($this->site_id);
  138. return $this->response($this->success($express_type));
  139. }
  140. /**
  141. * 获取活动专区页面配置
  142. * @return false|string
  143. */
  144. public function promotionZoneConfig()
  145. {
  146. $name = isset($this->params[ 'name' ]) ? $this->params[ 'name' ] : ''; // 活动名称标识
  147. $promotion_model = new PrmotionModel();
  148. $res = $promotion_model->getPromotionZoneConfig($name, $this->site_id)[ 'data' ][ 'value' ];
  149. return $this->response($this->success($res));
  150. }
  151. }