lrf há 2 anos atrás
pai
commit
ae0e22dc21

+ 2 - 2
app/controller/shop/config/.goodsSpec.js

@@ -1,6 +1,6 @@
 module.exports = {
   create: {
-    requestBody: ['can_group', 'group_config', 'sell_money', 'flow_money', 'freight', 'goods', 'name', 'num', 'status'],
+    requestBody: ['file', 'can_group', 'group_config', 'sell_money', 'flow_money', 'freight', 'goods', 'name', 'num', 'status'],
   },
   destroy: {
     params: ['!id'],
@@ -8,7 +8,7 @@ module.exports = {
   },
   update: {
     params: ['!id'],
-    requestBody: ['can_group', 'group_config', 'sell_money', 'flow_money', 'freight', 'goods', 'name', 'num', 'status'],
+    requestBody: ['file', 'can_group', 'group_config', 'sell_money', 'flow_money', 'freight', 'goods', 'name', 'num', 'status'],
   },
   show: {
     parameters: {

+ 1 - 0
app/model/shop/goodsSpec.js

@@ -12,6 +12,7 @@ const goodsSpec = {
   status: { type: String, required: false, default: '0', zh: '状态' }, // 字典status
   can_group: { type: String, required: false, zh: '是否可以团购' }, // 字典:tf
   group_config: { type: Object, required: false, zh: '团购设置' }, // 团购模块的设置:团购金额:money,需要人数:need_person
+  file: { type: Array, required: false, zh: '图片' }, //
 };
 const schema = new Schema(goodsSpec, { toJSON: { getters: true, virtuals: true } });
 schema.index({ id: 1 });

+ 5 - 2
app/service/view/goods.js

@@ -60,8 +60,10 @@ class GoodsService extends CrudService {
     });
     // 按照规格平铺数据
     pipline.push({ $unwind: '$specs' });
-    // // 格式化平铺后的数据
-    pipline.push({ $project: { name: 1, view_num: 1, sell_num: 1, file: 1, sell_money: { $toDouble: '$specs.sell_money' }, createdAt: '$meta.createdAt' } });
+    // 格式化平铺后的数据
+    // 2022-10-17反馈-问题6:将规格图片也拿出来
+    // TODO: 整理规格图片与正常的商品图片
+    pipline.push({ $project: { name: 1, view_num: 1, sell_num: 1, file: 1, sell_money: { $toDouble: '$specs.sell_money' }, createdAt: '$meta.createdAt' }, spec_file: '$specs.file' });
     pipline.push({
       $group: {
         _id: '$_id',
@@ -70,6 +72,7 @@ class GoodsService extends CrudService {
         sell_num: { $first: '$sell_num' },
         sell_money: { $min: '$sell_money' },
         file: { $first: '$file' },
+        spec_file: { $first: 'spec_file' },
         createdAt: { $first: '$createdAt' },
       },
     });