|
|
@@ -0,0 +1,55 @@ |
|
|
|
package db |
|
|
|
|
|
|
|
import ( |
|
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_day_luck_draw.git/db/model" |
|
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_day_luck_draw.git/md" |
|
|
|
zhios_day_luck_draw_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_day_luck_draw.git/utils" |
|
|
|
"xorm.io/xorm" |
|
|
|
) |
|
|
|
|
|
|
|
func GetDayLuckDrawPeriodRewardList(Db *xorm.Engine, parameter *md.DayLuckDrawPeriodRewardRequest) ([]*model.DayLuckDrawPeriodReward, int, error) { |
|
|
|
var list []*model.DayLuckDrawPeriodReward |
|
|
|
count := DayLuckDrawPeriodRewardGetCount(Db, parameter) |
|
|
|
session := Db.Where("") |
|
|
|
DayLuckDrawPeriodRewardSearchCondition(Db, session, parameter) |
|
|
|
//分页 |
|
|
|
if zhios_day_luck_draw_utils.StrToInt(parameter.P) > 0 && zhios_day_luck_draw_utils.StrToInt(parameter.PageSize) > 0 { |
|
|
|
session = session.Limit(zhios_day_luck_draw_utils.StrToInt(parameter.PageSize), (zhios_day_luck_draw_utils.StrToInt(parameter.P)-1)*zhios_day_luck_draw_utils.StrToInt(parameter.PageSize)) |
|
|
|
} |
|
|
|
//排序 |
|
|
|
err := session.Desc("create_time").Find(&list) |
|
|
|
if err != nil { |
|
|
|
return nil, 0, err |
|
|
|
} |
|
|
|
return list, count, nil |
|
|
|
} |
|
|
|
func DayLuckDrawPeriodRewardGetCount(Db *xorm.Engine, parameter *md.DayLuckDrawPeriodRewardRequest) int { |
|
|
|
var ord model.DayLuckDrawPeriodReward |
|
|
|
session := Db.Where("") |
|
|
|
DayLuckDrawPeriodRewardSearchCondition(Db, session, parameter) |
|
|
|
count, err := session.Count(&ord) |
|
|
|
if err != nil { |
|
|
|
return 0 |
|
|
|
} |
|
|
|
return int(count) |
|
|
|
} |
|
|
|
func DayLuckDrawPeriodRewardSearchCondition(Db *xorm.Engine, session *xorm.Session, parameter *md.DayLuckDrawPeriodRewardRequest) { |
|
|
|
if parameter.Uid != "" { |
|
|
|
session = session.And("uid = ? ", parameter.Uid) |
|
|
|
} |
|
|
|
if parameter.Phone != "" { |
|
|
|
uid := 0 |
|
|
|
mobile, _ := UserFindByMobile(Db, parameter.Phone) |
|
|
|
if mobile != nil { |
|
|
|
uid = mobile.Uid |
|
|
|
} |
|
|
|
session = session.And("uid = ? ", uid) |
|
|
|
} |
|
|
|
if parameter.StartTime != "" { |
|
|
|
session = session.And("create_time >=?", parameter.StartTime) |
|
|
|
} |
|
|
|
if parameter.EndTime != "" { |
|
|
|
session = session.And("create_time <=?", parameter.EndTime) |
|
|
|
} |
|
|
|
|
|
|
|
} |