liuyu 4 years ago
parent
commit
bd93a80ae1
3 changed files with 28 additions and 0 deletions
  1. 5 0
      app/controller/dock.js
  2. 1 0
      app/router.js
  3. 22 0
      app/service/dock.js

+ 5 - 0
app/controller/dock.js

@@ -28,6 +28,11 @@ class DockController extends Controller {
     const res = await this.service.createvipuser(this.ctx.params, this.ctx.request.body);
     this.ctx.ok({ ...res });
   }
+
+  async dockfetch() {
+    const res = await this.service.dockfetch(this.ctx.params);
+    this.ctx.ok({ ...res });
+  }
 }
 
 module.exports = CrudController(DockController, meta);

+ 1 - 0
app/router.js

@@ -36,6 +36,7 @@ module.exports = app => {
   router.post('chat', '/api/live/chat/:id', controller.chat.update);
 
   // 对接会表设置路由
+  router.get('/api/live/dock/dockfetch/:id', controller.dock.dockfetch); // 查询申请的对接列表
   router.get('/api/live/dock/myapply', controller.dock.myapply); // 查询申请的对接列表
   router.resources('dock', '/api/live/dock', controller.dock); // index、create、show、destroy
   router.post('dock', '/api/live/dock/:id', controller.dock.update);

+ 22 - 0
app/service/dock.js

@@ -136,6 +136,28 @@ class ChatService extends CrudService {
     dock.vipuser.push(vipuser);
     return await dock.save();
   }
+
+  async dockfetch({ id }) {
+    const dock = await this.model.findById(id);
+    const data = JSON.parse(JSON.stringify(dock));
+    if (dock) {
+      const applydata = [];
+      for (const elm of dock.apply) {
+        const url = 'http://localhost:9004/api/market/transaction?userid=' + elm.user_id;
+        const res = await this.ctx.curl(url, {
+          method: 'get',
+          headers: {
+            'content-type': 'application/json',
+          },
+          dataType: 'json',
+        });
+        const newdata = { ...JSON.parse(JSON.stringify(elm)), transdata: res.data.data };
+        applydata.push(newdata);
+      }
+      data.apply = applydata;
+    }
+    return data;
+  }
 }
 
 module.exports = ChatService;