Example #1
0
 public static function getsubgoods($params)
 {
     if (!isset($params['subid']) || empty($params['subid'])) {
         return null;
     }
     $subid = $params['subid'];
     $organID = $params['organID'];
     $code = self::getCode($subid);
     $cri = new CDbCriteria();
     $cri->addInCondition('StandCode', $code);
     $cri->addCondition('IsSale=1');
     $cri->addCondition('ISdelete=1');
     $goods = PapGoods::model()->findAll($cri);
     //$goods=PapGoodsGcategory::model()->findAll('SubParts=:sub',array(':sub'=>$subid));
     $result = array();
     if ($goods) {
         foreach ($goods as $key => $val) {
             $res = PapGoods::model()->findByPk($val['ID'], 'IsSale=1 and ISdelete=1');
             //获取商品首张图片
             if (isset($res['ID']) && !is_null($res['ID'])) {
                 $result[$key] = $res->attributes;
                 $price = MallService::getContactprice($res['OrganID'], $organID);
                 $result[$key]['PriceRatio'] = $price['PriceRatio'] ? $price['PriceRatio'] : "100%";
                 $result[$key]['Price'] = sprintf("%.2f", $res['Price'] * $result[$key]['PriceRatio'] / 100);
                 if ($res['IsPro'] == 1) {
                     if (!is_null($res['ProPrice']) && $res['ProPrice']) {
                         $result[$key]['Price'] = $res['ProPrice'];
                     }
                 }
                 $image = PapGoodsImageRelation::model()->find('GoodsID=:goodsID', array(':goodsID' => $res['ID']));
                 if (empty($image['ImageUrl'])) {
                     $result[$key]['imageurl'] = 'dealer/default-goods.png';
                 } else {
                     $result[$key]['imageurl'] = $image['ImageUrl'];
                 }
             }
         }
         return $result;
     }
 }
Example #2
0
 public static function getOneGoodsImage($id)
 {
     return PapGoodsImageRelation::model()->find(array('condition' => "GoodsID={$id}", 'select' => 'ImageUrl'))->attributes['ImageUrl'];
 }
Example #3
0
 public static function idgetimg($ID)
 {
     $model = PapGoodsImageRelation::model()->findAll("GoodsID =:ID", array(":ID" => $ID));
     return $model;
 }
Example #4
0
 public static function newgoodsxinfo($GoodsID)
 {
     $PartsLevel = array('A' => '原厂', 'B' => '高端品牌', 'C' => '经济实用', 'D' => '下线', 'E' => '拆车');
     $Goods = PapGoods::model()->findBypk($GoodsID);
     if ($Goods) {
         $arr = $Goods->attributes;
         $arr['Brand'] = self::idgetjpbrand($Goods->attributes['BrandID'], 'BrandName');
         //机构名称
         $arr['OrganName'] = self::getnamebyorganid($Goods->attributes['OrganID']);
         //获得配件档次名称
         $arr['PartsLevelName'] = $PartsLevel[$Goods->attributes['PartsLevel']];
         //获得标准名称
         $arr['StandCodeName'] = DealergoodsService::StandCodegetcpname($Goods->attributes['StandCode'], 'Name');
         //商品-OE号
         $oeno = PapGoodsOeRelation::model()->findAll('GoodsID=:GoodsID', array(':GoodsID' => $GoodsID));
         foreach ($oeno as $value) {
             $arr['oeno'][] = $value->attributes['OENO'];
         }
         $gcategory = MallService::getCategory($Goods->attributes['StandCode']);
         //            $version['gcategory'] = $gcategory->attributes;
         $redis['gcategory']['BigParts'] = $gcategory['BigPartsID'];
         $redis['gcategory']['SubParts'] = $gcategory['SubPartsID'];
         $redis['gcategory']['BigName'] = $gcategory['BigParts'];
         $redis['gcategory']['SubName'] = $gcategory['SubParts'];
         //商品-图片
         $img = PapGoodsImageRelation::model()->findAll('GoodsID=:GoodsID', array(':GoodsID' => $GoodsID));
         foreach ($img as $key => $value) {
             $arr['img'][$key]['ImageUrl'] = $value->attributes['ImageUrl'];
             $arr['img'][$key]['ImageName'] = $value->attributes['ImageName'];
             $arr['img'][$key]['BigImage'] = $value->attributes['BigImage'];
             $arr['img'][$key]['MallImage'] = $value->attributes['MallImage'];
         }
         //商品-属性
         $spec = PapGoodsSpec::model()->find('GoodsID=:GoodsID', array(':GoodsID' => $GoodsID));
         $arr['spec']['ValidityType'] = $spec->attributes['ValidityType'];
         $arr['spec']['ValidityDate'] = $spec->attributes['ValidityDate'];
         $arr['spec']['Unit'] = $spec->attributes['Unit'];
         $arr['spec']['BganCompany'] = $spec->attributes['BganCompany'];
         $arr['spec']['BganGoodsNO'] = $spec->attributes['BganGoodsNO'];
         //商品-包装
         $pack = PapGoodsPack::model()->find('GoodsID=:GoodsID', array(':GoodsID' => $GoodsID));
         $arr['pack']['MinQuantity'] = $pack->attributes['MinQuantity'];
     }
     return $arr;
 }
Example #5
0
 public static function order($orderId)
 {
     $orderArr = array();
     $organID = Yii::app()->user->getOrganID();
     $orders = PapOrder::model()->findAll("ID=:ID and BuyerID=:BuyerID", array(":ID" => $orderId, ':BuyerID' => $organID));
     foreach ($orders as $order) {
         $orderArr['order'] = $order->attributes;
         if (!empty($order['OrderType'])) {
             $discount = PapOrderDiscount::model()->find(array("condition" => "OrderType = {$order['OrderType']}"));
             $orderArr['discount'] = $discount->attributes;
         }
         $goods = PapOrderGoods::model()->findAll("OrderID=:ID and IsDelete=0", array(":ID" => $orderId));
         foreach ($goods as $key => $value) {
             $data = $value->attributes;
             $image = PapGoodsImageRelation::model()->find('GoodsID=:goodsID', array(':goodsID' => $value['GoodsID']));
             $data['ImageUrl'] = $image['ImageUrl'];
             $orderArr['goodsList'][$key] = $data;
         }
     }
     return $orderArr;
 }
Example #6
0
 public function actionBuytoevaluation()
 {
     $this->pageTitle = Yii::app()->name . '-' . "修理厂评价商品";
     $this->layout = '';
     $OrderStatus = $_GET['OrderStatus'];
     $EvaStatus = $_GET['EvaStatus'];
     $OrderID = $_GET['OrderID'];
     $omodel = PapOrder::model()->findByPk($OrderID, '(EvaStatus=0 or EvaStatus=16) and (Status=9 or Status = 16)');
     if (!$omodel) {
         $this->redirect(array('orderreview/index/orderstype/4/evastatus/1'));
     }
     $model = PapOrderGoods::model()->findAll("OrderID=:ID", array(":ID" => $OrderID));
     foreach ($model as $key => $value) {
         //获得机构ID
         //            $goodsinfo = PapGoods::model()->find("ID=:ID", array(":ID" => $value['GoodsID']));
         //            $data[$key]['GoodsID'] = $GoodsID = $goodsinfo->ID;
         //            $data[$key]['GoodsName'] = $goodsinfo->Name;
         //            $data[$key]['GoodsNO'] = $goodsinfo->GoodsNO;
         //            $data[$key]['OrganID'] = $OrganID = $goodsinfo->OrganID;
         $data[$key]['GoodsID'] = $GoodsID = $value['GoodsID'];
         $data[$key]['GoodsName'] = $value['GoodsName'];
         $data[$key]['GoodsNO'] = $value['GoodsNum'];
         $data[$key]['OrganID'] = $OrganID = $omodel->SellerID;
         //卖家ID
         //获得图片
         $goodsimg = PapGoodsImageRelation::model()->findAll("GoodsID=:GoodsID ", array(":GoodsID" => $GoodsID));
         $data[$key]['GoodsIMG'] = $goodsimg[0]->ImageUrl;
     }
     $evarr = EvaluateService::getevainfo(2);
     $this->render("papeva", array('data' => $data, 'OrderID' => $OrderID, 'OrderStatus' => $OrderStatus, 'EvaStatus' => $EvaStatus, 'evarr' => $evarr));
 }
Example #7
0
 public static function getredis($GoodsID, $search = '')
 {
     $info = Yii::app()->redis->get('GoodsID' . $GoodsID);
     if ($info) {
         $info = json_decode($info, true);
         //            $info['atBrand'] = Yii::app()->redis->get('Brand' . $Goods->attributes['BrandID'] . 'o' . $Goods->attributes['OrganID']);
     } else {
         $Goods = PapGoods::model()->findBypk($GoodsID);
         //            if ($search != 'search') {
         //                if (!$Goods || $Goods->ISdelete == 0) {
         //                    return 'null';
         //                } else if ($Goods->IsSale == 0) {
         //                    return 'nosale';
         //                }
         //            }
         $redis = $Goods->attributes;
         $brandid = $Goods->attributes['BrandID'];
         if ($brandid) {
             $sql = "select BrandName from pap_brand where ID={$brandid}";
             $res = Yii::app()->papdb->createCommand($sql)->queryRow();
         }
         //if($res['Name']){
         $redis['Brand'] = $res['BrandName'] ? $res['BrandName'] : '';
         //品牌认证
         //}
         //机构名称
         $redis['OrganName'] = DealergoodsService::getnamebyorganid($Goods->attributes['OrganID']);
         $redis['PartsLevelName'] = Yii::app()->getParams()->PartsLevel[$Goods->attributes['PartsLevel']];
         $redis['StandCodeName'] = DealergoodsService::StandCodegetcpname($Goods->attributes['StandCode'], 'Name');
         //var_dump($redis);exit;
         $gcategory = self::getCategory($Goods->attributes['StandCode']);
         //            $version['gcategory'] = $gcategory->attributes;
         $redis['gcategory']['BigParts'] = $gcategory['BigPartsID'];
         $redis['gcategory']['SubParts'] = $gcategory['SubPartsID'];
         $redis['gcategory']['BigName'] = $gcategory['BigParts'];
         $redis['gcategory']['SubName'] = $gcategory['SubParts'];
         $oeno = PapGoodsOeRelation::model()->findAll('GoodsID=:GoodsID', array(':GoodsID' => $GoodsID));
         if ($oeno) {
             foreach ($oeno as $value) {
                 $redis['oeno'][] = $value->attributes['OENO'];
             }
         }
         $img = PapGoodsImageRelation::model()->findAll('GoodsID=:GoodsID', array(':GoodsID' => $GoodsID));
         if ($img) {
             foreach ($img as $key => $value) {
                 $redis['img'][$key]['ImageUrl'] = $value->attributes['ImageUrl'];
                 $redis['img'][$key]['ImageName'] = $value->attributes['ImageName'];
                 $redis['img'][$key]['MallImage'] = $value->attributes['MallImage'];
                 $redis['img'][$key]['BigImage'] = $value->attributes['BigImage'];
             }
         }
         $spec = PapGoodsSpec::model()->find('GoodsID=:GoodsID', array(':GoodsID' => $GoodsID));
         $redis['spec']['ValidityType'] = $spec->attributes['ValidityType'];
         $redis['spec']['ValidityDate'] = $spec->attributes['ValidityDate'];
         $redis['spec']['Unit'] = $spec->attributes['Unit'];
         $redis['spec']['BganCompany'] = $spec->attributes['BganCompany'];
         $redis['spec']['BganGoodsNO'] = $spec->attributes['BganGoodsNO'];
         $pack = PapGoodsPack::model()->find('GoodsID=:GoodsID', array(':GoodsID' => $GoodsID));
         $redis['pack']['MinQuantity'] = $pack->attributes['MinQuantity'];
         $vehicle = PapGoodsVehicleRelation::model()->findAll('GoodsID=:GoodsID', array(':GoodsID' => $GoodsID));
         if ($vehicle) {
             foreach ($vehicle as $value) {
                 $redis['vehicle'][$key]['Make'] = $value->attributes['Make'];
                 $redis['vehicle'][$key]['Car'] = $value->attributes['Car'];
                 $redis['vehicle'][$key]['Year'] = $value->attributes['Year'];
                 $redis['vehicle'][$key]['Model'] = $value->attributes['Model'];
                 $redis['vehicle'][$key]['Marktxt'] = $value->attributes['Marktxt'];
                 $redis['vehicle'][$key]['Cartxt'] = $value->attributes['Cartxt'];
                 $redis['vehicle'][$key]['Modeltxt'] = $value->attributes['Modeltxt'];
             }
         }
         if ($search == 'search') {
             $redis['atBrand'] = Yii::app()->redis->get('Brand' . $Goods->attributes['BrandID'] . 'o' . $Goods->attributes['OrganID']);
             return $redis;
         }
         $info = $redis;
         Yii::app()->redis->set('GoodsID' . $GoodsID, json_encode($redis));
     }
     $info['atBrand'] = Yii::app()->redis->get('Brand' . $Goods->attributes['BrandID'] . 'o' . $Goods->attributes['OrganID']);
     return $info;
 }