PublicController.php 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2026 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\activity\coupon\StoreCouponIssueServices;
  14. use app\services\activity\lottery\LuckLotteryRecordServices;
  15. use app\services\article\ArticleServices;
  16. use app\services\diy\DiyServices;
  17. use app\services\diy\ThemeServices;
  18. use app\services\kefu\service\StoreServiceServices;
  19. use app\services\message\MessageSystemServices;
  20. use app\services\order\DeliveryServiceServices;
  21. use app\services\order\StoreCartServices;
  22. use app\services\order\StoreOrderCartInfoServices;
  23. use app\services\order\StoreOrderRefundServices;
  24. use app\services\order\StoreOrderServices;
  25. use app\services\other\AgreementServices;
  26. use app\services\other\CacheServices;
  27. use app\services\product\product\StoreCategoryServices;
  28. use app\services\product\product\StoreProductRelationServices;
  29. use app\services\product\product\StoreProductServices;
  30. use app\services\shipping\ExpressServices;
  31. use app\services\shipping\SystemCityServices;
  32. use app\services\system\AppVersionServices;
  33. use app\services\system\attachment\SystemAttachmentServices;
  34. use app\services\system\config\SystemConfigServices;
  35. use app\services\system\config\SystemStorageServices;
  36. use app\services\system\lang\LangCodeServices;
  37. use app\services\system\lang\LangCountryServices;
  38. use app\services\system\lang\LangTypeServices;
  39. use app\services\system\store\SystemStoreServices;
  40. use app\services\system\store\SystemStoreStaffServices;
  41. use app\services\user\UserBillServices;
  42. use app\services\user\UserExtractServices;
  43. use app\services\user\UserInvoiceServices;
  44. use app\services\user\UserServices;
  45. use app\services\wechat\RoutineSchemeServices;
  46. use app\services\wechat\WechatUserServices;
  47. use app\Request;
  48. use crmeb\services\CacheService;
  49. use app\services\other\UploadService;
  50. use crmeb\services\pay\Pay;
  51. use crmeb\services\workerman\ChannelService;
  52. /**
  53. * 公共类
  54. * Class PublicController
  55. * @package app\api\controller
  56. */
  57. class PublicController
  58. {
  59. /**
  60. * 主页获取
  61. * @param Request $request
  62. * @return mixed
  63. */
  64. public function index(Request $request)
  65. {
  66. $banner = sys_data('routine_home_banner') ?: []; //TODO 首页banner图
  67. $menus = sys_data('routine_home_menus') ?: []; //TODO 首页按钮
  68. $roll = sys_data('routine_home_roll_news') ?: []; //TODO 首页滚动新闻
  69. $activity = sys_data('routine_home_activity', 3) ?: []; //TODO 首页活动区域图片
  70. $explosive_money = sys_data('index_categy_images') ?: []; //TODO 首页超值爆款
  71. $site_name = sys_config('site_name');
  72. $routine_index_page = sys_data('routine_index_page');
  73. $info['fastInfo'] = $routine_index_page[0]['fast_info'] ?? ''; //TODO 快速选择简介
  74. $info['bastInfo'] = $routine_index_page[0]['bast_info'] ?? ''; //TODO 精品推荐简介
  75. $info['firstInfo'] = $routine_index_page[0]['first_info'] ?? ''; //TODO 首发新品简介
  76. $info['salesInfo'] = $routine_index_page[0]['sales_info'] ?? ''; //TODO 促销单品简介
  77. $logoUrl = sys_config('routine_index_logo'); //TODO 促销单品简介
  78. if (strstr($logoUrl, 'http') === false && $logoUrl) {
  79. $logoUrl = sys_config('site_url') . $logoUrl;
  80. }
  81. $logoUrl = str_replace('\\', '/', $logoUrl);
  82. $fastNumber = (int)sys_config('fast_number', 0);//TODO 快速选择分类个数
  83. /** @var StoreCategoryServices $categoryService */
  84. $categoryService = app()->make(StoreCategoryServices::class);
  85. $info['fastList'] = $fastNumber ? $categoryService->byIndexList($fastNumber, 'id,cate_name,pid,pic') : [];//TODO 快速选择分类个数
  86. /** @var StoreProductServices $storeProductServices */
  87. $storeProductServices = app()->make(StoreProductServices::class);
  88. //获取推荐商品
  89. [$baseList, $firstList, $benefit, $likeInfo, $vipList] = $storeProductServices->getRecommendProductArr((int)$request->uid(), ['is_best', 'is_new', 'is_benefit', 'is_hot']);
  90. $info['bastList'] = $baseList; //TODO 精品推荐个数
  91. $info['firstList'] = $firstList; //TODO 首发新品个数
  92. $info['bastBanner'] = sys_data('routine_home_bast_banner') ?? []; //TODO 首页精品推荐图片
  93. $lovely = sys_data('routine_home_new_banner') ?: []; //TODO 首发新品顶部图
  94. if ($request->uid()) {
  95. /** @var WechatUserServices $wechatUserService */
  96. $wechatUserService = app()->make(WechatUserServices::class);
  97. $subscribe = (bool)$wechatUserService->value(['uid' => $request->uid()], 'subscribe');
  98. } else {
  99. $subscribe = true;
  100. }
  101. $newGoodsBananr = sys_config('new_goods_bananr');
  102. $tengxun_map_key = sys_config('tengxun_map_key');
  103. return app('json')->success(compact('banner', 'menus', 'roll', 'info', 'activity', 'lovely', 'benefit', 'likeInfo', 'logoUrl', 'site_name', 'subscribe', 'newGoodsBananr', 'tengxun_map_key', 'explosive_money'));
  104. }
  105. /**
  106. * 获取分享配置
  107. * @return mixed
  108. */
  109. public function share()
  110. {
  111. $data['img'] = sys_config('wechat_share_img');
  112. if (strstr($data['img'], 'http') === false && $data['img'] != '') {
  113. $data['img'] = sys_config('site_url') . $data['img'];
  114. }
  115. $data['img'] = str_replace('\\', '/', $data['img']);
  116. $data['title'] = sys_config('wechat_share_title');
  117. $data['synopsis'] = sys_config('wechat_share_synopsis');
  118. return app('json')->success($data);
  119. }
  120. /**
  121. * 获取网站配置
  122. * @return mixed
  123. */
  124. public function getSiteConfig()
  125. {
  126. $data['record_No'] = sys_config('record_No');
  127. $data['icp_url'] = sys_config('icp_url');
  128. $data['network_security'] = sys_config('network_security');
  129. $data['network_security_url'] = sys_config('network_security_url');
  130. return app('json')->success($data);
  131. }
  132. /**
  133. * 获取个人中心菜单
  134. * @param Request $request
  135. * @return mixed
  136. * @throws \think\db\exception\DataNotFoundException
  137. * @throws \think\db\exception\ModelNotFoundException
  138. * @throws \think\exception\DbException
  139. */
  140. public function menu_user(Request $request)
  141. {
  142. $menusInfo = sys_data('routine_my_menus') ?? [];
  143. $uid = 0;
  144. $userInfo = [];
  145. if ($request->hasMacro('user')) $userInfo = $request->user();
  146. if ($request->hasMacro('uid')) $uid = $request->uid();
  147. //用户等级开关
  148. $vipOpen = sys_config('member_func_status');
  149. //分销功能开关
  150. $brokerageFuncStatus = sys_config('brokerage_func_status');
  151. //余额功能开关
  152. $balanceFuncStatus = sys_config('balance_func_status');
  153. //付费会员开关
  154. $svipOpen = sys_config('member_card_status');
  155. $userService = $userOrder = $userVerifyStatus = $deliveryUser = $invoiceStatus = $isUserPromoter = false;
  156. if ($uid && $userInfo) {
  157. /** @var StoreServiceServices $storeService */
  158. $storeService = app()->make(StoreServiceServices::class);
  159. //是否客服
  160. $userService = $storeService->checkoutIsService(['uid' => $uid, 'status' => 1]);
  161. //是否订单管理
  162. $userOrder = $storeService->checkoutIsService(['uid' => $uid, 'status' => 1, 'customer' => 1]);
  163. //是否核销员
  164. $userVerifyStatus = app()->make(SystemStoreStaffServices::class)->verifyStatus($uid);
  165. //是否配送员
  166. $deliveryUser = app()->make(DeliveryServiceServices::class)->checkoutIsService($uid);
  167. //发票功能开关
  168. $invoiceStatus = app()->make(UserInvoiceServices::class)->invoiceFuncStatus(false);
  169. //是否分销员
  170. $isUserPromoter = app()->make(UserServices::class)->checkUserPromoter($uid, $userInfo);
  171. }
  172. $auth = [];
  173. $auth['/pages/users/user_vip/index'] = $vipOpen;
  174. $auth['/pages/users/user_spread_user/index'] = $brokerageFuncStatus && $isUserPromoter;
  175. $auth['/pages/annex/settled/index'] = $brokerageFuncStatus && sys_config('store_brokerage_statu') == 1 && !$isUserPromoter;
  176. $auth['/pages/users/user_money/index'] = $balanceFuncStatus;
  177. $auth['/pages/admin/order/index'] = $auth['/pages/admin/manage/index'] = $userOrder;
  178. $auth['/pages/admin/order_cancellation/index'] = $userVerifyStatus || $deliveryUser;
  179. $auth['/pages/users/user_invoice_list/index'] = $invoiceStatus;
  180. $auth['/pages/annex/vip_paid/index'] = $svipOpen;
  181. $auth['/kefu/mobile_list'] = $userService;
  182. foreach ($menusInfo as $key => &$value) {
  183. if (isset($value['is_show']) && $value['is_show'] == 0) {
  184. unset($menusInfo[$key]);
  185. continue;
  186. }
  187. if ($value['url'] == '/pages/users/user_spread_user/index' && $auth['/pages/annex/settled/index']) {
  188. $value['name'] = '分销申请';
  189. $value['url'] = '/pages/annex/settled/index';
  190. }
  191. if (isset($auth[$value['url']]) && !$auth[$value['url']]) {
  192. unset($menusInfo[$key]);
  193. continue;
  194. }
  195. if ($value['url'] == '/kefu/mobile_list') {
  196. $value['url'] = sys_config('site_url') . $value['url'];
  197. if ($request->isRoutine()) {
  198. $value['url'] = str_replace('http://', 'https://', $value['url']);
  199. }
  200. }
  201. }
  202. /** @var SystemConfigServices $systemConfigServices */
  203. $systemConfigServices = app()->make(SystemConfigServices::class);
  204. $bannerInfo = $systemConfigServices->getSpreadBanner() ?? [];
  205. $my_banner = sys_data('routine_my_banner');
  206. $routine_contact_type = sys_config('routine_contact_type', 0);
  207. /** @var DiyServices $diyServices */
  208. $diyServices = app()->make(DiyServices::class);
  209. $diy_data = $diyServices->get(['template_name' => 'member', 'type' => 1], ['value', 'order_status', 'my_banner_status', 'my_menus_status', 'business_status']);
  210. $diy_data = $diy_data ? $diy_data->toArray() : [];
  211. 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]);
  212. }
  213. /**
  214. * 热门搜索关键字获取
  215. * @return mixed
  216. * @throws \think\db\exception\DataNotFoundException
  217. * @throws \think\db\exception\ModelNotFoundException
  218. * @throws \think\exception\DbException
  219. */
  220. public function search()
  221. {
  222. $routineHotSearch = sys_data('routine_hot_search') ?? [];
  223. $searchKeyword = [];
  224. if (count($routineHotSearch)) {
  225. foreach ($routineHotSearch as $key => &$item) {
  226. array_push($searchKeyword, $item['title']);
  227. }
  228. }
  229. return app('json')->success($searchKeyword);
  230. }
  231. /**
  232. * 图片上传
  233. * @param Request $request
  234. * @param SystemAttachmentServices $services
  235. * @return mixed
  236. */
  237. public function upload_image(Request $request, SystemAttachmentServices $services)
  238. {
  239. $data = $request->postMore([
  240. ['filename', 'file'],
  241. ]);
  242. if (!$data['filename']) return app('json')->fail('参数错误');
  243. if (CacheService::has('start_uploads_' . $request->uid()) && CacheService::get('start_uploads_' . $request->uid()) >= 100) return app('json')->fail('非法操作');
  244. $upload = UploadService::init();
  245. $info = $upload->to('store/comment')->validate()->move($data['filename']);
  246. if ($info === false) {
  247. return app('json')->fail($upload->getError());
  248. }
  249. $res = $upload->getUploadInfo();
  250. $services->attachmentAdd($res['name'], $res['size'], $res['type'], $res['dir'], $res['thumb_path'], 1, (int)sys_config('upload_type', 1), $res['time'], 3);
  251. if (CacheService::has('start_uploads_' . $request->uid()))
  252. $start_uploads = (int)CacheService::get('start_uploads_' . $request->uid());
  253. else
  254. $start_uploads = 0;
  255. $start_uploads++;
  256. CacheService::set('start_uploads_' . $request->uid(), $start_uploads, 86400);
  257. $res['dir'] = path_to_url($res['dir']);
  258. if (strpos($res['dir'], 'http') === false) $res['dir'] = $request->domain() . $res['dir'];
  259. return app('json')->success('图片上传成功', ['name' => $res['name'], 'url' => $res['dir']]);
  260. }
  261. /**
  262. * 物流公司
  263. * @return mixed
  264. */
  265. public function logistics(ExpressServices $services)
  266. {
  267. $expressList = $services->expressList();
  268. return app('json')->success($expressList ?? []);
  269. }
  270. /**
  271. * 短信购买异步通知
  272. *
  273. * @param Request $request
  274. * @return mixed
  275. */
  276. public function sms_pay_notify(Request $request)
  277. {
  278. [$order_id, $price, $status, $num, $pay_time, $attach] = $request->postMore([
  279. ['order_id', ''],
  280. ['price', 0.00],
  281. ['status', 400],
  282. ['num', 0],
  283. ['pay_time', time()],
  284. ['attach', 0],
  285. ], true);
  286. if ($status == 200) {
  287. try {
  288. ChannelService::instance()->send('PAY_SMS_SUCCESS', ['price' => $price, 'number' => $num], [$attach]);
  289. } catch (\Throwable $e) {
  290. }
  291. return app('json')->success('操作成功');
  292. }
  293. return app('json')->fail('操作失败');
  294. }
  295. /**
  296. * 记录用户分享
  297. * @param Request $request
  298. * @param UserBillServices $services
  299. * @return mixed
  300. */
  301. public function user_share(Request $request, UserBillServices $services)
  302. {
  303. $uid = (int)$request->uid();
  304. $services->setUserShare($uid);
  305. return app('json')->success('更新成功');
  306. }
  307. /**
  308. * 获取图片base64
  309. * @param Request $request
  310. * @return mixed
  311. */
  312. public function get_image_base64(Request $request)
  313. {
  314. [$imageUrl, $codeUrl] = $request->postMore([
  315. ['image', ''],
  316. ['code', ''],
  317. ], true);
  318. /** @var SystemStorageServices $systemStorageServices */
  319. $systemStorageServices = app()->make(SystemStorageServices::class);
  320. $domainArr = $systemStorageServices->getColumn([], 'domain');
  321. $domainArr = array_merge($domainArr, [$request->host()]);
  322. $domainArr = array_unique(array_diff($domainArr, ['']));
  323. if (count($domainArr)) {
  324. $domainArr = array_map(function ($item) {
  325. return str_replace(['https://', 'http://'], '', $item);
  326. }, $domainArr);
  327. }
  328. $domainArr[] = 'mp.weixin.qq.com';
  329. $imageUrlHost = $imageUrl ? (parse_url($imageUrl)['host'] ?? $imageUrl) : $imageUrl;
  330. $codeUrlHost = $codeUrl ? (parse_url($codeUrl)['host'] ?? $codeUrl) : $codeUrl;
  331. if ($domainArr && (($imageUrl && !in_array($imageUrlHost, $domainArr)) || ($codeUrl && !in_array($codeUrlHost, $domainArr)))) {
  332. return app('json')->success(['code' => false, 'image' => false]);
  333. }
  334. if ($imageUrl !== '' && !preg_match('/.*(\.png|\.jpg|\.jpeg|\.gif)$/', $imageUrl) && strpos(strtolower($imageUrl), "phar://") !== false) {
  335. return app('json')->success(['code' => false, 'image' => false]);
  336. }
  337. if ($codeUrl !== '' && !(preg_match('/.*(\.png|\.jpg|\.jpeg|\.gif)$/', $codeUrl) || strpos($codeUrl, 'https://mp.weixin.qq.com/cgi-bin/showqrcode') !== false) && strpos(strtolower($codeUrl), "phar://") !== false) {
  338. return app('json')->success(['code' => false, 'image' => false]);
  339. }
  340. try {
  341. $code = CacheService::remember($codeUrl, function () use ($codeUrl) {
  342. $codeTmp = $code = $codeUrl ? image_to_base64($codeUrl) : false;
  343. if (!$codeTmp) {
  344. $putCodeUrl = put_image($codeUrl);
  345. //TODO
  346. $code = $putCodeUrl ? image_to_base64(app()->request->domain(true) . '/' . $putCodeUrl) : false;
  347. if ($putCodeUrl) {
  348. unlink($_SERVER["DOCUMENT_ROOT"] . DS . $putCodeUrl);
  349. }
  350. }
  351. return $code;
  352. });
  353. $image = CacheService::remember($imageUrl, function () use ($imageUrl) {
  354. $imageTmp = $image = $imageUrl ? image_to_base64($imageUrl) : false;
  355. if (!$imageTmp) {
  356. $putImageUrl = put_image($imageUrl);
  357. //TODO
  358. $image = $putImageUrl ? image_to_base64(app()->request->domain(true) . '/' . $putImageUrl) : false;
  359. if ($putImageUrl) {
  360. unlink($_SERVER["DOCUMENT_ROOT"] . DS . $putImageUrl);
  361. }
  362. }
  363. return $image;
  364. });
  365. return app('json')->success(compact('code', 'image'));
  366. } catch (\Exception $e) {
  367. return app('json')->fail('操作失败');
  368. }
  369. }
  370. /**
  371. * 门店列表
  372. * @return mixed
  373. */
  374. public function store_list(Request $request, SystemStoreServices $services)
  375. {
  376. list($latitude, $longitude) = $request->getMore([
  377. ['latitude', ''],
  378. ['longitude', ''],
  379. ], true);
  380. $data['list'] = $services->getStoreList(['type' => 0], ['id', 'name', 'phone', 'address', 'detailed_address', 'image', 'latitude', 'longitude'], $latitude, $longitude);
  381. $data['tengxun_map_key'] = sys_config('tengxun_map_key');
  382. return app('json')->success($data);
  383. }
  384. /**
  385. * 查找城市数据
  386. * @param Request $request
  387. * @return mixed
  388. */
  389. public function city_list(Request $request)
  390. {
  391. /** @var SystemCityServices $systemCity */
  392. $systemCity = app()->make(SystemCityServices::class);
  393. return app('json')->success($systemCity->cityList());
  394. }
  395. /**
  396. * 获取拼团数据
  397. * @return mixed
  398. */
  399. public function pink(StorePinkServices $pink, UserServices $user)
  400. {
  401. $data['pink_count'] = $pink->getCount(['is_refund' => 0]);
  402. $uids = array_flip($pink->getColumn(['is_refund' => 0], 'uid'));
  403. if (count($uids)) {
  404. $uids = array_rand($uids, count($uids) < 3 ? count($uids) : 3);
  405. }
  406. $data['avatars'] = $uids ? $user->getColumn(is_array($uids) ? [['uid', 'in', $uids]] : ['uid' => $uids], 'avatar') : [];
  407. foreach ($data['avatars'] as &$avatar) {
  408. if (strpos($avatar, '/statics/system_images/') !== false) {
  409. $avatar = set_file_url($avatar);
  410. }
  411. }
  412. return app('json')->success($data);
  413. }
  414. /**
  415. * 复制口令接口
  416. * @return mixed
  417. */
  418. public function copy_words()
  419. {
  420. $data['words'] = sys_config('copy_words');
  421. return app('json')->success($data);
  422. }
  423. /**生成口令关键字
  424. * @param Request $request
  425. * @return mixed
  426. * @throws \think\db\exception\DataNotFoundException
  427. * @throws \think\db\exception\DbException
  428. * @throws \think\db\exception\ModelNotFoundException
  429. */
  430. public function copy_share_words(Request $request)
  431. {
  432. list($productId) = $request->getMore([
  433. ['product_id', ''],
  434. ], true);
  435. /** @var StoreProductServices $productService */
  436. $productService = app()->make(StoreProductServices::class);
  437. $keyWords['key_words'] = $productService->getProductWords($productId);
  438. return app('json')->success($keyWords);
  439. }
  440. /**
  441. * 获取页面数据
  442. * @return mixed
  443. * @throws \think\db\exception\DataNotFoundException
  444. * @throws \think\db\exception\DbException
  445. * @throws \think\db\exception\ModelNotFoundException
  446. */
  447. public function getDiy(DiyServices $services, $id = 0)
  448. {
  449. return app('json')->success($services->getDiyInfo((int)$id));
  450. }
  451. /**
  452. * 获取底部导航
  453. * @param DiyServices $services
  454. * @param string $template_name
  455. * @return mixed
  456. */
  457. public function getNavigation(DiyServices $services, string $template_name = '')
  458. {
  459. return app('json')->success($services->getNavigation($template_name));
  460. }
  461. /**
  462. * 首页商品数据
  463. * @param Request $request
  464. */
  465. public function home_products_list(Request $request, DiyServices $services)
  466. {
  467. $data = $request->getMore([
  468. ['priceOrder', ''],
  469. ['newsOrder', ''],
  470. ['salesOrder', ''],
  471. [['type', 'd'], 0],
  472. ['ids', ''],
  473. [['selectId', 'd'], ''],
  474. ['selectType', 0],
  475. ['isType', 0],
  476. ]);
  477. $where = [];
  478. $where['is_show'] = 1;
  479. $where['is_del'] = 0;
  480. $where['productId'] = '';
  481. if ($data['selectType'] == 1) {
  482. if (!$data['ids']) {
  483. return app('json')->success('暂无数据');
  484. }
  485. $where['ids'] = $data['ids'] ? explode(',', $data['ids']) : [];
  486. if ($data['type'] != 2 && $data['type'] != 3 && $data['type'] != 8) {
  487. $where['type'] = 0;
  488. } else {
  489. $where['type'] = $data['type'];
  490. }
  491. } else {
  492. $where['priceOrder'] = $data['priceOrder'];
  493. $where['newsOrder'] = $data['newsOrder'];
  494. $where['salesOrder'] = $data['salesOrder'];
  495. $where['type'] = $data['type'];
  496. if ($data['selectId']) {
  497. /** @var StoreCategoryServices $storeCategoryServices */
  498. $storeCategoryServices = app()->make(StoreCategoryServices::class);
  499. if ($storeCategoryServices->value(['id' => $data['selectId']], 'pid')) {
  500. $where['sid'] = $data['selectId'];
  501. } else {
  502. $where['cid'] = $data['selectId'];
  503. }
  504. }
  505. }
  506. return app('json')->success($services->homeProductList($where, $request->uid()));
  507. }
  508. public function getNewAppVersion($platform)
  509. {
  510. /** @var AppVersionServices $appService */
  511. $appService = app()->make(AppVersionServices::class);
  512. return app('json')->success($appService->getNewInfo($platform));
  513. }
  514. public function getCustomerType()
  515. {
  516. $data = [];
  517. $data['customer_type'] = sys_config('customer_type', 0);
  518. $data['customer_phone'] = sys_config('customer_phone', 0);
  519. $data['customer_url'] = sys_config('customer_url', 0);
  520. $data['customer_corpId'] = sys_config('customer_corpId', 0);
  521. return app('json')->success($data);
  522. }
  523. /**
  524. * 统计代码
  525. * @return array|string
  526. */
  527. public function getScript()
  528. {
  529. return sys_config('statistic_script', '');
  530. }
  531. public function customPcJs()
  532. {
  533. return sys_config('custom_pc_js', '');
  534. }
  535. /**
  536. * 获取workerman请求域名
  537. * @return mixed
  538. */
  539. public function getWorkerManUrl()
  540. {
  541. return app('json')->success(getWorkerManUrl());
  542. }
  543. /**
  544. * 首页开屏广告
  545. * @return mixed
  546. */
  547. public function getOpenAdv()
  548. {
  549. /** @var CacheServices $cache */
  550. $cache = app()->make(CacheServices::class);
  551. $data = $cache->getDbCache('open_adv', '');
  552. return app('json')->success($data);
  553. }
  554. /**
  555. * 获取用户协议内容
  556. * @return mixed
  557. */
  558. public function getUserAgreement()
  559. {
  560. /** @var CacheServices $cache */
  561. $cache = app()->make(CacheServices::class);
  562. $content = $cache->getDbCache('user_agreement', '');
  563. return app('json')->success(compact('content'));
  564. }
  565. /**
  566. * 获取协议
  567. * @param AgreementServices $agreementServices
  568. * @param $type
  569. * @return mixed
  570. * @throws \think\db\exception\DataNotFoundException
  571. * @throws \think\db\exception\DbException
  572. * @throws \think\db\exception\ModelNotFoundException
  573. */
  574. public function getAgreement(AgreementServices $agreementServices, $type)
  575. {
  576. $data = $agreementServices->getAgreementBytype($type);
  577. return app('json')->success($data);
  578. }
  579. /**
  580. * 查询版权信息
  581. * @return mixed
  582. */
  583. public function copyright()
  584. {
  585. $copyrightContext = sys_config('nncnL_crmeb_copyright', '');
  586. $copyrightImage = sys_config('nncnL_crmeb_copyright_image', '');
  587. $siteName = sys_config('site_name', '');
  588. $siteLogo = sys_config('wap_login_logo', '');
  589. return app('json')->success(compact('copyrightContext', 'copyrightImage', 'siteName', 'siteLogo'));
  590. }
  591. /**
  592. * 获取多语言类型列表
  593. * @return mixed
  594. * @throws \think\db\exception\DataNotFoundException
  595. * @throws \think\db\exception\DbException
  596. * @throws \think\db\exception\ModelNotFoundException
  597. */
  598. public function getLangTypeList()
  599. {
  600. /** @var LangTypeServices $langTypeServices */
  601. $langTypeServices = app()->make(LangTypeServices::class);
  602. $list = $langTypeServices->langTypeList(['status' => 1, 'is_del' => 0])['list'];
  603. $data = [];
  604. foreach ($list as $item) {
  605. $data[] = ['name' => $item['language_name'], 'value' => $item['file_name']];
  606. }
  607. return app('json')->success($data);
  608. }
  609. /**
  610. * 获取当前语言json
  611. * @return mixed
  612. * @throws \Throwable
  613. */
  614. public function getLangJson()
  615. {
  616. /** @var LangTypeServices $langTypeServices */
  617. $langTypeServices = app()->make(LangTypeServices::class);
  618. /** @var LangCountryServices $langCountryServices */
  619. $langCountryServices = app()->make(LangCountryServices::class);
  620. $request = app()->request;
  621. //获取接口传入的语言类型
  622. if (!$range = $request->header('cb-lang')) {
  623. //没有传入则使用系统默认语言显示
  624. if (!$range = $langTypeServices->value(['is_default' => 1], 'file_name')) {
  625. //系统没有设置默认语言的话,根据浏览器语言显示,如果浏览器语言在库中找不到,则使用简体中文
  626. if ($request->header('accept-language') !== null) {
  627. $range = explode(',', $request->header('accept-language'))[0];
  628. } else {
  629. $range = 'zh-CN';
  630. }
  631. }
  632. }
  633. // 获取type_id
  634. $typeId = $langCountryServices->value(['code' => $range], 'type_id') ?: 1;
  635. // 获取缓存key
  636. $langData = $langTypeServices->getColumn(['status' => 1, 'is_del' => 0], 'file_name', 'id');
  637. $langStr = 'api_lang_' . str_replace('-', '_', $langData[$typeId]);
  638. //读取当前语言的语言包
  639. $lang = CacheService::remember($langStr, function () use ($typeId, $range) {
  640. /** @var LangCodeServices $langCodeServices */
  641. $langCodeServices = app()->make(LangCodeServices::class);
  642. return $langCodeServices->getColumn(['type_id' => $typeId, 'is_admin' => 0], 'lang_explain', 'code');
  643. }, 3600);
  644. return app('json')->success([$range => $lang]);
  645. }
  646. /**
  647. * 获取当前后台设置的默认语言类型
  648. * @return mixed
  649. */
  650. public function getDefaultLangType()
  651. {
  652. /** @var LangTypeServices $langTypeServices */
  653. $langTypeServices = app()->make(LangTypeServices::class);
  654. $lang_type = $langTypeServices->value(['is_default' => 1], 'file_name');
  655. return app('json')->success(compact('lang_type'));
  656. }
  657. /**
  658. * 获取版本号
  659. * @return mixed
  660. */
  661. public function getVersion()
  662. {
  663. $version = parse_ini_file(app()->getRootPath() . '.version');
  664. return app('json')->success(['version' => $version['version'], 'version_code' => $version['version_code']]);
  665. }
  666. /**
  667. * 获取多语言缓存
  668. * @return \think\Response
  669. * @author 吴汐
  670. * @email 442384644@qq.com
  671. * @date 2023/03/06
  672. */
  673. public function getLangVersion()
  674. {
  675. return app('json')->success(app()->make(LangCodeServices::class)->getLangVersion());
  676. }
  677. /**
  678. * 商城基础配置汇总接口
  679. * @return \think\Response
  680. * @author 吴汐
  681. * @email 442384644@qq.com
  682. * @date 2023/04/03
  683. */
  684. public function getMallBasicConfig()
  685. {
  686. $data['site_name'] = sys_config('site_name'); //网站名称
  687. $data['site_url'] = sys_config('site_url'); //网站地址
  688. $data['wap_login_logo'] = sys_config('wap_login_logo'); //移动端登录logo
  689. $data['record_No'] = sys_config('record_No'); //备案号
  690. $data['icp_url'] = sys_config('icp_url'); //备案号链接
  691. $data['network_security'] = sys_config('network_security'); //网安备案
  692. $data['network_security_url'] = sys_config('network_security_url'); //网安备案链接
  693. $data['store_self_mention'] = sys_config('store_self_mention'); //是否开启到店自提
  694. $data['invoice_func_status'] = sys_config('invoice_func_status'); //发票功能启用
  695. $data['special_invoice_status'] = sys_config('special_invoice_status'); //专用发票启用
  696. $data['member_func_status'] = sys_config('member_func_status'); //用户等级启用
  697. $data['balance_func_status'] = sys_config('balance_func_status'); //余额功能启用
  698. $data['recharge_switch'] = sys_config('recharge_switch'); //小程序充值开关
  699. $data['member_card_status'] = sys_config('member_card_status'); //是否开启付费会员
  700. $data['member_price_status'] = sys_config('member_price_status'); //商品会员折扣价展示启用
  701. $data['ali_pay_status'] = sys_config('ali_pay_status') != '0'; //支付宝是否启用
  702. $data['pay_weixin_open'] = sys_config('pay_weixin_open') != '0'; //微信是否启用
  703. $data['yue_pay_status'] = sys_config('yue_pay_status') == 1 && sys_config('balance_func_status') != 0; //余额是否启用
  704. $data['offline_pay_status'] = sys_config('offline_pay_status') == 1; //线下是否启用
  705. $data['friend_pay_status'] = sys_config('friend_pay_status') == 1; //好友是否启用
  706. $data['wechat_auth_switch'] = (int)in_array(1, sys_config('routine_auth_type')); //微信登录开关
  707. $data['phone_auth_switch'] = (int)in_array(2, sys_config('routine_auth_type')); //手机号登录开关
  708. $data['wechat_status'] = sys_config('wechat_appid') != '' && sys_config('wechat_appsecret') != ''; //公众号是否配置
  709. $data['site_func'] = sys_config('model_checkbox', ['seckill', 'bargain', 'combination']);
  710. return app('json')->success($data);
  711. }
  712. /**
  713. * 小程序跳转链接接口
  714. * @param $id
  715. * @author wuhaotian
  716. * @email 442384644@qq.com
  717. * @date 2024/2/26
  718. */
  719. public function getSchemeUrl($id)
  720. {
  721. $url = app()->make(RoutineSchemeServices::class)->value($id, 'url');
  722. if ($url) {
  723. echo '<script>window.location.href="' . $url . '";</script>';
  724. } else {
  725. echo '<h1>未找到跳转路径</h1>';
  726. }
  727. }
  728. /**
  729. * 微信服务商支付
  730. * @param Request $request
  731. * @return \think\Response
  732. * @throws \think\db\exception\DataNotFoundException
  733. * @throws \think\db\exception\DbException
  734. * @throws \think\db\exception\ModelNotFoundException
  735. * @author wuhaotian
  736. * @email 442384644@qq.com
  737. * @date 2024/4/7
  738. */
  739. public function servicePayResult(Request $request)
  740. {
  741. [$sub_mch_id, $out_trade_no, $check_code] = $request->getMore([
  742. ['sub_mch_id', ''],
  743. ['out_trade_no', ''],
  744. ['check_code', ''],
  745. ], true);
  746. $data['site_name'] = sys_config('site_name'); //网站名称
  747. $data['site_url'] = sys_config('site_url'); //网站地址
  748. $data['site_logo'] = sys_config('wap_login_logo'); //移动端登录logo
  749. $order = app()->make(StoreOrderServices::class)->getOne(['order_id' => $out_trade_no]);
  750. $data['goods_name'] = app()->make(StoreOrderCartInfoServices::class)->getCarIdByProductTitle((int)$order['id']);
  751. $data['pay_price'] = $order['pay_price'];
  752. $data['jump_url'] = sys_config('site_url') . '/pages/goods/order_pay_status/index?order_id=' . $out_trade_no . '&msg=支付成功&type=3&totalPrice=' . $data['pay_price'];
  753. return app('json')->header(['X-Frame-Options' => 'payapp.weixin.qq.com'])->success($data);
  754. }
  755. public function getTransferInfo(Request $request, $order_id, $type)
  756. {
  757. $extractServices = app()->make(UserExtractServices::class);
  758. $lotteryRecordServices = app()->make(LuckLotteryRecordServices::class);
  759. $uid = (int)$request->uid();
  760. if ($type == 1) {
  761. $info = $extractServices->getExtractByOrderId($uid, $order_id);
  762. $info['true_extract_price'] = bcsub($info['extract_price'], $info['extract_fee'], 2);
  763. } else {
  764. $info = $lotteryRecordServices->getRecordByOrderId($uid, $order_id);
  765. $info['true_extract_price'] = $info['num'];
  766. }
  767. if ($info['state'] == 'WAIT_USER_CONFIRM') {
  768. $pay = new Pay('v3_wechat_pay');
  769. $res = $pay->queryTransferBills($order_id);
  770. if (isset($res['fail_reason']) && $res['fail_reason'] != '') {
  771. if ($type == 1) {
  772. $extractServices->changeFail($info['id'], $info, '提现失败,原因:超时未领取');
  773. $extractServices->update($info['id'], ['state' => 'FAIL']);
  774. } else {
  775. $lotteryRecordServices->update($info['id'], ['state' => 'FAIL']);
  776. }
  777. $info['state'] = 'FAIL';
  778. }
  779. }
  780. switch ($info['channel_type']) {
  781. case 'wechat':
  782. $info['wechat_appid'] = sys_config('wechat_appid');
  783. break;
  784. case 'routine':
  785. $info['wechat_appid'] = sys_config('routine_appid');
  786. break;
  787. case 'app':
  788. $info['wechat_appid'] = sys_config('app_appid');
  789. break;
  790. }
  791. $info['mchid'] = sys_config('pay_weixin_mchid');
  792. return app('json')->success($info);
  793. }
  794. /**
  795. * 获取主题信息
  796. * @param string $type 主题类型,当为'user'时会附加用户权限和订单统计信息
  797. * @return \think\Response
  798. * @throws \think\db\exception\DataNotFoundException
  799. * @throws \think\db\exception\DbException
  800. * @throws \think\db\exception\ModelNotFoundException
  801. * @author wuhaotian
  802. * @email 442384644@qq.com
  803. * @date 2025/12/25
  804. */
  805. public function themeInfo(Request $request, $type = '')
  806. {
  807. // 获取主题ID参数
  808. [$theme_id] = $request->getMore([
  809. ['theme_id', 0],
  810. ], true);
  811. $themeInfo = app()->make(ThemeServices::class)->getThemeInfo($theme_id, $type);
  812. if (in_array($type, ['home', 'detail', 'user']) && $themeInfo) {
  813. foreach ($themeInfo['value'] as &$userDataItem) {
  814. if ($userDataItem['name'] == 'customerService') {
  815. $userDataItem['routine_contact_type'] = (int)sys_config('routine_contact_type');
  816. }
  817. }
  818. }
  819. // 当类型为'user'时,处理用户相关的权限和菜单配置
  820. if ($type == 'user') {
  821. // 初始化用户信息
  822. $uid = 0;
  823. $userInfo = [];
  824. if ($request->hasMacro('uid')) $uid = $request->uid();
  825. if ($request->hasMacro('user')) $userInfo = $request->user();
  826. // 获取系统功能开关配置
  827. //用户等级开关
  828. $levelOpen = (bool)sys_config('member_func_status');
  829. //分销功能开关
  830. $brokerageOpen = (bool)sys_config('brokerage_func_status');
  831. //余额功能开关
  832. $balanceOpen = (bool)sys_config('balance_func_status');
  833. //付费会员开关
  834. $sVipOpen = (bool)sys_config('member_card_status');
  835. //发票功能
  836. $invoiceOpen = (bool)sys_config('invoice_func_status');
  837. // 初始化用户角色标识
  838. $userIsService = $userIsOrder = $userIsVerify = $userIsDelivery = $userIsPromoter = false;
  839. if ($uid && $userInfo) {
  840. /** @var StoreServiceServices $storeService */
  841. $storeService = app()->make(StoreServiceServices::class);
  842. /** @var StoreOrderServices $orderServices */
  843. $orderServices = app()->make(StoreOrderServices::class);
  844. /** @var StoreOrderRefundServices $storeOrderRefundServices */
  845. $orderRefundServices = app()->make(StoreOrderRefundServices::class);
  846. // 检查用户角色权限
  847. //是否客服
  848. $userIsService = (bool)$storeService->checkoutIsService(['uid' => $uid, 'status' => 1]);
  849. //是否订单管理
  850. $userIsOrder = (bool)$storeService->checkoutIsService(['uid' => $uid, 'status' => 1, 'customer' => 1]);
  851. //是否核销员
  852. $userIsVerify = (bool)app()->make(SystemStoreStaffServices::class)->verifyStatus($uid);
  853. //是否配送员
  854. $userIsDelivery = (bool)app()->make(DeliveryServiceServices::class)->checkoutIsService($uid);
  855. //是否分销员
  856. $userIsPromoter = (bool)app()->make(UserServices::class)->checkUserPromoter($uid, $userInfo);
  857. // 统计各状态订单数量,用于菜单角标显示
  858. $orderAuth = [];
  859. $countWhere = ['is_del' => 0, 'is_system_del' => 0, 'uid' => $uid];
  860. $orderAuth['/pages/goods/order_list/index'] = (int)$orderServices->count($countWhere + ['refund_status' => [0, 3], 'pid' => 0]);
  861. $orderAuth['/pages/goods/order_list/index?status=0'] = (int)$orderServices->count($countWhere + ['status' => 0]);
  862. $orderAuth['/pages/goods/order_list/index?status=1'] = (int)$orderServices->count($countWhere + ['status' => 1, 'pid' => 0]);
  863. $orderAuth['/pages/goods/order_list/index?status=2'] = (int)$orderServices->count($countWhere + ['status' => 2, 'pid' => 0]);
  864. $orderAuth['/pages/goods/order_list/index?status=3'] = (int)$orderServices->count($countWhere + ['status' => 3, 'pid' => 0]);
  865. $orderAuth['/pages/goods/order_list/index?status=4'] = (int)$orderServices->count($countWhere + ['status' => 4, 'pid' => 0]);
  866. $orderAuth['/pages/users/user_return_list/index'] = (int)$orderRefundServices->count(['uid' => $uid, 'is_cancel' => 0, 'is_del' => 0, 'refund_type' => [1, 2, 4, 5]]);
  867. }
  868. // 配置各页面的访问权限
  869. $auth = [];
  870. $auth['/pages/users/user_vip/index'] = $levelOpen;
  871. $auth['/pages/users/user_spread_user/index'] = $brokerageOpen && $userIsPromoter;
  872. $auth['/pages/annex/settled/index'] = $brokerageOpen && sys_config('store_brokerage_statu') == 1 && !$userIsPromoter;
  873. $auth['/pages/users/user_money/index'] = $balanceOpen;
  874. $auth['/pages/admin/order/index'] = $auth['/pages/admin/manage/index'] = $userIsOrder;
  875. $auth['/pages/admin/order_cancellation/index'] = $userIsVerify || $userIsDelivery;
  876. $auth['/pages/users/user_invoice_list/index'] = $invoiceOpen;
  877. $auth['/pages/annex/vip_paid/index'] = $sVipOpen;
  878. $auth['/kefu/mobile_list'] = $userIsService;
  879. // 处理主题菜单配置
  880. if ($themeInfo) {
  881. foreach ($themeInfo['value'] as &$userDataItem) {
  882. if ($userDataItem['name'] == 'menus') {
  883. foreach ($userDataItem['menuConfig']['list'] as &$menuDataItem) {
  884. // 设置菜单显示权限和角标数量
  885. $menuDataItem['show'] = ($auth[$menuDataItem['info'][1]['value']] ?? true) && $menuDataItem['show'];
  886. $menuDataItem['num'] = $orderAuth[$menuDataItem['info'][1]['value']] ?? 0;
  887. // 处理客服链接,拼接完整URL
  888. if ($menuDataItem['info'][1]['value'] == '/kefu/mobile_list') {
  889. $menuDataItem['info'][1]['value'] = sys_config('site_url') . $menuDataItem['info'][1]['value'];
  890. // 小程序环境强制使用https
  891. if ($request->isRoutine()) {
  892. $menuDataItem['info'][1]['value'] = str_replace('http://', 'https://', $menuDataItem['info'][1]['value']);
  893. }
  894. }
  895. // 处理客服聊天页面,添加联系方式类型配置
  896. if ($menuDataItem['info'][1]['value'] == '/pages/extension/customer_list/chat') {
  897. if ($request->isRoutine()) {
  898. $menuDataItem['routine_contact_type'] = (int)sys_config('routine_contact_type', 0);
  899. }
  900. }
  901. if ($menuDataItem['info'][1]['value'] == '/pages/users/user_spread_user/index' && $brokerageOpen && sys_config('store_brokerage_statu') == 1 && !$userIsPromoter) {
  902. $menuDataItem['info'][0]['value'] = '分销申请';
  903. $menuDataItem['info'][1]['value'] = '/pages/annex/settled/index';
  904. $menuDataItem['show'] = true;
  905. }
  906. }
  907. }
  908. }
  909. }
  910. }
  911. return app('json')->success($themeInfo);
  912. }
  913. /**
  914. * 获取主题版本信息
  915. * @return \think\Response
  916. * @author wuhaotian
  917. * @email 442384644@qq.com
  918. * @date 2025/12/25
  919. */
  920. public function themeVersion(Request $request)
  921. {
  922. [$theme_id] = $request->getMore([
  923. ['theme_id', 0],
  924. ], true);
  925. $themeVersion = app()->make(ThemeServices::class)->getThemeVersion($theme_id);
  926. return app('json')->success(['version' => $themeVersion]);
  927. }
  928. /**
  929. * 自定义组件-用户
  930. * @param Request $request
  931. * @return \think\Response
  932. * @author wuhaotian
  933. * @email 442384644@qq.com
  934. * @date 2026/1/12
  935. */
  936. public function themeUser(Request $request)
  937. {
  938. $userInfo = $request->uid() ? $request->user() : [];
  939. if (!$userInfo) return app('json')->fail('暂无数据');
  940. $user = [
  941. 'nickname' => $userInfo['nickname'],
  942. 'uid' => $userInfo['uid'],
  943. 'image' => $userInfo['avatar'],
  944. 'collection_num' => app()->make(StoreProductRelationServices::class)->count(['uid' => $userInfo['uid']]),
  945. 'cart_num' => app()->make(StoreCartServices::class)->count(['uid' => $userInfo['uid']]),
  946. 'order_num' => $userInfo['pay_count'],
  947. 'integral' => $userInfo['integral'],
  948. 'now_money' => $userInfo['now_money'],
  949. 'brokerage_price' => $userInfo['brokerage_price'],
  950. 'unread_msg_num' => app()->make(MessageSystemServices::class)->count(['uid' => $userInfo['uid'], 'look' => 0]),
  951. ];
  952. return app('json')->success($user);
  953. }
  954. /**
  955. * 自定义组件-文章
  956. * @param Request $request
  957. * @return \think\Response
  958. * @throws \ReflectionException
  959. * @throws \think\db\exception\DataNotFoundException
  960. * @throws \think\db\exception\DbException
  961. * @throws \think\db\exception\ModelNotFoundException
  962. * @author wuhaotian
  963. * @email 442384644@qq.com
  964. * @date 2026/1/12
  965. */
  966. public function themeArticle(Request $request)
  967. {
  968. $where = $request->getMore([
  969. ['ids', ''],
  970. ['cid', ''],
  971. ['order', 0],
  972. ['sort', 0],
  973. ['limit', 10],
  974. ]);
  975. $data = app()->make(ArticleServices::class)->getThemeArticle($where);
  976. return app('json')->success($data);
  977. }
  978. /**
  979. * 自定义组件-优惠券
  980. * @param Request $request
  981. * @return \think\Response
  982. * @throws \think\db\exception\DataNotFoundException
  983. * @throws \think\db\exception\DbException
  984. * @throws \think\db\exception\ModelNotFoundException
  985. * @author wuhaotian
  986. * @email 442384644@qq.com
  987. * @date 2026/1/14
  988. */
  989. public function themeCoupon(Request $request)
  990. {
  991. $where = $request->getMore([
  992. ['ids', ''],
  993. ['type', ''],
  994. ['user_type', ''],
  995. ['send_type', ''],
  996. ['is_min_price', 0],
  997. ['min_price', 0],
  998. ['start_time', ''],
  999. ['end_time', ''],
  1000. ['order', 0],
  1001. ['sort', 0],
  1002. ['limit', 10],
  1003. ]);
  1004. $data = app()->make(StoreCouponIssueServices::class)->getThemeCoupon($where);
  1005. return app('json')->success($data);
  1006. }
  1007. /**
  1008. * 自定义组件-商品
  1009. * @param Request $request
  1010. * @return \think\Response
  1011. * @throws \think\db\exception\DataNotFoundException
  1012. * @throws \think\db\exception\DbException
  1013. * @throws \think\db\exception\ModelNotFoundException
  1014. * @author wuhaotian
  1015. * @email 442384644@qq.com
  1016. * @date 2026/1/14
  1017. */
  1018. public function themeProduct(Request $request)
  1019. {
  1020. $where = $request->getMore([
  1021. ['ids', ''],
  1022. ['cate_ids', ''],
  1023. ['order', 0],
  1024. ['sort', 0],
  1025. ['limit', 10],
  1026. ]);
  1027. $data = app()->make(StoreProductServices::class)->getThemeProduct($where);
  1028. return app('json')->success($data);
  1029. }
  1030. /**
  1031. * 获取主题导航数据
  1032. * 调用 ThemeServices 中的 themeNavigation 方法获取导航配置并返回 JSON 响应
  1033. * @return mixed
  1034. */
  1035. public function themeNavigation()
  1036. {
  1037. // 实例化 ThemeServices 并调用 themeNavigation 方法获取导航数据
  1038. $data = app()->make(ThemeServices::class)->themeNavigation();
  1039. // 返回成功响应,包含导航数据
  1040. return app('json')->success($data);
  1041. }
  1042. }