Browse Source

update

master
DengBiao 11 months ago
parent
commit
23cc4354aa
3 changed files with 64 additions and 10 deletions
  1. +22
    -2
      db/db_one_circles_user_watch_records.go
  2. +6
    -7
      db/model/one_circles_user_watch_records.go
  3. +36
    -1
      rule/one_circles/one_circles_public_platoon_give_activty_coin.go

+ 22
- 2
db/db_one_circles_user_watch_records.go View File

@@ -58,7 +58,23 @@ func OneCirclesUserWatchRecordsDelete(Db *xorm.Engine, id interface{}) (int64, e
} }


// OneCirclesUserWatchRecordsUpdate 更新记录 // OneCirclesUserWatchRecordsUpdate 更新记录
func OneCirclesUserWatchRecordsUpdate(session *xorm.Session, id interface{}, OneCirclesUserWatchRecords *model.OneCirclesUserWatchRecords, forceColums ...string) (int64, error) {
func OneCirclesUserWatchRecordsUpdate(Db *xorm.Engine, id interface{}, OneCirclesUserWatchRecords *model.OneCirclesUserWatchRecords, forceColums ...string) (int64, error) {
var (
affected int64
err error
)
if forceColums != nil {
affected, err = Db.Where("id=?", id).Cols(forceColums...).Update(OneCirclesUserWatchRecords)
} else {
affected, err = Db.Where("id=?", id).Update(OneCirclesUserWatchRecords)
}
if err != nil {
return 0, err
}
return affected, nil
}

func OneCirclesUserWatchRecordsUpdateBySession(session *xorm.Session, id interface{}, OneCirclesUserWatchRecords *model.OneCirclesUserWatchRecords, forceColums ...string) (int64, error) {
var ( var (
affected int64 affected int64
err error err error
@@ -92,9 +108,13 @@ func OneCirclesUserWatchRecordsGetOneByParamsBySession(session *xorm.Session, pa
func OneCirclesUserWatchRecordsGetOneByParams(Db *xorm.Engine, params map[string]interface{}) (*model.OneCirclesUserWatchRecords, error) { func OneCirclesUserWatchRecordsGetOneByParams(Db *xorm.Engine, params map[string]interface{}) (*model.OneCirclesUserWatchRecords, error) {
var m model.OneCirclesUserWatchRecords var m model.OneCirclesUserWatchRecords
var query = fmt.Sprintf("%s =?", params["key"]) var query = fmt.Sprintf("%s =?", params["key"])
if has, err := Db.Where(query, params["value"]).Get(&m); err != nil || has == false {
has, err := Db.Where(query, params["value"]).Get(&m)
if err != nil {
return nil, zhios_order_relate_logx.Error(err) return nil, zhios_order_relate_logx.Error(err)
} }
if !has {
return nil, nil
}
return &m, nil return &m, nil
} }




+ 6
- 7
db/model/one_circles_user_watch_records.go View File

@@ -5,11 +5,10 @@ import (
) )


type OneCirclesUserWatchRecords struct { type OneCirclesUserWatchRecords struct {
Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"`
Uid int `json:"uid" xorm:"not null default 0 comment('用户id') INT(11)"`
NextWatchAdDate time.Time `json:"next_watch_ad_date" xorm:"not null default 'CURRENT_TIMESTAMP' comment('下一轮观看视屏时间') DATETIME"`
LastRoundWatchAdTotal int `json:"last_round_watch_ad_total" xorm:"not null default 0 comment('上一轮观看视屏总数') INT(11)"`
ResidueWatchAdNum int `json:"residue_watch_ad_num" xorm:"not null default 0 comment('剩余观看视屏数') INT(11)"`
CreateAt time.Time `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
UpdateAt time.Time `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"`
Uid int `json:"uid" xorm:"not null default 0 comment('用户id') INT(11)"`
NextWatchAdDate time.Time `json:"next_watch_ad_date" xorm:"not null default 'CURRENT_TIMESTAMP' comment('下一轮观看视屏时间') DATETIME"`
ResidueWatchAdNum int `json:"residue_watch_ad_num" xorm:"not null default 0 comment('剩余观看视屏数') INT(11)"`
CreateAt time.Time `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
UpdateAt time.Time `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
} }

+ 36
- 1
rule/one_circles/one_circles_public_platoon_give_activty_coin.go View File

@@ -53,7 +53,7 @@ func SettlementPublicGiveActivityCoin(engine *xorm.Engine, masterId string, uid
"value": uid, "value": uid,
}) })
if err1 != nil { if err1 != nil {
return
return err1
} }


var rewardFather []struct { var rewardFather []struct {
@@ -81,6 +81,41 @@ func SettlementPublicGiveActivityCoin(engine *xorm.Engine, masterId string, uid
} }
} }


//增加 one_circles_user_watch_records 记录
oneCirclesUserWatchRecords, err1 := db.OneCirclesUserWatchRecordsGetOneByParams(engine, map[string]interface{}{
"key": "uid",
"value": uid,
})
if err1 != nil {
return err1
}
now := time.Now()
if oneCirclesUserWatchRecords == nil {
_, err2 := db.OneCirclesUserWatchRecordsInsert(engine, &model.OneCirclesUserWatchRecords{
Uid: uid,
NextWatchAdDate: now.Add(time.Hour * time.Duration(zhios_order_relate_utils.StrToInt(videoRewardSystem.EachRoundHour))),
ResidueWatchAdNum: zhios_order_relate_utils.StrToInt(videoRewardSystem.RewardTotalNum) - 1,
CreateAt: now,
UpdateAt: now,
})
if err2 != nil {
return err2
}
} else {
residueWatchAdNum := oneCirclesUserWatchRecords.ResidueWatchAdNum - 1
nextWatchAdDate := oneCirclesUserWatchRecords.NextWatchAdDate
if residueWatchAdNum == 0 {
nextWatchAdDate = now.Add(time.Hour * time.Duration(zhios_order_relate_utils.StrToInt(videoRewardSystem.EachRoundHour)))
residueWatchAdNum = zhios_order_relate_utils.StrToInt(videoRewardSystem.EachRoundHour)
}
oneCirclesUserWatchRecords.ResidueWatchAdNum = residueWatchAdNum
oneCirclesUserWatchRecords.NextWatchAdDate = nextWatchAdDate
_, err2 := db.OneCirclesUserWatchRecordsUpdate(engine, oneCirclesUserWatchRecords.Id, oneCirclesUserWatchRecords, "residue_watch_ad_num", "next_watch_ad_date")
if err2 != nil {
return err2
}
}

session := engine.NewSession() session := engine.NewSession()
//给相应的用户加上"个人"活跃积分 //给相应的用户加上"个人"活跃积分
err = DealUserCoin(session, md.DealUserCoinReq{ err = DealUserCoin(session, md.DealUserCoinReq{


Loading…
Cancel
Save