ConfigLogic.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop100%开源免费商用商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | 商业版本务必购买商业授权,以免引起法律纠纷
  8. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  9. // | gitee下载:https://gitee.com/likeshop_gitee
  10. // | github下载:https://github.com/likeshop-github
  11. // | 访问官网:https://www.likeshop.cn
  12. // | 访问社区:https://home.likeshop.cn
  13. // | 访问手册:http://doc.likeshop.cn
  14. // | 微信公众号:likeshop技术社区
  15. // | likeshop团队 版权所有 拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshopTeam
  18. // +----------------------------------------------------------------------
  19. // +----------------------------------------------------------------------
  20. // | likeshop100%开源免费商用商城系统
  21. // +----------------------------------------------------------------------
  22. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  23. // | 开源版本可自由商用,可去除界面版权logo
  24. // | 商业版本务必购买商业授权,以免引起法律纠纷
  25. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  26. // | gitee下载:https://gitee.com/likeshop_gitee
  27. // | github下载:https://github.com/likeshop-github
  28. // | 访问官网:https://www.likeshop.cn
  29. // | 访问社区:https://home.likeshop.cn
  30. // | 访问手册:http://doc.likeshop.cn
  31. // | 微信公众号:likeshop技术社区
  32. // | likeshop团队 版权所有 拥有最终解释权
  33. // +----------------------------------------------------------------------
  34. // | author: likeshopTeam
  35. // +----------------------------------------------------------------------
  36. namespace app\shopapi\logic;
  37. use app\common\enum\DistributionConfigEnum;
  38. use app\common\model\DevShare;
  39. use app\common\model\DistributionConfig;
  40. use app\common\service\{
  41. FileService,
  42. ConfigService,
  43. };
  44. /**
  45. * 配置逻辑层
  46. * Class CollectLogic
  47. * @package app\common\logic
  48. */
  49. class ConfigLogic
  50. {
  51. /**
  52. * @notes 获取商城配置
  53. * @return array
  54. * @author cjhao
  55. * @date 2021/8/28 17:23
  56. */
  57. public function getConfig():array
  58. {
  59. $share_image = ConfigService::get('shop', 'share_image');
  60. $favicon = ConfigService::get('shop', 'favicon');
  61. $config = [
  62. //注册方式
  63. 'register_way' => ConfigService::get('config', 'register_way', config('project.login.register_way')),
  64. //登录方式
  65. 'login_way' => ConfigService::get('config', 'login_way',config('project.login.login_way')),
  66. //手机号码注册需验证码
  67. 'is_mobile_register_code' => ConfigService::get('config', 'is_mobile_register_code', config('project.login.is_mobile_register_code')),
  68. //注册强制绑定手机
  69. 'coerce_mobile' => ConfigService::get('config', 'coerce_mobile', config('project.login.coerce_mobile')),
  70. //公众号微信授权登录
  71. 'h5_wechat_auth' => ConfigService::get('config', 'h5_wechat_auth', config('project.login.h5_wechat_auth')),
  72. //公众号自动微信授权登录
  73. 'h5_auto_wechat_auth' => ConfigService::get('config', 'h5_auto_wechat_auth', config('project.login.h5_auto_wechat_auth')),
  74. //小程序微信授权登录
  75. 'mnp_wechat_auth' => ConfigService::get('config', 'mnp_wechat_auth', config('project.login.mnp_wechat_auth')),
  76. //小程序自动微信授权登录
  77. 'mnp_auto_wechat_auth' => ConfigService::get('config', 'mnp_auto_wechat_auth', config('project.login.mnp_auto_wechat_auth')),
  78. //字节小程序授权登录
  79. 'toutiao_auth' => ConfigService::get('config', 'toutiao_auth', config('project.login.toutiao_auth')),
  80. //字节小程序自动授权登录
  81. 'toutiao_auto_auth' => ConfigService::get('config', 'toutiao_auto_auth', config('project.login.toutiao_auto_auth')),
  82. //APP微信授权登录
  83. 'app_wechat_auth' => ConfigService::get('config', 'app_wechat_auth', config('project.login.app_wechat_auth')),
  84. //oss域名
  85. 'oss_domain' => FileService::getFileUrl(),
  86. //店铺logo
  87. 'logo' => FileService::getFileUrl(ConfigService::get('shop', 'mobile_logo')),
  88. //分享页面
  89. 'share_page' => ConfigService::get('shop', 'share_page'),
  90. //分享标题
  91. 'share_title' => ConfigService::get('shop', 'share_title', ''),
  92. //分享简介
  93. 'share_intro' => ConfigService::get('shop', 'share_intro', ''),
  94. //分享图片
  95. 'share_image' => $share_image ? FileService::getFileUrl($share_image) : '',
  96. // 小程序商城关闭状态
  97. 'mnp_status' => ConfigService::get('shop', 'status', 1),
  98. // H5商城关闭状态
  99. 'h5_status' => ConfigService::get('h5', 'status', 1),
  100. // PC商城关闭状态
  101. 'pc_status' => ConfigService::get('pc', 'status', 1),
  102. // 版权信息
  103. 'copyright' => ConfigService::get('shop', 'copyright', ''),
  104. // 备案号
  105. 'record_number' => ConfigService::get('shop', 'record_number', ''),
  106. // 备案链接
  107. 'record_system_link' => ConfigService::get('shop', 'record_system_link', ''),
  108. // 客服请求域名
  109. 'ws_domain' => env('project.ws_domain', 'ws:127.0.0.1'),
  110. //app协议弹出
  111. 'app_pop_agreement' => ConfigService::get('app','pop_agreement',1),
  112. // app微信登录
  113. // 'wechat_login' => ConfigService::get('app','wechat_login',1),
  114. 'area_js' => '/resource/js/area.js',
  115. 'shop_name' => ConfigService::get('shop', 'name'),
  116. 'domain' => request()->domain(true),
  117. 'favicon' => $favicon ? FileService::getFileUrl($favicon) : '',
  118. // 发货配置
  119. 'mini_express_send_sync' => ConfigService::get('mini_program', 'express_send_sync', 1),
  120. // 站点统计
  121. 'site_statistic' => [
  122. 'clarity_app_id' => ConfigService::get('site_statistic', 'clarity_app_id', '')
  123. ],
  124. 'area_flag' => ConfigService::get('shop', 'area_flag'),
  125. ];
  126. return $config;
  127. }
  128. /**
  129. * @notes 获取政策协议
  130. * @return array|string
  131. * @author Tab
  132. * @date 2021/7/28 16:08
  133. */
  134. public function getPolicyAgreement()
  135. {
  136. $params = request()->get();
  137. // 服务协议
  138. if (isset($params['type']) && $params['type'] == 1) {
  139. return [
  140. 'content' => ConfigService::get('shop', 'service_agreement_content', ''),
  141. 'name' => ConfigService::get('shop', 'service_agreement_name', ''),
  142. ];
  143. }
  144. // 隐私政策
  145. if (isset($params['type']) && $params['type'] == 2) {
  146. return [
  147. 'content' => ConfigService::get('shop', 'privacy_policy_content', ''),
  148. 'name' => ConfigService::get('shop', 'privacy_policy_name', ''),
  149. ];
  150. }
  151. // 分销协议
  152. if (isset($params['type']) && $params['type'] == 3) {
  153. $dbConfig = DistributionConfig::column('value', 'key');
  154. return [
  155. 'content' => $dbConfig['protocol_content'] ?? DistributionConfigEnum::DEFAULT_PROTOCOL_CONTENT,
  156. 'name' => $dbConfig['protocol_name'] ?? '分销协议',
  157. ];
  158. }
  159. //注销协议
  160. if (isset($params['type']) && $params['type'] == 4) {
  161. return [
  162. 'content' => ConfigService::get('shop', 'user_delete_content', ''),
  163. 'name' => ConfigService::get('shop', 'user_delete_name', ''),
  164. ];
  165. }
  166. return [ 'content' => '', 'name' => '' ];
  167. }
  168. /**
  169. * @notes 版权资质
  170. * @return array|int|mixed|string|null
  171. * @author ljj
  172. * @date 2022/2/22 11:49 上午
  173. */
  174. public function copyright()
  175. {
  176. $business_license = ConfigService::get('shop', 'business_license');
  177. $other_qualifications = ConfigService::get('shop', 'other_qualifications',[]);
  178. if (!empty($business_license)) {
  179. array_unshift($other_qualifications,$business_license);
  180. }
  181. if (!empty($other_qualifications)) {
  182. foreach ($other_qualifications as &$val) {
  183. $val = FileService::getFileUrl($val);
  184. }
  185. }
  186. return $other_qualifications;
  187. }
  188. /**
  189. * @notes 获取客服配置
  190. * @return array
  191. * @author ljj
  192. * @date 2024/8/28 下午4:06
  193. */
  194. public function getKefuConfig()
  195. {
  196. $defaultData = [
  197. 'way' => 1,
  198. 'name' => '',
  199. 'remarks' => '',
  200. 'phone' => '',
  201. 'business_time' => '',
  202. 'qr_code' => '',
  203. 'enterprise_id' => '',
  204. 'kefu_link' => ''
  205. ];
  206. $config = [
  207. 'mnp' => ConfigService::get('kefu_config', 'mnp', $defaultData),
  208. 'oa' => ConfigService::get('kefu_config', 'oa', $defaultData),
  209. 'h5' => ConfigService::get('kefu_config', 'h5', $defaultData),
  210. 'pc' => ConfigService::get('kefu_config', 'pc', $defaultData),
  211. 'app' => ConfigService::get('kefu_config', 'app', $defaultData),
  212. ];
  213. if (!empty($config['mnp']['qr_code'])) $config['mnp']['qr_code'] = FileService::getFileUrl($config['mnp']['qr_code']);
  214. if (!empty($config['oa']['qr_code'])) $config['oa']['qr_code'] = FileService::getFileUrl($config['oa']['qr_code']);
  215. if (!empty($config['h5']['qr_code'])) $config['h5']['qr_code'] = FileService::getFileUrl($config['h5']['qr_code']);
  216. if (!empty($config['pc']['qr_code'])) $config['pc']['qr_code'] = FileService::getFileUrl($config['pc']['qr_code']);
  217. if (!empty($config['app']['qr_code'])) $config['app']['qr_code'] = FileService::getFileUrl($config['app']['qr_code']);
  218. return $config;
  219. }
  220. /**
  221. * @notes 获取分享配置
  222. * @return array
  223. * @throws \think\db\exception\DataNotFoundException
  224. * @throws \think\db\exception\DbException
  225. * @throws \think\db\exception\ModelNotFoundException
  226. * @author ljj
  227. * @date 2024/9/11 下午3:20
  228. */
  229. public function getShareConfig()
  230. {
  231. $lists = DevShare::field('*')
  232. ->append(['type_desc','page_desc'])
  233. ->select()
  234. ->toArray();
  235. return $lists;
  236. }
  237. }