소스 검색

更新

master
huangjiajun 1 년 전
부모
커밋
6c61fe7d49
1개의 변경된 파일17개의 추가작업 그리고 16개의 파일을 삭제
  1. +17
    -16
      hdl/hdl_upgrade.go

+ 17
- 16
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 判断是否可以升级


불러오는 중...
취소
저장