| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402 |
- <?php
- namespace app\index\controller;
- use app\index\model\ShareKey;
- use app\index\service\passport\MailCaptcha as MailCaptchaService;
- use app\index\model\OrderAddress;
- use app\index\model\user\PointsLog as PointsLogModel;
- use app\index\model\Goods as GoodsModel;
- use app\index\model\Order as OrderModel;
- use app\store\model\Express as ExpressModel;
- use think\facade\Log;
- use think\facade\Session;
- /**
- * 默认控制器
- * Class User
- * @package app\api\controller
- */
- class User extends Controller
- {
- /**
- * 个人中心
- * @return \think\response\View
- */
- public function personal()
- {
- $userId = Session::get('user_id');
- if (empty($userId)) {
- return view('passport/logIn');
- }
- $goodsModel = new GoodsModel();
- //$goods['content'] = html_entity_decode($goods['content']);
- return view('order', ['goods' => []]);
- }
- /**
- * 我的订单页面
- * @return \think\response\View
- */
- public function order(string $orderType = 'received')
- {
- $userId = Session::get('user_id');
- if (empty($userId)) {
- return view('passport/logIn');
- }
- return view('order');
- }
- /**
- * 订单详情
- * @param $orderId
- * @return \think\response\View
- * @throws \cores\exception\BaseException
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function orderDetails($orderId)
- {
- $userId = Session::get('user_id');
- if (empty($userId)) {
- return view('passport/logIn');
- }
- $orderId = intval($orderId);
- $model = OrderModel::getUserOrderDetail($orderId);
- $orderAddress = OrderAddress::get(['order_id' => $orderId]);
- if (!empty($model['express_no'])) {
- $expModel = new ExpressModel();
- $tracks = $expModel->dynamicUsps($model['express_no']);
- //dd($tracks);
- } else {
- $tracks = [];
- }
- if (!$tracks) {
- $f1Track = [];
- } else {
- $f1Track = $tracks['list'][0]['trackList'] ?? [];
- }
- $createTimeInt = strtotime($model['create_time']);
- $selfTrack = [];
- if (time() > $createTimeInt + 9864) {
- $selfTrack[] = ['time' => date('Y-m-d H:i:s', $createTimeInt + 9864), 'text' => 'Orders taken', 'desc' => 'The order has entered the warehouse'];
- }
- if (time() > $createTimeInt + 3653) {
- $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'];
- }
- $selfTrack[] = ['time' => date('Y-m-d H:i:s', $createTimeInt + 5), 'text' => 'Order paid', 'desc' => 'Successful'];
- return view('orderDetails', ['order' => $model, 'orderAddress' => $orderAddress, 'selfTrack' => $selfTrack, 'f1Track' => $f1Track]);
- }
- /**
- * 我的积分页面
- * @return \think\response\View
- */
- public function myScores()
- {
- $userId = Session::get('user_id');
- if (empty($userId)) {
- return view('passport/logIn');
- }
- $model = new PointsLogModel;
- $list = $model->getList();
- $user = \app\index\service\User::getCurrentLoginUser();
- return view('integral', ['user' => $user]);
- }
- /**
- * 我的积分列表
- * @return \think\response\Json
- * @throws \app\common\exception\BaseException
- * @throws \think\db\exception\DbException
- */
- public function pointsLogs()
- {
- $model = new PointsLogModel;
- $list = $model->getList();
- return $this->renderSuccess(compact('list'));
- }
- /**
- * 分享商品
- * @return \think\response\Json
- */
- public function shareUser()
- {
- $userId = Session::get('user_id');
- if (empty($userId)) {
- return $this->renderJson(config('status.not_logged'), 'Log in please!');
- }
- $goodsId = $this->request->param('goodsId');
- if (empty($goodsId)) {
- return $this->renderError('Invalid goods');
- }
- $mailbox = $this->request->param('mailbox');
- if (empty($mailbox)) {
- return $this->renderError('Invalid mailbox');
- }
- $encryptUserId = encrypt(strval($userId));
- $url = 'Your friend shared a product with you. Click on the link to view it now:'
- . config('app.app_host') . '/index/index/productDetails.html?goodsId=' . $goodsId . '&key=' . $encryptUserId;
- Log::info($url);
- $MailCaptchaService = new MailCaptchaService;
- if ($MailCaptchaService->sendText($mailbox, 'From Your Friend', $url)) {
- $shareKeyModel = new ShareKey();
- $shareKeyModel->save(['key_string' => $encryptUserId, 'user_id' => $userId, 'create_time' => time(), 'is_delete' => 0, 'update_time' => time()]);
- return $this->renderSuccess([], 'Successful! Tell your friends to check for new emails.');
- }
- return $this->renderSuccess([], 'Successful! Tell your friends to check for new emails.');
- }
- public function genFakeUsers()
- {
- $names = ['Eliana',
- 'Elias',
- 'Brooklyn',
- 'Joshua',
- 'Elena',
- 'Nathan',
- 'Aubrey',
- 'Caleb',
- 'Claire',
- 'Ryan',
- 'Ivy',
- 'Adrian',
- 'Kinsley',
- 'Miles',
- 'Audrey',
- 'Eli',
- 'Maya',
- 'Nolan',
- 'Genesis',
- 'Christian',
- 'Skylar',
- 'Aaron',
- 'Bella',
- 'Cameron',
- 'Aaliyah',
- 'Ezekiel',
- 'Madelyn',
- 'Colton',
- 'Savannah',
- 'Luca',
- 'Anna',
- 'Landon',
- 'Delilah',
- 'Hunter',
- 'Serenity',
- 'Jonathan',
- 'Caroline',
- 'Santiago',
- 'Kennedy',
- 'Axel',
- 'Valentina',
- 'Easton',
- 'Ruby',
- 'Cooper',
- 'Sophie',
- 'Jeremiah',
- 'Alice',
- 'Angel',
- 'Gabriella',
- 'Roman',
- 'Sadie',
- 'Connor',
- 'Ariana',
- 'Jameson',
- 'Allison',
- 'Robert',
- 'Hailey',
- 'Greyson',
- 'Autumn',
- 'Jordan',
- 'Nevaeh',
- 'Ian',
- 'Natalia',
- 'Carson',
- 'Quinn',
- 'Jaxson',
- 'Josephine',
- 'Leonardo',
- 'Sarah',
- 'Nicholas',
- 'Cora',
- 'Dominic',
- 'Emery',
- 'Austin',
- 'Samantha',
- 'Everett',
- 'Piper',
- 'Brooks',
- 'Leilani',
- 'Xavier',
- 'Eva',
- 'Kai',
- 'Everleigh',
- 'Jose',
- 'Madeline',
- 'Parker',
- 'Lydia',
- 'Adam',
- 'Jade',
- 'Jace',
- 'Peyton',
- 'Wesley',
- 'Brielle',
- 'Kayden',
- 'Adeline',
- 'Silas',
- 'Vivian',
- 'Bennett',
- 'Rylee',
- 'Declan',
- 'Clara',
- 'Waylon',
- 'Raelynn',
- 'Weston',
- 'Melanie',
- 'Evan',
- 'Melody',
- 'Emmett',
- 'Julia',
- 'Micah',
- 'Athena',
- 'Ryder',
- 'Maria',
- 'Beau',
- 'Liliana',
- 'Damian',
- 'Hadley',
- 'Hadley',
- 'Brayden',
- 'Arya',
- 'Gael',
- 'Rose',
- 'Rowan',
- 'Reagan',
- 'Harrison',
- 'Eliza',
- 'Bryson',
- 'Adalynn',
- 'Adalynn',
- 'Sawyer',
- 'Kaylee',
- 'Amir',
- 'Lyla',
- 'Kingston',
- 'Mackenzie',
- 'Jason',
- 'Alaia',
- 'Giovanni',
- 'Isabelle',
- 'Vincent',
- 'Charlie',
- 'Ayden',
- 'Arianna',
- 'Chase',
- 'Mary',
- 'Myles',
- 'Myles',
- 'Remi',
- 'Diego',
- 'Margaret',
- 'Nathaniel',
- 'Iris',
- 'Legend',
- 'Parker',
- 'Jonah',
- 'Ximena',
- 'River',
- 'Eden',
- 'Tyler',
- 'Ayla',
- 'Cole',
- 'Kylie',
- 'Braxton',
- 'Elliana',
- 'George',
- 'Josie',
- 'Milo',
- 'Katherine',
- 'Zachary',
- 'Faith',
- 'Ashton',
- 'Alexandra',
- 'Luis',
- 'Eloise',
- 'Jasper',
- 'Adalyn',
- 'Adalyn',
- 'Kaiden',
- 'Amaya',
- 'Adriel',
- 'Jasmine',
- 'Gavin',
- 'Amara',
- 'Bentley',
- 'Daisy',
- 'Calvin',
- 'Reese',
- 'Zion',
- 'Valerie',
- 'Juan',
- 'Brianna',
- 'Maxwell',
- 'Cecilia',
- 'Max',
- 'Andrea',
- 'Ryker',
- 'Summer',
- 'Carlos',
- 'Valeria',
- 'Emmanuel',
- 'Norah',
- 'Jayce',
- 'Ariella',
- 'Lorenzo',
- 'Esther',
- 'Ivan',
- 'Ashley',
- 'Jude',
- 'Emerson',
- 'August',
- 'August',
- 'Aubree',
- 'Kevin',
- 'Isabel',
- 'Malachi',
- 'Anastasia',
- 'Elliott',
- 'Genevieve',
- 'Jesus',
- 'Alina',
- 'Maddox',
- 'Bailey',
- 'King',
- 'Juniper',
- 'Theo',
- 'Maeve'];
- //pre(count($names));
- for ($i = 0; $i < 100; $i++) {
- $mobile = $names[rand(0,225)] . '_' . rand(1000, 9999);
- pre($mobile);
- }
- }
- }
|