1])->count('goods_id'); if ($data) { Cache::set($cacheKey, $data, rand(3, 5)); } return $data; } return Cache::get($cacheKey); } public static function getList($page, $limit, $where) { $model = new ShopGoods(); $count = $model ->withJoin(['supplier', 'cate' => function (Query $query) { $query->where('cate.id', '>', 0); }], 'LEFT') ->where($where) ->count(); $list = $model ->withJoin(['supplier', 'cate' => function (Query $query) { $query->where('cate.id', '>', 0); }], 'LEFT') ->where($where) ->page($page, $limit) ->order('goods_id desc') ->select()->toArray(); foreach ($list as $k => &$v) { $v['id'] = $v['goods_id']; $v['box_pic'] = isset($v['box_pic'])? getPreviewUrl($v['box_pic']):''; $v['goods_img'] = $v['goods_img']? getPreviewUrl($v['goods_img']):''; $v['goods_type'] = ShopGoodsTypeLogic::getNameByCache($v['goods_type']); } return [$count, $list]; } public static function getGoodsOrEmpty($id) { } public static function getGoodsBase($id) { $model = new ShopGoods(); $data = $model->where(['goods_id' => $id])->findOrEmpty()->toArray(); // if ($data['goods_img_banner']) { // $data['goods_img_banner'] = implode('|', json_decode($data['goods_img_banner'], true)); // } $data['goods_img'] = $data['goods_img']? getPreviewUrl($data['goods_img']):''; $data['box_pic'] = $data['box_pic']? getPreviewUrl($data['box_pic']):''; $banners = $data['goods_img_banner']? json_decode($data['goods_img_banner'], true): []; if($banners){ foreach ($banners as &$v){ $v = getPreviewUrl($v); } } $data['goods_img_banner'] = $banners?implode('|',$banners):''; $data['goods_remark'] = getContent(htmlspecialchars_decode($data['goods_remark'])); $specRelation = ShopGoodsSpecRelation::getArrListByGoodsId($id); $specAttrId = isset($specRelation[0])?ShopGoodsSpecType::getPidById($specRelation[0]['spec_id']):0; if ($data['is_exist_many_spec'] == 0) { $data['defaultSku'] = ShopGoodsSpec::getGoodsSpecByGoodId($id); if(empty($data['defaultSku'])){ $data['defaultSku'] = [ 'price'=> 0.00, 'original_price'=>0.00, 'cost_price'=>0.00, 'stock'=> 0, ]; } } $hot_keywords = ShopHotKeywordsLogic::getCacheList(); $shop_supplier = ShopSupplierLogic::getCacheList(); $shop_goods_type = ShopGoodsTypeLogic::getCacheList(); return [$data, $hot_keywords, $shop_goods_type, $shop_supplier, $specAttrId]; } }