lrf преди 2 години
родител
ревизия
59818bc5cd
променени са 2 файла, в които са добавени 7 реда и са изтрити 2 реда
  1. 5 1
      app/service/trade/cart.js
  2. 2 1
      app/service/trade/order.js

+ 5 - 1
app/service/trade/cart.js

@@ -24,7 +24,11 @@ class CartService extends CrudService {
    */
   async selfCart({ customer }) {
     assert(customer, '缺少顾客信息');
-    const data = await this.model.find({ customer });
+    let data = await this.model.find({ customer });
+    if (data.length > 0) {
+      data = JSON.parse(JSON.stringify(data));
+      data = data.map(i => ({ ...i, cart_id: i._id }));
+    }
     const actList = await this.ctx.service.trade.order.getActList(data);
     const pageData = await this.ctx.service.trade.order.getPageData(data, actList);
     return pageData;

+ 2 - 1
app/service/trade/order.js

@@ -332,7 +332,7 @@ class OrderService extends CrudService {
   async getPageData(data, actList) {
     const arr = [];
     for (const i of data) {
-      const { goodsSpec, num } = i;
+      const { goodsSpec, num, cart_id } = i;
       const d = await this.goodsSpecModel.aggregate([
         { $match: { _id: ObjectId(goodsSpec) } },
         // #region 处理店铺与商品部分
@@ -381,6 +381,7 @@ class OrderService extends CrudService {
       ]);
       let gs = _.head(d);
       if (gs) gs = JSON.parse(JSON.stringify(gs));
+      if (cart_id)gs.cart_id = cart_id;
       arr.push(gs);
     }
     // 平铺数据后,需要处理活动相关部分