|
@@ -35,12 +35,12 @@ func (service *ActivityService) LotteryReceive(data *activity.LotteryOperation,
|
|
|
Join("left", "prize p", "l.prizeId=p.id").
|
|
|
Where("l.id=?", lotteryId).Get(&prizeData)
|
|
|
if err != nil {
|
|
|
- log.Panicln("查询奖品信息:", err)
|
|
|
+ log.Println("查询奖品信息:", err)
|
|
|
orm.Rollback()
|
|
|
return entity.ErrorCode, "奖品信息查询失败"
|
|
|
}
|
|
|
if !bool {
|
|
|
- log.Panicln("查询奖品信息:", err)
|
|
|
+ log.Println("查询奖品信息:", err)
|
|
|
orm.Rollback()
|
|
|
return entity.ErrorCode, "奖品信息查询失败"
|
|
|
}
|
|
@@ -48,12 +48,12 @@ func (service *ActivityService) LotteryReceive(data *activity.LotteryOperation,
|
|
|
activity := entity.Activity{}
|
|
|
bool, err = orm.Table("activity").Where("prizeId=? and state=1", prizeData.PrizeId).Get(&activity)
|
|
|
if !bool {
|
|
|
- log.Panicln("查询奖品信息:", err)
|
|
|
+ log.Println("查询奖品信息:", err)
|
|
|
orm.Rollback()
|
|
|
return entity.ErrorCode, "奖品信息查询失败"
|
|
|
}
|
|
|
if !activityTime(activity.BeginDate) {
|
|
|
- log.Panicln("活动没有开始不可领劵", activity)
|
|
|
+ log.Println("活动没有开始不可领劵", activity)
|
|
|
orm.Rollback()
|
|
|
return entity.ErrorCode, "活动没有开始不可领劵"
|
|
|
}
|
|
@@ -64,7 +64,7 @@ func (service *ActivityService) LotteryReceive(data *activity.LotteryOperation,
|
|
|
err = orm.Table("user_prize").
|
|
|
Where("userId=? and appId=? and lotteryId=? and to_days(createTime) = to_days(now()) ", data.UserId, data.AppId, lotteryId).Find(&userLotteryList)
|
|
|
if err != nil {
|
|
|
- log.Panicln("查询奖品信息:", err)
|
|
|
+ log.Println("查询奖品信息:", err)
|
|
|
orm.Rollback()
|
|
|
return entity.ErrorCode, "查询领取次数失败"
|
|
|
}
|
|
@@ -78,7 +78,7 @@ func (service *ActivityService) LotteryReceive(data *activity.LotteryOperation,
|
|
|
err = orm.Table("user_prize").
|
|
|
Where("userId=? and appId=? and lotteryId=?", data.UserId, data.AppId, lotteryId).Find(&userLotteryList)
|
|
|
if err != nil {
|
|
|
- log.Panicln("查询奖品信息:", err)
|
|
|
+ log.Println("查询奖品信息:", err)
|
|
|
orm.Rollback()
|
|
|
return entity.ErrorCode, "查询领取次数失败"
|
|
|
}
|
|
@@ -119,28 +119,27 @@ func (service *ActivityService) LotteryReceive(data *activity.LotteryOperation,
|
|
|
}
|
|
|
numb, err := orm.Table("user_prize").Insert(&userLettry)
|
|
|
if err != nil || numb == int64(0) {
|
|
|
- log.Panicln("领取奖券失败:", err)
|
|
|
+ log.Println("领取奖券失败:", err)
|
|
|
orm.Rollback()
|
|
|
return entity.ErrorCode, "领取奖券失败"
|
|
|
}
|
|
|
-
|
|
|
- //7、修改redis余额
|
|
|
+ //6、修改redis余额
|
|
|
if util.GetInt(code, "lottery_"+fmt.Sprint(lotteryId)) <= 0 {
|
|
|
- log.Panicln("奖券余额不足:", err)
|
|
|
+ log.Println("奖券余额不足:", err)
|
|
|
orm.Rollback()
|
|
|
return entity.ErrorCode, "奖券余额不足"
|
|
|
}
|
|
|
if !util.DecrbyLimit(code, "lottery_"+fmt.Sprint(lotteryId), 1, 0) {
|
|
|
- log.Panicln("修改redis奖券库存失败:", err)
|
|
|
+ log.Println("修改redis奖券库存失败:", err)
|
|
|
orm.Rollback()
|
|
|
return entity.ErrorCode, "修改redis奖券库存失败"
|
|
|
}
|
|
|
- //6、修改奖券余额数量
|
|
|
+ //7、修改奖券余额数量
|
|
|
lottery := entity.Lottery{}
|
|
|
lottery.Id = lotteryId
|
|
|
_, err = orm.Exec("UPDATE lottery SET `stockNumber` = stockNumber-1, `receiveNumber` = receiveNumber+1 WHERE `id` = ?", lotteryId)
|
|
|
if err != nil {
|
|
|
- log.Panicln("修改奖券库存失败:", err)
|
|
|
+ log.Println("修改奖券库存失败:", err)
|
|
|
orm.Rollback()
|
|
|
return entity.ErrorCode, "修改奖券库存失败"
|
|
|
}
|