소스 검색

账号列表页,刷新工作手机账号状态

DESKTOP-53URE31\USER 3 달 전
부모
커밋
f9274ff519
3개의 변경된 파일51개의 추가작업 그리고 30개의 파일을 삭제
  1. 1 29
      internal/logic/WorkPhone/wx_refresh_logic.go
  2. 19 1
      internal/logic/Wx/get_wx_list_logic.go
  3. 31 0
      internal/types/workphone.go

+ 1 - 29
internal/logic/WorkPhone/wx_refresh_logic.go

@@ -30,36 +30,8 @@ func NewWxRefreshLogic(ctx context.Context, svcCtx *svc.ServiceContext) *WxRefre
 		svcCtx: svcCtx}
 }
 
-type GetWeChatsResp struct {
-	Code int64 `json:"code"`
-	Data []struct {
-		Accountid   string      `json:"accountid"`
-		Avatar      string      `json:"avatar"`
-		Brand       string      `json:"brand"`
-		Cid         int64       `json:"cid"`
-		City        string      `json:"city"`
-		Cname       interface{} `json:"cname"`
-		Country     string      `json:"country"`
-		Deviceid    string      `json:"deviceid"`
-		Devnickname string      `json:"devnickname"`
-		Gender      int64       `json:"gender"`
-		Groupid     interface{} `json:"groupid"`
-		ID          int64       `json:"id"`
-		Isonline    int64       `json:"isonline"`
-		LoginTime   int64       `json:"login_time"`
-		ModifyTime  int64       `json:"modify_time"`
-		Module      string      `json:"module"`
-		Province    string      `json:"province"`
-		Snumber     int64       `json:"snumber"`
-		Wechatid    string      `json:"wechatid"`
-		Wechatnick  string      `json:"wechatnick"`
-		Wechatno    string      `json:"wechatno"`
-	} `json:"data"`
-	Msg string `json:"msg"`
-}
-
 func (l *WxRefreshLogic) WxRefresh() (resp *types.BaseMsgResp, err error) {
-	var result GetWeChatsResp
+	var result types.WorkPhoneGetWeChatsResp
 	client := req.C().DevMode()
 	client.SetCommonRetryCount(2).
 		SetCommonRetryBackoffInterval(1*time.Second, 5*time.Second).

+ 19 - 1
internal/logic/Wx/get_wx_list_logic.go

@@ -2,6 +2,8 @@ package Wx
 
 import (
 	"context"
+	"fmt"
+	reqv3 "github.com/imroc/req/v3"
 	"github.com/suyuan32/simple-admin-core/rpc/types/core"
 	"wechat-api/ent"
 	"wechat-api/ent/predicate"
@@ -83,6 +85,22 @@ func (l *GetWxListLogic) GetWxList(req *types.WxListReq) (*types.WxListResp, err
 	resp.Msg = errormsg.Success
 	resp.Data.Total = data.PageDetails.Total
 
+	var result types.WorkPhoneGetWeChatsResp
+
+	res, err := reqv3.C().DevMode().R().SetSuccessResult(&result).Post("http://chat.gkscrm.com:13086/pc/GetWeChatsReq?id=13")
+	if err != nil {
+		return nil, err
+	}
+	if !res.IsSuccessState() {
+		err = fmt.Errorf("GetWeChats failed with status code %d", res.StatusCode)
+		return nil, err
+	}
+
+	var workphoneWxList map[string]types.WorkPhoneWeChat
+	for _, v := range result.Data {
+		workphoneWxList[v.Wechatid] = v
+	}
+
 	for _, v := range data.List {
 		// 创建 hookClient 客户端
 		serverInfo := serverSet[v.ServerID]
@@ -103,7 +121,7 @@ func (l *GetWxListLogic) GetWxList(req *types.WxListReq) (*types.WxListResp, err
 				}
 			}
 		} else {
-			loginStatus = v.Status
+			loginStatus = uint8(workphoneWxList[v.Wxid].Isonline)
 		}
 
 		processID := v.ProcessID

+ 31 - 0
internal/types/workphone.go

@@ -0,0 +1,31 @@
+package types
+
+type WorkPhoneWeChat struct {
+	Accountid   string      `json:"accountid"`
+	Avatar      string      `json:"avatar"`
+	Brand       string      `json:"brand"`
+	Cid         int64       `json:"cid"`
+	City        string      `json:"city"`
+	Cname       interface{} `json:"cname"`
+	Country     string      `json:"country"`
+	Deviceid    string      `json:"deviceid"`
+	Devnickname string      `json:"devnickname"`
+	Gender      int64       `json:"gender"`
+	Groupid     interface{} `json:"groupid"`
+	ID          int64       `json:"id"`
+	Isonline    int64       `json:"isonline"`
+	LoginTime   int64       `json:"login_time"`
+	ModifyTime  int64       `json:"modify_time"`
+	Module      string      `json:"module"`
+	Province    string      `json:"province"`
+	Snumber     int64       `json:"snumber"`
+	Wechatid    string      `json:"wechatid"`
+	Wechatnick  string      `json:"wechatnick"`
+	Wechatno    string      `json:"wechatno"`
+}
+
+type WorkPhoneGetWeChatsResp struct {
+	Code int64             `json:"code"`
+	Data []WorkPhoneWeChat `json:"data"`
+	Msg  string            `json:"msg"`
+}