lrf 2 年之前
父節點
當前提交
a3dbf92807
共有 1 個文件被更改,包括 6 次插入9 次删除
  1. 6 9
      app/service/trade/order.js

+ 6 - 9
app/service/trade/order.js

@@ -439,18 +439,15 @@ class OrderService extends CrudService {
    * 将平铺的数据按店铺分组形成
    * * [  { shop:${value}, shop_name:${value}, goods:${value} }  ]
    * 的形式
-   * @param {Array} list 平铺的数据集合
+   * @param {Array} cartList 平铺的数据集合
    */
-  async toMakeGroupData(list) {
-    list = Object.values(_.groupBy(list, 'shop'));
-    const result = [];
+  async toMakeGroupData(cartList) {
+    const notSetList = cartList.filter(f => _.get(f, 'is_set', '1') === '1');
+    const setList = cartList.filter(f => _.get(f, 'is_set', '1') === '0');
+    const list = Object.values(_.groupBy(notSetList, 'shop'));
+    const result = [ ...setList ];
     // 按店铺分组
     for (const i of list) {
-      const { is_set = '1' } = i;
-      if (is_set !== '1') {
-        result.push(i);
-        continue;
-      }
       const head = _.head(i);
       const obj = { shop: _.get(head, 'shop'), shop_name: _.get(head, 'shop_name') };
       const goods = i.map(e => _.omit(e, [ 'shop', 'shop_name' ]));