lrf пре 2 година
родитељ
комит
9c9541e129
1 измењених фајлова са 12 додато и 8 уклоњено
  1. 12 8
      app/service/trade/afterSale.js

+ 12 - 8
app/service/trade/afterSale.js

@@ -79,14 +79,18 @@ class AfterSaleService extends CrudService {
       if (type === '1') {
         // 仅退款,退优惠券,退款
         // 如果不是处理中,则不进行退款
-        if (_.get(update, 'status') !== '1') throw new BusinessError(ErrorCode.DATA_INVALID, '订单状态错误');
-        // 1.检验并组织退款信息
-        refundInfo = await this.toReturnMoney(entity, update, this.tran);
-        // 2.检查是否退优惠券,该退就退
-        await this.toReturnCoupons(entity, update, this.tran);
-        // 3.修改数据, 直接修改成退完款的状态.如果后面退款失败了.直接回滚了
-        update.status = '-1';
-        update.end_time = moment().format('YYYY-MM-DD HH:mm:ss');
+        if (_.get(update, 'status') === '1') {
+          // 1.检验并组织退款信息
+          refundInfo = await this.toReturnMoney(entity, update, this.tran);
+          // 2.检查是否退优惠券,该退就退
+          await this.toReturnCoupons(entity, update, this.tran);
+          // 3.修改数据, 直接修改成退完款的状态.如果后面退款失败了.直接回滚了
+          update.status = '-1';
+          update.end_time = moment().format('YYYY-MM-DD HH:mm:ss');
+        } else if (_.get(update, 'status') === '!1') {
+          update.end_time = moment().format('YYYY-MM-DD HH:mm:ss');
+        }
+
         // 4.修改订单状态
         await this.refundOrder(entity, this.tran);
       } else if (type === '2') {