lrf 2 سال پیش
والد
کامیت
35ab30cff3
2فایلهای تغییر یافته به همراه18 افزوده شده و 15 حذف شده
  1. 18 14
      app/service/trade/afterSale.js
  2. 0 1
      app/service/trade/pay.js

+ 18 - 14
app/service/trade/afterSale.js

@@ -18,22 +18,26 @@ class AfterSaleService extends CrudService {
   async create({ order_detail, goods_id, ...others }) {
     const orderDetail = await this.orderDetailModel.findById(order_detail);
     if (!orderDetail) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到订单信息');
-    // TODO:查看订单是否签收
+    // 查看订单是否签收
+
+    // 查看该商品是否已经申请售后
+    const hasData = await this.model.count({ order_detail, 'goods._id': goods_id, type: [ '0', '1', '2', '3' ] });
+    if (hasData > 0) throw new BusinessError(ErrorCode.DATA_EXISTED, '该商品已有正在处理中的售后申请.请勿重复申请');
 
     // 查询该商品是不是申请退款,如果是申请退款,查看是否有记录,如果有记录,是否已经退款
-    const type = _.get(others, 'type');
-    if (type === '0') {
-      const record = await this.model.find({ order_detail, 'goods._id': goods_id, type: '0' });
-      if (record) {
-        const rs = _.get(record, 'status');
-        if (rs === '0' || rs === '1') throw new BusinessError(ErrorCode.DATA_EXISTED, '已申请退款,正在等待处理');
-        else if (rs === '-1') throw new BusinessError(ErrorCode.DATA_EXISTED, '该商品已退款');
-      }
-    } else {
-      // 如果是换货/维修,那么可以重复多次,也就是需要查当前该货物是否有未结束的售后,如果有,则不能添加
-      const num = await this.model.count({ order_detail, 'goods._id': goods_id, type, status: [ '2', '3' ] });
-      if (num) throw new BusinessError(ErrorCode.DATA_INVALID, '商品正在售后中');
-    }
+    // const type = _.get(others, 'type');
+    // if (type === '0') {
+    //   const record = await this.model.find({ order_detail, 'goods._id': goods_id, type: '0' });
+    //   if (record) {
+    //     const rs = _.get(record, 'status');
+    //     if (rs === '0' || rs === '1') throw new BusinessError(ErrorCode.DATA_EXISTED, '已申请退款,正在等待处理');
+    //     else if (rs === '-1') throw new BusinessError(ErrorCode.DATA_EXISTED, '该商品已退款');
+    //   }
+    // } else {
+    //   // 如果是换货/维修,那么可以重复多次,也就是需要查当前该货物是否有未结束的售后,如果有,则不能添加
+    //   const num = await this.model.count({ order_detail, 'goods._id': goods_id, type, status: [ '2', '3' ] });
+    //   if (num) throw new BusinessError(ErrorCode.DATA_INVALID, '商品正在售后中');
+    // }
     const { goods: goodsList } = orderDetail;
     const goods = goodsList.find(f => ObjectId(f._id).equals(goods_id));
     if (!goods) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未在当前订单中搜索到要售后的商品');

+ 0 - 1
app/service/trade/pay.js

@@ -39,7 +39,6 @@ class PayService extends CrudService {
       const pay_no = _.get(pay, 'pay_no');
       if (pay_no) {
         // 有支付订单.则先查支付订单是否可以继续支付
-        // TODO:
         // 1.如果有支付信息及支付单号,直接关闭.重开
         const arr = pay_no.split('-');
         // 获取重支付的次数,重支付次数+1