User.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625
  1. <?php
  2. namespace app\index\controller;
  3. use app\index\model\ShareKey;
  4. use app\index\service\passport\MailCaptcha as MailCaptchaService;
  5. use app\index\model\OrderAddress;
  6. use app\index\model\user\PointsLog as PointsLogModel;
  7. use app\index\model\Goods as GoodsModel;
  8. use app\index\model\Order as OrderModel;
  9. use app\store\model\Express as ExpressModel;
  10. use think\facade\Log;
  11. use think\facade\Session;
  12. /**
  13. * 默认控制器
  14. * Class User
  15. * @package app\api\controller
  16. */
  17. class User extends Controller
  18. {
  19. /**
  20. * 个人中心
  21. * @return \think\response\View
  22. */
  23. public function personal()
  24. {
  25. $userId = Session::get('user_id');
  26. if (empty($userId)) {
  27. return view('passport/logIn');
  28. }
  29. $goodsModel = new GoodsModel();
  30. //$goods['content'] = html_entity_decode($goods['content']);
  31. return view('order', ['goods' => []]);
  32. }
  33. /**
  34. * 我的订单页面
  35. * @return \think\response\View
  36. */
  37. public function order(string $orderType = 'received')
  38. {
  39. $userId = Session::get('user_id');
  40. if (empty($userId)) {
  41. return view('passport/logIn');
  42. }
  43. return view('order');
  44. }
  45. /**
  46. * 订单详情
  47. * @param $orderId
  48. * @return \think\response\View
  49. * @throws \cores\exception\BaseException
  50. * @throws \think\db\exception\DataNotFoundException
  51. * @throws \think\db\exception\DbException
  52. * @throws \think\db\exception\ModelNotFoundException
  53. */
  54. public function orderDetails($orderId)
  55. {
  56. $userId = Session::get('user_id');
  57. if (empty($userId)) {
  58. return view('passport/logIn');
  59. }
  60. $orderId = intval($orderId);
  61. $model = OrderModel::getUserOrderDetail($orderId);
  62. $orderAddress = OrderAddress::get(['order_id' => $orderId]);
  63. if (!empty($model['express_no'])) {
  64. $expModel = new ExpressModel();
  65. $tracks = $expModel->dynamicUsps($model['express_no']);
  66. //dd($tracks);
  67. } else {
  68. $tracks = [];
  69. }
  70. if (!$tracks) {
  71. $f1Track = [];
  72. } else {
  73. $f1Track = $tracks['list'][0]['trackList'] ?? [];
  74. }
  75. $createTimeInt = strtotime($model['create_time']);
  76. $selfTrack = [];
  77. if (time() > $createTimeInt + 9864) {
  78. $selfTrack[] = ['time' => date('Y-m-d H:i:s', $createTimeInt + 9864), 'text' => 'Orders taken', 'desc' => 'The order has entered the warehouse'];
  79. }
  80. if (time() > $createTimeInt + 3653) {
  81. $selfTrack[] = ['time' => date('Y-m-d H:i:s', $createTimeInt + 3653), 'text' => 'Orders taken', 'desc' => 'The merchant has received your order and is waiting to be shipped'];
  82. }
  83. $selfTrack[] = ['time' => date('Y-m-d H:i:s', $createTimeInt + 5), 'text' => 'Order paid', 'desc' => 'Successful'];
  84. return view('orderDetails', ['order' => $model, 'orderAddress' => $orderAddress, 'selfTrack' => $selfTrack, 'f1Track' => $f1Track]);
  85. }
  86. /**
  87. * 我的积分页面
  88. * @return \think\response\View
  89. */
  90. public function myScores()
  91. {
  92. $userId = Session::get('user_id');
  93. if (empty($userId)) {
  94. return view('passport/logIn');
  95. }
  96. $model = new PointsLogModel;
  97. $list = $model->getList();
  98. $user = \app\index\service\User::getCurrentLoginUser();
  99. return view('integral', ['user' => $user]);
  100. }
  101. /**
  102. * 我的积分列表
  103. * @return \think\response\Json
  104. * @throws \app\common\exception\BaseException
  105. * @throws \think\db\exception\DbException
  106. */
  107. public function pointsLogs()
  108. {
  109. $model = new PointsLogModel;
  110. $list = $model->getList();
  111. return $this->renderSuccess(compact('list'));
  112. }
  113. /**
  114. * 分享商品
  115. * @return \think\response\Json
  116. */
  117. public function shareUser()
  118. {
  119. $userId = Session::get('user_id');
  120. if (empty($userId)) {
  121. return $this->renderJson(config('status.not_logged'), 'Log in please!');
  122. }
  123. $goodsId = $this->request->param('goodsId');
  124. if (empty($goodsId)) {
  125. return $this->renderError('Invalid goods');
  126. }
  127. $mailbox = $this->request->param('mailbox');
  128. if (empty($mailbox)) {
  129. return $this->renderError('Invalid mailbox');
  130. }
  131. $encryptUserId = encrypt(strval($userId));
  132. $url = 'Your friend shared a product with you. Click on the link to view it now:'
  133. . config('app.app_host') . '/index/index/productDetails.html?goodsId=' . $goodsId . '&key=' . $encryptUserId;
  134. Log::info($url);
  135. $MailCaptchaService = new MailCaptchaService;
  136. if ($MailCaptchaService->sendText($mailbox, 'From Your Friend', $url)) {
  137. $shareKeyModel = new ShareKey();
  138. $shareKeyModel->save(['key_string' => $encryptUserId, 'user_id' => $userId, 'create_time' => time(), 'is_delete' => 0, 'update_time' => time()]);
  139. return $this->renderSuccess([], 'Successful! Tell your friends to check for new emails.');
  140. }
  141. return $this->renderSuccess([], 'Successful! Tell your friends to check for new emails.');
  142. }
  143. /**
  144. * 生成马甲号
  145. * @return \think\response\Json
  146. * @throws \Exception
  147. */
  148. public function genFakeUsers()
  149. {
  150. $names = ['Eliana',
  151. 'Elias',
  152. 'Brooklyn',
  153. 'Joshua',
  154. 'Elena',
  155. 'Nathan',
  156. 'Aubrey',
  157. 'Caleb',
  158. 'Claire',
  159. 'Ryan',
  160. 'Ivy',
  161. 'Adrian',
  162. 'Kinsley',
  163. 'Miles',
  164. 'Audrey',
  165. 'Eli',
  166. 'Maya',
  167. 'Nolan',
  168. 'Genesis',
  169. 'Christian',
  170. 'Skylar',
  171. 'Aaron',
  172. 'Bella',
  173. 'Cameron',
  174. 'Aaliyah',
  175. 'Ezekiel',
  176. 'Madelyn',
  177. 'Colton',
  178. 'Savannah',
  179. 'Luca',
  180. 'Anna',
  181. 'Landon',
  182. 'Delilah',
  183. 'Hunter',
  184. 'Serenity',
  185. 'Jonathan',
  186. 'Caroline',
  187. 'Santiago',
  188. 'Kennedy',
  189. 'Axel',
  190. 'Valentina',
  191. 'Easton',
  192. 'Ruby',
  193. 'Cooper',
  194. 'Sophie',
  195. 'Jeremiah',
  196. 'Alice',
  197. 'Angel',
  198. 'Gabriella',
  199. 'Roman',
  200. 'Sadie',
  201. 'Connor',
  202. 'Ariana',
  203. 'Jameson',
  204. 'Allison',
  205. 'Robert',
  206. 'Hailey',
  207. 'Greyson',
  208. 'Autumn',
  209. 'Jordan',
  210. 'Nevaeh',
  211. 'Ian',
  212. 'Natalia',
  213. 'Carson',
  214. 'Quinn',
  215. 'Jaxson',
  216. 'Josephine',
  217. 'Leonardo',
  218. 'Sarah',
  219. 'Nicholas',
  220. 'Cora',
  221. 'Dominic',
  222. 'Emery',
  223. 'Austin',
  224. 'Samantha',
  225. 'Everett',
  226. 'Piper',
  227. 'Brooks',
  228. 'Leilani',
  229. 'Xavier',
  230. 'Eva',
  231. 'Kai',
  232. 'Everleigh',
  233. 'Jose',
  234. 'Madeline',
  235. 'Parker',
  236. 'Lydia',
  237. 'Adam',
  238. 'Jade',
  239. 'Jace',
  240. 'Peyton',
  241. 'Wesley',
  242. 'Brielle',
  243. 'Kayden',
  244. 'Adeline',
  245. 'Silas',
  246. 'Vivian',
  247. 'Bennett',
  248. 'Rylee',
  249. 'Declan',
  250. 'Clara',
  251. 'Waylon',
  252. 'Raelynn',
  253. 'Weston',
  254. 'Melanie',
  255. 'Evan',
  256. 'Melody',
  257. 'Emmett',
  258. 'Julia',
  259. 'Micah',
  260. 'Athena',
  261. 'Ryder',
  262. 'Maria',
  263. 'Beau',
  264. 'Liliana',
  265. 'Damian',
  266. 'Hadley',
  267. 'Hadley',
  268. 'Brayden',
  269. 'Arya',
  270. 'Gael',
  271. 'Rose',
  272. 'Rowan',
  273. 'Reagan',
  274. 'Harrison',
  275. 'Eliza',
  276. 'Bryson',
  277. 'Adalynn',
  278. 'Adalynn',
  279. 'Sawyer',
  280. 'Kaylee',
  281. 'Amir',
  282. 'Lyla',
  283. 'Kingston',
  284. 'Mackenzie',
  285. 'Jason',
  286. 'Alaia',
  287. 'Giovanni',
  288. 'Isabelle',
  289. 'Vincent',
  290. 'Charlie',
  291. 'Ayden',
  292. 'Arianna',
  293. 'Chase',
  294. 'Mary',
  295. 'Myles',
  296. 'Myles',
  297. 'Remi',
  298. 'Diego',
  299. 'Margaret',
  300. 'Nathaniel',
  301. 'Iris',
  302. 'Legend',
  303. 'Parker',
  304. 'Jonah',
  305. 'Ximena',
  306. 'River',
  307. 'Eden',
  308. 'Tyler',
  309. 'Ayla',
  310. 'Cole',
  311. 'Kylie',
  312. 'Braxton',
  313. 'Elliana',
  314. 'George',
  315. 'Josie',
  316. 'Milo',
  317. 'Katherine',
  318. 'Zachary',
  319. 'Faith',
  320. 'Ashton',
  321. 'Alexandra',
  322. 'Luis',
  323. 'Eloise',
  324. 'Jasper',
  325. 'Adalyn',
  326. 'Adalyn',
  327. 'Kaiden',
  328. 'Amaya',
  329. 'Adriel',
  330. 'Jasmine',
  331. 'Gavin',
  332. 'Amara',
  333. 'Bentley',
  334. 'Daisy',
  335. 'Calvin',
  336. 'Reese',
  337. 'Zion',
  338. 'Valerie',
  339. 'Juan',
  340. 'Brianna',
  341. 'Maxwell',
  342. 'Cecilia',
  343. 'Max',
  344. 'Andrea',
  345. 'Ryker',
  346. 'Summer',
  347. 'Carlos',
  348. 'Valeria',
  349. 'Emmanuel',
  350. 'Norah',
  351. 'Jayce',
  352. 'Ariella',
  353. 'Lorenzo',
  354. 'Esther',
  355. 'Ivan',
  356. 'Ashley',
  357. 'Jude',
  358. 'Emerson',
  359. 'August',
  360. 'August',
  361. 'Aubree',
  362. 'Kevin',
  363. 'Isabel',
  364. 'Malachi',
  365. 'Anastasia',
  366. 'Elliott',
  367. 'Genevieve',
  368. 'Jesus',
  369. 'Alina',
  370. 'Maddox',
  371. 'Bailey',
  372. 'King',
  373. 'Juniper',
  374. 'Theo',
  375. 'Maeve'];
  376. $salt = 'xxxxxx';
  377. $password = md5('123456' . $salt);
  378. for ($i = 0; $i < 100; $i++) {
  379. $user = [];
  380. $temp = $names[rand(0, 225)] . '_' . rand(100000, 999999);
  381. $user['mobile'] = $temp . '@fvp.com';
  382. $user['nick_name'] = $temp;
  383. $user['avatar_id'] = 0;
  384. $user['gender'] = 1;
  385. $user['country'] = 'US';
  386. $user['province'] = '';
  387. $user['city'] = '';
  388. $user['address_id'] = 0;
  389. $user['balance'] = 0;
  390. $user['points'] = 0;
  391. $user['pay_money'] = 0;
  392. $user['expend_money'] = 0;
  393. $user['platform'] = 'h5';
  394. $user['last_login_time'] = time();
  395. $user['is_delete'] = 0;
  396. $user['store_id'] = 10001;
  397. $user['create_time'] = time();
  398. $user['update_time'] = time();
  399. $user['salt'] = $salt;
  400. $user['password'] = $password;
  401. $users[] = $user;
  402. }
  403. $userModel = new \app\index\model\User();
  404. $userModel->saveAll($users);
  405. return $this->renderSuccess([], 'Successful!');
  406. }
  407. public function genGoodsComments()
  408. {
  409. $others = ['very realistic',];
  410. $favor = ['tastes very good',
  411. 'like fresh strawberries',
  412. 'refreshing but not overwhelming',
  413. 'very refreshing',
  414. 'tastes like enjoying a cup of hot cocoa',
  415. 'completely different from the bitterness and throat irritation of traditional cigarettes',
  416. 'different favor',
  417. "Tastes like enjoying a cup of hot cocoa, warm and delightful.",
  418. "addictive!",
  419. "Feels like biting into a fresh apple, crisp and delicious.",
  420. "There's a subtle vanilla flavor, making you feel like you're in a garden.",
  421. "Tastes like caramel with a delicate sweetness.",
  422. "It feels like savoring the aroma of freshly baked bread, absolutely tantalizing.",
  423. "Tastes like sipping on a tangy-sweet lemonade.",
  424. "There's a refreshing oceanic taste, making you feel like you're on the beach.",
  425. "The taste of this electronic product is like fresh grass, uplifting.",
  426. "It feels like tasting the richness of coffee.",
  427. "Feels like indulging in a mouthful of creamy ice cream, smooth and delicious.",
  428. "Tastes a bit like smelling a bouquet of fresh roses.",
  429. "Feels like tasting the aroma of freshly baked bread.",
  430. "There's a rich chocolate flavor, making you feel like you're in heaven.",
  431. "The taste of this electronic product is like a fresh fruit platter, delightful in every way.",
  432. "The taste is like savoring a mouthful of sweet honey.",
  433. "Feels like enjoying a cup of mild tea, warm and comforting.",
  434. "Tastes like indulging in a sweet and chilled fruit juice.",
  435. "There's a refreshing herbal taste, making you feel refreshed.",
  436. "Feels like savoring a cup of rich Italian coffee, strong and aromatic.",
  437. "The taste is like enjoying a dense chocolate cake.",
  438. "Feels like being surrounded by the scent of flowers in a garden.",
  439. "Tastes a bit like biting into a fresh watermelon, sweet and juicy.",
  440. "There's a cool minty flavor, instantly refreshing.",
  441. "Feels like savoring a cup of aromatic latte, full of vitality.",
  442. "Tastes like indulging in a sweet marshmallow.",
  443. "Feels like enjoying a tangy-sweet lemon tea.",
  444. "Tastes a bit like sipping on a fresh coconut water, sweet and refreshing.",
  445. "There's a subtle vanilla flavor, uplifting the mood.",
  446. "Feels like savoring a rich chocolate cake, delicious and delightful.",
  447. "Tastes like enjoying a cool scoop of ice cream.",
  448. "Feels like being surrounded by the scent of fresh flowers.",
  449. "Tastes a bit like indulging in a scoop of fresh strawberry ice cream.",
  450. "There's a rich coffee flavor, making you feel energetic.",
  451. "Feels like savoring a cup of steaming hot black tea, warm and comforting.",
  452. "Tastes like indulging in a rich chocolate cake.",
  453. "Feels like enjoying a cup of sweet coconut milkshake.",
  454. "Tastes a bit like savoring a fresh blueberry ice cream.",
  455. "There's a subtle herbal taste, making you feel connected to nature.",
  456. "Feels like savoring a cup of aromatic mocha coffee, with fragrance filling the air.",
  457. "Tastes like enjoying a smooth scoop of mango ice cream.",
  458. "Feels like bathing in the refreshing scent of oranges.",
  459. "Tastes a bit like indulging in a sweet fruit salad.",
  460. 'very rich',
  461. 'So rich',
  462. 'Very delicate',
  463. 'So Delicate',
  464. 'Fresh',
  465. 'Pleasant',
  466. 'Refreshing',
  467. 'Robust',
  468. 'Aromatic',
  469. 'So Clean',
  470. 'Clean',
  471. 'Mild',
  472. 'Very Sweet',
  473. 'So Smooth',
  474. 'Mellow',
  475. 'Fragrant',
  476. 'So Warm',
  477. 'Intense',
  478. 'Light',
  479. 'Velvety',
  480. 'Deep',
  481. 'So deep',
  482. 'Satisfying',
  483. 'Subtle sweetness',
  484. 'Minty freshness',
  485. 'Luscious',
  486. 'Sweet-tasting',
  487. 'Long-lasting aftertaste',
  488. 'Zesty',
  489. 'Pure',
  490. 'Very Pure',
  491. 'Silky',
  492. 'Very Silky',
  493. 'Fiery',
  494. 'Icy',
  495. 'Very Icy',
  496. 'Exquisite fragrance',
  497. 'Comforting',
  498. 'Honeyed',
  499. 'Strong',
  500. 'So Strong, I like it',
  501. 'Balanced acidity',
  502. 'Subtle',
  503. 'Silken',
  504. 'Smooth and mellow',
  505. 'Creamy',
  506. 'Rich flavor',
  507. 'Delicious',
  508. 'Richly fragrant',
  509. 'Comfortable',
  510. 'Tasty',
  511. 'Tasty good',
  512. 'Full-bodied',
  513. 'Fresh and invigorating',
  514. 'Refreshing',
  515. 'Pleasing to the palate',
  516. 'Crisp',
  517. 'Complex',
  518. 'Satisfying',
  519. ];
  520. $price = [
  521. 'Affordable',
  522. 'Budget-friendly',
  523. 'Inexpensive',
  524. 'Economical',
  525. 'Cost-effective',
  526. 'Reasonably priced',
  527. 'Wallet-friendly',
  528. 'Cheap',
  529. 'Low-cost',
  530. 'Pocket-friendly',
  531. 'Bargain',
  532. 'Value for money',
  533. 'Dirt cheap',
  534. 'Cost-efficient',
  535. 'Discounted',
  536. 'Thrifty',
  537. 'Economically priced',
  538. 'Within budget',
  539. 'Modestly priced',
  540. 'Frugal',
  541. 'Low-priced',
  542. 'Marked down',
  543. 'Unbeatable price',
  544. 'Discounted rate',
  545. 'Value-priced',
  546. 'Competitive pricing',
  547. 'Affordable option',
  548. 'Great value',
  549. 'Rock-bottom prices',
  550. 'Cost-conscious',
  551. 'Sale price',
  552. 'Reasonable cost',
  553. 'Budget-conscious',
  554. 'Discount pricing',
  555. 'Low-priced option',
  556. 'Wallet-friendly choice',
  557. 'Entry-level pricing',
  558. 'Discounted deal',
  559. 'Cost-saving',
  560. 'Discounted rate',
  561. 'Sale bargain',
  562. 'Unmatched value',
  563. 'Unbelievably cheap',
  564. 'Steal deal',
  565. 'Slashed prices',
  566. 'Reduced rate',
  567. 'Great deal',
  568. 'Budget-friendly option',
  569. 'Money-saving',
  570. 'On a budget',
  571. ];
  572. $amount = ['the amount of smoke is very large', 'very large', 'On sale',
  573. 'Abundant',
  574. 'Plentiful',
  575. 'Ample',
  576. 'Copious',
  577. 'Generous',
  578. 'Substantial',
  579. 'Bountiful',
  580. 'Overflowing',
  581. 'Profuse',
  582. 'Plenty',
  583. 'Rich in quantity',
  584. 'Prolific',
  585. 'Luxuriant',
  586. 'In abundance',
  587. ];
  588. $delivery = [];
  589. $end = ['good', 'my favorite'];
  590. $pool = [
  591. 'The taste of this e-cigarette is really great, completely different from the bitterness and throat irritation of traditional cigarettes.',
  592. 'The smoke effect of electronic cigarettes is very realistic, as if I can truly feel the pleasure of smoking, and the amount of smoke is very large, so I can enjoy the smoking experience for a long time.',
  593. 'After switching to e-cigarettes, I found that my body seemed to be healthier and there was no intake of harmful substances like traditional cigarettes. It was really great.',
  594. 'Electronic cigarettes are very environmentally friendly, do not produce smoke, and have no negative impact on the environment, which makes me feel very proud.',
  595. 'very portable', ' I can use them anytime, anywhere. They are very convenient, and I no longer have to worry about not finding an ashtray.'
  596. ];
  597. }
  598. }