Ejemplo n.º 1
0
 public static function editpackgoods($pid, $goods)
 {
     $goodspack['MinQuantity'] = $goods['MinQuantity'];
     //
     $pcid = PapGoodsPack::model()->find("GoodsID={$pid}")->attributes['ID'];
     $goodspc = PapGoodsPack::model()->findByPk($pcid);
     if (empty($pcid)) {
         $goodspc = new PapGoodsPack();
     }
     $goodspc->attributes = $goodspack;
     $goodspc->GoodsID = $pid;
     $goodspc->save();
     $arr['MinQuantity'] = $goodspack['MinQuantity'];
 }
Ejemplo n.º 2
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;
 }