cheny 4 rokov pred
rodič
commit
7bdc57848c
2 zmenil súbory, kde vykonal 29 pridanie a 8 odobranie
  1. 0 4
      app/model/dock.js
  2. 29 4
      app/service/dock.js

+ 0 - 4
app/model/dock.js

@@ -36,12 +36,8 @@ goods.index({ id: 1 });
 const apply = new Schema({
   user_id: { type: String, required: true, maxLength: 200 }, // 用户id
   user_name: { type: String, required: true, maxLength: 200 }, // 用户名称
-  // buyer: { type: String, required: true, maxLength: 1 }, // 买家/卖家 0/1
   goodsList: { type: [ goods ], default: [] }, // 产品列表
-  // contact: { type: String, required: false, maxLength: 200 }, // 联系人
   contact_tel: { type: String, required: false, maxLength: 200 }, // 联系人电话
-  // email: { type: String, maxLength: 200 }, // 邮箱
-  // company: { type: String, maxLength: 200 }, // 单位名称
   apply_time: { type: String, maxLength: 200 }, // 申请时间
   role: { type: String, maxLength: 200 }, // 申请人类型
   status: { type: String, default: '0', maxLength: 1 }, // 申请状态 (0未审核;1已通过;2已拒绝)

+ 29 - 4
app/service/dock.js

@@ -58,10 +58,35 @@ class ChatService extends CrudService {
     if (!dock) {
       throw new BusinessError('没有查询到该对接会');
     }
-    dock.apply.push({
-      ...body,
-      apply_time: moment().format('YYYY-MM-DD HH:mm:ss'),
-    });
+    if (body._id) {
+      // 修改
+      const apply = dock.apply.find(item => item._id === body._id);
+      if (body.user_name) {
+        apply.user_name = body.user_name;
+      }
+      if (body.goodsList) {
+        apply.goodsList = body.goodsList;
+      }
+      if (body.contact_tel) {
+        apply.contact_tel = body.contact_tel;
+      }
+      if (body.apply_time) {
+        apply.apply_time = body.apply_time;
+      }
+      if (body.role) {
+        apply.role = body.role;
+      }
+      if (body.status) {
+        apply.status = body.status;
+      }
+    } else {
+      // 保存
+      dock.apply.push({
+        ...body,
+        apply_time: moment().format('YYYY-MM-DD HH:mm:ss'),
+      });
+    }
+
     const res = await dock.save();
     const info = _.last(res.apply);
     return info;