|
@@ -141,7 +141,6 @@ func getFromRegisterBehavior(ctx context.Context, rule entity.NewUserSendRule) (
|
|
|
}
|
|
|
g.Log().Info(ctx, userList)
|
|
|
g.Log().Info(ctx, "getFromRegisterBehavior 获得用户数量", len(userList))
|
|
|
-
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -150,56 +149,60 @@ func filterCallState(ctx context.Context, rule entity.NewUserSendRule, userList
|
|
|
start := time.Now()
|
|
|
defer func() {
|
|
|
g.Log().Info(ctx, "filterCallState 耗时:", time.Since(start))
|
|
|
-
|
|
|
}()
|
|
|
callstateList := strings.Split(rule.CallState, ",")
|
|
|
- for i := 0; i < len(userList); i++ {
|
|
|
+ processCallState := func(user entity.NewUserSendLog) {
|
|
|
for j := 0; j < len(callstateList); j++ {
|
|
|
+ switch callstateList[j] {
|
|
|
// 未拨打 判断不存在
|
|
|
- if callstateList[j] == CallStateNotDialed {
|
|
|
- exist, err := dao.VoiceRecord.Ctx(ctx).Where("CalledNo=?", userList[i].Phone).Exist()
|
|
|
+ case CallStateNotDialed:
|
|
|
+ exist, err := dao.VoiceRecord.Ctx(ctx).Where("CalledNo=?", user.Phone).Exist()
|
|
|
if err != nil {
|
|
|
g.Log().Error(ctx, "filterCallState CallStateNotDialed err:", err)
|
|
|
continue
|
|
|
}
|
|
|
if !exist {
|
|
|
- newUserList = append(newUserList, userList[i])
|
|
|
- continue
|
|
|
+ newUserList = append(newUserList, user)
|
|
|
+ return
|
|
|
}
|
|
|
- }
|
|
|
- // 已接听 至少一个记录
|
|
|
- if callstateList[j] == CallStatDealing {
|
|
|
- exist, err := dao.VoiceRecord.Ctx(ctx).Where("CalledNo=? and State=?", userList[i].Phone, CallStatDealing).Exist()
|
|
|
+ // 已接听 至少一个记录
|
|
|
+ case CallStatDealing:
|
|
|
+ exist, err := dao.VoiceRecord.Ctx(ctx).Where("CalledNo=? and State=?", user.Phone, CallStatDealing).Exist()
|
|
|
if err != nil {
|
|
|
- g.Log().Error(ctx, "filterCallState CallStatDealing err:", err, userList[i])
|
|
|
+ g.Log().Error(ctx, "filterCallState CallStatDealing err:", err, user)
|
|
|
continue
|
|
|
}
|
|
|
if exist {
|
|
|
- newUserList = append(newUserList, userList[i])
|
|
|
+ newUserList = append(newUserList, user)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ // 其他的 判断是否存在指定状态的记录
|
|
|
+ findState := strings.Split(callstateList[j], "#")
|
|
|
+ exist, err := dao.VoiceRecord.Ctx(ctx).Where("CalledNo=?", user.Phone).WhereNotIn(dao.VoiceRecord.Columns().CallState, findState).Exist()
|
|
|
+ if err != nil {
|
|
|
+ g.Log().Error(ctx, "filterCallState otherstate err:", err, findState, user)
|
|
|
continue
|
|
|
}
|
|
|
- }
|
|
|
- // 其他的 判断是否存在记录
|
|
|
- findState := strings.Split(callstateList[j], "#")
|
|
|
- exist, err := dao.VoiceRecord.Ctx(ctx).Where("CalledNo=?", userList[i].Phone).WhereNotIn(dao.VoiceRecord.Columns().CallState, findState).Exist()
|
|
|
- if err != nil {
|
|
|
- g.Log().Error(ctx, "filterCallState otherstate err:", err, findState, userList[i])
|
|
|
- continue
|
|
|
- }
|
|
|
- if !exist {
|
|
|
- continue
|
|
|
- }
|
|
|
- // 存在则查询是否包含其他记录
|
|
|
- exist, err = dao.VoiceRecord.Ctx(ctx).Where("CalledNo=?", userList[i].Phone).WhereNotIn(dao.VoiceRecord.Columns().CallState, findState).Exist()
|
|
|
- if err != nil {
|
|
|
- g.Log().Error(ctx, "filterCallState otherstate notin err:", err, findState, userList[i])
|
|
|
- continue
|
|
|
- }
|
|
|
- if !exist {
|
|
|
- newUserList = append(newUserList, userList[i])
|
|
|
- continue
|
|
|
+ if !exist {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ // 存在则查询是否包含除指定状态外的其他记录
|
|
|
+ exist, err = dao.VoiceRecord.Ctx(ctx).Where("CalledNo=?", user.Phone).WhereNotIn(dao.VoiceRecord.Columns().CallState, findState).Exist()
|
|
|
+ if err != nil {
|
|
|
+ g.Log().Error(ctx, "filterCallState otherstate notin err:", err, findState, user)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ if !exist {
|
|
|
+ newUserList = append(newUserList, user)
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ }
|
|
|
+ for i := 0; i < len(userList); i++ {
|
|
|
+ processCallState(userList[i])
|
|
|
}
|
|
|
g.Log().Info(ctx, "filterCallState 获得用户数量", len(userList))
|
|
|
return
|
|
@@ -214,16 +217,16 @@ func filterTrailStatus(ctx context.Context, rule entity.NewUserSendRule, userLis
|
|
|
}()
|
|
|
for i := 0; i < len(userList); i++ {
|
|
|
var intersectSet *gset.StrSet
|
|
|
- var uid string
|
|
|
+ var uidInfo *entity.DwdFUserbaseBaseinfo
|
|
|
// 先查询出 uid
|
|
|
- err := dao.DwdFUserbaseBaseinfo.Ctx(ctx).Fields("uid").Where("userid=?", userList[i].UserId).Scan(&uid)
|
|
|
+ err := dao.DwdFUserbaseBaseinfo.Ctx(ctx).Fields("uid").Where("userid=?", userList[i].UserId).Scan(&uidInfo)
|
|
|
if err != nil {
|
|
|
g.Log().Error(ctx, "查询跟进状态-获取uid异常", err, userList[i].UserId, userList[i].Phone)
|
|
|
continue
|
|
|
}
|
|
|
info := entity.DwdFCrmClueInfo{}
|
|
|
// 再根据uid 查询
|
|
|
- err = dao.DwdFCrmClueInfo.Ctx(ctx).Fields("trailstatus,industry").Where("uid=?").Order("update_time desc").Limit(1).Scan(&info)
|
|
|
+ err = dao.DwdFCrmClueInfo.Ctx(ctx).Fields("trailstatus,industry").Where("uid=?", uidInfo.Uid).Order("updatetime desc").Limit(1).Scan(&info)
|
|
|
if err != nil {
|
|
|
g.Log().Error(ctx, "查询跟进状态异常", err)
|
|
|
continue
|