PublicController.php 27 KB

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