public static function editspecgoods($pid, $goods) { $goodsspec['ValidityType'] = $goods['ValidityType']; // 保质期类型 if ($goodsspec['ValidityType'] == 3) { $goodsspec['ValidityDate'] = $goods['ValidityDate'] . $goods['dataday']; // 保质期 } $goodsspec['BganCompany'] = $goods['BganCompany']; // 标杆公司 $goodsspec['BganGoodsNO'] = $goods['BganGoodsNO']; // 标杆商品号 $goodsspec['Unit'] = $goods['Unit']; // 配件单位 $psid = PapGoodsSpec::model()->find("GoodsID={$pid}")->attributes['ID']; $goodssp = PapGoodsSpec::model()->findByPk($psid); if (empty($psid)) { $goodssp = new PapGoodsSpec(); } $goodssp->attributes = $goodsspec; $goodssp->GoodsID = $pid; $goodssp->save(); }
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; }