public function actionInsertorderdata()
 {
     $userId = Yii::$app->session->get(FVariable::$session_userId_str);
     if (!$userId) {
         return $this->redirect(FVariable::$siteLogin_view);
     }
     $addressId = intval(Yii::$app->request->post("addressId"));
     $TotalPrice = floatval(Yii::$app->request->post("TotalPrice"));
     $order = new Order();
     $cart = new Cart();
     $cartList = $cart->findById($userId);
     if (!$cartList) {
         return $this->redirect(FVariable::$home_view);
     }
     $allMoney = "";
     foreach ($cartList as $mk => $mv) {
         $allMoney += $mv['count'] * $mv['productPrice'];
     }
     if ($TotalPrice != $allMoney) {
         $TotalPrice = $allMoney;
     }
     $orderNo = Tool::getOrderNumber();
     $connection = Yii::$app->getDb();
     $transaction = $connection->beginTransaction();
     try {
         $orderDetail = new OrderDetail();
         $orderData = $order->insertOrder($orderNo, $TotalPrice, GlobalArray::$orderStateConstantArray['waitPay'], GlobalArray::$orderPayMethodConstantArray['alipay'], GlobalArray::$orderComeFromConstantArray['WEB'], $userId, $addressId);
         $orderId = Yii::$app->db->getLastInsertID();
         $cartDetail = $cart->findByIdIs($userId);
         if (!$cartDetail) {
             return $this->redirect(FVariable::$home_view);
         }
         $detailArr = [];
         foreach ($cartDetail as $k => $v) {
             $new = [];
             $new[0] = $orderId;
             $new[1] = $v['productId'];
             $new[2] = $v['count'];
             $new[3] = $v['money'];
             $detailArr[$k] = $new;
         }
         $orderDetail->insertOrderDetail($detailArr);
         $product = new Product();
         $orderDetailFind = $orderDetail->findByOrderIdProduct($orderId);
         foreach ($orderDetailFind as $k => $v) {
             $productSelect = $product->findByProductId($v['productId']);
             $productStock = $productSelect->productStock;
             $productSales = $productSelect->productSales;
             $detailArrCount = $productStock - $v['productCount'];
             $productSales = $productSales + $v['productCount'];
             $product->UpdateByStock($v['productId'], $detailArrCount, $productSales);
         }
         $cart->findByIdDelCartAll($userId);
         $transaction->commit();
     } catch (Exception $e) {
         $transaction->rollBack();
         throw $e;
     }
     $this->redirect(Yii::$app->urlManager->createUrl([FVariable::$userOrderpayment_view, 'id' => $orderId]));
 }