Browse Source

更改助手设置方法

gemercheung 3 years ago
parent
commit
e01157ad14
2 changed files with 24 additions and 26 deletions
  1. 3 2
      src/controller/room/assistant.js
  2. 21 24
      src/controller/room/index.js

+ 3 - 2
src/controller/room/assistant.js

@@ -81,9 +81,10 @@ export class RoomAssistant {
         console.log("不能设置自己为助理!");
         return;
       }
-      const role = cancel ? "customer" : "assistant";
+      // const role = cancel ? "customer" : "assistant";
+      const isAssistant = cancel ? 0 : 1;
       //  assistant是助手,customer是普通角色,操作role会好些
-      const userObj = Object.assign({}, user, { role: role, order: 1 });
+      const userObj = Object.assign({}, user, { '"customer"': role, order: 1, isAssistant });
       const roomObj = Object.assign({}, roomConfigRes, { assistantId: user.userId });
       // console.log("setAssistant", userObj, roomObj);
       // console.error("roomObj", roomObj);

+ 21 - 24
src/controller/room/index.js

@@ -33,6 +33,7 @@ export class RoomController extends BasicController {
       assistantId: null,
       onlineStatus: 0,
       voiceStatus: 0,
+      isAssistant: 0,
       enableTalk: null,
       oid: null, // openid
     };
@@ -74,34 +75,30 @@ export class RoomController extends BasicController {
       const oneSceneNum = this.user.sceneNumber || this.user.sceneNum;
       const { userId, roomId } = this.user;
       await this.initParams(userId, roomId, oneSceneNum);
-      let order;
-      switch (this.user.role) {
-        case "leader":
-          order = 0;
-          break;
-        case "assistant":
-          order = 1;
-          break;
-        case "customer":
-          order = 2;
-          break;
-        default:
-          order = 2;
-          break;
+
+      //role的顺序
+      let order = 2;
+      if (this.user.role === "leader") {
+        order = 0;
+      }
+      if (this.user.role === "customer" && Number(this.issAssistant) === 1) {
+        order = 1;
       }
 
       const userObj = { ...this.user, onlineStatus: 1, isConnected: true, order };
-      const assistantId = await this.roomAssistant.getRoomAssistant(this.roomId);
-      if (!this.isHoster(this.user.role)) {
-        console.log("assistantId", assistantId);
-        console.log("this.userId", this.user.userId);
-        this.logger.info("默认变更条件:" + (assistantId && Number(this.user.userId) !== Number(assistantId)));
 
-        if (assistantId && Number(this.user.userId) !== Number(assistantId)) {
-          this.logger.info("已存在默认助手变更:" + "room助手ID: " + assistantId + " userId: " + this.user.userId);
-          userObj.role = "customer";
-        }
-      }
+      
+      // const assistantId = await this.roomAssistant.getRoomAssistant(this.roomId);
+      // if (!this.isHoster(this.user.role)) {
+      //   console.log("assistantId", assistantId);
+      //   console.log("this.userId", this.user.userId);
+      //   this.logger.info("默认变更条件:" + (assistantId && Number(this.user.userId) !== Number(assistantId)));
+
+      //   if (assistantId && Number(this.user.userId) !== Number(assistantId)) {
+      //     this.logger.info("已存在默认助手变更:" + "room助手ID: " + assistantId + " userId: " + this.user.userId);
+      //     userObj.role = "customer";
+      //   }
+      // }
 
       // if (assistantId && Number(this.userId) !== Number(assistantId) && !this.isHoster(this.user.role)) {
       //   userObj.role = "customer";