@@ -30,6 +30,7 @@ func AddOrderJackpot(eg *xorm.Engine, req md.DayLuckDrawOrderJackpotReq) error { | |||||
return nil | return nil | ||||
} | } | ||||
func GetAllOrderOid(sess *xorm.Session) []string { | func GetAllOrderOid(sess *xorm.Session) []string { | ||||
sql := `SELECT oid,uid FROM day_luck_draw_order_jackpot where period=0;` | sql := `SELECT oid,uid FROM day_luck_draw_order_jackpot where period=0;` | ||||
data, _ := QueryNativeStringSess(sess, sql) | data, _ := QueryNativeStringSess(sess, sql) | ||||
@@ -38,6 +38,23 @@ func CheckSetting(eg *xorm.Engine, pvd string) bool { | |||||
} | } | ||||
return true | 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 { | func GetDayLuckDrawSettingSess(sess *xorm.Session) *model.DayLuckDrawSetting { | ||||
var data model.DayLuckDrawSetting | var data model.DayLuckDrawSetting | ||||
get, err := sess.Get(&data) | get, err := sess.Get(&data) | ||||
@@ -36,3 +36,26 @@ func AddSettle(eg *xorm.Engine, req md.DayLuckDrawOrderJackpotReq) error { | |||||
} | } | ||||
return nil | 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 | |||||
} |
@@ -17,3 +17,4 @@ func AddOrderJackpot(eg *xorm.Engine, req md.DayLuckDrawOrderJackpotReq) error { | |||||
} | } | ||||
return nil | return nil | ||||
} | } | ||||
@@ -17,3 +17,14 @@ func AddSettleOrder(eg *xorm.Engine, req md.DayLuckDrawOrderJackpotReq) error { | |||||
} | } | ||||
return nil | 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 | |||||
} |