ShopSettingLogic.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  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. namespace app\adminapi\logic\settings\shop;
  20. use app\common\enum\YesNoEnum;
  21. use app\common\logic\BaseLogic;
  22. use app\common\service\ConfigService;
  23. use app\common\service\FileService;
  24. use app\common\service\RegionService;
  25. use think\facade\Request;
  26. class ShopSettingLogic extends BaseLogic
  27. {
  28. /**
  29. * @notes 获取店铺信息
  30. * @return array
  31. * @author Tab
  32. * @date 2021/7/28 14:19
  33. */
  34. public static function getShopInfo()
  35. {
  36. $config = [
  37. 'name' => ConfigService::get('shop', 'name'),
  38. 'logo' => ConfigService::get('shop', 'logo'),
  39. 'mobile_logo' => ConfigService::get('shop','mobile_logo'),
  40. 'pc_logo' => ConfigService::get('shop','pc_logo'),
  41. 'admin_login_image' => ConfigService::get('shop', 'admin_login_image'),
  42. 'login_restrictions' => ConfigService::get('shop', 'login_restrictions'),
  43. 'password_error_times' => ConfigService::get('shop', 'password_error_times'),
  44. 'limit_login_time' => ConfigService::get('shop', 'limit_login_time'),
  45. 'status' => ConfigService::get('shop', 'status'),
  46. 'close_example_image' => ConfigService::get('shop', 'close_example_image'),
  47. 'logo_example_image' => ConfigService::get('shop', 'logo_example_image'),
  48. 'login_example_image' => ConfigService::get('shop', 'login_example_image'),
  49. 'mall_contact' => ConfigService::get('shop', 'mall_contact', ''),
  50. 'mall_contact_mobile' => ConfigService::get('shop', 'mall_contact_mobile', ''),
  51. // 'return_contact' => ConfigService::get('shop', 'return_contact', ''),
  52. // 'return_contact_mobile' => ConfigService::get('shop', 'return_contact_mobile', ''),
  53. // 'return_province' => ConfigService::get('shop', 'return_province', ''),
  54. // 'return_city' => ConfigService::get('shop', 'return_city', ''),
  55. // 'return_district' => ConfigService::get('shop', 'return_district', ''),
  56. // 'return_address' => ConfigService::get('shop', 'return_address', ''),
  57. 'favicon' => ConfigService::get('shop','favicon'),
  58. 'document_status' => ConfigService::get('shop','document_status',1),
  59. ];
  60. $config['logo'] = FileService::getFileUrl($config['logo']);
  61. $config['mobile_logo'] = FileService::getFileUrl($config['mobile_logo']);
  62. $config['pc_logo'] = FileService::getFileUrl($config['pc_logo']);
  63. $config['favicon'] = FileService::getFileUrl($config['favicon']);
  64. $config['admin_login_image'] = FileService::getFileUrl($config['admin_login_image']);
  65. $config['close_example_image'] = FileService::getFileUrl($config['close_example_image']);
  66. $config['logo_example_image'] = FileService::getFileUrl($config['logo_example_image']);
  67. $config['login_example_image'] = FileService::getFileUrl($config['login_example_image']);
  68. // $config['address'] = RegionService::getAddress([$config['return_province'], $config['return_city'], $config['return_district']], $config['return_address']);
  69. return $config;
  70. }
  71. /**
  72. * @notes 设置店铺信息
  73. * @param $params
  74. * @author Tab
  75. * @date 2021/7/28 14:47
  76. */
  77. public static function setShopInfo($params)
  78. {
  79. $params['logo'] = FileService::setFileUrl($params['logo']);
  80. $params['admin_login_image'] = FileService::setFileUrl($params['admin_login_image']);
  81. $params['favicon'] = FileService::setFileUrl($params['favicon']);
  82. ConfigService::set('shop','name', $params['name']);
  83. ConfigService::set('shop','logo', $params['logo']);
  84. ConfigService::set('shop','mobile_logo', $params['mobile_logo']);
  85. ConfigService::set('shop','pc_logo', $params['pc_logo']);
  86. ConfigService::set('shop','favicon', $params['favicon']);
  87. ConfigService::set('shop','admin_login_image', $params['admin_login_image']);
  88. ConfigService::set('shop','login_restrictions', $params['login_restrictions']);
  89. ConfigService::set('shop','status', $params['status']);
  90. ConfigService::set('shop','mall_contact', $params['mall_contact']);
  91. ConfigService::set('shop','mall_contact_mobile', $params['mall_contact_mobile']);
  92. // ConfigService::set('shop','return_contact', $params['return_contact']);
  93. // ConfigService::set('shop','return_contact_mobile', $params['return_contact_mobile']);
  94. // ConfigService::set('shop','return_province', $params['return_province']);
  95. // ConfigService::set('shop','return_city', $params['return_city']);
  96. // ConfigService::set('shop','return_district', $params['return_district']);
  97. // ConfigService::set('shop','return_address', $params['return_address']);
  98. if($params['login_restrictions']) {
  99. ConfigService::set('shop','password_error_times', $params['password_error_times']);
  100. ConfigService::set('shop','limit_login_time', $params['limit_login_time']);
  101. }
  102. //文档信息开关
  103. ConfigService::set('shop','document_status', $params['document_status']);
  104. }
  105. /**
  106. * @notes 获取备案信息
  107. * @param $params
  108. * @return array
  109. * @author Tab
  110. * @date 2021/7/28 15:08
  111. */
  112. public static function getRecordInfo()
  113. {
  114. $config = [
  115. 'copyright' => ConfigService::get('shop', 'copyright', ''),
  116. 'record_number' => ConfigService::get('shop', 'record_number', ''),
  117. 'record_system_link' => ConfigService::get('shop', 'record_system_link', ''),
  118. // 'business_license' => ConfigService::get('shop', 'business_license'),
  119. // 'other_qualifications' => ConfigService::get('shop', 'other_qualifications',[]),
  120. 'copyright2' => ConfigService::get('shop', 'copyright2', ''),
  121. 'copyright_auth' => ConfigService::get('shop', 'copyright_auth', []) ? : [
  122. 'type' => "1",
  123. 'list' => [
  124. [ 'image' => '', 'name' =>'', 'link' => '' ],
  125. ]
  126. ],
  127. ];
  128. return $config;
  129. }
  130. /**
  131. * @notes 设置备案信息
  132. * @param $params
  133. * @author Tab
  134. * @date 2021/7/28 15:14
  135. */
  136. public static function setRecordInfo($params)
  137. {
  138. ConfigService::set('shop', 'copyright', $params['copyright'] ?? '');
  139. ConfigService::set('shop', 'record_number', $params['record_number'] ?? '');
  140. ConfigService::set('shop', 'record_system_link', $params['record_system_link'] ?? '');
  141. ConfigService::set('shop', 'copyright2', $params['copyright2'] ?? '');
  142. ConfigService::set('shop', 'copyright_auth', $params['copyright_auth'] ?? []);
  143. return true;
  144. }
  145. /**
  146. * @notes 获取分享设置
  147. * @return array
  148. * @author Tab
  149. * @date 2021/7/28 15:29
  150. */
  151. public static function getShareSetting()
  152. {
  153. $config = [
  154. 'share_page' => ConfigService::get('shop', 'share_page'),
  155. 'share_title' => ConfigService::get('shop', 'share_title', ''),
  156. 'share_intro' => ConfigService::get('shop', 'share_intro', ''),
  157. 'share_image' => ConfigService::get('shop', 'share_image'),
  158. ];
  159. $config['share_image'] = $config['share_image'] ? FileService::getFileUrl($config['share_image']) : '';
  160. return $config;
  161. }
  162. /**
  163. * @notes 分享设置
  164. * @param $params
  165. * @author Tab
  166. * @date 2021/7/28 15:37
  167. */
  168. public static function setShareSetting($params)
  169. {
  170. ConfigService::set('shop', 'share_page', $params['share_page']);
  171. ConfigService::set('shop', 'share_title', $params['share_title'] ?? '');
  172. ConfigService::set('shop', 'share_intro', $params['share_intro'] ?? '');
  173. ConfigService::set('shop', 'share_image', FileService::setFileUrl($params['share_image']));
  174. }
  175. /**
  176. * @notes 获取政策协议
  177. * @return array
  178. * @author Tab
  179. * @date 2021/7/28 16:08
  180. */
  181. public static function getPolicyAgreement()
  182. {
  183. $config = [
  184. 'service_agreement_name' => ConfigService::get('shop', 'service_agreement_name', ''),
  185. 'service_agreement_content' => ConfigService::get('shop', 'service_agreement_content', ''),
  186. 'privacy_policy_name' => ConfigService::get('shop', 'privacy_policy_name', ''),
  187. 'privacy_policy_content' => ConfigService::get('shop', 'privacy_policy_content', ''),
  188. 'user_delete_name' => ConfigService::get('shop', 'user_delete_name', ''),
  189. 'user_delete_content' => ConfigService::get('shop', 'user_delete_content', ''),
  190. ];
  191. return $config;
  192. }
  193. /**
  194. * @notes 设置政策协议
  195. * @param $params
  196. * @author Tab
  197. * @date 2021/7/28 16:13
  198. */
  199. public static function setPolicyAgreement($params)
  200. {
  201. if(isset($params['service_agreement_name']) && isset($params['service_agreement_content'])) {
  202. ConfigService::set('shop', 'service_agreement_name', $params['service_agreement_name']);
  203. ConfigService::set('shop', 'service_agreement_content', $params['service_agreement_content']);
  204. }
  205. if(isset($params['privacy_policy_name']) && isset($params['privacy_policy_content'])) {
  206. ConfigService::set('shop', 'privacy_policy_name', $params['privacy_policy_name']);
  207. ConfigService::set('shop', 'privacy_policy_content', $params['privacy_policy_content']);
  208. }
  209. if(isset($params['user_delete_name']) && isset($params['user_delete_content'])) {
  210. ConfigService::set('shop', 'user_delete_name', $params['user_delete_name']);
  211. ConfigService::set('shop', 'user_delete_content', $params['user_delete_content']);
  212. }
  213. }
  214. /**
  215. * @notes 设置地图秘钥
  216. * @param array $params
  217. * @return bool
  218. * @author ljj
  219. * @date 2022/3/10 5:11 下午
  220. */
  221. public static function setMapKey(array $params)
  222. {
  223. ConfigService::set('map', 'tencent_map_key', $params['tencent_map_key'] ?? '');
  224. return true;
  225. }
  226. /**
  227. * @notes 获取地图秘钥
  228. * @return array
  229. * @author ljj
  230. * @date 2022/3/10 5:12 下午
  231. */
  232. public static function getMapKey(): array
  233. {
  234. return [
  235. 'tencent_map_key' => ConfigService::get('map', 'tencent_map_key',''),
  236. ];
  237. }
  238. /**
  239. * @notes 获取站点统计配置
  240. * @return array
  241. * @author yfdong
  242. * @date 2024/09/20 22:25
  243. */
  244. public static function getSiteStatistics()
  245. {
  246. return [
  247. 'clarity_code' => ConfigService::get('siteStatistics', 'clarity_code')
  248. ];
  249. }
  250. /**
  251. * @notes 设置站点统计配置
  252. * @param array $params
  253. * @return void
  254. * @author yfdong
  255. * @date 2024/09/20 22:31
  256. */
  257. public static function setSiteStatistics($params)
  258. {
  259. ConfigService::set('siteStatistics', 'clarity_code', $params['clarity_code']);
  260. }
  261. }