diff --git a/internal/model/noble_m/userNoble.go b/internal/model/noble_m/userNoble.go index 06daa123246069f0ac82a91b87ac15941619bd1e..2a4dfdab49e613a8c9528d187ef20efdf2b318aa 100644 --- a/internal/model/noble_m/userNoble.go +++ b/internal/model/noble_m/userNoble.go @@ -22,6 +22,12 @@ func (ub *UserNoble) UpdateEndTime(db *gorm.DB, endTime time.Time) (int64, error return r.RowsAffected, r.Error } +// 延长贵族 +func (ub *UserNoble) ExtenedEndTime(db *gorm.DB, day int) (int64, error) { + r := db.Model(&UserNoble{}).Where(ub).Update("end_time", gorm.Expr("DATE_ADD(end_time,INTERVAL ? day)", day)) + return r.RowsAffected, r.Error +} + // 查询用户未过期的贵族 func (ub *UserNoble) Find(db *gorm.DB) ([]UserNoble, error) { rows := make([]UserNoble, 0) diff --git a/script/fruit_day_award.go b/script/fruit_day_award.go index 90bdcf58135188575483d1c650768e488c8b33ef..c499eaec3eba7ca5a9250df938f5c505da9e7243 100644 --- a/script/fruit_day_award.go +++ b/script/fruit_day_award.go @@ -41,7 +41,7 @@ func ats32(a interface{}) string { } func main() { - url := "https://apiv2.faceline.live/v1/fruitMachine/rank/award?lang=zh-cn&pageIndex=1&pageSize=5000&beginDate=2023-08-30&endDate=2023-08-30&userCode=&timezone=1" + url := "https://apiv2.faceline.live/v1/fruitMachine/rank/award?lang=zh-cn&pageIndex=1&pageSize=5000&beginDate=2023-08-31&endDate=2023-08-31&userCode=&timezone=1" method := "GET" client := &http.Client{} @@ -95,7 +95,7 @@ func main() { for _, v := range svips { svipMap[v.Code] = v.Level } - excelFileName := fmt.Sprintf("./0830水果机中奖榜.xlsx") + excelFileName := fmt.Sprintf("./0831水果机中奖榜.xlsx") xlFile := xlsx.NewFile() sheet, _ := xlFile.AddSheet("charge") row := sheet.AddRow() diff --git a/txop/noble_tx/noble.go b/txop/noble_tx/noble.go index 4670ba7c97b62a0180c0f33dbc88cb8cf8c29ca5..5b9dae011bdeed29d1f6410ab119283452ffeb5b 100644 --- a/txop/noble_tx/noble.go +++ b/txop/noble_tx/noble.go @@ -21,7 +21,7 @@ func SendNoble(model *domain.Model, receiverUserId mysql.ID, level uint16, days return fmt.Errorf("level is 0") } - cfg, err := noble_m.GetConfigByLevel(model.Db, level) + cfg, err := noble_m.GetConfigByLevel(model.DB(), level) if err != nil { return err } @@ -29,7 +29,7 @@ func SendNoble(model *domain.Model, receiverUserId mysql.ID, level uint16, days return fmt.Errorf("level is 0") } n := noble_m.UserNoble{UserId: receiverUserId, Level: level} - records, err := n.FindAll(model.Db) + records, err := n.FindAll(model.DB()) if err != nil { return err } @@ -42,7 +42,7 @@ func SendNoble(model *domain.Model, receiverUserId mysql.ID, level uint16, days // 新增贵族 endTime := time.Now().AddDate(0, 0, int(days)) n = noble_m.UserNoble{UserId: receiverUserId, Level: level, EndTime: endTime} - err = n.Create(model.Db) + err = n.Create(model.DB()) if err != nil { return err } @@ -55,7 +55,7 @@ func SendNoble(model *domain.Model, receiverUserId mysql.ID, level uint16, days SrcType: noble_m.SRC_APP, NewEndTime: endTime, } - err = nbl.Create(model.Db) + err = nbl.Create(model.DB()) if err != nil { return err } @@ -71,12 +71,16 @@ func SendNoble(model *domain.Model, receiverUserId mysql.ID, level uint16, days Entity: mysql.Entity{ID: n.ID, UpdatedTime: n.UpdatedTime}, } - af, err := nn.UpdateEndTime(model.Db, endTime) + af, err := nn.UpdateEndTime(model.DB(), endTime) if err != nil { return err } if af <= 0 { - return fmt.Errorf("bizerr.TransactionFailed") + if af2, err := nn.ExtenedEndTime(model.DB(), days); err != nil { + return err + } else if af2 <= 0 { + return fmt.Errorf("bizerr.TransactionFailed rows 0") + } } nbl := noble_m.UserNobleLog{ @@ -88,7 +92,7 @@ func SendNoble(model *domain.Model, receiverUserId mysql.ID, level uint16, days OldEndTime: n.EndTime, NewEndTime: endTime, } - err = nbl.Create(model.Db) + err = nbl.Create(model.DB()) if err != nil { return err }