diff --git a/db/db_day_luck_draw_order_jackpot.go b/db/db_day_luck_draw_order_jackpot.go index 42e2c33..c97e3bd 100644 --- a/db/db_day_luck_draw_order_jackpot.go +++ b/db/db_day_luck_draw_order_jackpot.go @@ -30,6 +30,7 @@ func AddOrderJackpot(eg *xorm.Engine, req md.DayLuckDrawOrderJackpotReq) error { return nil } + func GetAllOrderOid(sess *xorm.Session) []string { sql := `SELECT oid,uid FROM day_luck_draw_order_jackpot where period=0;` data, _ := QueryNativeStringSess(sess, sql) diff --git a/db/db_day_luck_draw_setting.go b/db/db_day_luck_draw_setting.go index 8bf93d1..b4fc905 100644 --- a/db/db_day_luck_draw_setting.go +++ b/db/db_day_luck_draw_setting.go @@ -38,6 +38,23 @@ func CheckSetting(eg *xorm.Engine, pvd string) bool { } return true } +func CheckSettingSess(sess *xorm.Session, pvd string) bool { + setting := GetDayLuckDrawSettingSess(sess) + if setting == nil { + return false + } + now := time.Now().Unix() + if setting.IsUse == 0 || setting.StartTime.IsZero() || setting.EndTime.IsZero() { + return false + } + if now < setting.StartTime.Unix() || now > setting.EndTime.Unix() { + return false + } + if setting.OrderSoruce == "mall" && pvd != "" && zhios_day_luck_draw_utils.InArr(pvd, []string{"mall_goods", "mall_group_buy", "mall_goods_user_lv", "super_group_buy", "mall_supply", "mall_group_own_buy"}) == false { + return false + } + return true +} func GetDayLuckDrawSettingSess(sess *xorm.Session) *model.DayLuckDrawSetting { var data model.DayLuckDrawSetting get, err := sess.Get(&data) diff --git a/db/db_day_luck_draw_settle_order.go b/db/db_day_luck_draw_settle_order.go index b248eaf..9ba4513 100644 --- a/db/db_day_luck_draw_settle_order.go +++ b/db/db_day_luck_draw_settle_order.go @@ -36,3 +36,26 @@ func AddSettle(eg *xorm.Engine, req md.DayLuckDrawOrderJackpotReq) error { } return nil } + +func AddSettleSess(sess *xorm.Session, req md.DayLuckDrawOrderJackpotReq) error { + count, _ := sess.Where("oid=? and uid=? and pvd=?", req.Oid, req.Uid, req.Pvd).Count(&model.DayLuckDrawSettleOrder{}) + if count > 0 { + return nil + } + var data = &model.DayLuckDrawSettleOrder{ + Oid: req.Oid, + Pvd: req.Pvd, + Amount: req.Amount, + Commission: req.Commission, + Uid: zhios_day_luck_draw_utils.StrToInt(req.Uid), + CreateTime: time.Now(), + } + one, err := sess.Insert(data) + if one == 0 { + return errors.New("失败") + } + if err != nil { + return err + } + return nil +} diff --git a/svc/svc_day_luck_draw_order_jackpot.go b/svc/svc_day_luck_draw_order_jackpot.go index d36bfba..e8f232c 100644 --- a/svc/svc_day_luck_draw_order_jackpot.go +++ b/svc/svc_day_luck_draw_order_jackpot.go @@ -17,3 +17,4 @@ func AddOrderJackpot(eg *xorm.Engine, req md.DayLuckDrawOrderJackpotReq) error { } return nil } + diff --git a/svc/svc_day_luck_draw_settle_order.go b/svc/svc_day_luck_draw_settle_order.go index b217a72..16ffe65 100644 --- a/svc/svc_day_luck_draw_settle_order.go +++ b/svc/svc_day_luck_draw_settle_order.go @@ -17,3 +17,14 @@ func AddSettleOrder(eg *xorm.Engine, req md.DayLuckDrawOrderJackpotReq) error { } return nil } +func AddSettleOrderSess(sess *xorm.Session, req md.DayLuckDrawOrderJackpotReq) error { + setting := db.CheckSettingSess(sess, req.Pvd) + if setting == false { + return nil + } + err := db.AddSettleSess(sess, req) + if err != nil { + return err + } + return nil +}