PublicController.php 27 KB

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