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

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

@@ -36,7 +36,7 @@ class OrderService extends CrudService {
       const user = this.ctx.user;
       const customer = _.get(user, '_id');
       if (!customer) throw new BusinessError(ErrorCode.NOT_LOGIN, '未找到用户信息');
-      const { address, goods, total_detail, coupon = [], type = '0', group, inviter } = body;
+      const { address, goods, total_detail, coupon = [], type = '0', inviter } = body;
       if (coupon.length > 1) throw new BusinessError(ErrorCode.DATA_INVALID, '目前只允许使用1张优惠券');
       // 检测商品是否可以下单
       for (const i of goods) {
@@ -93,15 +93,8 @@ class OrderService extends CrudService {
       orderData.no = `${moment().format('YYYYMMDDHHmmss')}-${str}`;
       // 4.状态
       orderData.status = '0';
-      // #region 是否是团购
-      orderData.type = type;
-      if (type === '1' || group) {
-        orderData.group = group;
-      }
-      // #endregion
       // 5.返现部分:邀请人: 自己发链接自己买不行
       if (customer !== inviter && ObjectId.isValid(inviter)) orderData.inviter = inviter;
-
       // 生成数据
       const order_id = this.tran.insert('Order', orderData);
       // 处理库存,删除购物车

+ 5 - 2
app/service/util/order.js

@@ -308,15 +308,18 @@ class OrderService extends CrudService {
       const actResult = [];
       for (const goods of goodsInAct) {
         const { goodsSpec_id } = goods;
-        if (spec === goodsSpec_id) actResult.push({ platform_act, platform_act_type, gift, goodsSpec_id });
+        if (spec === goodsSpec_id) {
+          actResult.push({ platform_act, platform_act_type, gift, goodsSpec_id });
+        }
       }
       for (const i of actResult) {
-        const { goodsSpec_id, ...others } = i;
+        const { goodsSpec_id, gift, ...others } = i;
         const r = goodsList.find(f => f.goodsSpec_id === goodsSpec_id);
         if (r) {
           const { act = [] } = r;
           act.push(others);
           r.act = act;
+          r.gift = gift;
         }
       }
     }