ShopSettingLogic.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  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. ];
  121. $config['business_license'] = $config['business_license'] ? FileService::getFileUrl($config['business_license']) : '';
  122. if (!empty($config['other_qualifications'])) {
  123. foreach ($config['other_qualifications'] as &$val) {
  124. $val = FileService::getFileUrl($val);
  125. }
  126. }
  127. return $config;
  128. }
  129. /**
  130. * @notes 设置备案信息
  131. * @param $params
  132. * @author Tab
  133. * @date 2021/7/28 15:14
  134. */
  135. public static function setRecordInfo($params)
  136. {
  137. ConfigService::set('shop', 'copyright', $params['copyright'] ?? '');
  138. ConfigService::set('shop', 'record_number', $params['record_number'] ?? '');
  139. ConfigService::set('shop', 'record_system_link', $params['record_system_link'] ?? '');
  140. ConfigService::set('shop', 'business_license', FileService::setFileUrl($params['business_license'] ?? ''));
  141. $other_qualifications = [];
  142. if (!empty($params['other_qualifications'])) {
  143. foreach ($params['other_qualifications'] as &$val) {
  144. $val = FileService::setFileUrl($val);
  145. }
  146. $other_qualifications = json_encode($params['other_qualifications']);
  147. }
  148. ConfigService::set('shop', 'other_qualifications', $other_qualifications);
  149. return true;
  150. }
  151. /**
  152. * @notes 获取分享设置
  153. * @return array
  154. * @author Tab
  155. * @date 2021/7/28 15:29
  156. */
  157. public static function getShareSetting()
  158. {
  159. $config = [
  160. 'share_page' => ConfigService::get('shop', 'share_page'),
  161. 'share_title' => ConfigService::get('shop', 'share_title', ''),
  162. 'share_intro' => ConfigService::get('shop', 'share_intro', ''),
  163. 'share_image' => ConfigService::get('shop', 'share_image'),
  164. ];
  165. $config['share_image'] = $config['share_image'] ? FileService::getFileUrl($config['share_image']) : '';
  166. return $config;
  167. }
  168. /**
  169. * @notes 分享设置
  170. * @param $params
  171. * @author Tab
  172. * @date 2021/7/28 15:37
  173. */
  174. public static function setShareSetting($params)
  175. {
  176. ConfigService::set('shop', 'share_page', $params['share_page']);
  177. ConfigService::set('shop', 'share_title', $params['share_title'] ?? '');
  178. ConfigService::set('shop', 'share_intro', $params['share_intro'] ?? '');
  179. ConfigService::set('shop', 'share_image', FileService::setFileUrl($params['share_image']));
  180. }
  181. /**
  182. * @notes 获取政策协议
  183. * @return array
  184. * @author Tab
  185. * @date 2021/7/28 16:08
  186. */
  187. public static function getPolicyAgreement()
  188. {
  189. $config = [
  190. 'service_agreement_name' => ConfigService::get('shop', 'service_agreement_name', ''),
  191. 'service_agreement_content' => ConfigService::get('shop', 'service_agreement_content', ''),
  192. 'privacy_policy_name' => ConfigService::get('shop', 'privacy_policy_name', ''),
  193. 'privacy_policy_content' => ConfigService::get('shop', 'privacy_policy_content', ''),
  194. 'user_delete_name' => ConfigService::get('shop', 'user_delete_name', ''),
  195. 'user_delete_content' => ConfigService::get('shop', 'user_delete_content', ''),
  196. ];
  197. return $config;
  198. }
  199. /**
  200. * @notes 设置政策协议
  201. * @param $params
  202. * @author Tab
  203. * @date 2021/7/28 16:13
  204. */
  205. public static function setPolicyAgreement($params)
  206. {
  207. if(isset($params['service_agreement_name']) && isset($params['service_agreement_content'])) {
  208. ConfigService::set('shop', 'service_agreement_name', $params['service_agreement_name']);
  209. ConfigService::set('shop', 'service_agreement_content', $params['service_agreement_content']);
  210. }
  211. if(isset($params['privacy_policy_name']) && isset($params['privacy_policy_content'])) {
  212. ConfigService::set('shop', 'privacy_policy_name', $params['privacy_policy_name']);
  213. ConfigService::set('shop', 'privacy_policy_content', $params['privacy_policy_content']);
  214. }
  215. if(isset($params['user_delete_name']) && isset($params['user_delete_content'])) {
  216. ConfigService::set('shop', 'user_delete_name', $params['user_delete_name']);
  217. ConfigService::set('shop', 'user_delete_content', $params['user_delete_content']);
  218. }
  219. }
  220. /**
  221. * @notes 设置地图秘钥
  222. * @param array $params
  223. * @return bool
  224. * @author ljj
  225. * @date 2022/3/10 5:11 下午
  226. */
  227. public static function setMapKey(array $params)
  228. {
  229. ConfigService::set('map', 'tencent_map_key', $params['tencent_map_key'] ?? '');
  230. return true;
  231. }
  232. /**
  233. * @notes 获取地图秘钥
  234. * @return array
  235. * @author ljj
  236. * @date 2022/3/10 5:12 下午
  237. */
  238. public static function getMapKey(): array
  239. {
  240. return [
  241. 'tencent_map_key' => ConfigService::get('map', 'tencent_map_key',''),
  242. ];
  243. }
  244. /**
  245. * @notes 获取站点统计配置
  246. * @return array
  247. * @author yfdong
  248. * @date 2024/09/20 22:25
  249. */
  250. public static function getSiteStatistics()
  251. {
  252. return [
  253. 'clarity_code' => ConfigService::get('siteStatistics', 'clarity_code')
  254. ];
  255. }
  256. /**
  257. * @notes 设置站点统计配置
  258. * @param array $params
  259. * @return void
  260. * @author yfdong
  261. * @date 2024/09/20 22:31
  262. */
  263. public static function setSiteStatistics($params)
  264. {
  265. ConfigService::set('siteStatistics', 'clarity_code', $params['clarity_code']);
  266. }
  267. }