public function actionAddgoodstocar() { $goodsId = Yii::app()->request->getParam("goodsid"); $quant = Yii::app()->request->getParam("quant"); //商品数量 $locate = Yii::app()->request->getParam("locate"); //定位车型 if ($quant) { $goodscount = $quant; } else { $goodscount = 1; } if (!$goodsId) { echo false; } $payment = 1; //通过商品ID获取商品信息 $goods = MallService::getGoodByID($goodsId, $payment); if (!$goods) { echo false; } if ($goods["ProPrice"]) { //促销价大于折扣价,则折扣价作为销售价存入购物车表 $SellPrice = $goods["ProPrice"]; } else { if ($goods['DisPrice']) { $SellPrice = $goods["DisPrice"]; } else { $SellPrice = $goods['Price']; } } //定位车系 $cookie = Yii::app()->request->getCookies(); if ($locate) { $locate = explode('_', $locate); $make = $locate[0]; $series = $locate[1]; $year = $locate[2]; $model = $locate[3]; } else { $make = $cookie['mallmake']->value; $series = $cookie['mallseries']->value; $year = $cookie['mallyear']->value; $model = $cookie['mallmodel']->value; } //提出商品信息中需要加入购物车中的字段 $params = array("GoodsID" => $goodsId, "GoodsName" => $goods["Name"], "CpName" => $goods["CpName"], "GoodsNum" => $goods["GoodsNO"], "Brand" => $goods["BrandName"], "ImageUrl" => $goods['Images'][0]["ImageUrl"], "Price" => $goods["Price"], "ProPrice" => $SellPrice ? $SellPrice : $goods["Price"], "BuyerID" => Yii::app()->user->getOrganID(), "BuyerName" => Yii::app()->user->getOrganName(), "SellerID" => $goods["SellerID"], "SellerName" => $goods["OrganName"], "CreateTime" => time(), "UpdateTime" => time(), "Quantity" => $goodscount, "MakeID" => $make, "CarID" => $series, "Year" => $year, "ModelID" => $model); //var_dump($params);exit; echo MallService::addtocart($params); }