lrf 2 年之前
父節點
當前提交
4935cd2510
共有 4 個文件被更改,包括 7 次插入3 次删除
  1. 1 1
      app/model/trade/afterSale.js
  2. 1 1
      app/model/trade/order.js
  3. 1 1
      app/model/trade/orderDetail.js
  4. 4 0
      app/service/trade/afterSale.js

+ 1 - 1
app/model/trade/afterSale.js

@@ -5,7 +5,7 @@ const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
 // 售后进度
 const afterSale = {
   order_detail: { type: String, required: false, zh: '订单详情', ref: 'Trade.OrderDetail' }, //
-  customer: { type: String, required: false, zh: '顾客', ref: 'User.Customer' }, //
+  customer: { type: String, required: false, zh: '顾客', ref: 'User.User' }, //
   shop: { type: String, required: false, zh: '店铺', ref: 'Shop.Shop' }, //
   goods: { type: Object, required: false, zh: '需要售后的商品快照清单' }, // 一条记录值售后1个商品
   type: { type: String, required: false, zh: '售后类型' }, // 字典:afterSale_type

+ 1 - 1
app/model/trade/order.js

@@ -8,7 +8,7 @@ const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  *  之后的优惠都放在total_detail中进行计算
  */
 const order = {
-  customer: { type: String, required: false, zh: '顾客', ref: 'User.Customer' }, //
+  customer: { type: String, required: false, zh: '顾客', ref: 'User.User' }, //
   address: { type: Object, required: false, zh: '邮寄地址' }, //
   goods: { type: Array, required: false, zh: '商品' }, // 按店铺分组,快照过来
   total_detail: { type: Object, required: false, zh: '总金额明细' }, // 优惠,活动;商品总额和运费由商品而来

+ 1 - 1
app/model/trade/orderDetail.js

@@ -6,7 +6,7 @@ const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
 const orderDetail = {
   order: { type: String, required: false, zh: '总订单', ref: 'Trade.order' }, //
   shop: { type: String, required: false, zh: '店铺', ref: 'Shop.Shop' }, //
-  customer: { type: String, required: false, zh: '顾客', ref: 'User.Customer' }, //
+  customer: { type: String, required: false, zh: '顾客', ref: 'User.User' }, //
   address: { type: Object, required: false, zh: '邮寄地址' }, //
   no: { type: String, required: false, zh: '订单号' }, //
   transport: { type: Object, required: false, zh: '快递' }, //

+ 4 - 0
app/service/trade/afterSale.js

@@ -27,6 +27,10 @@ class AfterSaleService extends CrudService {
         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: order_id, '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));