|
@@ -18,7 +18,7 @@ class GoodsService extends CrudService {
|
|
|
*/
|
|
|
async goodsDetail({ id }) {
|
|
|
const { populate } = this.ctx.service.shop.goods.getRefMods();
|
|
|
- let goods = await this.goodsModel.findById(id, { file: 1, tags: 1, name: 1, shot_brief: 1, brief: 1, send_time: 1, shop: 1 }).populate(populate);
|
|
|
+ let goods = await this.goodsModel.findById(id, { file: 1, tags: 1, name: 1, shot_brief: 1, brief: 1, send_time: 1, shop: 1, view_num: 1 }).populate(populate);
|
|
|
if (!goods) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到商品数据');
|
|
|
goods = JSON.parse(JSON.stringify(goods));
|
|
|
let specs = await this.goodsSpecModel.find({ goods: id, status: '0' }, { sell_money: 1, flow_money: 1, freight: 1, name: 1, num: 1 });
|
|
@@ -30,6 +30,9 @@ class GoodsService extends CrudService {
|
|
|
// goods: 商品信息; specs:商品规格信息; shop:店铺信息
|
|
|
const returnData = { goods, specs, shop };
|
|
|
|
|
|
+
|
|
|
+ // 添加浏览次数
|
|
|
+ await this.goodsModel.updateOne({ _id: id }, { view_num: (goods.view_num || 0) + 1 });
|
|
|
return returnData;
|
|
|
}
|
|
|
}
|