diff --git a/enum/user_level_task.go b/enum/user_level_task.go index 2867a4e..21b932a 100644 --- a/enum/user_level_task.go +++ b/enum/user_level_task.go @@ -7,6 +7,7 @@ const ( DirectPushMembersNum UserLevelTaskType = iota + 1 DirectPushActiveDayNum DirectPushLevel + DirectPushMembersNumActivity ) func (kind UserLevelTaskType) String() string { @@ -17,6 +18,8 @@ func (kind UserLevelTaskType) String() string { return "直推会员活跃天数" case DirectPushLevel: return "直推会员等级" + case DirectPushMembersNumActivity: + return "直推会员有效活跃人数" default: return "未知状态" } diff --git a/rule/user_upgrade.go b/rule/user_upgrade.go index 871d1e8..a57311f 100644 --- a/rule/user_upgrade.go +++ b/rule/user_upgrade.go @@ -99,6 +99,12 @@ func UserUpgradeTask(eg *xorm.Engine, uid, lv int) ([]map[string]string, error) isSuccess = 1 } break + case 4: //直推会员活跃 + count = ExtendUserCountActivity(eg, uid, v.WithinDays, v.ActiveDays, v.FinishCount) + if count >= int64(v.FinishCount) { + isSuccess = 1 + } + break } tmp := map[string]string{ "id": utils.IntToStr(v.Id), @@ -161,3 +167,16 @@ func ExtendUserCountWithDay(eg *xorm.Engine, uid, day, activityDay int) int64 { } return num } + +// 直推人数 +func ExtendUserCountActivity(eg *xorm.Engine, uid, day, activityNum, finishCount int) int64 { + today := utils.GetTimeRange("today") + times := today["start"] - int64(day*86400) + sql := `SELECT COUNT(*) as count,u.id FROM user u +LEFT JOIN egg_sign_in esi on esi.uid=u.id +WHERE esi.start_time>='%s' and u.parent_uid=%d GROUP BY u.id HAVING count>=%d LIMIT %d` + sql = fmt.Sprintf(sql, time.Unix(times, 0).Format("2006-01-02 15:04:05"), uid, activityNum, finishCount) + nativeString, _ := db.QueryNativeString(eg, sql) + return int64(len(nativeString)) + +}