From 6c61fe7d49d39e0bad241317b2a958e92fe16c03 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Wed, 20 Sep 2023 14:05:44 +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_upgrade.go | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/hdl/hdl_upgrade.go b/hdl/hdl_upgrade.go index f2e3076..564cfe2 100644 --- a/hdl/hdl_upgrade.go +++ b/hdl/hdl_upgrade.go @@ -11,37 +11,38 @@ import ( "xorm.io/xorm" ) -func CommUpdate(blockStarChain string, eg *xorm.Engine, dbName string, user *model.User, DataDetail md.DataDetail) (error, bool) { +func CommUpdate(blockStarChain string, eg *xorm.Engine, dbName string, user *model.User, DataDetail md.DataDetail) (error, bool, int) { uid := DataDetail.Uid //判断有没有审核通过或审核中的记录 has, err := db.UserLevelAuditingFindByUid(eg, zhios_condition_statistics_utils.StrToInt(uid)) if err != nil { - return err, false + return err, false, 0 } if has != nil { var msg = "您已审核通过,请勿重复申请" if has.State == 1 { msg = "正在审核中,请稍后再查看" } - return errors.New(msg), false + return errors.New(msg), false, 0 } lv := user.Level - result := CommUplv(blockStarChain, eg, dbName, user, lv, DataDetail) + result, AutoAudit := CommUplv(blockStarChain, eg, dbName, user, lv, DataDetail) if result == false { - return errors.New("升级失败"), false + return errors.New("升级失败"), false, AutoAudit } - return nil, result + return nil, result, AutoAudit } -func CommUplv(blockStarChain string, eg *xorm.Engine, dbName string, user *model.User, lv int, DataDetail md.DataDetail) bool { +func CommUplv(blockStarChain string, eg *xorm.Engine, dbName string, user *model.User, lv int, DataDetail md.DataDetail) (bool, int) { levelExpireAt := user.LevelExpireAt levelArriveAt := user.LevelArriveAt oldLevel := user.Level uid := zhios_condition_statistics_utils.IntToStr(user.Uid) result, _, payOrdId := IsCompleteSchemeTask(blockStarChain, eg, user, DataDetail.AgentType, DataDetail.IsChangeTime) + AutoAudit := 0 if result { level, err := db.UserLevelByID(eg, zhios_condition_statistics_utils.StrToInt(DataDetail.AgentType)) if err != nil || level == nil { - return false + return false, 0 } date := time.Now() var auditData = model.UserLevelAudit{ @@ -59,7 +60,7 @@ func CommUplv(blockStarChain string, eg *xorm.Engine, dbName string, user *model } has, err := db.UserLevelAuditInsertWithEngine(eg, &auditData) if has == 0 || err != nil { - return false + return false, 0 } //自动审核 if level.AutoAudit == 1 { @@ -80,7 +81,7 @@ func CommUplv(blockStarChain string, eg *xorm.Engine, dbName string, user *model auditData.State = 2 //审核记录修改 if _, err := db.UserLevelAuditUpdateById(eg, auditData.Id, &auditData, "state"); err != nil { - return false + return false, 0 } t := time.Now() var expire time.Time @@ -88,11 +89,11 @@ func CommUplv(blockStarChain string, eg *xorm.Engine, dbName string, user *model if payOrdId > 0 { ord, err := db.UserLevelOrderById(eg, zhios_condition_statistics_utils.Int64ToStr(payOrdId)) if err != nil { - return false + return false, 0 } //过期时间在当前时间之前 并且 创建时间跟过期时间不相等 相等的话是永久会员 if ord.ExpireAt.Unix() < t.Unix() && ord.CreateAt.Format("2006-01-02 15:04:05") != ord.ExpireAt.Format("2006-01-02 15:04:05") && ord.DateType != 4 { - return false + return false, 0 } switch ord.DateType { case 1: @@ -112,7 +113,7 @@ func CommUplv(blockStarChain string, eg *xorm.Engine, dbName string, user *model ord.ExpireAt = t } if _, err := db.UserLevelOrdUpdateOne(eg, ord); err != nil { - return false + return false, 0 } } user.Level = zhios_condition_statistics_utils.StrToInt(DataDetail.AgentType) @@ -132,12 +133,12 @@ func CommUplv(blockStarChain string, eg *xorm.Engine, dbName string, user *model //用户等级修改 // 更新user level 和 过期时间 if _, err := db.UserUpdate(eg, user.Uid, user, "level,level_expire_at,level_arrive_at,first_arrive_at"); err != nil { - return false + return false, 0 } - + AutoAudit = 1 } } - return result + return result, AutoAudit } // IsCompleteSchemeTask 根据传入的 level 判断是否可以升级