lrf 2 years ago
parent
commit
c7a94895ca
1 changed files with 4 additions and 3 deletions
  1. 4 3
      app/service/trade/order.js

+ 4 - 3
app/service/trade/order.js

@@ -34,7 +34,7 @@ class OrderService extends CrudService {
       const { result, msg } = await this.ctx.service.util.trade.checkCanBuy(data, false);
       if (!result) throw new BusinessError(ErrorCode.DATA_INVALID, msg);
       const list = await this.goodsSpecModel.find({ _id: data.goodsSpec }).populate(populate);
-      specsData = this.setGoodsToPageData(list);
+      specsData = this.setGoodsToPageData(list, data.num);
     } else throw new BusinessError(ErrorCode.DATA_INVALID, '数据不正确,请重新下单');
     // 组装页面的数据
     const user = this.ctx.user;
@@ -52,8 +52,9 @@ class OrderService extends CrudService {
   /**
    * 单商品整理数据,需要商品与规格的快照,剩下的可以简略
    * @param {Array} list 规格数组
+   * @param num 购买数量
    */
-  setGoodsToPageData(list) {
+  setGoodsToPageData(list, num) {
     // 按店铺分组,精简字段
     const arr = [];
     for (const i of list) {
@@ -67,7 +68,7 @@ class OrderService extends CrudService {
       goods.goodsSpec_name = _.get(i, 'name');
       goods.freight = _.get(i, 'freight');
       goods.money = _.get(i, 'sell_money');
-      goods.num = _.get(i, 'num');
+      goods.num = num;
       goods.file = _.get(i.goods, 'file');
       obj.goods = goods;
       arr.push(obj);