123456789101112131415161718192021222324252627282930313233343536 |
- <?php
- declare(strict_types=1);
- namespace app\api\model;
- use app\common\model\ShopGoods as ShopGoodsModel;
- use app\common\exception\BaseException;
- /**
- * 门店商品模型
- * Class ShopGoods
- * @package app\store\model
- */
- class ShopGoods extends ShopGoodsModel
- {
- /**
- * 获取详情
- * @param int $id
- * @return mixed
- * @throws BaseException
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function getDetail(int $id)
- {
- // 关联查询
- $with = ['goods', 'shopGoodsSku.goodsSku'];
- // 获取商品记录
- $goodsInfo = self::with($with)->find($id);
- empty($goodsInfo) && throwError('很抱歉,商品信息不存在');
- return $goodsInfo;
- }
- }
|