|
@@ -18,6 +18,7 @@ class GoodsService extends CrudService {
|
|
* @param query.id 商品数据id
|
|
* @param query.id 商品数据id
|
|
*/
|
|
*/
|
|
async goodsDetail({ id }) {
|
|
async goodsDetail({ id }) {
|
|
|
|
+ // TODO 添加宝贝数,商店3个评价
|
|
const { populate } = this.ctx.service.shop.goods.getRefMods();
|
|
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, view_num: 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, '未找到商品数据');
|
|
if (!goods) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到商品数据');
|
|
@@ -27,6 +28,8 @@ class GoodsService extends CrudService {
|
|
goods = _.omit(goods, [ 'meta', '__v' ]);
|
|
goods = _.omit(goods, [ 'meta', '__v' ]);
|
|
const shop = _.pick(goods.shop, [ 'logo', 'name', 'person', 'phone', '_id' ]);
|
|
const shop = _.pick(goods.shop, [ 'logo', 'name', 'person', 'phone', '_id' ]);
|
|
delete goods.shop;
|
|
delete goods.shop;
|
|
|
|
+ const goodsNum = await this.goodsModel.count({ shop });
|
|
|
|
+ shop.goods_num = goodsNum;
|
|
// 2022-10-17反馈问题6:将规格图片和商品图片合并,规格图片在前
|
|
// 2022-10-17反馈问题6:将规格图片和商品图片合并,规格图片在前
|
|
for (const spec of specs) {
|
|
for (const spec of specs) {
|
|
if (_.isArray(spec.file)) {
|
|
if (_.isArray(spec.file)) {
|