PublicController.php 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\controller\api\v1;
  12. use app\jobs\integral\IntegralJob;
  13. use app\model\user\UserIntegral;
  14. use app\services\activity\combination\StorePinkServices;
  15. use app\services\diy\DiyServices;
  16. use app\services\message\service\StoreServiceServices;
  17. use app\services\store\DeliveryServiceServices;
  18. use app\services\other\CacheServices;
  19. use app\services\product\category\StoreProductCategoryServices;
  20. use app\services\product\product\StoreProductServices;
  21. use app\services\other\ExpressServices;
  22. use app\services\other\SystemCityServices;
  23. use app\services\system\attachment\SystemAttachmentServices;
  24. use app\services\system\config\SystemConfigServices;
  25. use app\services\store\SystemStoreServices;
  26. use app\services\store\SystemStoreStaffServices;
  27. use app\services\user\level\UserLevelServices;
  28. use app\services\user\UserAwardIntegralServices;
  29. use app\services\user\UserBillServices;
  30. use app\services\user\UserInvoiceServices;
  31. use app\services\user\UserServices;
  32. use app\services\wechat\WechatUserServices;
  33. use app\webscoket\SocketPush;
  34. use Joypack\Tencent\Map\Bundle\Location;
  35. use Joypack\Tencent\Map\Bundle\LocationOption;
  36. use app\Request;
  37. use crmeb\services\CacheService;
  38. use crmeb\services\UploadService;
  39. use crmeb\basic\BaseController;
  40. /**
  41. * 公共类
  42. * Class PublicController
  43. * @package app\controller\api
  44. */
  45. class PublicController extends BaseController
  46. {
  47. public function test()
  48. {
  49. $levelServices = app()->make(IntegralJob::class);
  50. foreach (UserIntegral::where('status', 0)->select() as $v) {
  51. $levelServices->extract($v['id']);
  52. }
  53. }
  54. /**
  55. * 主页获取
  56. * @param Request $request
  57. * @return mixed
  58. */
  59. public function index(Request $request)
  60. {
  61. $uid = $request->hasMacro('uid') ? (int)$request->uid() : 0;
  62. $banner = sys_data('routine_home_banner') ?: [];// 首页banner图
  63. $menus = sys_data('routine_home_menus') ?: [];// 首页按钮
  64. $roll = sys_data('routine_home_roll_news') ?: [];// 首页滚动新闻
  65. $activity = sys_data('routine_home_activity', 3) ?: [];// 首页活动区域图片
  66. $explosive_money = sys_data('index_categy_images') ?: [];// 首页超值爆款
  67. $site_name = sys_config('site_name');
  68. $routine_index_page = sys_data('routine_index_page');
  69. $info['fastInfo'] = $routine_index_page[0]['fast_info'] ?? '';// 快速选择简介
  70. $info['bastInfo'] = $routine_index_page[0]['bast_info'] ?? '';// 精品推荐简介
  71. $info['firstInfo'] = $routine_index_page[0]['first_info'] ?? '';// 首发新品简介
  72. $info['salesInfo'] = $routine_index_page[0]['sales_info'] ?? '';// 促销单品简介
  73. $logoUrl = sys_config('routine_index_logo');// 促销单品简介
  74. if (strstr($logoUrl, 'http') === false && $logoUrl) {
  75. $logoUrl = sys_config('site_url') . $logoUrl;
  76. }
  77. $logoUrl = str_replace('\\', '/', $logoUrl);
  78. $fastNumber = (int)sys_config('fast_number', 0);// 快速选择分类个数
  79. $bastNumber = (int)sys_config('bast_number', 0);// 精品推荐个数
  80. $firstNumber = (int)sys_config('first_number', 0);// 首发新品个数
  81. $promotionNumber = (int)sys_config('promotion_number', 0);// 首发新品个数
  82. /** @var StoreProductCategoryServices $categoryService */
  83. $categoryService = app()->make(StoreProductCategoryServices::class);
  84. $info['fastList'] = $fastNumber ? $categoryService->byIndexList($fastNumber, 'id,cate_name,pid,pic') : [];// 快速选择分类个数
  85. /** @var StoreProductServices $storeProductServices */
  86. $storeProductServices = app()->make(StoreProductServices::class);
  87. $info['bastList'] = $bastNumber ? $storeProductServices->getRecommendProduct($uid, ['is_best' => 1], $bastNumber) : [];// 精品推荐个数
  88. $info['firstList'] = $firstNumber ? $storeProductServices->getRecommendProduct($uid, ['is_new' => 1], $firstNumber) : [];// 首发新品个数
  89. $info['bastBanner'] = sys_data('routine_home_bast_banner') ?? [];// 首页精品推荐图片
  90. $benefit = $promotionNumber ? $storeProductServices->getRecommendProduct($uid, ['is_benefit' => 1], $promotionNumber) : [];// 首页促销单品
  91. $lovely = sys_data('routine_home_new_banner') ?: [];// 首发新品顶部图
  92. $likeInfo = $storeProductServices->getRecommendProduct($uid, ['is_hot' => 1], 3);// 热门榜单 猜你喜欢
  93. if ($uid) {
  94. /** @var WechatUserServices $wechatUserService */
  95. $wechatUserService = app()->make(WechatUserServices::class);
  96. $subscribe = (bool)$wechatUserService->value(['uid' => $uid], 'subscribe');
  97. } else {
  98. $subscribe = true;
  99. }
  100. $newGoodsBananr = sys_config('new_goods_bananr');
  101. $tengxun_map_key = sys_config('tengxun_map_key');
  102. $award_integral_service = app()->make(UserAwardIntegralServices::class);
  103. $award_lack = $award_integral_service->getLake();
  104. $integral_price = $award_integral_service->getPrice();
  105. return app('json')->successful(compact('award_lack', 'integral_price', 'banner', 'menus', 'roll', 'info', 'activity', 'lovely', 'benefit', 'likeInfo', 'logoUrl', 'site_name', 'subscribe', 'newGoodsBananr', 'tengxun_map_key', 'explosive_money'));
  106. }
  107. /**
  108. * 获取分享配置
  109. * @return mixed
  110. */
  111. public function share()
  112. {
  113. $data['img'] = sys_config('wechat_share_img');
  114. if (strstr($data['img'], 'http') === false) {
  115. $data['img'] = sys_config('site_url') . $data['img'];
  116. }
  117. $data['img'] = str_replace('\\', '/', $data['img']);
  118. $data['title'] = sys_config('wechat_share_title');
  119. $data['synopsis'] = sys_config('wechat_share_synopsis');
  120. return app('json')->successful($data);
  121. }
  122. /**
  123. * 获取网站配置
  124. * @return mixed
  125. */
  126. public function getSiteConfig()
  127. {
  128. $data['record_No'] = sys_config('record_No');
  129. return app('json')->success($data);
  130. }
  131. /**
  132. * 获取个人中心菜单
  133. * @param Request $request
  134. * @return mixed
  135. * @throws \think\db\exception\DataNotFoundException
  136. * @throws \think\db\exception\ModelNotFoundException
  137. * @throws \think\exception\DbException
  138. */
  139. public function menu_user(Request $request)
  140. {
  141. $menusInfo = sys_data('routine_my_menus') ?? [];
  142. $uid = 0;
  143. $userInfo = [];
  144. if ($request->hasMacro('user')) $userInfo = $request->user();
  145. if ($request->hasMacro('uid')) $uid = $request->uid();
  146. $vipOpen = sys_config('member_func_status');
  147. $brokerageFuncStatus = sys_config('brokerage_func_status');
  148. $balanceFuncStatus = sys_config('balance_func_status');
  149. $vipCard = sys_config('member_card_status', 0);
  150. $svipOpen = (bool)sys_config('member_card_status');
  151. $userService = $invoiceStatus = $deliveryUser = $isUserPromoter = $userVerifyStatus = $userOrder = $isStaff = $isDelivery = true;
  152. if ($uid && $userInfo) {
  153. /** @var StoreServiceServices $storeService */
  154. $storeService = app()->make(StoreServiceServices::class);
  155. $userService = $storeService->checkoutIsService(['uid' => $uid, 'status' => 1, 'account_status' => 1]);
  156. $userOrder = $storeService->checkoutIsService(['uid' => $uid, 'account_status' => 1, 'customer' => 1]);
  157. /** @var SystemStoreStaffServices $systemStoreStaff */
  158. $systemStoreStaff = app()->make(SystemStoreStaffServices::class);
  159. /** @var UserServices $user */
  160. $user = app()->make(UserServices::class);
  161. /** @var UserInvoiceServices $userInvoice */
  162. $userInvoice = app()->make(UserInvoiceServices::class);
  163. $invoiceStatus = $userInvoice->invoiceFuncStatus(false);
  164. /** @var DeliveryServiceServices $deliveryService */
  165. $deliveryService = app()->make(DeliveryServiceServices::class);
  166. $deliveryUser = $deliveryService->checkoutIsService($uid);
  167. $isUserPromoter = $user->checkUserPromoter($uid, $userInfo);
  168. $userVerifyStatus = $systemStoreStaff->verifyStatus($uid);
  169. try {
  170. $isStaff = $systemStoreStaff->getStaffInfoByUid($uid);
  171. } catch (\Throwable $e) {
  172. $isStaff = false;
  173. }
  174. try {
  175. $isDelivery = $deliveryService->getDeliveryInfoByUid($uid);
  176. } catch (\Throwable $e) {
  177. $isDelivery = false;
  178. }
  179. }
  180. $auth = [];
  181. $auth['/pages/users/user_vip/index'] = !$vipOpen;
  182. $auth['/pages/users/user_spread_user/index'] = !$brokerageFuncStatus || !$isUserPromoter || $uid == 0;
  183. $auth['/pages/users/user_money/index'] = !$balanceFuncStatus;
  184. $auth['/pages/admin/order/index'] = !$userOrder || $uid == 0;
  185. $auth['/pages/admin/order_cancellation/index'] = (!$userVerifyStatus && !$deliveryUser) || $uid == 0;
  186. $auth['/pages/users/user_invoice_list/index'] = !$invoiceStatus;
  187. $auth['/pages/annex/vip_paid/index'] = !$vipCard || !$svipOpen;
  188. $auth['/kefu/mobile_list'] = !$userService || $uid == 0;
  189. $auth['/pages/admin/store/index'] = $uid == 0 || !$isStaff;
  190. $auth['/pages/admin/distribution/index'] = $uid == 0 || !$isDelivery;
  191. $auth['/pages/store_spread/index'] = $uid == 0 || !$isStaff;
  192. foreach ($menusInfo as $key => &$value) {
  193. $value['pic'] = set_file_url($value['pic'] ?? '');
  194. $value['url'] = $value['url'] ?? '';
  195. if (isset($auth[$value['url']]) && $auth[$value['url']]) {
  196. unset($menusInfo[$key]);
  197. continue;
  198. }
  199. if ($value['url'] == '/kefu/mobile_list') {
  200. $value['url'] = sys_config('site_url') . $value['url'];
  201. if ($request->isRoutine()) {
  202. $value['url'] = str_replace('http://', 'https://', $value['url']);
  203. }
  204. }
  205. }
  206. /** @var SystemConfigServices $systemConfigServices */
  207. $systemConfigServices = app()->make(SystemConfigServices::class);
  208. $bannerInfo = $systemConfigServices->getSpreadBanner() ?? [];
  209. $my_banner = sys_data('routine_my_banner');
  210. $routine_contact_type = sys_config('routine_contact_type', 0);
  211. /** @var DiyServices $diyServices */
  212. $diyServices = app()->make(DiyServices::class);
  213. $diy_data = $diyServices->cacheRemember('diy_data_member_3', function () use ($diyServices) {
  214. $diy_data = $diyServices->get(['template_name' => 'member', 'type' => 3], ['value', 'status', 'order_status', 'my_banner_status', 'menu_status', 'service_status']);
  215. $diy_data = $diy_data ? $diy_data->toArray() : [];
  216. return $diy_data;
  217. });
  218. if ($diy_data) {
  219. $diy_value = json_decode($diy_data['value'], true);
  220. $new_value = [];
  221. if (is_int($diy_value)) {
  222. $new_value['status'] = $diy_value;
  223. $new_value['vip_type'] = 1;
  224. $new_value['newcomer_status'] = 1;
  225. $new_value['newcomer_style'] = 1;
  226. } else {
  227. $new_value = $diy_value;
  228. }
  229. $diy_data = array_merge($diy_data, $new_value);
  230. $diy_data['order_status'] = (int)$diy_data['order_status'];
  231. }
  232. unset($diy_data['value']);
  233. return app('json')->successful(['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]);
  234. }
  235. /**
  236. * 热门搜索关键字获取
  237. * @return mixed
  238. * @throws \think\db\exception\DataNotFoundException
  239. * @throws \think\db\exception\ModelNotFoundException
  240. * @throws \think\exception\DbException
  241. */
  242. public function search()
  243. {
  244. $routineHotSearch = sys_data('routine_hot_search') ?? [];
  245. $searchKeyword = [];
  246. if (count($routineHotSearch)) {
  247. foreach ($routineHotSearch as $key => &$item) {
  248. array_push($searchKeyword, $item['title'] ?? '');
  249. }
  250. }
  251. return app('json')->successful($searchKeyword);
  252. }
  253. /**
  254. * 图片上传
  255. * @param Request $request
  256. * @return mixed
  257. * @throws \Psr\SimpleCache\InvalidArgumentException
  258. */
  259. public function upload_image(Request $request, SystemAttachmentServices $services)
  260. {
  261. $data = $request->postMore([
  262. ['filename', 'file'],
  263. ]);
  264. if (!$data['filename']) return app('json')->fail('参数有误');
  265. if (CacheService::has('start_uploads_' . $request->uid()) && CacheService::get('start_uploads_' . $request->uid()) >= 100) return app('json')->fail('非法操作');
  266. $upload = UploadService::init();
  267. $info = $upload->to('store/comment')->validate()->move($data['filename']);
  268. if ($info === false) {
  269. return app('json')->fail($upload->getError());
  270. }
  271. $res = $upload->getUploadInfo();
  272. $services->attachmentAdd($res['name'], $res['size'], $res['type'], $res['dir'], $res['thumb_path'], 1, (int)sys_config('upload_type', 1), $res['time'], 3);
  273. if (CacheService::has('start_uploads_' . $request->uid()))
  274. $start_uploads = (int)CacheService::get('start_uploads_' . $request->uid());
  275. else
  276. $start_uploads = 0;
  277. $start_uploads++;
  278. CacheService::set('start_uploads_' . $request->uid(), $start_uploads, 86400);
  279. $res['dir'] = path_to_url($res['dir']);
  280. if (strpos($res['dir'], 'http') === false) $res['dir'] = sys_config('site_url') . $res['dir'];
  281. return app('json')->successful('图片上传成功!', ['name' => $res['name'], 'url' => $res['dir']]);
  282. }
  283. /**
  284. * 物流公司
  285. * @return mixed
  286. */
  287. public function logistics(Request $request, ExpressServices $services)
  288. {
  289. [$status] = $request->getMore([
  290. ['status', ''],
  291. ], true);
  292. if ($status == 1) $data['status'] = $status;
  293. $data['is_show'] = 1;
  294. $expressList = $services->expressList($data);
  295. return app('json')->successful($expressList ?? []);
  296. }
  297. /**
  298. * 反向解析地址
  299. * @param Request $request
  300. * @return mixed
  301. */
  302. public function geoLbscoder(Request $request)
  303. {
  304. [$data] = $request->getMore([
  305. ['location', '']
  306. ], true);
  307. $locationOption = new LocationOption(sys_config('tengxun_map_key'));
  308. $data = explode(',', $data);
  309. $locationOption->setLocation($data[0] ?? '', $data[1] ?? '');
  310. $location = new Location($locationOption);
  311. $res = $location->request();
  312. if ($res->error) {
  313. return app('json')->fail($res->error);
  314. }
  315. if ($res->status) {
  316. return app('json')->fail($res->message);
  317. }
  318. if (!$res->result) {
  319. return app('json')->fail('获取失败');
  320. }
  321. return app('json')->success($res->result);
  322. }
  323. /**
  324. * 短信购买异步通知
  325. *
  326. * @param Request $request
  327. * @return mixed
  328. */
  329. public function sms_pay_notify(Request $request)
  330. {
  331. [$order_id, $price, $status, $num, $pay_time, $attach] = $request->postMore([
  332. ['order_id', ''],
  333. ['price', 0.00],
  334. ['status', 400],
  335. ['num', 0],
  336. ['pay_time', time()],
  337. ['attach', 0],
  338. ], true);
  339. if ($status == 200) {
  340. try {
  341. SocketPush::admin()->type('PAY_SMS_SUCCESS')->data(['price' => $price, 'number' => $num])->push();
  342. } catch (\Throwable $e) {
  343. }
  344. return app('json')->successful();
  345. }
  346. return app('json')->fail();
  347. }
  348. /**
  349. * 记录用户分享
  350. * @param Request $request
  351. * @param UserBillServices $services
  352. * @return mixed
  353. */
  354. public function user_share(Request $request, UserBillServices $services)
  355. {
  356. $uid = (int)$request->uid();
  357. return app('json')->successful($services->setUserShare($uid));
  358. }
  359. /**
  360. * 获取图片base64
  361. * @param Request $request
  362. * @return mixed
  363. */
  364. public function get_image_base64(Request $request)
  365. {
  366. [$imageUrl, $codeUrl] = $request->postMore([
  367. ['image', ''],
  368. ['code', ''],
  369. ], true);
  370. if ($imageUrl !== '' && !preg_match('/.*(\.png|\.jpg|\.jpeg|\.gif)$/', $imageUrl)) {
  371. return app('json')->success(['code' => false, 'image' => false]);
  372. }
  373. if ($codeUrl !== '' && !(preg_match('/.*(\.png|\.jpg|\.jpeg|\.gif)$/', $codeUrl) || strpos($codeUrl, 'https://mp.weixin.qq.com/cgi-bin/showqrcode') !== false)) {
  374. return app('json')->success(['code' => false, 'image' => false]);
  375. }
  376. try {
  377. $code = CacheService::get($codeUrl, function () use ($codeUrl) {
  378. $codeTmp = $code = $codeUrl ? image_to_base64($codeUrl) : false;
  379. if (!$codeTmp) {
  380. $codeUrl = explode('?', $codeUrl)[0] ?? $codeUrl;
  381. $putCodeUrl = put_image($codeUrl);
  382. $code = $putCodeUrl ? image_to_base64(public_path() . $putCodeUrl) : false;
  383. $code ?? unlink(public_path() . $putCodeUrl);
  384. }
  385. return $code;
  386. });
  387. $image = CacheService::get($imageUrl, function () use ($imageUrl) {
  388. $imageTmp = $image = $imageUrl ? image_to_base64($imageUrl) : false;
  389. if (!$imageTmp) {
  390. $imageUrl = explode('?', $imageUrl)[0] ?? $imageUrl;
  391. $putImageUrl = put_image($imageUrl);
  392. $image = $putImageUrl ? image_to_base64(public_path() . $putImageUrl) : false;
  393. $image ?? unlink(public_path() . $putImageUrl);
  394. }
  395. return $image;
  396. });
  397. return app('json')->successful(compact('code', 'image'));
  398. } catch (\Exception $e) {
  399. return app('json')->fail($e->getMessage());
  400. }
  401. }
  402. /**
  403. * 门店列表
  404. * @param Request $request
  405. * @param SystemStoreServices $services
  406. * @return mixed
  407. * @throws \think\db\exception\DataNotFoundException
  408. * @throws \think\db\exception\DbException
  409. * @throws \think\db\exception\ModelNotFoundException
  410. */
  411. public function store_list(Request $request, SystemStoreServices $services)
  412. {
  413. [$latitude, $longitude, $product_id, $type, $is_store, $store_id] = $request->getMore([
  414. ['latitude', ''],
  415. ['longitude', ''],
  416. ['product_id', 0],
  417. ['type', 0],//商品类型 0:普通 1:秒杀
  418. ['is_store', 1], //前端传值为 1|商城配送 2|门店自提 3|门店配送
  419. ['store_id', 0], //前端传值为 1|商城配送 2|门店自提 3|门店配送
  420. ], true);
  421. //判断是否门店自提
  422. $is_store == 2 ? $is_store = 1 : $is_store = '';
  423. $where = ['type' => 0, 'is_store' => $is_store];
  424. $field = ['id', 'name', 'phone', 'image', 'latitude', 'longitude', 'address', 'detailed_address', 'is_show', 'is_store', 'day_time', 'day_start', 'day_end', 'valid_range'];
  425. $data['list'] = $services->getStoreList($where, $field, $latitude, $longitude, (int)$product_id, [], (int)$type, $store_id);
  426. $data['tengxun_map_key'] = sys_config('tengxun_map_key');
  427. return app('json')->successful($data);
  428. }
  429. /**
  430. * 查找城市数据
  431. * @param Request $request
  432. * @return mixed
  433. */
  434. public function city_list(Request $request)
  435. {
  436. /** @var SystemCityServices $systemCity */
  437. $systemCity = app()->make(SystemCityServices::class);
  438. return app('json')->successful($systemCity->cityList());
  439. }
  440. /**
  441. * 获取拼团数据
  442. * @return mixed
  443. */
  444. public function pink(Request $request, StorePinkServices $pink, UserServices $user)
  445. {
  446. [$type] = $request->getMore([
  447. ['type', 1],
  448. ], true);
  449. $where = ['is_refund' => 0];
  450. if ($type == 1) {
  451. $where['status'] = 2;
  452. }
  453. $data['pink_count'] = $pink->getCount($where);
  454. $uids = array_flip($pink->getColumn($where, 'uid'));
  455. if (count($uids)) {
  456. mt_srand();
  457. $uids = array_rand($uids, count($uids) < 3 ? count($uids) : 3);
  458. }
  459. $data['avatars'] = $uids ? $user->getColumn(is_array($uids) ? [['uid', 'in', $uids]] : ['uid' => $uids], 'avatar') : [];
  460. return app('json')->successful($data);
  461. }
  462. /**
  463. * 复制口令接口
  464. * @return mixed
  465. */
  466. public function copy_words()
  467. {
  468. $data['words'] = sys_config('copy_words');
  469. return app('json')->successful($data);
  470. }
  471. /**
  472. * 生成口令关键字
  473. * @param Request $request
  474. * @return mixed
  475. * @throws \think\db\exception\DataNotFoundException
  476. * @throws \think\db\exception\DbException
  477. * @throws \think\db\exception\ModelNotFoundException
  478. */
  479. public function copy_share_words(Request $request)
  480. {
  481. [$productId] = $request->getMore([
  482. ['product_id', ''],
  483. ], true);
  484. /** @var StoreProductServices $productService */
  485. $productService = app()->make(StoreProductServices::class);
  486. $keyWords['key_words'] = $productService->getProductWords($productId);
  487. return app('json')->successful($keyWords);
  488. }
  489. /**
  490. * 获取页面数据
  491. * @return mixed
  492. * @throws \think\db\exception\DataNotFoundException
  493. * @throws \think\db\exception\DbException
  494. * @throws \think\db\exception\ModelNotFoundException
  495. */
  496. public function getDiy(DiyServices $services, $id = 0)
  497. {
  498. return app('json')->successful($services->getDiyInfo((int)$id));
  499. }
  500. /**
  501. * @param DiyServices $services
  502. * @param int $id
  503. * @return mixed
  504. * @author 等风来
  505. * @email 136327134@qq.com
  506. * @date 2022/11/9
  507. */
  508. public function getDiyVersion(DiyServices $services, $id = 0)
  509. {
  510. return app('json')->successful(['version' => $services->getDiyVersion((int)$id)]);
  511. }
  512. /**
  513. * 获取底部导航
  514. * @param DiyServices $services
  515. * @param string $template_name
  516. * @return mixed
  517. */
  518. public function getNavigation(DiyServices $services, string $template_name = '')
  519. {
  520. return app('json')->success($services->getNavigation($template_name));
  521. }
  522. /**
  523. * 获取用户协议内容
  524. * @return mixed
  525. */
  526. public function getUserAgreement(Request $request, $type = 1)
  527. {
  528. /** @var CacheServices $cache */
  529. $cache = app()->make(CacheServices::class);
  530. /** @var UserServices $userService */
  531. $userService = app()->make(UserServices::class);
  532. $content = $cache->getDbCache($type, '');
  533. $uid = $request->uid() ?? 0;
  534. $userInfo = $userService->get($uid);
  535. $name = $userInfo['nickname'] ?? '';
  536. $avatar = $userInfo['avatar'] ?? '';
  537. return app('json')->success(compact('content', 'uid', 'name', 'avatar'));
  538. }
  539. /**
  540. * 统计代码
  541. * @return array|string
  542. */
  543. public function getScript()
  544. {
  545. return sys_config('system_statistics', '');
  546. }
  547. /**
  548. * 首页开屏广告
  549. * @return mixed
  550. */
  551. public function getOpenAdv()
  552. {
  553. /** @var CacheServices $cache */
  554. $cache = app()->make(CacheServices::class);
  555. $data = $cache->getDbCache('open_adv', '');
  556. $data['time'] = (float)($data['time'] ?? 3);
  557. $data['interval_time'] = (float)($data['interval_time'] ?? 24);
  558. return app('json')->success($data);
  559. }
  560. /**
  561. * 用户注销
  562. * @param Request $request
  563. * @return mixed
  564. */
  565. public function cancelUser(Request $request)
  566. {
  567. $uid = $request->uid();
  568. if (!$uid) return app('json')->fail('用户不存在');
  569. event('user.cancelUser', [$uid]);
  570. return app('json')->success('注销成功');
  571. }
  572. /**
  573. * 获取版权
  574. * @return mixed
  575. */
  576. public function getCopyright()
  577. {
  578. try {
  579. $copyright = $this->__z6uxyJQ4xYa5ee1mx5();
  580. } catch (\Throwable $e) {
  581. $copyright = [
  582. 'copyrightContext' => '',
  583. 'copyrightImage' => '',
  584. ];
  585. }
  586. $copyright['record_No'] = sys_config('record_No');
  587. $copyright['version'] = get_crmeb_version();
  588. $copyright['routine_contact_type'] = sys_config('routine_contact_type');
  589. $copyright['store_user_agreement'] = (int)sys_config('store_user_agreement');
  590. $copyright['routine_auth_type'] = sys_config('routine_auth_type', []);
  591. $copyright['wechat_auth_switch'] = (int)in_array(1, $copyright['routine_auth_type']);//微信登录开关
  592. $copyright['phone_auth_switch'] = (int)in_array(2, $copyright['routine_auth_type']);//手机号登录开关
  593. $copyright['site_name'] = sys_config('site_name', '');
  594. $copyright['site_logo'] = sys_config('wap_login_logo', '');
  595. $copyright['wechat_status'] = sys_config('wechat_appid') && sys_config('wechat_appsecret');
  596. return $this->success($copyright);
  597. }
  598. /**
  599. * 登录页面获取logo以及版本全新
  600. * @return mixed
  601. */
  602. public function getLogo()
  603. {
  604. try {
  605. $copyright = $this->__z6uxyJQ4xYa5ee1mx5();
  606. } catch (\Throwable $e) {
  607. $copyright = [
  608. 'copyrightContext' => '',
  609. 'copyrightImage' => '',
  610. ];
  611. }
  612. $copyright['record_No'] = sys_config('record_No');
  613. $copyright['version'] = get_crmeb_version();
  614. $logo = sys_config('wap_login_logo');
  615. if (strstr($logo, 'http') === false && $logo) $logo = sys_config('site_url') . $logo;
  616. $copyright['site_name'] = sys_config('site_name');
  617. $copyright['logo_url'] = str_replace('\\', '/', $logo);
  618. $copyright['store_user_agreement'] = (int)sys_config('store_user_agreement');
  619. $copyright['routine_auth_type'] = sys_config('routine_auth_type', []);
  620. $copyright['wechat_auth_switch'] = (int)in_array(1, $copyright['routine_auth_type']);//微信登录开关
  621. $copyright['phone_auth_switch'] = (int)in_array(2, $copyright['routine_auth_type']);//手机号登录开关
  622. $copyright['wechat_status'] = sys_config('wechat_appid') && sys_config('wechat_appsecret');
  623. return app('json')->successful($copyright);
  624. }
  625. }