예제 #1
0
 /**
  * 品牌
  */
 public function actionOct()
 {
     $brand_id = 24;
     $type_brand_list = TypeBrand::model()->findAll('brand_id = :brand_id', array(':brand_id' => $brand_id));
     $TypeBrand = new TypeBrand();
     $type_ids = implode(',', $TypeBrand->getFindAllids($type_brand_list, 'type_id'));
     //类型列表
     $type_list = GoodsType::model()->findAllBySql('SELECT * FROM car_b2c_goods_type WHERE type_id IN (' . $type_ids . ')');
     //价格区间
     $type_price_item = array();
     foreach ($type_list as $v) {
         $price = unserialize($v->price);
         if (empty($price)) {
             continue;
         }
         $type_price_item = $price;
     }
     //商品属性值
     $goods_type_props_list = GoodsTypeProps::model()->findAllBySql('SELECT * FROM car_b2c_goods_type_props WHERE type_id IN (' . $type_ids . ')');
     $Goodstypeprops = new GoodsTypeProps();
     $props_ids = implode(',', $Goodstypeprops->getFindAllids($goods_type_props_list, 'props_id'));
     //商品属性值数据
     $goods_type_props_value_list = GoodsTypePropsValue::model()->findAllBySql('SELECT * FROM car_b2c_goods_type_props_value WHERE props_id IN (' . $props_ids . ')');
     $goods_type_props_value_item = array();
     foreach ($goods_type_props_value_list as $v) {
         $goods_type_props_value_item[$v->props_id][] = $v;
     }
     //规格
     /*提交数据到页面*/
     $data = array('type_list' => $type_list, 'goods_type_props_list' => $goods_type_props_list, 'goods_type_props_value_item' => $goods_type_props_value_item, 'type_price_item' => $type_price_item);
     $this->render('oct', $data);
 }
예제 #2
0
 /**
  * 根据类型获取品牌
  */
 public function actionAjaxtypebrand()
 {
     $TypeBrand = new TypeBrand();
     $type_id = $this->post('type_id');
     $list = $TypeBrand->type_brand($type_id);
     $str = '<option value="">请选择</option>';
     foreach ($list as $v) {
         $str .= '<option value="' . $v['brand_id'] . '">' . $v['brand_name'] . '</option>';
     }
     echo $str;
 }
예제 #3
0
 /**
  * 类型删除
  */
 public function actionDelete()
 {
     $type_id = $this->get('type_id');
     //商品类型主表修改
     $type_attributes['disabled'] = 'true';
     $type_attributes['lastmodify'] = time();
     $result = GoodsType::model()->updatebypk($type_id, $type_attributes);
     if (!$result) {
         $GoodsType = new GoodsType();
         $this->message('error', CHtml::errorSummary($GoodsType), $this->createUrl('index'));
     }
     //类型-品牌
     $result = TypeBrand::model()->deleteAll('type_id = :type_id', array(':type_id' => $type_id));
     if (!$result) {
         $TypeBrand = new TypeBrand();
         $this->message('error', CHtml::errorSummary($TypeBrand), $this->createUrl('index'));
     }
     //类型-扩展属性
     $result = GoodsTypePropsRelation::model()->deleteAll('type_id = :type_id', array(':type_id' => $type_id));
     if (!$result) {
         $GoodsTypePropsRelation = new GoodsTypePropsRelation();
         $this->message('error', CHtml::errorSummary($GoodsTypePropsRelation), $this->createUrl('index'));
     }
     //类型-规格
     $result = GoodsTypeSpec::model()->deleteAll('type_id = :type_id', array(':type_id' => $type_id));
     if (!$result) {
         $GoodsTypeSpec = new GoodsTypeSpec();
         $this->message('error', CHtml::errorSummary($GoodsTypeSpec), $this->createUrl('index'));
     }
     $this->message('success', '删除成功', $this->createUrl('index'));
 }
예제 #4
0
 /**
  * 商品添加
  */
 public function actionCreate()
 {
     if ($_POST) {
         $Goods = new Goods();
         $ImageImage = new ImageImage();
         $goods_attributes = $this->post('Goods');
         //判断货号是否存在
         $bn_goods = Goods::model()->find('bn = :bn', array(':bn' => $goods_attributes['bn']));
         if ($bn_goods) {
             $this->message('error', '货号冲突', $this->createUrl('index'));
         }
         $goods_attributes['update_time'] = time();
         $Goods->attributes = $goods_attributes;
         if (!$Goods->save()) {
             $this->message('error', CHtml::errorSummary($Goods), $this->createUrl('index'));
         }
         $goods_id = Yii::app()->db->getLastInsertID();
         //商品图片
         $image_attributes = $this->post('Image');
         $image_attach_attributes = $this->post('ImageAttach');
         $image_ids = $this->post('ImageId');
         $result = $ImageImage->imageList($image_attributes, $image_attach_attributes, $image_ids, $goods_id);
         if (!$result) {
             $this->message('error', CHtml::errorSummary($ImageImage), $this->createUrl('index'));
         }
         //创建货品
         $product_attributes = array('goods_id' => $goods_id, 'bn' => $goods_attributes['bn'], 'price' => $goods_attributes['price'], 'cost' => $goods_attributes['cost'], 'mktprice' => $goods_attributes['mktprice'], 'name' => $goods_attributes['name'], 'weight' => $goods_attributes['weight'], 'unit' => $goods_attributes['unit'], 'store' => $goods_attributes['store'], 'freez' => 0, 'goods_type' => 'normal', 'is_default' => 'true', 'uptime' => time(), 'marketable' => 'true');
         $Product = new Products();
         $Product->attributes = $product_attributes;
         if (!$Product->save()) {
             $this->message('error', CHtml::errorSummary($Product), $this->createUrl('index'));
         }
         $this->referrer();
     }
     //商品类型
     $type_list = GoodsType::model()->findAll();
     $type_arr = array();
     if ($type_list) {
         foreach ($type_list as $v) {
             $type_arr[$v->type_id] = $v->name;
         }
     }
     //品牌
     $TypeBrand = new TypeBrand();
     $model['brand'] = $TypeBrand->type_brand();
     $model['type'] = $type_arr;
     $this->render('create', array('model' => $model));
 }