<?php
// +----------------------------------------------------------------------
// | Sunnyi 多语商城建站系统 (Build on ThinkPHP)
// +----------------------------------------------------------------------
// | Copyright (c) 2009 http://www.sunnyi.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 商易网络(admin@sunnyi.cn)
// +----------------------------------------------------------------------

// 促销赠品
class PromoteGoodsModel extends MultiLangModel implements CartItemInterface  {
	
	
	//用于购物车提取的方法
	public function getCartItem($id)
	{
		$spec_info = D("GoodsSpecItem")->getById($id);
		$goods_info = D("Goods")->getGoodsItem("id=".$spec_info['goods_id']);
		//组合规格信息至商品信息中
		$goods_info['sn'] = $spec_info['sn'];
		$goods_info['stock'] = $spec_info['stock'];
		$goods_info['weight'] = $spec_info['weight'];
		$goods_info['id'] = $spec_info['id'];
		$goods_info['goods_id'] = $spec_info['goods_id'];
		$goods_info['score'] = 0;    	
		

		$goods_info['name'] = $goods_info['name_'.FANWE_LANG_ID];
    	$goods_info['data_weight'] = $goods_info['weight'];
	   					
		$spec_conf_str = '';
		if($spec_info['spec1_id']!=0)
		$spec_conf_str.=D("GoodsSpec")->where("id=".$spec_info['spec1_id'])->getField("spec_name_".FANWE_LANG_ID).",";
						
		if($spec_info['spec2_id']!=0)
		$spec_conf_str.=D("GoodsSpec")->where("id=".$spec_info['spec2_id'])->getField("spec_name_".FANWE_LANG_ID).",";

		if($spec_conf_str!='')
		$spec_conf_str = substr($spec_conf_str,0,-1);
		
		if($spec_conf_str != '')
		{
			$goods_info['name'].="(".$spec_conf_str.")";
		}		
		
		return $goods_info;
	}
		

	public function getOrderGoodsItem($rec_id)
	{
		$spec_info = D("GoodsSpecItem")->getById($rec_id);
		
		$goods_info = D("Goods")->getGoodsItem("id=".$spec_info['goods_id']);
		
		if($goods_info)
		{
			$data['small_img'] = $goods_info['small_img'];
			$data['url'] = $goods_info['url'];
		}
		
		
		return $data;
	}
}
?>