<?php
/**积分商品
 * @Copyright (C) 2016 汉潮 All rights reserved.
 * @License http://www.hanchao9999.com
 * @Author xiaogg <xiaogg@sina.cn>
 */
namespace Mobile\Model;
use Think\Model;
class GoodsIntegralModel extends Model
{
    /**商品详情页
     * @param $goods_id
     */
    public function getmobile_goodscontent($id,$shop_id){
        //获取商品基本信息
        $root=array();
        $info=D('Common/GoodsIntegral')->get_integral($id,$shop_id);
        if($info['status']==0)$this->error($info['msg']);
        $where['id']=$id;
        $goods_id=M('GoodsIntegral')->where($where)->getField('goods_id');
        $map['goods_id']=$goods_id;
        $goods_imgs=M("GoodsGallery")->where($map)->select();
        if(empty($goods_imgs))$goods_imgs[0]['goods_img']=$info['data']['img'];
        //获取商品属性和规格
        $data = D("Common/GoodsAttr")->getattr($goods_id);
        //判断商品是否有库存
        if($info['data']['is_add'] == 1){
            $stock = D("Common/Cart")->shopgoodsstock($goods_id,$shop_id,$attr_key=0);
            if($stock['goods_number'] > 0){
                $info['data']['is_add'] = 1;
            }else{
                $info['data']['is_add'] = 0;
            }
        }else{
            $info['data']['is_add'] = 0;
        }
        $commlist = D('Dp')->get_goods($goods_id);
        //总评论个数
        $dp_count=count($commlist['dp_id']);
        //总评论个数
       // $root['attr']=$data;//商品属性规格
        $root['goods_info']=$info['data'];//商品基本信息
        $root['goods_imgs']=$goods_imgs;//商品相册;
        $root['commlist']=$commlist;//商品评论
        $root['c_count']=$dp_count;
        return $root;
    }
}