User.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  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. public function genFakeUsers()
  144. {
  145. $names = ['Eliana',
  146. 'Elias',
  147. 'Brooklyn',
  148. 'Joshua',
  149. 'Elena',
  150. 'Nathan',
  151. 'Aubrey',
  152. 'Caleb',
  153. 'Claire',
  154. 'Ryan',
  155. 'Ivy',
  156. 'Adrian',
  157. 'Kinsley',
  158. 'Miles',
  159. 'Audrey',
  160. 'Eli',
  161. 'Maya',
  162. 'Nolan',
  163. 'Genesis',
  164. 'Christian',
  165. 'Skylar',
  166. 'Aaron',
  167. 'Bella',
  168. 'Cameron',
  169. 'Aaliyah',
  170. 'Ezekiel',
  171. 'Madelyn',
  172. 'Colton',
  173. 'Savannah',
  174. 'Luca',
  175. 'Anna',
  176. 'Landon',
  177. 'Delilah',
  178. 'Hunter',
  179. 'Serenity',
  180. 'Jonathan',
  181. 'Caroline',
  182. 'Santiago',
  183. 'Kennedy',
  184. 'Axel',
  185. 'Valentina',
  186. 'Easton',
  187. 'Ruby',
  188. 'Cooper',
  189. 'Sophie',
  190. 'Jeremiah',
  191. 'Alice',
  192. 'Angel',
  193. 'Gabriella',
  194. 'Roman',
  195. 'Sadie',
  196. 'Connor',
  197. 'Ariana',
  198. 'Jameson',
  199. 'Allison',
  200. 'Robert',
  201. 'Hailey',
  202. 'Greyson',
  203. 'Autumn',
  204. 'Jordan',
  205. 'Nevaeh',
  206. 'Ian',
  207. 'Natalia',
  208. 'Carson',
  209. 'Quinn',
  210. 'Jaxson',
  211. 'Josephine',
  212. 'Leonardo',
  213. 'Sarah',
  214. 'Nicholas',
  215. 'Cora',
  216. 'Dominic',
  217. 'Emery',
  218. 'Austin',
  219. 'Samantha',
  220. 'Everett',
  221. 'Piper',
  222. 'Brooks',
  223. 'Leilani',
  224. 'Xavier',
  225. 'Eva',
  226. 'Kai',
  227. 'Everleigh',
  228. 'Jose',
  229. 'Madeline',
  230. 'Parker',
  231. 'Lydia',
  232. 'Adam',
  233. 'Jade',
  234. 'Jace',
  235. 'Peyton',
  236. 'Wesley',
  237. 'Brielle',
  238. 'Kayden',
  239. 'Adeline',
  240. 'Silas',
  241. 'Vivian',
  242. 'Bennett',
  243. 'Rylee',
  244. 'Declan',
  245. 'Clara',
  246. 'Waylon',
  247. 'Raelynn',
  248. 'Weston',
  249. 'Melanie',
  250. 'Evan',
  251. 'Melody',
  252. 'Emmett',
  253. 'Julia',
  254. 'Micah',
  255. 'Athena',
  256. 'Ryder',
  257. 'Maria',
  258. 'Beau',
  259. 'Liliana',
  260. 'Damian',
  261. 'Hadley',
  262. 'Hadley',
  263. 'Brayden',
  264. 'Arya',
  265. 'Gael',
  266. 'Rose',
  267. 'Rowan',
  268. 'Reagan',
  269. 'Harrison',
  270. 'Eliza',
  271. 'Bryson',
  272. 'Adalynn',
  273. 'Adalynn',
  274. 'Sawyer',
  275. 'Kaylee',
  276. 'Amir',
  277. 'Lyla',
  278. 'Kingston',
  279. 'Mackenzie',
  280. 'Jason',
  281. 'Alaia',
  282. 'Giovanni',
  283. 'Isabelle',
  284. 'Vincent',
  285. 'Charlie',
  286. 'Ayden',
  287. 'Arianna',
  288. 'Chase',
  289. 'Mary',
  290. 'Myles',
  291. 'Myles',
  292. 'Remi',
  293. 'Diego',
  294. 'Margaret',
  295. 'Nathaniel',
  296. 'Iris',
  297. 'Legend',
  298. 'Parker',
  299. 'Jonah',
  300. 'Ximena',
  301. 'River',
  302. 'Eden',
  303. 'Tyler',
  304. 'Ayla',
  305. 'Cole',
  306. 'Kylie',
  307. 'Braxton',
  308. 'Elliana',
  309. 'George',
  310. 'Josie',
  311. 'Milo',
  312. 'Katherine',
  313. 'Zachary',
  314. 'Faith',
  315. 'Ashton',
  316. 'Alexandra',
  317. 'Luis',
  318. 'Eloise',
  319. 'Jasper',
  320. 'Adalyn',
  321. 'Adalyn',
  322. 'Kaiden',
  323. 'Amaya',
  324. 'Adriel',
  325. 'Jasmine',
  326. 'Gavin',
  327. 'Amara',
  328. 'Bentley',
  329. 'Daisy',
  330. 'Calvin',
  331. 'Reese',
  332. 'Zion',
  333. 'Valerie',
  334. 'Juan',
  335. 'Brianna',
  336. 'Maxwell',
  337. 'Cecilia',
  338. 'Max',
  339. 'Andrea',
  340. 'Ryker',
  341. 'Summer',
  342. 'Carlos',
  343. 'Valeria',
  344. 'Emmanuel',
  345. 'Norah',
  346. 'Jayce',
  347. 'Ariella',
  348. 'Lorenzo',
  349. 'Esther',
  350. 'Ivan',
  351. 'Ashley',
  352. 'Jude',
  353. 'Emerson',
  354. 'August',
  355. 'August',
  356. 'Aubree',
  357. 'Kevin',
  358. 'Isabel',
  359. 'Malachi',
  360. 'Anastasia',
  361. 'Elliott',
  362. 'Genevieve',
  363. 'Jesus',
  364. 'Alina',
  365. 'Maddox',
  366. 'Bailey',
  367. 'King',
  368. 'Juniper',
  369. 'Theo',
  370. 'Maeve'];
  371. //pre(count($names));
  372. for ($i = 0; $i < 100; $i++) {
  373. $mobile = $names[rand(0,225)] . '_' . rand(1000, 9999);
  374. pre($mobile);
  375. }
  376. }
  377. }