|
@@ -64,26 +64,35 @@ class OrderDetailService extends CrudService {
|
|
// const list = [];
|
|
// const list = [];
|
|
const ids = [];
|
|
const ids = [];
|
|
for (const s of shopGoods) {
|
|
for (const s of shopGoods) {
|
|
- const shop = _.get(s, 'shop');
|
|
|
|
- const remarks = _.get(s, 'remarks');
|
|
|
|
- const goodsList = _.get(s, 'goods', []);
|
|
|
|
- const detailNo = `${no}-${noTimes}`;
|
|
|
|
- const total_detail = shopMoneyDetail[shop];
|
|
|
|
- // 优惠部分分割
|
|
|
|
- if (_.get(otd, 'discount_detail')) {
|
|
|
|
- // 如果有优惠部分,那就得找,优惠里面有没有对应的商品规格
|
|
|
|
- const discount_detail = this.getGoodsListDiscountDetail(goodsList, _.get(otd, 'discount_detail'));
|
|
|
|
- total_detail.discount_detail = discount_detail;
|
|
|
|
|
|
+ const { is_set = '1' } = s;
|
|
|
|
+ if (is_set === '1') {
|
|
|
|
+ const shop = _.get(s, 'shop');
|
|
|
|
+ const remarks = _.get(s, 'remarks');
|
|
|
|
+ const goodsList = _.get(s, 'goods', []);
|
|
|
|
+ const detailNo = `${no}-${noTimes}`;
|
|
|
|
+ const total_detail = shopMoneyDetail[shop];
|
|
|
|
+ // 优惠部分分割
|
|
|
|
+ if (_.get(otd, 'discount_detail')) {
|
|
|
|
+ // 如果有优惠部分,那就得找,优惠里面有没有对应的商品规格
|
|
|
|
+ const discount_detail = this.getGoodsListDiscountDetail(goodsList, _.get(otd, 'discount_detail'));
|
|
|
|
+ total_detail.discount_detail = discount_detail;
|
|
|
|
+ }
|
|
|
|
+ noTimes++;
|
|
|
|
+ const obj = { ...orderDetailData, shop, goods: goodsList, no: detailNo, total_detail, remarks };
|
|
|
|
+ obj.status = '1';
|
|
|
|
+ // list.push(obj);
|
|
|
|
+ const od_id = tran.insert('OrderDetail', obj);
|
|
|
|
+ ids.push(od_id);
|
|
|
|
+ } else {
|
|
|
|
+ const shop = _.get(s, 'shop');
|
|
|
|
+ const detailNo = `${no}-${noTimes}`;
|
|
|
|
+ const total_detail = shopMoneyDetail[shop];
|
|
|
|
+ const remarks = _.get(s, 'remarks');
|
|
|
|
+ const g = _.pick(s, [ 'name', 'buy_num', 'freight', 'is_set', 'is_use', 'meta', 'sell_money', 'set_id', 'goods' ]);
|
|
|
|
+ const obj = { ...orderDetailData, shop, goods: g, no: detailNo, total_detail, remarks, status: '1' };
|
|
|
|
+ const od_id = tran.insert('OrderDetail', obj);
|
|
|
|
+ ids.push(od_id);
|
|
}
|
|
}
|
|
- noTimes++;
|
|
|
|
- const obj = { ...orderDetailData, shop, goods: goodsList, no: detailNo, total_detail, remarks };
|
|
|
|
- // 测试用
|
|
|
|
- obj.status = '1';
|
|
|
|
- // list.push(obj);
|
|
|
|
- const od_id = tran.insert('OrderDetail', obj);
|
|
|
|
- ids.push(od_id);
|
|
|
|
- // 添加该商品是否和平台活动有关,做记录
|
|
|
|
- // await this.ctx.service.trade.actOrder.create(orderDetail_id, obj, tran);
|
|
|
|
}
|
|
}
|
|
return ids;
|
|
return ids;
|
|
// await this.model.insertMany(list);
|
|
// await this.model.insertMany(list);
|
|
@@ -125,7 +134,7 @@ class OrderDetailService extends CrudService {
|
|
const { _id, id } = filter;
|
|
const { _id, id } = filter;
|
|
if (_id || id) filter = { _id: ObjectId(_id || id) };
|
|
if (_id || id) filter = { _id: ObjectId(_id || id) };
|
|
const { populate } = this.getRefMods();
|
|
const { populate } = this.getRefMods();
|
|
- let res = await this.model.findOne(filter).populate(populate).exec();
|
|
|
|
|
|
+ let res = await this.model.findOne(filter).populate(populate).lean();
|
|
res = JSON.parse(JSON.stringify(res));
|
|
res = JSON.parse(JSON.stringify(res));
|
|
// 找售后和评论
|
|
// 找售后和评论
|
|
const afterSale = await this.afterSaleModel.find({ order_detail: res._id });
|
|
const afterSale = await this.afterSaleModel.find({ order_detail: res._id });
|