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