public function getGoods($id)
 {
     $model = D('Loan/shop_goods');
     $goods = $model->alias('g')->join('__LOAN_SHOP_GOODS_DETAIL__ d on d.id = g.id')->join('__LOAN_SHOP_COLUMN__ c on c.id = g.column_id', 'left')->where(['g.status' => 1, 'd.id' => $id])->field('g.*, d.*, c.name as column_name')->find() or $this->error('此商品已下架!');
     if ($goods['column_name']) {
         $goods['title'] = "【{$goods['column_name']}】{$goods['title']}";
     }
     $goods['tag'] = explode(',', $goods['tag']);
     $goods['icon'] = ShopGoodsModel::getIconUrl($goods['icon_id']);
     $goods['property'] = json_decode($goods['property'], true);
     $goods['property_info'] = json_decode($goods['property_info'], true);
     return $goods;
 }
 public function detail($id = 0)
 {
     $id = intval($id);
     $user = get_user();
     $goodsModel = D('Loan/shop_goods');
     $goods = $goodsModel->alias('g')->join('zj_loan_shop_goods_detail d on d.id=g.id')->join('zj_loan_shop_column c on c.id=g.column_id', 'left')->where('g.status=1 and d.id=' . $id)->field('g.*, d.*, c.name as column_name')->find() or $this->error('此商品已下架!');
     if ($goods['column_name']) {
         $goods['title'] = "【{$goods['column_name']}】{$goods['title']}";
     }
     $goods['comment_rate'] = $goods['total_comment'] > 0 ? intval($goods['total_comment_good'] / $goods['total_comment'] * 100) : 0;
     $goods['property'] = json_decode($goods['property'], true);
     if ($goods['property']) {
         $goods['property_info'] = $property_info = json_decode($goods['property_info'], true);
     }
     $goods['icon'] = ShopGoodsModel::getIconUrl($goods['icon_id']);
     $goods['tag'] = explode(',', $goods['tag']);
     $goods['max_month'] = $goodsModel->getMaxMonth(0, $goods['price'], 0, $goods['max_month'], $goods['fix_month']);
     $goods['picture'] = M('loan_shop_goods_picture')->field('url')->where(['goods_id' => $id])->order('sort')->getField('url', true);
     $this->assign('goods', $goods);
     $rate = $goodsModel->getFeeRate($goods['fee_id']) or $this->error('无法读取服务费率!');
     $this->assign('rate', $rate);
     $this->display();
 }
    public function __construct()
    {
        parent::__construct();
        $goodsModel = D('Loan/shop_goods');
        $list = M('loan_web_index i')->join('__LOAN_SHOP_GOODS__ g on g.id = i.goods_id', 'left')->where(['i.city_id' => ['in', [0, I('cookie.city_id')]], 'position_id' => ['in', 'banner,dn,fqg,hot,hw,jrth,jxzq,login,ly,reg,sh,sj,sm,xb,xh']])->field('
				i.position_id, i.goods_id, i.pic, i.url, i.sort, i.city_id,
				g.pic as goods_pic, g.title, g.price, g.max_month, g.fix_month, g.fee_id, g.icon_id')->select();
        foreach ($list as $item) {
            if (!$item['url']) {
                if ($item['price']) {
                    $item['max_month'] = $goodsModel->getMaxMonth(0, $item['price'], 0, $item['max_month'], $item['fix_month']);
                    $item['month_money'] = $goodsModel->getMonthMoney($item['price'], $item['max_month'], $item['fee_id']);
                    $item['url'] = U('/' . $item['goods_id']);
                    $item['icon'] = ShopGoodsModel::getIconUrl($item['icon_id']);
                } else {
                    $item['url'] = 'javascript:';
                }
            }
            $_item = isset($this->categories[$item['position_id']][$item['sort'] - 1]) ? $this->categories[$item['position_id']][$item['sort'] - 1] : null;
            if (!$_item || $_item['city_id'] == 0 && ($item['pic'] || $item['goods_pic'])) {
                $this->categories[$item['position_id']][$item['sort'] - 1] = $item;
            }
        }
    }