getCart(); $cartlist = $cart->getList($food_mode); $list=array(); $other = Setting::getItem('other');//获取基本配置 for($i=0;$i $category[$i]['category_id'], 'shop_id' => $shop_id ]; //下架是否显示 if($other['goods']['delisting'] == 0){ $filter['goods_status'] = 10; } $list = $this->with(['spec', 'image.file', 'spec_rel.spec']) ->where($filter) ->order(['goods_sort', 'goods_id' => 'desc']) ->select(); $goods = []; //筛选是否显示售罄商品 foreach ($list as $item){ //判断是否开启库存 if($other['is_stock'] == 1 and $item['stock'] < 1 and $other['goods']['sell_out'] == 0){ continue; } $goods[] = $item; } for($n=0;$ngetManySpecData($goods[$n]['spec_rel'], $goods[$n]['spec']); for($s=0;$swith(['image.file', 'spec', 'spec.image', 'spec_rel.spec'])->where(['is_recommend' => 1, 'goods_status' => 10,'shop_id' => $shop_id])->select(); $goods = []; //筛选是否显示售罄商品 foreach ($list as $item){ //判断是否开启库存 if($other['is_stock'] == 1 and $item['stock'] < 1 and $other['goods']['sell_out'] == 0){ continue; } $goods[] = $item; } if(sizeof($goods)){ for($n=0;$ngetManySpecData($goods[$n]['spec_rel'], $goods[$n]['spec']); for($s=0;$s 10000, 'name' => '商家推荐', 'goods' => $goods ]); } return compact('category','cartlist'); } /** * 商品详情:HTML实体转换回普通字符 */ public function getContentAttr($value) { return htmlspecialchars_decode($value); } /** * 根据商品id集获取商品列表 (购物车列表用) */ public function getListByIds($goodsIds) { return $this->with(['category','image.file', 'spec','spec.image','spec_rel.spec']) ->where('goods_id', 'in', $goodsIds)->select(); } }