PublicController.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\api\controller\v1;
  12. use app\services\activity\combination\StorePinkServices;
  13. use app\services\diy\DiyServices;
  14. use app\services\kefu\service\StoreServiceServices;
  15. use app\services\order\DeliveryServiceServices;
  16. use app\services\other\AgreementServices;
  17. use app\services\other\CacheServices;
  18. use app\services\product\product\StoreCategoryServices;
  19. use app\services\product\product\StoreProductServices;
  20. use app\services\shipping\ExpressServices;
  21. use app\services\shipping\SystemCityServices;
  22. use app\services\system\AppVersionServices;
  23. use app\services\system\attachment\SystemAttachmentServices;
  24. use app\services\system\config\SystemConfigServices;
  25. use app\services\system\lang\LangCodeServices;
  26. use app\services\system\lang\LangCountryServices;
  27. use app\services\system\lang\LangTypeServices;
  28. use app\services\system\store\SystemStoreServices;
  29. use app\services\system\store\SystemStoreStaffServices;
  30. use app\services\user\UserBillServices;
  31. use app\services\user\UserInvoiceServices;
  32. use app\services\user\UserServices;
  33. use app\services\wechat\WechatUserServices;
  34. use app\Request;
  35. use crmeb\services\CacheService;
  36. use app\services\other\UploadService;
  37. use crmeb\services\workerman\ChannelService;
  38. use think\facade\Cache;
  39. /**
  40. * 公共类
  41. * Class PublicController
  42. * @package app\api\controller
  43. */
  44. class PublicController
  45. {
  46. /**
  47. * 主页获取
  48. * @param Request $request
  49. * @return mixed
  50. */
  51. public function index(Request $request)
  52. {
  53. $banner = sys_data('routine_home_banner') ?: [];//TODO 首页banner图
  54. $menus = sys_data('routine_home_menus') ?: [];//TODO 首页按钮
  55. $roll = sys_data('routine_home_roll_news') ?: [];//TODO 首页滚动新闻
  56. $activity = sys_data('routine_home_activity', 3) ?: [];//TODO 首页活动区域图片
  57. $explosive_money = sys_data('index_categy_images') ?: [];//TODO 首页超值爆款
  58. $site_name = sys_config('site_name');
  59. $routine_index_page = sys_data('routine_index_page');
  60. $info['fastInfo'] = $routine_index_page[0]['fast_info'] ?? '';//TODO 快速选择简介
  61. $info['bastInfo'] = $routine_index_page[0]['bast_info'] ?? '';//TODO 精品推荐简介
  62. $info['firstInfo'] = $routine_index_page[0]['first_info'] ?? '';//TODO 首发新品简介
  63. $info['salesInfo'] = $routine_index_page[0]['sales_info'] ?? '';//TODO 促销单品简介
  64. $logoUrl = sys_config('routine_index_logo');//TODO 促销单品简介
  65. if (strstr($logoUrl, 'http') === false && $logoUrl) {
  66. $logoUrl = sys_config('site_url') . $logoUrl;
  67. }
  68. $logoUrl = str_replace('\\', '/', $logoUrl);
  69. $fastNumber = (int)sys_config('fast_number', 0);//TODO 快速选择分类个数
  70. /** @var StoreCategoryServices $categoryService */
  71. $categoryService = app()->make(StoreCategoryServices::class);
  72. $info['fastList'] = $fastNumber ? $categoryService->byIndexList($fastNumber, 'id,cate_name,pid,pic') : [];//TODO 快速选择分类个数
  73. /** @var StoreProductServices $storeProductServices */
  74. $storeProductServices = app()->make(StoreProductServices::class);
  75. //获取推荐商品
  76. [$baseList, $firstList, $benefit, $likeInfo, $vipList] = $storeProductServices->getRecommendProductArr((int)$request->uid(), ['is_best', 'is_new', 'is_benefit', 'is_hot']);
  77. $info['bastList'] = $baseList;//TODO 精品推荐个数
  78. $info['firstList'] = $firstList;//TODO 首发新品个数
  79. $info['bastBanner'] = sys_data('routine_home_bast_banner') ?? [];//TODO 首页精品推荐图片
  80. $lovely = sys_data('routine_home_new_banner') ?: [];//TODO 首发新品顶部图
  81. if ($request->uid()) {
  82. /** @var WechatUserServices $wechatUserService */
  83. $wechatUserService = app()->make(WechatUserServices::class);
  84. $subscribe = (bool)$wechatUserService->value(['uid' => $request->uid()], 'subscribe');
  85. } else {
  86. $subscribe = true;
  87. }
  88. $newGoodsBananr = sys_config('new_goods_bananr');
  89. $tengxun_map_key = sys_config('tengxun_map_key');
  90. return app('json')->success(compact('banner', 'menus', 'roll', 'info', 'activity', 'lovely', 'benefit', 'likeInfo', 'logoUrl', 'site_name', 'subscribe', 'newGoodsBananr', 'tengxun_map_key', 'explosive_money'));
  91. }
  92. /**
  93. * 获取分享配置
  94. * @return mixed
  95. */
  96. public function share()
  97. {
  98. $data['img'] = sys_config('wechat_share_img');
  99. if (strstr($data['img'], 'http') === false) {
  100. $data['img'] = sys_config('site_url') . $data['img'];
  101. }
  102. $data['img'] = str_replace('\\', '/', $data['img']);
  103. $data['title'] = sys_config('wechat_share_title');
  104. $data['synopsis'] = sys_config('wechat_share_synopsis');
  105. return app('json')->success($data);
  106. }
  107. /**
  108. * 获取网站配置
  109. * @return mixed
  110. */
  111. public function getSiteConfig()
  112. {
  113. $data['record_No'] = sys_config('record_No');
  114. return app('json')->success($data);
  115. }
  116. /**
  117. * 获取个人中心菜单
  118. * @param Request $request
  119. * @return mixed
  120. * @throws \think\db\exception\DataNotFoundException
  121. * @throws \think\db\exception\ModelNotFoundException
  122. * @throws \think\exception\DbException
  123. */
  124. public function menu_user(Request $request)
  125. {
  126. $menusInfo = sys_data('routine_my_menus') ?? [];
  127. $uid = 0;
  128. $userInfo = [];
  129. if ($request->hasMacro('user')) $userInfo = $request->user();
  130. if ($request->hasMacro('uid')) $uid = $request->uid();
  131. $vipOpen = sys_config('member_func_status');
  132. $brokerageFuncStatus = sys_config('brokerage_func_status');
  133. $balanceFuncStatus = sys_config('balance_func_status');
  134. $vipCard = sys_config('member_card_status', 0);
  135. $svipOpen = (bool)sys_config('member_card_status');
  136. $userService = $invoiceStatus = $deliveryUser = $isUserPromoter = $userVerifyStatus = $userOrder = true;
  137. if ($uid && $userInfo) {
  138. /** @var StoreServiceServices $storeService */
  139. $storeService = app()->make(StoreServiceServices::class);
  140. $userService = $storeService->checkoutIsService(['uid' => $uid, 'status' => 1]);
  141. $userOrder = $storeService->checkoutIsService(['uid' => $uid, 'status' => 1, 'customer' => 1]);
  142. /** @var SystemStoreStaffServices $systemStoreStaff */
  143. $systemStoreStaff = app()->make(SystemStoreStaffServices::class);
  144. /** @var UserServices $user */
  145. $user = app()->make(UserServices::class);
  146. /** @var UserInvoiceServices $userInvoice */
  147. $userInvoice = app()->make(UserInvoiceServices::class);
  148. $invoiceStatus = $userInvoice->invoiceFuncStatus(false);
  149. /** @var DeliveryServiceServices $deliveryService */
  150. $deliveryService = app()->make(DeliveryServiceServices::class);
  151. $deliveryUser = $deliveryService->checkoutIsService($uid);
  152. $isUserPromoter = $user->checkUserPromoter($uid, $userInfo);
  153. $userVerifyStatus = $systemStoreStaff->verifyStatus($uid);
  154. }
  155. $auth = [];
  156. $auth['/pages/users/user_vip/index'] = !$vipOpen;
  157. $auth['/pages/users/user_spread_user/index'] = !$brokerageFuncStatus || !$isUserPromoter || $uid == 0;
  158. $auth['/pages/users/user_money/index'] = !$balanceFuncStatus;
  159. $auth['/pages/admin/order/index'] = !$userOrder || $uid == 0;
  160. $auth['/pages/admin/order_cancellation/index'] = (!$userVerifyStatus && !$deliveryUser) || $uid == 0;
  161. $auth['/pages/users/user_invoice_list/index'] = !$invoiceStatus;
  162. $auth['/pages/annex/vip_paid/index'] = !$vipCard || !$svipOpen;
  163. $auth['/kefu/mobile_list'] = !$userService || $uid == 0;
  164. foreach ($menusInfo as $key => &$value) {
  165. if (isset($auth[$value['url']]) && $auth[$value['url']]) {
  166. unset($menusInfo[$key]);
  167. continue;
  168. }
  169. if ($value['url'] == '/kefu/mobile_list') {
  170. $value['url'] = sys_config('site_url') . $value['url'];
  171. if ($request->isRoutine()) {
  172. $value['url'] = str_replace('http://', 'https://', $value['url']);
  173. }
  174. }
  175. }
  176. /** @var SystemConfigServices $systemConfigServices */
  177. $systemConfigServices = app()->make(SystemConfigServices::class);
  178. $bannerInfo = $systemConfigServices->getSpreadBanner() ?? [];
  179. $my_banner = sys_data('routine_my_banner');
  180. $routine_contact_type = sys_config('routine_contact_type', 0);
  181. /** @var DiyServices $diyServices */
  182. $diyServices = app()->make(DiyServices::class);
  183. $diy_data = $diyServices->get(['template_name' => 'member', 'type' => 1], ['value', 'order_status', 'my_banner_status']);
  184. $diy_data = $diy_data ? $diy_data->toArray() : [];
  185. return app('json')->success(['routine_my_menus' => array_merge($menusInfo), 'routine_my_banner' => $my_banner, 'routine_spread_banner' => $bannerInfo, 'routine_contact_type' => $routine_contact_type, 'diy_data' => $diy_data]);
  186. }
  187. /**
  188. * 热门搜索关键字获取
  189. * @return mixed
  190. * @throws \think\db\exception\DataNotFoundException
  191. * @throws \think\db\exception\ModelNotFoundException
  192. * @throws \think\exception\DbException
  193. */
  194. public function search()
  195. {
  196. $routineHotSearch = sys_data('routine_hot_search') ?? [];
  197. $searchKeyword = [];
  198. if (count($routineHotSearch)) {
  199. foreach ($routineHotSearch as $key => &$item) {
  200. array_push($searchKeyword, $item['title']);
  201. }
  202. }
  203. return app('json')->success($searchKeyword);
  204. }
  205. /**
  206. * 图片上传
  207. * @param Request $request
  208. * @return mixed
  209. * @throws \Psr\SimpleCache\InvalidArgumentException
  210. */
  211. public function upload_image(Request $request, SystemAttachmentServices $services)
  212. {
  213. $data = $request->postMore([
  214. ['filename', 'file'],
  215. ]);
  216. if (!$data['filename']) return app('json')->fail(100100);
  217. if (Cache::has('start_uploads_' . $request->uid()) && Cache::get('start_uploads_' . $request->uid()) >= 100) return app('json')->fail(100101);
  218. $upload = UploadService::init();
  219. $info = $upload->to('store/comment')->validate()->move($data['filename']);
  220. if ($info === false) {
  221. return app('json')->fail($upload->getError());
  222. }
  223. $res = $upload->getUploadInfo();
  224. $services->attachmentAdd($res['name'], $res['size'], $res['type'], $res['dir'], $res['thumb_path'], 1, (int)sys_config('upload_type', 1), $res['time'], 3);
  225. if (Cache::has('start_uploads_' . $request->uid()))
  226. $start_uploads = (int)Cache::get('start_uploads_' . $request->uid());
  227. else
  228. $start_uploads = 0;
  229. $start_uploads++;
  230. Cache::set('start_uploads_' . $request->uid(), $start_uploads, 86400);
  231. $res['dir'] = path_to_url($res['dir']);
  232. if (strpos($res['dir'], 'http') === false) $res['dir'] = $request->domain() . $res['dir'];
  233. return app('json')->success(100009, ['name' => $res['name'], 'url' => $res['dir']]);
  234. }
  235. /**
  236. * 物流公司
  237. * @return mixed
  238. */
  239. public function logistics(ExpressServices $services)
  240. {
  241. $expressList = $services->expressList();
  242. return app('json')->success($expressList ?? []);
  243. }
  244. /**
  245. * 短信购买异步通知
  246. *
  247. * @param Request $request
  248. * @return mixed
  249. */
  250. public function sms_pay_notify(Request $request)
  251. {
  252. [$order_id, $price, $status, $num, $pay_time, $attach] = $request->postMore([
  253. ['order_id', ''],
  254. ['price', 0.00],
  255. ['status', 400],
  256. ['num', 0],
  257. ['pay_time', time()],
  258. ['attach', 0],
  259. ], true);
  260. if ($status == 200) {
  261. try {
  262. ChannelService::instance()->send('PAY_SMS_SUCCESS', ['price' => $price, 'number' => $num], [$attach]);
  263. } catch (\Throwable $e) {
  264. }
  265. return app('json')->success(100010);
  266. }
  267. return app('json')->fail(100005);
  268. }
  269. /**
  270. * 记录用户分享
  271. * @param Request $request
  272. * @return mixed
  273. */
  274. public function user_share(Request $request, UserBillServices $services)
  275. {
  276. $uid = (int)$request->uid();
  277. return app('json')->success($services->setUserShare($uid));
  278. }
  279. /**
  280. * 获取图片base64
  281. * @param Request $request
  282. * @return mixed
  283. */
  284. public function get_image_base64(Request $request)
  285. {
  286. [$imageUrl, $codeUrl] = $request->postMore([
  287. ['image', ''],
  288. ['code', ''],
  289. ], true);
  290. if ($imageUrl !== '' && !preg_match('/.*(\.png|\.jpg|\.jpeg|\.gif)$/', $imageUrl)) {
  291. return app('json')->success(['code' => false, 'image' => false]);
  292. }
  293. if ($codeUrl !== '' && !preg_match('/.*(\.png|\.jpg|\.jpeg|\.gif)$/', $codeUrl)) {
  294. return app('json')->success(['code' => false, 'image' => false]);
  295. }
  296. try {
  297. $code = CacheService::get($codeUrl, function () use ($codeUrl) {
  298. $codeTmp = $code = $codeUrl ? image_to_base64($codeUrl) : false;
  299. if (!$codeTmp) {
  300. $putCodeUrl = put_image($codeUrl);
  301. $code = $putCodeUrl ? image_to_base64(app()->request->domain(true) . '/' . $putCodeUrl) : false;
  302. $code ?? unlink($_SERVER["DOCUMENT_ROOT"] . '/' . $putCodeUrl);
  303. }
  304. return $code;
  305. });
  306. $image = CacheService::get($imageUrl, function () use ($imageUrl) {
  307. $imageTmp = $image = $imageUrl ? image_to_base64($imageUrl) : false;
  308. if (!$imageTmp) {
  309. $putImageUrl = put_image($imageUrl);
  310. $image = $putImageUrl ? image_to_base64(app()->request->domain(true) . '/' . $putImageUrl) : false;
  311. $image ?? unlink($_SERVER["DOCUMENT_ROOT"] . '/' . $putImageUrl);
  312. }
  313. return $image;
  314. });
  315. return app('json')->success(compact('code', 'image'));
  316. } catch (\Exception $e) {
  317. return app('json')->fail(100005);
  318. }
  319. }
  320. /**
  321. * 门店列表
  322. * @return mixed
  323. */
  324. public function store_list(Request $request, SystemStoreServices $services)
  325. {
  326. list($latitude, $longitude) = $request->getMore([
  327. ['latitude', ''],
  328. ['longitude', ''],
  329. ], true);
  330. $data['list'] = $services->getStoreList(['type' => 0], ['id', 'name', 'phone', 'address', 'detailed_address', 'image', 'latitude', 'longitude'], $latitude, $longitude);
  331. $data['tengxun_map_key'] = sys_config('tengxun_map_key');
  332. return app('json')->success($data);
  333. }
  334. /**
  335. * 查找城市数据
  336. * @param Request $request
  337. * @return mixed
  338. */
  339. public function city_list(Request $request)
  340. {
  341. /** @var SystemCityServices $systemCity */
  342. $systemCity = app()->make(SystemCityServices::class);
  343. return app('json')->success($systemCity->cityList());
  344. }
  345. /**
  346. * 获取拼团数据
  347. * @return mixed
  348. */
  349. public function pink(StorePinkServices $pink, UserServices $user)
  350. {
  351. $data['pink_count'] = $pink->getCount(['is_refund' => 0]);
  352. $uids = array_flip($pink->getColumn(['is_refund' => 0], 'uid'));
  353. if (count($uids)) {
  354. $uids = array_rand($uids, count($uids) < 3 ? count($uids) : 3);
  355. }
  356. $data['avatars'] = $uids ? $user->getColumn(is_array($uids) ? [['uid', 'in', $uids]] : ['uid' => $uids], 'avatar') : [];
  357. return app('json')->success($data);
  358. }
  359. /**
  360. * 复制口令接口
  361. * @return mixed
  362. */
  363. public function copy_words()
  364. {
  365. $data['words'] = sys_config('copy_words');
  366. return app('json')->success($data);
  367. }
  368. /**生成口令关键字
  369. * @param Request $request
  370. * @return mixed
  371. * @throws \think\db\exception\DataNotFoundException
  372. * @throws \think\db\exception\DbException
  373. * @throws \think\db\exception\ModelNotFoundException
  374. */
  375. public function copy_share_words(Request $request)
  376. {
  377. list($productId) = $request->getMore([
  378. ['product_id', ''],
  379. ], true);
  380. /** @var StoreProductServices $productService */
  381. $productService = app()->make(StoreProductServices::class);
  382. $keyWords['key_words'] = $productService->getProductWords($productId);
  383. return app('json')->success($keyWords);
  384. }
  385. /**
  386. * 获取页面数据
  387. * @return mixed
  388. * @throws \think\db\exception\DataNotFoundException
  389. * @throws \think\db\exception\DbException
  390. * @throws \think\db\exception\ModelNotFoundException
  391. */
  392. public function getDiy(DiyServices $services, $id = 0)
  393. {
  394. return app('json')->success($services->getDiyInfo((int)$id));
  395. }
  396. /**
  397. * 获取底部导航
  398. * @param DiyServices $services
  399. * @param string $template_name
  400. * @return mixed
  401. */
  402. public function getNavigation(DiyServices $services, string $template_name = '')
  403. {
  404. return app('json')->success($services->getNavigation($template_name));
  405. }
  406. /**
  407. * 首页商品数据
  408. * @param Request $request
  409. */
  410. public function home_products_list(Request $request, DiyServices $services)
  411. {
  412. $data = $request->getMore([
  413. ['priceOrder', ''],
  414. ['newsOrder', ''],
  415. ['salesOrder', ''],
  416. [['type', 'd'], 0],
  417. ['ids', ''],
  418. [['selectId', 'd'], ''],
  419. ['selectType', 0],
  420. ['isType', 0],
  421. ]);
  422. $where = [];
  423. $where['is_show'] = 1;
  424. $where['is_del'] = 0;
  425. $where['productId'] = '';
  426. if ($data['selectType'] == 1) {
  427. if (!$data['ids']) {
  428. return app('json')->success(100011);
  429. }
  430. $where['ids'] = $data['ids'] ? explode(',', $data['ids']) : [];
  431. if ($data['type'] != 2 && $data['type'] != 3 && $data['type'] != 8) {
  432. $where['type'] = 0;
  433. } else {
  434. $where['type'] = $data['type'];
  435. }
  436. } else {
  437. $where['priceOrder'] = $data['priceOrder'];
  438. $where['newsOrder'] = $data['newsOrder'];
  439. $where['salesOrder'] = $data['salesOrder'];
  440. $where['type'] = $data['type'];
  441. if ($data['selectId']) {
  442. /** @var StoreCategoryServices $storeCategoryServices */
  443. $storeCategoryServices = app()->make(StoreCategoryServices::class);
  444. if ($storeCategoryServices->value(['id' => $data['selectId']], 'pid')) {
  445. $where['sid'] = $data['selectId'];
  446. } else {
  447. $where['cid'] = $data['selectId'];
  448. }
  449. }
  450. }
  451. return app('json')->success($services->homeProductList($where, $request->uid()));
  452. }
  453. public function getNewAppVersion($platform)
  454. {
  455. /** @var AppVersionServices $appService */
  456. $appService = app()->make(AppVersionServices::class);
  457. return app('json')->success($appService->getNewInfo($platform));
  458. }
  459. public function getCustomerType()
  460. {
  461. $data = [];
  462. $data['customer_type'] = sys_config('customer_type', 0);
  463. $data['customer_phone'] = sys_config('customer_phone', 0);
  464. $data['customer_url'] = sys_config('customer_url', 0);
  465. $data['customer_corpId'] = sys_config('customer_corpId', 0);
  466. return app('json')->success($data);
  467. }
  468. /**
  469. * 统计代码
  470. * @return array|string
  471. */
  472. public function getScript()
  473. {
  474. return sys_config('statistic_script', '');
  475. }
  476. /**
  477. * 获取workerman请求域名
  478. * @return mixed
  479. */
  480. public function getWorkerManUrl()
  481. {
  482. return app('json')->success(getWorkerManUrl());
  483. }
  484. /**
  485. * 首页开屏广告
  486. * @return mixed
  487. */
  488. public function getOpenAdv()
  489. {
  490. /** @var CacheServices $cache */
  491. $cache = app()->make(CacheServices::class);
  492. $data = $cache->getDbCache('open_adv', '');
  493. return app('json')->success($data);
  494. }
  495. /**
  496. * 获取用户协议内容
  497. * @return mixed
  498. */
  499. public function getUserAgreement()
  500. {
  501. /** @var CacheServices $cache */
  502. $cache = app()->make(CacheServices::class);
  503. $content = $cache->getDbCache('user_agreement', '');
  504. return app('json')->success(compact('content'));
  505. }
  506. /**
  507. * 获取协议
  508. * @param AgreementServices $agreementServices
  509. * @param $type
  510. * @return mixed
  511. * @throws \think\db\exception\DataNotFoundException
  512. * @throws \think\db\exception\DbException
  513. * @throws \think\db\exception\ModelNotFoundException
  514. */
  515. public function getAgreement(AgreementServices $agreementServices, $type)
  516. {
  517. $data = $agreementServices->getAgreementBytype($type);
  518. return app('json')->success($data);
  519. }
  520. /**
  521. * 查询版权信息
  522. * @return mixed
  523. */
  524. public function copyright()
  525. {
  526. try {
  527. if (Cache::has('nncnL_crmeb_copyright')) {
  528. $copyrightContext = Cache::get('nncnL_crmeb_copyright');
  529. } else {
  530. /** @var SystemConfigServices $services */
  531. $services = app()->make(SystemConfigServices::class);
  532. $copyrightContext = $services->value(['menu_name' => 'nncnL_crmeb_copyright'], 'value');
  533. $copyrightContext = $copyrightContext ? json_decode($copyrightContext, true) : null;
  534. Cache::set('nncnL_crmeb_copyright', $copyrightContext, 3600);
  535. }
  536. // dump(Cache::has('nncnL_crmeb_copyright_image'));
  537. if (Cache::has('nncnL_crmeb_copyright_image')) {
  538. $copyrightImage = Cache::get('nncnL_crmeb_copyright_image');
  539. } else {
  540. /** @var SystemConfigServices $services */
  541. $services = app()->make(SystemConfigServices::class);
  542. $copyrightImage = $services->value(['menu_name' => 'nncnL_crmeb_copyright_image'], 'value');
  543. $copyrightImage = $copyrightImage ? json_decode($copyrightImage, true) : null;
  544. Cache::set('nncnL_crmeb_copyright_image', $copyrightImage, 3600);
  545. }
  546. } catch (\Throwable $e) {
  547. $copyrightContext = '';
  548. $copyrightImage = '';
  549. }
  550. return app('json')->success(compact('copyrightContext', 'copyrightImage'));
  551. }
  552. }