lichangdong 1 giorno fa
parent
commit
b350c6ce04

+ 2 - 2
ent/addwechatfriendlog.go

@@ -20,7 +20,7 @@ type AddWechatFriendLog struct {
 	ID int64 `json:"id,omitempty"`
 	// 属主的wxid
 	OwnerWxID string `json:"owner_wx_id,omitempty"`
-	// 属主的微信类型(1个微,2企微)
+	// 属主的微信类型(1个微,3企微)
 	OwnerWxType int `json:"owner_wx_type,omitempty"`
 	// 手机号
 	FindContent string `json:"find_content,omitempty"`
@@ -32,7 +32,7 @@ type AddWechatFriendLog struct {
 	FindResult map[string]interface{} `json:"find_result,omitempty"`
 	// 任务执行次数
 	IsCanAdd int `json:"is_can_add,omitempty"`
-	// 是否可以添加好友(与属主账号非好友且其数据查询正常时 0 不可以,1 可以 2成功添加申请
+	// 是否可以添加好友(与属主账号非好友且其数据查询正常时 0数据准备中,1 待执行 2成功添加申请 3timeout及其他错误 4用户不存在 5手动取消
 	TaskCount int `json:"task_count,omitempty"`
 	// 添加时候的请求体
 	TaskID int64 `json:"task_id,omitempty"`

+ 2 - 2
ent/schema/add_wechat_friend_log.go

@@ -30,7 +30,7 @@ func (AddWechatFriendLog) Fields() []ent.Field {
 
 		field.Int("owner_wx_type").
 			Default(1).
-			Comment("属主的微信类型(1个微,2企微)"),
+			Comment("属主的微信类型(1个微,3企微)"),
 
 		field.String("find_content").
 			Default("").
@@ -55,7 +55,7 @@ func (AddWechatFriendLog) Fields() []ent.Field {
 			Comment("任务执行次数"),
 		field.Int("task_count").
 			Default(0).
-			Comment("是否可以添加好友(与属主账号非好友且其数据查询正常时 0数据准备中,1 待执行 2成功添加申请 3timeout及其他错误 4用户不存在 5手动取消)"),
+			Comment("是否可以添加好友(与属主账号非好友且其数据查询正常时 0数据准备中,1 待执行 2成功添加申请 3timeout及其他错误 4用户不存在 5手动取消 6已经是好友)"),
 		field.Int64("task_id").Default(0).Comment("添加时候的请求体"),
 		field.JSON("add_request", map[string]interface{}{}).
 			Optional().Comment("添加时候的请求体"),

+ 5 - 4
internal/logic/add_friend/add_friend_list_logic.go

@@ -31,7 +31,7 @@ func (l *AddFriendListLogic) AddFriendList(req *types.AddFriendListReq) (resp *t
 	organizationId := l.ctx.Value("organizationId").(uint64)
 	//通过organizationId去wx表拿微信机器人的数
 
-	query := l.svcCtx.DB.Wx.Query().Where(wx.OrganizationIDEQ(organizationId), wx.StatusEQ(1))
+	query := l.svcCtx.DB.Wx.Query().Where(wx.OrganizationIDEQ(organizationId), wx.DeletedAtIsNil())
 	// 动态添加条件示例:假设 req.OwnerWxId 存在时添加额外的 Where 条件
 	if utils.IsNonEmptyString(req.OwnerWxId) {
 		query = query.Where(wx.WxidEQ(*req.OwnerWxId))
@@ -64,13 +64,13 @@ func (l *AddFriendListLogic) AddFriendList(req *types.AddFriendListReq) (resp *t
 		case 1:
 			IsCanAdd = append(IsCanAdd, 0, 1)
 		case 2:
-			IsCanAdd = append(IsCanAdd, 3, 4)
+			IsCanAdd = append(IsCanAdd, 3, 4, 6)
 		case 3:
 			IsCanAdd = append(IsCanAdd, 2)
 		default:
-			IsCanAdd = append(IsCanAdd, 0, 1, 2, 3, 4, 5)
+			IsCanAdd = append(IsCanAdd, 0, 1, 2, 3, 4, 5, 6)
 		}
-		if len(IsCanAdd) < 6 {
+		if len(IsCanAdd) < 7 {
 			predicates = append(predicates, addwechatfriendlog.IsCanAddIn(IsCanAdd...))
 		}
 	}
@@ -103,6 +103,7 @@ func (l *AddFriendListLogic) AddFriendList(req *types.AddFriendListReq) (resp *t
 						3: "timeout及其他错误",
 						4: "用户不存在",
 						5: "后台取消",
+						6: "已是好友",
 					}
 					statusStr := statusMap[v.IsCanAdd]
 					return &statusStr

+ 1 - 1
internal/service/MessageHandlers/find_contact_task_result_notice.go

@@ -90,7 +90,7 @@ func (f *FindContactTaskResultNoticeHandler) Handle(ctx context.Context, msg *we
 		SetUpdatedAt(time.Now().Unix())
 	if message.Success {
 		if message.IsFriend {
-			update = update.SetIsCanAdd(0)
+			update = update.SetIsCanAdd(6)
 		} else {
 			update = update.SetIsCanAdd(1)
 		}

+ 2 - 2
internal/service/addfriend/add_wechat_friend_log.go

@@ -60,7 +60,7 @@ func (l *AddWechatFriendService) FindFriendByContent(wechatId, content string) b
 
 func (l *AddWechatFriendService) AddNewFriend(wechatId, content, message string, wechatType int) bool {
 	//先记录请求
-	if wechatType != 1 && wechatType != 2 {
+	if wechatType != 1 && wechatType != 3 {
 		return false
 	}
 	node, err := snowflake.NewNode(1) // 1 是节点 ID,根据需要设置
@@ -77,7 +77,7 @@ func (l *AddWechatFriendService) AddNewFriend(wechatId, content, message string,
 	case 1:
 		hookClient = hook.NewHook("", "", "")
 		result, err = hookClient.AddFriendTask(wechatId, content, message, taskId.Int64())
-	case 2:
+	case 3:
 		hookClient = hook.NewWecomHook("", "", "")
 		result, err = hookClient.AddWecomCustomerFromSearchTask(wechatId, content, message, taskId.Int64())
 	default: