boweniac 3 недель назад
Родитель
Сommit
79d8d05874

+ 6 - 3
internal/logic/Wx/get_wx_list_logic.go

@@ -165,7 +165,7 @@ func (l *GetWxListLogic) GetWxList(req *types.WxListReq) (*types.WxListResp, err
 	} else {
 		var result types.WorkPhoneGetWeChatsResp
 
-		res, err := reqv3.C().DevMode().R().SetSuccessResult(&result).Post("http://chat.gkscrm.com:13086/pc/GetWeChatsReq?id=13")
+		res, err := reqv3.C().DevMode().R().SetSuccessResult(&result).Post("http://chat.gkscrm.com:13086/pc/GetWeChatsReq?id=0")
 		if err != nil {
 			return nil, err
 		}
@@ -176,7 +176,10 @@ func (l *GetWxListLogic) GetWxList(req *types.WxListReq) (*types.WxListResp, err
 
 		workphoneWxList := make(map[string]types.WorkPhoneWeChat, len(result.Data))
 		for _, v := range result.Data {
-			workphoneWxList[v.Wechatid] = v
+			if v.Wechatid == nil || *v.Wechatid == "" {
+				continue
+			}
+			workphoneWxList[*v.Wechatid] = v
 		}
 
 		for _, v := range data.List {
@@ -203,7 +206,7 @@ func (l *GetWxListLogic) GetWxList(req *types.WxListReq) (*types.WxListResp, err
 				}
 			} else {
 				workphoneWx, exists := workphoneWxList[v.Wxid]
-				if exists && workphoneWx.Isonline == 0 {
+				if exists && *workphoneWx.Isonline == 0 {
 					loginStatus = 1
 				} else {
 					loginStatus = 0

+ 7 - 2
internal/logic/chat/chat_completions_logic.go

@@ -49,9 +49,14 @@ func (l *ChatCompletionsLogic) ChatCompletions(req *types.CompApiReq) (resp *typ
 	if !ok {
 		return nil, errors.New("content get token err")
 	}
-	if req.WorkId == "TEST_DOUYIN" || req.WorkId == "travel" { //临时加
+	if req.WorkId == "TEST_DOUYIN" || req.WorkId == "TEST_DOUYIN_CN" || req.WorkId == "travel" { //临时加
 		apiKeyObj.OpenaiBase = "http://cn-agent.gkscrm.com/api/v1/"
-		workToken = "fastgpt-jsMmQKEM5uX7tDimT1zHlZHkBhMHRT2k61YaxyDJRZTUHehID7sG8BKXADNIU"
+		if req.WorkId == "TEST_DOUYIN" || req.WorkId == "TEST_DOUYIN_CN" {
+			workToken = "fastgpt-jsMmQKEM5uX7tDimT1zHlZHkBhMHRT2k61YaxyDJRZTUHehID7sG8BKXADNIU"
+		} else if req.WorkId == "travel" {
+			workToken = "fastgpt-bcnfFtw1lXWdmYGOv165UVD5R1kY28tyXX8SJv8MHhrSMOgVJsuU"
+		}
+
 	}
 
 	/*

+ 29 - 22
internal/service/wechat/sync_wx.go

@@ -3,6 +3,7 @@ package wechat
 import (
 	"context"
 	"encoding/json"
+	"fmt"
 	"github.com/imroc/req/v3"
 	"github.com/zeromicro/go-zero/core/logx"
 	"strconv"
@@ -32,16 +33,13 @@ func SyncAllWx(svcCtx *svc.ServiceContext) {
 
 	// 遍历微信列表
 	for _, account := range result.Data {
-		if account.Wechatid == "" {
+		if account.Wechatid == nil || *account.Wechatid == "" {
 			continue
 		}
 		wxinfo, err := svcCtx.DB.Wx.Query().
 			Where(
 				wx.And(
-					wx.Or(
-						wx.WxidEQ(account.Wechatid),
-						wx.PortEQ(account.Deviceid),
-					),
+					wx.WxidEQ(*account.Wechatid),
 					wx.CtypeEQ(1),
 				),
 			).
@@ -52,66 +50,75 @@ func SyncAllWx(svcCtx *svc.ServiceContext) {
 			return
 		}
 		var status uint8
-		if account.Isonline == 0 {
+		logx.Info(fmt.Printf("*account.Isonline: %d\n", *account.Isonline))
+		if *account.Isonline == 0 {
 			status = 1
 		} else {
 			status = 0
 		}
+
 		if wxinfo != nil {
+			logx.Info(fmt.Printf("wxinfo is not nil, account: %s\n", *account.Wechatid))
+			logx.Info(fmt.Printf("wxinfo is not nil, account: %s\n", *account.Wechatnick))
 			err = svcCtx.DB.Wx.UpdateOneID(wxinfo.ID).
 				SetServerID(0).
-				SetPort(account.Deviceid).
+				SetPort(*account.Deviceid).
 				SetProcessID(strconv.FormatInt(account.Cid, 10)).
-				SetAccount(account.Wechatno).
-				SetNickname(account.Wechatnick).
-				SetHeadBig(account.Avatar).
+				SetNotNilAccount(account.Wechatno).
+				SetNotNilNickname(account.Wechatnick).
+				SetNotNilHeadBig(account.Avatar).
 				SetStatus(status).
 				Exec(context.TODO())
-
 			if err != nil {
 				logx.Error("syncWx: ", err)
-				return
+				continue
 			}
 		} else {
-			logx.Debug("wxinfo is nil")
+			logx.Error(fmt.Printf("wxinfo is nil, account: %+v\n", account))
 			_, err := svcCtx.DB.Wx.Create().
 				SetServerID(0).
-				SetPort(account.Deviceid).
+				SetPort(*account.Deviceid).
 				SetProcessID(strconv.FormatInt(account.Cid, 10)).
-				SetWxid(account.Wechatid).
-				SetAccount(account.Wechatno).
-				SetHeadBig(account.Avatar).
-				SetNickname(account.Wechatnick).
+				SetWxid(*account.Wechatid).
+				SetNotNilAccount(account.Wechatno).
+				SetNotNilHeadBig(account.Avatar).
+				SetNotNilNickname(account.Wechatnick).
 				SetStatus(status).
 				SetAllowList([]string{}).SetBlockList([]string{}).SetGroupAllowList([]string{}).SetGroupBlockList([]string{}).
 				Save(context.TODO())
 			if err != nil {
 				logx.Error("syncWx: ", err)
-				return
+				continue
 			}
 		}
 
 		data := map[string]interface{}{
 			"MsgType": "TriggerFriendPushTask",
 			"Content": map[string]interface{}{
-				"WeChatId": account.Wechatid,
+				"WeChatId": *account.Wechatid,
 			},
 		}
+		//logx.Info("data: ", data)
 		jsonStr, err := json.Marshal(data)
 		err = svcCtx.WechatWs["default"].SendMsg([]byte(jsonStr))
 		if err != nil {
 			logx.Error("syncWx: ", err)
-			return
+			continue
 		}
 
 		dataChatroom := map[string]interface{}{
 			"MsgType": "TriggerChatroomPushTask",
 			"Content": map[string]interface{}{
-				"WeChatId": account.Wechatid,
+				"WeChatId": *account.Wechatid,
 				"Flag":     1,
 			},
 		}
+		//logx.Info("dataChatroom: ", dataChatroom)
 		jsonStrChatroom, err := json.Marshal(dataChatroom)
 		err = svcCtx.WechatWs["default"].SendMsg([]byte(jsonStrChatroom))
+		if err != nil {
+			logx.Error("syncWx: ", err)
+			continue
+		}
 	}
 }

+ 18 - 18
internal/types/workphone.go

@@ -1,27 +1,27 @@
 package types
 
 type WorkPhoneWeChat struct {
-	Accountid   string      `json:"accountid"`
-	Avatar      string      `json:"avatar"`
-	Brand       string      `json:"brand"`
+	Accountid   *string     `json:"accountid"`
+	Avatar      *string     `json:"avatar"`
+	Brand       *string     `json:"brand"`
 	Cid         int64       `json:"cid"`
-	City        string      `json:"city"`
+	City        *string     `json:"city"`
 	Cname       interface{} `json:"cname"`
-	Country     string      `json:"country"`
-	Deviceid    string      `json:"deviceid"`
-	Devnickname string      `json:"devnickname"`
-	Gender      int64       `json:"gender"`
+	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"`
+	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 {