|
@@ -26,10 +26,10 @@ class OrderDetailService extends CrudService {
|
|
|
if (goods_id) {
|
|
|
// 传来指定商品,查有该商品的订单,但是如果没有,就查每一项中是否有 shop_transport_no 和 shop_transport_type
|
|
|
// 如果有这俩属性,说明也有单子,也查出来
|
|
|
- toSearch = transport.filter(f => _.isArray(f.goods) && f.goods.find(fg => fg.goods_id === goods_id));
|
|
|
+ toSearch = transport.filter((f) => _.isArray(f.goods) && f.goods.find((fg) => fg.goods_id === goods_id));
|
|
|
console.log(toSearch);
|
|
|
if (toSearch.length <= 0) {
|
|
|
- toSearch = transport.filter(f => f.shop_transport_no && f.shop_transport_type);
|
|
|
+ toSearch = transport.filter((f) => f.shop_transport_no && f.shop_transport_type);
|
|
|
}
|
|
|
} else {
|
|
|
toSearch = transport;
|
|
@@ -86,7 +86,6 @@ class OrderDetailService extends CrudService {
|
|
|
// await this.model.insertMany(list);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 将商品规格列表中,优惠的部分提取出来,分单用
|
|
|
* @param {Array} goodsList 某店的商品列表
|
|
@@ -130,10 +129,10 @@ class OrderDetailService extends CrudService {
|
|
|
const rate = await this.goodsRateModel.find({ orderDetail: res._id });
|
|
|
const goods = _.get(res, 'goods', []);
|
|
|
for (const g of goods) {
|
|
|
- const r = afterSale.find(f => ObjectId(_.get(f, 'goods._id')).equals(g._id));
|
|
|
+ const r = afterSale.find((f) => ObjectId(_.get(f, 'goods._id')).equals(g._id));
|
|
|
if (r) g.is_afterSale = true;
|
|
|
else g.is_afterSale = false;
|
|
|
- const r2 = rate.find(f => ObjectId(_.get(f, 'goodsSpec')).equals(g._id));
|
|
|
+ const r2 = rate.find((f) => ObjectId(_.get(f, 'goodsSpec')).equals(g._id));
|
|
|
if (r2) {
|
|
|
g.is_rate = true;
|
|
|
g.rate = r2._id;
|
|
@@ -179,7 +178,7 @@ class OrderDetailService extends CrudService {
|
|
|
if (sort && _.isString(sort)) {
|
|
|
sort = { [sort]: desc ? -1 : 1 };
|
|
|
} else if (sort && _.isArray(sort)) {
|
|
|
- sort = sort.map(f => ({ [f]: desc ? -1 : 1 })).reduce((p, c) => ({ ...p, ...c }), {});
|
|
|
+ sort = sort.map((f) => ({ [f]: desc ? -1 : 1 })).reduce((p, c) => ({ ...p, ...c }), {});
|
|
|
}
|
|
|
let condition = _.cloneDeep(filter);
|
|
|
condition = await this.beforeQuery(condition);
|
|
@@ -266,7 +265,7 @@ class OrderDetailService extends CrudService {
|
|
|
for (const og of obj.goods) {
|
|
|
const { file = [], _id: goodsSpec } = og;
|
|
|
const gfile = _.get(og, 'goods.file', []);
|
|
|
- const nf = [ ...file, ...gfile ];
|
|
|
+ const nf = [...file, ...gfile];
|
|
|
const url = _.get(_.head(nf), 'url');
|
|
|
og.url = url;
|
|
|
delete og.file;
|
|
@@ -278,7 +277,7 @@ class OrderDetailService extends CrudService {
|
|
|
obj.price = _.get(obj, 'price', obj.sell_money);
|
|
|
}
|
|
|
// 售后
|
|
|
- const asum = await this.afterSaleModel.count({ order_detail: obj._id, status: { $nin: [ '-1', '!1', '-2', '!2', '-3', '!3', '-4', '!4', '-5', '!5' ] } });
|
|
|
+ const asum = await this.afterSaleModel.count({ order_detail: obj._id, status: { $nin: ['-1', '!1', '-2', '!2', '-3', '!3', '-4', '!4', '-5', '!5'] } });
|
|
|
obj.is_afterSale = asum > 0;
|
|
|
list.push(obj);
|
|
|
}
|
|
@@ -300,6 +299,8 @@ class OrderDetailService extends CrudService {
|
|
|
await this.ctx.service.user.point.addPoints(filter._id, this.tran);
|
|
|
// 返现部分
|
|
|
await this.ctx.service.user.cashBack.create(filter._id, this.tran);
|
|
|
+ // 店铺流水部分
|
|
|
+ await this.ctx.service.shop.shopInBill.createByOrder(entity, this.tran);
|
|
|
}
|
|
|
|
|
|
await this.tran.run();
|
|
@@ -307,7 +308,6 @@ class OrderDetailService extends CrudService {
|
|
|
return e;
|
|
|
} catch (error) {
|
|
|
await this.tran.rollback();
|
|
|
-
|
|
|
} finally {
|
|
|
this.tran.clean();
|
|
|
}
|