|
@@ -33,14 +33,20 @@ func GetLotteryActiveInfo(activeId int64, sess map[string]interface{}, session *
|
|
|
var (
|
|
|
err error
|
|
|
prizeRs []map[string]interface{}
|
|
|
+ now = time.Now()
|
|
|
)
|
|
|
+ activeInfo = LotteryActiveInfoRes{
|
|
|
+ Lai: &Lai{},
|
|
|
+ Prize: prizeRs,
|
|
|
+ NowUnix: now.Unix(),
|
|
|
+ }
|
|
|
r.DLai, _ = r.ActiveInfo()
|
|
|
if r.DLai == nil {
|
|
|
return
|
|
|
}
|
|
|
- ast, _ := time.ParseInLocation(date.Date_Full_Layout, r.DLai.ActiveStartTime, time.Local) //活动开始时间
|
|
|
- aet, _ := time.ParseInLocation(date.Date_Full_Layout, r.DLai.ActiveEndTime, time.Local) //活动结束时间 这里处理是因为前端要求是时间戳
|
|
|
- now := time.Now()
|
|
|
+ activeInfo.ActiveStartTime = r.DLai.ActiveStartTime //活动开始时间
|
|
|
+ activeInfo.ActiveEndTime = r.DLai.ActiveEndTime //活动结束时间
|
|
|
+ activeInfo.LotteryStartUnix = r.DLai.LotteryStartTime //抽奖开始时间
|
|
|
platform := GetPlatform(req)
|
|
|
if platform != "pc" {
|
|
|
platform = "app"
|
|
@@ -64,41 +70,52 @@ func GetLotteryActiveInfo(activeId int64, sess map[string]interface{}, session *
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
+ activeInfo.Lai = &Lai{
|
|
|
+ Name: r.DLai.Name,
|
|
|
+ LotteryStartTime: r.DLai.LotteryStartTime,
|
|
|
+ LotteryEndTime: r.DLai.LotteryEndTime,
|
|
|
+ Cost: r.DLai.Cost,
|
|
|
+ Rule: r.DLai.Rule,
|
|
|
+ ShareCopy: r.DLai.ShareCopy,
|
|
|
+ Pic: pic,
|
|
|
+ }
|
|
|
//activeInfo.Prize = prizeRs
|
|
|
- lotteryStart := time.Date(now.Year(), now.Month(), now.Day(), r.DLai.LotteryStartTime, 0, 0, 0, time.Local)
|
|
|
+ //lotteryStart := time.Date(now.Year(), now.Month(), now.Day(), r.DLai.LotteryStartTime, 0, 0, 0, time.Local)
|
|
|
//time.Duration(r.DLai.LotteryStartTime) * time.Hour) // 将当前时间截断到0点并加上小时(去除了最后一纳秒)
|
|
|
- LotteryStartUnix := lotteryStart.Unix()
|
|
|
- activeInfo = LotteryActiveInfoRes{
|
|
|
- Lai: &Lai{
|
|
|
- Name: r.DLai.Name,
|
|
|
- LotteryStartTime: r.DLai.LotteryStartTime,
|
|
|
- LotteryEndTime: r.DLai.LotteryEndTime,
|
|
|
- Cost: r.DLai.Cost,
|
|
|
- Rule: r.DLai.Rule,
|
|
|
- ShareCopy: r.DLai.ShareCopy,
|
|
|
- Pic: pic,
|
|
|
- },
|
|
|
- Prize: prizeRs,
|
|
|
- ActiveStartTime: ast.Unix(),
|
|
|
- ActiveEndTime: aet.Unix(),
|
|
|
- NowUnix: now.Unix(),
|
|
|
- LotteryStartUnix: LotteryStartUnix,
|
|
|
- }
|
|
|
- if ast.Unix() > now.Unix() || activeInfo.LotteryStartTime > now.Hour() {
|
|
|
- if ast.Unix() > now.Unix() {
|
|
|
- activeInfo.LotteryStartUnix = time.Date(ast.Year(), ast.Month(), ast.Day(), r.DLai.LotteryStartTime, 0, 0, 0, time.Local).Unix()
|
|
|
- }
|
|
|
- activeInfo.Status = 1
|
|
|
- activeInfo.Msg = consts.NotStarted
|
|
|
- return
|
|
|
- }
|
|
|
- if ast.Unix() < now.Unix() && aet.Unix() > now.Unix() && activeInfo.LotteryEndTime < now.Hour() {
|
|
|
+ //LotteryStartUnix := lotteryStart.Unix()
|
|
|
+ //activeInfo = LotteryActiveInfoRes{
|
|
|
+ // Lai: &Lai{
|
|
|
+ // Name: r.DLai.Name,
|
|
|
+ // LotteryStartTime: r.DLai.LotteryStartTime,
|
|
|
+ // LotteryEndTime: r.DLai.LotteryEndTime,
|
|
|
+ // Cost: r.DLai.Cost,
|
|
|
+ // Rule: r.DLai.Rule,
|
|
|
+ // ShareCopy: r.DLai.ShareCopy,
|
|
|
+ // Pic: pic,
|
|
|
+ // },
|
|
|
+ // Prize: prizeRs,
|
|
|
+ // ActiveStartTime: ast.Unix(),
|
|
|
+ // ActiveEndTime: aet.Unix(),
|
|
|
+ // NowUnix: now.Unix(),
|
|
|
+ // LotteryStartUnix: r.DLai.LotteryStartTime,
|
|
|
+ //}
|
|
|
+ //活动已结束
|
|
|
+ if activeInfo.ActiveEndTime < now.Unix() {
|
|
|
activeInfo.Status = 2
|
|
|
- activeInfo.Msg = "不在当天抽奖时间内"
|
|
|
- return
|
|
|
+ activeInfo.Msg = consts.Ended
|
|
|
}
|
|
|
- // 未登录用户 显示抽奖
|
|
|
- if common.Int64All(sess["positionId"]) == 0 || r.DLai.Mold == 0 { //购买赠送奖品 只需要购买须知信息
|
|
|
+ //活动未开始 或 抽奖未开始
|
|
|
+ if activeInfo.ActiveStartTime > now.Unix() || activeInfo.LotteryStartTime > now.Unix() {
|
|
|
+ activeInfo.Status = 1
|
|
|
+ //活动未开始
|
|
|
+ if activeInfo.ActiveStartTime > now.Unix() {
|
|
|
+ activeInfo.Msg = consts.NotStarted
|
|
|
+ lst := time.Unix(activeInfo.LotteryStartTime, 0).Local() //每天抽奖开始时间
|
|
|
+ ast := time.Unix(activeInfo.ActiveStartTime, 0).Local() //活动开始时间
|
|
|
+ activeInfo.LotteryStartUnix = time.Date(ast.Year(), ast.Month(), ast.Day(), lst.Hour(), lst.Minute(), lst.Second(), 0, time.Local).Unix() //活动当天 抽奖开始时间
|
|
|
+ } else if activeInfo.LotteryStartTime > now.Unix() { //抽奖未开始
|
|
|
+ activeInfo.Msg = consts.LotteryNotStarted
|
|
|
+ }
|
|
|
return
|
|
|
}
|
|
|
activeInfo.Status = 2
|
|
@@ -107,17 +124,21 @@ func GetLotteryActiveInfo(activeId int64, sess map[string]interface{}, session *
|
|
|
activeInfo.Msg = err.Error()
|
|
|
return
|
|
|
}
|
|
|
+ // 未登录用户 显示抽奖
|
|
|
+ if common.Int64All(sess["positionId"]) == 0 || r.DLai.Mold == 0 { //购买赠送奖品 只需要购买须知信息
|
|
|
+ return
|
|
|
+ }
|
|
|
//用户获奖信息
|
|
|
if r.DLua, err = r.UserAccountInfo(); err != nil {
|
|
|
log.Println("当前用户暂无中奖记录:", r.UserInfo.Phone)
|
|
|
}
|
|
|
//是否是活动结束日
|
|
|
- lastDay := now.Format(date.Date_Short_Layout) == strings.Split(r.DLai.ActiveEndTime, " ")[0]
|
|
|
+ lastDay := now.Format(date.Date_Short_Layout) == time.Unix(r.DLai.ActiveEndTime, 0).Local().Format(date.Date_Short_Layout)
|
|
|
if r.DLua != nil {
|
|
|
//今天抽奖机会是否已用完
|
|
|
if num := r.DLua.CheckTodayLotteryNum(); num >= r.DLai.DailyNum {
|
|
|
//今日抽奖机会已用完
|
|
|
- err = fmt.Errorf(fmt.Sprintf(consts.LotteryUserMsg_Winner, r.DLai.LotteryStartTime)) //明天可抽奖
|
|
|
+ err = fmt.Errorf(fmt.Sprintf(consts.LotteryUserMsg_Winner, date.FormatDateByInt64(&r.DLai.LotteryStartTime, date.Date_Time_Layout))) //明天可抽奖
|
|
|
//是否是活动结束当天
|
|
|
if lastDay {
|
|
|
err = fmt.Errorf(consts.LotteryUserMsg_WinnerNoMore)
|
|
@@ -129,7 +150,7 @@ func GetLotteryActiveInfo(activeId int64, sess map[string]interface{}, session *
|
|
|
//今日库存 及 有效奖品整理
|
|
|
if todayPrizeNum := r.EffectivePrizeInventory(); todayPrizeNum == 0 {
|
|
|
//暂无库存
|
|
|
- err = fmt.Errorf(fmt.Sprintf(consts.LotteryUserMsg_NoPreze, r.DLai.LotteryStartTime))
|
|
|
+ err = fmt.Errorf(fmt.Sprintf(consts.LotteryUserMsg_NoPreze, date.FormatDateByInt64(&r.DLai.LotteryStartTime, date.Date_Time_Layout)))
|
|
|
//是否是活动结束当天
|
|
|
if lastDay {
|
|
|
err = fmt.Errorf(consts.LotteryUserMsg_NoMore)
|