lrf 2 éve
szülő
commit
646f4673ea
1 módosított fájl, 16 hozzáadás és 17 törlés
  1. 16 17
      app/service/view/order.js

+ 16 - 17
app/service/view/order.js

@@ -73,29 +73,28 @@ class OrderService extends CrudService {
         obj.shop = { _id: shopData.shop, name: shopData.shop_name };
         const specs = [];
         for (const shop of goods) {
-          const { goods: specGoods } = shop;
-          for (const sg of specGoods) {
-            const { is_set = '1' } = sg;
-            if (is_set === '1') {
+          const { goods: specGoods, is_set = '1' } = shop;
+          if (is_set === '1') {
+            for (const sg of specGoods) {
               const spec = _.pick(sg, [ '_id', 'name', 'file', 'act', 'buy_num', 'gift', 'price', 'freight', 'sp_price' ]);
               if (!spec.price) spec.price = _.get(sg, 'sell_money');
               const goods = _.pick(sg.goods, [ '_id', 'name', 'file' ]);
               spec.goods = goods;
               specs.push(spec);
-            } else {
-              const goods = _.get(sg, 'goods', []);
-              const obj = _.omit(sg, [ 'goods', 'meta' ]);
-              const newGoods = goods.map(i => {
-                const ngo = {
-                  goods: { name: _.get(i, 'goods.name'), file: _.get(i, 'goods.file') },
-                  spec: { name: _.get(i, 'spec.name'), file: _.get(i, 'spec.file') },
-                  set_num: _.get(i, 'set_num'),
-                };
-                return ngo;
-              });
-              obj.goods = newGoods;
-              specs.push(obj);
             }
+          } else {
+            const goods = _.get(shop, 'goods', []);
+            const obj = _.omit(shop, [ 'goods', 'meta' ]);
+            const newGoods = goods.map(i => {
+              const ngo = {
+                goods: { name: _.get(i, 'goods.name'), file: _.get(i, 'goods.file') },
+                spec: { name: _.get(i, 'spec.name'), file: _.get(i, 'spec.file') },
+                set_num: _.get(i, 'set_num'),
+              };
+              return ngo;
+            });
+            obj.goods = newGoods;
+            specs.push(obj);
           }
         }
         obj.spec = specs;