|
@@ -210,55 +210,52 @@ func (l *GetFriendsAndGroupsLogic) GetFriendsAndGroups(req *types.IDReq) (resp *
|
|
|
|
|
|
if wxInfo.Ctype == uint64(3) {
|
|
|
hookClient = hook.NewWecomHook("", "", "")
|
|
|
- wsUrl = "http://wecom.gkscrm.com:15086/pc/GetWechatFriendList?cid=" + wxInfo.ProcessID + "&wechatid=" + wxInfo.Wxid
|
|
|
+ _ = hookClient.TriggerCustomerPushTask(wxInfo.Wxid)
|
|
|
+ _ = hookClient.TriggerConversationPushTask(wxInfo.Wxid)
|
|
|
} else {
|
|
|
hookClient = hook.NewHook("", "", "")
|
|
|
wsUrl = "http://chat.gkscrm.com:13086/pc/GetWechatFriendList?cid=" + wxInfo.ProcessID + "&wechatid=" + wxInfo.Wxid
|
|
|
- }
|
|
|
- res, err := reqv3.C().DevMode().R().SetSuccessResult(&result).Post(wsUrl)
|
|
|
- if err != nil {
|
|
|
- return nil, err
|
|
|
- }
|
|
|
- if !res.IsSuccessState() {
|
|
|
- err = fmt.Errorf("GetFriendAndChatRoomList failed with status code %d", res.StatusCode)
|
|
|
- l.Error("GetWechatFriendList 请求失败", err)
|
|
|
- return nil, err
|
|
|
- }
|
|
|
|
|
|
- if wxInfo.Ctype == 3 {
|
|
|
- _ = hookClient.TriggerCustomerPushTask(wxInfo.Wxid)
|
|
|
- _ = hookClient.TriggerConversationPushTask(wxInfo.Wxid)
|
|
|
- } else {
|
|
|
+ res, err := reqv3.C().DevMode().R().SetSuccessResult(&result).Post(wsUrl)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ if !res.IsSuccessState() {
|
|
|
+ err = fmt.Errorf("GetFriendAndChatRoomList failed with status code %d", res.StatusCode)
|
|
|
+ l.Error("GetWechatFriendList 请求失败", err)
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+
|
|
|
_ = hookClient.TriggerChatroomPush(wxInfo.Wxid)
|
|
|
- }
|
|
|
|
|
|
- for _, friend := range result.Data {
|
|
|
- friendType := 1
|
|
|
- if friend.Type == 1 {
|
|
|
- friendType = 2
|
|
|
- _ = hookClient.RequestChatRoomInfo(friend.Friendid, wxInfo.Wxid)
|
|
|
- } else {
|
|
|
- friendType = 1
|
|
|
- }
|
|
|
+ for _, friend := range result.Data {
|
|
|
+ friendType := 1
|
|
|
+ if friend.Type == 1 {
|
|
|
+ friendType = 2
|
|
|
+ _ = hookClient.RequestChatRoomInfo(friend.Friendid, wxInfo.Wxid)
|
|
|
+ } else {
|
|
|
+ friendType = 1
|
|
|
+ }
|
|
|
|
|
|
- _, err = l.svcCtx.DB.Contact.Create().
|
|
|
- SetWxWxid(wxInfo.Wxid).
|
|
|
- SetType(friendType).
|
|
|
- SetWxid(friend.Friendid).
|
|
|
- SetAccount(friend.FriendWechatno).
|
|
|
- SetNickname(friend.Nickname).
|
|
|
- SetMarkname(friend.Memo).
|
|
|
- SetHeadimg(friend.Avatar).
|
|
|
- SetSex(cast.ToInt(friend.Gender)).
|
|
|
- SetOrganizationID(organizationId).
|
|
|
- OnConflict().
|
|
|
- UpdateNewValues().
|
|
|
- SetOrganizationID(organizationId).
|
|
|
- ID(l.ctx)
|
|
|
+ _, err = l.svcCtx.DB.Contact.Create().
|
|
|
+ SetWxWxid(wxInfo.Wxid).
|
|
|
+ SetType(friendType).
|
|
|
+ SetWxid(friend.Friendid).
|
|
|
+ SetAccount(friend.FriendWechatno).
|
|
|
+ SetNickname(friend.Nickname).
|
|
|
+ SetMarkname(friend.Memo).
|
|
|
+ SetHeadimg(friend.Avatar).
|
|
|
+ SetSex(cast.ToInt(friend.Gender)).
|
|
|
+ SetOrganizationID(organizationId).
|
|
|
+ OnConflict().
|
|
|
+ UpdateNewValues().
|
|
|
+ SetOrganizationID(organizationId).
|
|
|
+ ID(l.ctx)
|
|
|
|
|
|
- if err != nil {
|
|
|
- l.Error("创建联系人失败", err)
|
|
|
- continue
|
|
|
+ if err != nil {
|
|
|
+ l.Error("创建联系人失败", err)
|
|
|
+ continue
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|