[]]); } /** * 我的订单页面 * @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/productDetail.html?goodsId=' . $goodsId . '&key=' . $encryptUserId; //todo 发邮件 Log::info($url); $MailCaptchaService = new MailCaptchaService; if ($MailCaptchaService->sendText($mailbox, 'From Your Friend', $url)) { ShareKey::save(["key_string" => $encryptUserId, 'user_id' => $userId, 'create_time' => time(), 'is_delete' => 0, 'update_time' => time()]); return $this->renderSuccess('Sent Successful!Please check your new mails.'); } return $this->renderSuccess([]); } }