render('/default/cindex'); } /** * @return string */ public function actionOrderDetails() { $e = new stdClass(); $e->success = false; $e->message = 'ok'; $e->item = []; $orderUUId = $this->request->post('id'); $md5Mobile = $this->request->post('sn'); $orderModel = RepairOrderRepository::findOne(['short_uuid' => $orderUUId]); if (empty($orderModel)) { $e->message = '找不到该订单'; return $this->renderJson($e); } $orderId = $orderModel->id; $brokenImageModels = RepairOrderRepository::findOrderImageAll(['repair_order_id' => $orderId]); $brokenImages = []; $baseURL = Yii::$app->request->getHostInfo(); foreach($brokenImageModels as $k => $v) { $brokenImages[] = $baseURL.'/'.$v->image_path; } $totalPrice = $orderModel->order_price; $rPlans = RepairOrderRepository::findOrderPlansAll(['repair_order_id' => $orderId]); $repairPlans = []; foreach($rPlans as $k => $plan) { $repairPlans[] = ['plan' => $plan['repair_plan'] ,'price' => $plan['price']]; } $fImages = RepairOrderRepository::findOrderFinishImageAll(['repair_order_id' => $orderId]); $finishImages = []; foreach($fImages as $k => $image) { $finishImages[] = $baseURL.'/'.$image['image_path']; } $comments = []; $hasComment = false; $rateModel = RepairOrderRateRepository::findOne(['repair_order_id' => $orderId]); if ($rateModel) { $hasComment = true; $comments = ['starTxt' => RepairOrderRate::starLabel($rateModel->star_count), 'comment' => $rateModel->comment]; } $e->success = true; $e->item = [ 'carNo' => $orderModel->car_no, 'carModel' => $orderModel->car_model, 'customer' => $orderModel->customer, 'mobile' => '1*****'.substr($orderModel->contact_mobile,7,4), 'preRepair' => $orderModel->predict_fault, 'repairPrice' => $orderModel->predict_price.'元', 'preFinishDate' => date('Y-m-d H:00', $orderModel->predict_finish_time), 'orderDateTime' => date('Y-m-d H:00', $orderModel->created_at), 'status' => RepairOrderStatus::getEnLabel($orderModel->status), 'hasComment' => $hasComment, 'comments' => $comments, 'brokenImages' => $brokenImages, 'repairPlans' => $repairPlans, 'totalPrice' => $totalPrice, 'finishImages' => $finishImages ]; return $this->renderJson($e); } /** * @return string */ public function actionSubmitRate() { $e = new stdClass(); $e->success = false; $e->message = 'ok'; $star = $this->request->post('star'); $orderUUId = $this->request->post('id'); $comment = $this->request->post('comment'); $userId = $this->getUserId(); $orderModel = RepairOrderRepository::findOne(['short_uuid' => $orderUUId]); if (empty($orderModel)) { $e->message = '找不到订单'; return $this->renderJson($e); } if (RepairOrderStatus::WORKING == $orderModel->status) { $e->message = '订单还在维修中'; return $this->renderJson($e); } if(mb_strlen($comment) > 200) { $e->message = '评论只能200字内'; return $this->renderJson($e); } $rateModel = RepairOrderRateRepository::findOne(['repair_order_id' => $orderModel->id]); if ($rateModel) { $e->message = '已经评价过了'; return $this->renderJson($e); } if ($userId > 0) { $e->message = '维修厂人员不能评论'; //return $this->renderJson($e); } $items = [ 'ip_address' => Utils::clientIp(), 'customer_id' => 0, 'star_count' => $star, 'repair_order_id' => $orderModel->id, 'comment' => $comment, ]; $rateModel = RepairOrderRate::create($items); if($rateModel) { $e->success = true; $e->message = '提交成功'; } else { $e->message = '提交评论失败'; } return $this->renderJson($e); } }