public function actionEvaluatesubmit() { $userId = Yii::$app->session->get(FVariable::$session_userId_str); if (!$userId) { return $this->redirect(FVariable::$siteLogin_view); } $iNum = Yii::$app->request->post('iNum'); $iScore = Yii::$app->request->post('iScore'); $orderDetailId = Yii::$app->request->post('orderDetailId'); $orderId = Yii::$app->request->post('orderId'); $pId = Yii::$app->request->post('productId'); $commnet = new Comment(); $orderDetail = new OrderDetail(); $order = new Order(); $orderDetailUpdate = $orderDetail->UpdateOrderDetail($orderDetailId); $productId = $orderDetail->findIdOrderDetail($orderDetailId); $commnet->findByIdInsert($userId, GlobalArray::$commentTypeConstantArray['product'], $orderDetailId, $iNum, $iScore); $isEvaluate = $orderDetail->findByIsEvaluate($orderId); $product = new Product(); $commentList = $commnet->SelectAllProductCom(); $count = 0; $num = 0; if ($commentList) { foreach ($commentList as $k => $v) { $orderDetailProductId = $orderDetail->findIdOrderDetailIsEvaluate($v['typeId']); if ($orderDetailProductId->productId == $pId) { $count++; $num += $commnet->findByIdCom($orderDetailProductId->id)->score; } } $score = sprintf("%.1f", $num / $count); $product->UpdateByCommentCount($productId->productId, $score); } $isOk = true; foreach ($isEvaluate as $isEk => $isEv) { if ($isEv['isEvaluate'] == 0) { JsonParser::GenerateJsonResult('_0000', '评价成功!'); $isOk = false; break; } } if ($isOk) { $order->findByConfirm($orderId, $userId); JsonParser::GenerateJsonResult('_0001', '评价成功!'); exit; } }