/** * 获取OE号 */ public static function getOENOSByGoodsID($goodsID) { $key = 'oenu_' . $goodsID; $OENOS = Yii::app()->cache->get($key); if (!$OENOS) { $goodsOES = PapGoodsOeRelation::model()->findAll("GoodsID={$goodsID}"); $data = array(); $OENOS = ''; foreach ($goodsOES as $key => $value) { $data[$key]['ID'] = $value['ID']; $data[$key]['OENO'] = $value['OENO']; if ($key == 0) { $OENOS .= $value['OENO']; } else { $OENOS .= '、' . $value['OENO']; } } Yii::app()->cache->set($key, $OENOS); } return $OENOS; }
/** * 获取OE号 */ public static function getOENOSByGoodsID($goodsID) { $goodsOES = PapGoodsOeRelation::model()->findAll("GoodsID={$goodsID}"); $data = array(); $OENOS = ''; foreach ($goodsOES as $key => $value) { $data[$key]['ID'] = $value['ID']; $data[$key]['OENO'] = $value['OENO']; if ($key == 0) { $OENOS .= $value['OENO']; } else { $OENOS .= '、' . $value['OENO']; } } // return $data; return $OENOS; }
public static function editoegoods($pid, $organID, $goods) { $oenos = $goods['OENOS']; $oelegth = count($oenos); for ($i = 0; $i < $oelegth; $i++) { $goodsoeno = new PapGoodsOeRelation(); $goodsoeno->OrganID = $organID; $goodsoeno->GoodsID = $pid; $goodsoeno->OENO = $oenos[$i]; $goodsoeno->CreateTime = time(); $goodsoeno->save(); $oeno[$i] = $oenos[$i]; } return $oeno; }