From cb06c9e24f3f2fb1fcbb7480fb484938b4d33d91 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Fri, 17 Nov 2023 20:55:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hdl/hdl_condition.go | 11 ++++++----- hdl/hdl_upgrade.go | 13 +++++++------ 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/hdl/hdl_condition.go b/hdl/hdl_condition.go index a3dcf4a..070f533 100644 --- a/hdl/hdl_condition.go +++ b/hdl/hdl_condition.go @@ -65,9 +65,9 @@ func ExtendCount(engine *xorm.Engine, uid interface{}, task map[string]string, t stime := time.Date(t.Year(), t.Month(), t.Day()-zhios_condition_statistics_utils.StrToInt(task["within_days"]), t.Hour(), 0, 0, 0, t.Location()).Format("2006-1-02 15:04:05") etime := t.Format("2006-1-02 15:04:05") sqlTpl := `SELECT count(*) as count - FROM user_profile as up + FROM user_relate as up LEFT JOIN user as u ON u.uid=up.uid - WHERE %s;` + WHERE %s and up.level=1;` condStr := fmt.Sprintf("up.parent_uid=%s AND u.create_at>'%s' AND u.create_at<'%s'", zhios_condition_statistics_utils.AnyToString(uid), stime, etime) sql := fmt.Sprintf(sqlTpl, condStr) results, err := db.QueryNativeString(engine, sql) @@ -87,10 +87,11 @@ func TeamCount(engine *xorm.Engine, uid interface{}, task map[string]string, t t stime := time.Date(t.Year(), t.Month(), t.Day()-zhios_condition_statistics_utils.StrToInt(task["within_days"]), t.Hour(), 0, 0, 0, t.Location()).Format("2006-1-02 15:04:05") etime := t.Format("2006-1-02 15:04:05") sqlTpl := `SELECT count(*) as count - FROM user_profile as up + FROM user_relate as up LEFT JOIN user as u ON u.uid=up.uid - WHERE %s;` - condStr := fmt.Sprintf("up.parent_uid=%s AND u.create_at>'%s' AND u.create_at<'%s' and up.is_verify=%d", zhios_condition_statistics_utils.AnyToString(uid), stime, etime, 1) + LEFT JOIN user_profile as ups ON up.uid=ups.uid + WHERE %s and up.level=1;` + condStr := fmt.Sprintf("up.parent_uid=%s AND u.create_at>'%s' AND u.create_at<'%s' and ups.is_verify=%d", zhios_condition_statistics_utils.AnyToString(uid), stime, etime, 1) sql := fmt.Sprintf(sqlTpl, condStr) results, err := db.QueryNativeString(engine, sql) if err != nil { diff --git a/hdl/hdl_upgrade.go b/hdl/hdl_upgrade.go index 16763d9..7f92917 100644 --- a/hdl/hdl_upgrade.go +++ b/hdl/hdl_upgrade.go @@ -457,9 +457,9 @@ func GetFinishCount(blockStarChain string, engine *xorm.Engine, uid interface{}, stime := time.Date(t.Year(), t.Month(), t.Day()-task.WithinDays, t.Hour(), 0, 0, 0, t.Location()).Format("2006-1-02 15:04:05") etime := t.Format("2006-1-02 15:04:05") sqlTpl := `SELECT count(*) as count - FROM user_profile as up + FROM user_relate as up LEFT JOIN user as u ON u.uid=up.uid - WHERE %s;` + WHERE %s and up.level=1;` var condStr string if task.WithinDays <= 0 { condStr = fmt.Sprintf("up.parent_uid=%s ", zhios_condition_statistics_utils.AnyToString(uid)) @@ -481,15 +481,16 @@ func GetFinishCount(blockStarChain string, engine *xorm.Engine, uid interface{}, stime := time.Date(t.Year(), t.Month(), t.Day()-task.WithinDays, t.Hour(), 0, 0, 0, t.Location()).Format("2006-1-02 15:04:05") etime := t.Format("2006-1-02 15:04:05") sqlTpl := `SELECT count(*) as count - FROM user_profile as up + FROM user_relate as up LEFT JOIN user as u ON u.uid=up.uid - WHERE %s;` + LEFT JOIN user_profile as ups ON up.uid=ups.uid + WHERE %s and up.level=1;` var condStr string if task.WithinDays <= 0 { - condStr = fmt.Sprintf("up.parent_uid=%s and up.is_verify=%d", zhios_condition_statistics_utils.AnyToString(uid), 1) + condStr = fmt.Sprintf("up.parent_uid=%s and ups.is_verify=%d", zhios_condition_statistics_utils.AnyToString(uid), 1) } else { - condStr = fmt.Sprintf("up.parent_uid=%s AND u.create_at>'%s' AND u.create_at<'%s' and up.is_verify=%d", zhios_condition_statistics_utils.AnyToString(uid), stime, etime, 1) + condStr = fmt.Sprintf("up.parent_uid=%s AND u.create_at>'%s' AND u.create_at<'%s' and ups.is_verify=%d", zhios_condition_statistics_utils.AnyToString(uid), stime, etime, 1) } sql := fmt.Sprintf(sqlTpl, condStr) results, err := db.QueryNativeString(engine, sql)