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['cate'] = ShopCategoryLogic::getCateById($v['category']); $v['id'] = $v['goods_id']; // $v['supplier'] = Db::name('shop_supplier')->where(['id'=>$v['supplier']])->value('name'); $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_remark'] = htmlspecialchars_decode($data['goods_remark']); $specRelation = ShopGoodsSpecRelation::getArrListByGoodsId($id); $specAttrId = ShopGoodsSpecType::getPidById($specRelation[0]['spec_id']); if ($data['is_exist_many_spec'] == 0) { $data['defaultSku'] = ShopGoodsSpec::getGoodsSpecByGoodId($id); } $hot_keywords = ShopHotKeywordsLogic::getCacheList(); $shop_supplier = ShopSupplierLogic::getCacheList(); $shop_goods_type = ShopGoodsTypeLogic::getCacheList(); return [$data, $hot_keywords, $shop_goods_type, $shop_supplier, $specAttrId]; } }