|
@@ -34,12 +34,11 @@ class AfterSaleService extends CrudService {
|
|
|
if (!orderDetail) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到订单信息');
|
|
|
// 查看该商品是否已经申请售后
|
|
|
let goods;
|
|
|
- const hasData = await this.model.count({ order_detail, 'goods._id': goods_id, status: { $nin: [ '-1', '!1', '-2', '!2', '-3', '!3', '-4', '!4', '-5', '!5' ] } });
|
|
|
+ const hasData = await this.model.count({ order_detail, 'goods._id': goods_id, status: { $nin: [ '!1', '!2', '!3', '!4', '!5' ] } });
|
|
|
if (hasData > 0) throw new BusinessError(ErrorCode.DATA_EXISTED, '该商品已有正在处理中的售后申请.请勿重复申请');
|
|
|
if (type !== '4' && type !== '5') {
|
|
|
const { goods: goodsList } = orderDetail;
|
|
|
goods = goodsList.find(f => {
|
|
|
- console.log(f._id, goods_id);
|
|
|
return ObjectId(f._id).equals(goods_id);
|
|
|
});
|
|
|
if (!goods) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未在当前订单中搜索到要售后的商品');
|
|
@@ -76,7 +75,6 @@ class AfterSaleService extends CrudService {
|
|
|
let refundInfo;
|
|
|
// 要修改成的状态
|
|
|
const uStatus = _.get(update, 'status');
|
|
|
- console.log(type);
|
|
|
// 根据类型不同,处理的函数不一样.
|
|
|
if (type === '1') {
|
|
|
// 仅退款,退优惠券,退款
|
|
@@ -267,7 +265,7 @@ class AfterSaleService extends CrudService {
|
|
|
// 依次找这些商品是否都售后完成,都售后完成,就改订单状态
|
|
|
const asList = await this.model.find({ order_detail, status: { $nin: [ '0', '!1', '!2', '!3', '!4', '!5' ] } });
|
|
|
let status;
|
|
|
- const fl = [];
|
|
|
+ let fl = [];
|
|
|
// 将当前数据添加进去
|
|
|
fl.push({ goods: _.get(data, 'goods._id'), status: 'finish' });
|
|
|
for (const gs of goodsList) {
|
|
@@ -277,6 +275,7 @@ class AfterSaleService extends CrudService {
|
|
|
if (finishList.includes(r.status)) fl.push({ goods: gs._id, status: 'finish' });
|
|
|
}
|
|
|
}
|
|
|
+ fl = _.uniqBy(fl, 'goods');
|
|
|
// 说明所有的商品 都有 已处理的售后
|
|
|
if (fl.length === goodsList.length) status = '-4';
|
|
|
// 有状态码,则修改订单的状态
|