WH01243 4 years ago
parent
commit
ec4c3121fb
1 changed files with 17 additions and 1 deletions
  1. 17 1
      service/ActivityService.go

+ 17 - 1
service/ActivityService.go

@@ -58,7 +58,21 @@ func (service *ActivityService) LotteryReceive(data *activity.LotteryOperation,
 			return entity.ErrorCode, "活动没有开始不可领劵"
 		}
 		//3、先判断奖券是否可以重复领取,在判断之前是否领取过
-		if prizeData.IsLimitNumber == 1 {
+
+
+		userLotteryList := []entity.UserPrize{}
+		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)
+			orm.Rollback()
+			return entity.ErrorCode, "查询领取次数失败"
+		}
+		if len(userLotteryList) >0 {
+			orm.Rollback()
+			return entity.ErrorCode, "你今日领取奖券数量已达上限"
+		}
+		if prizeData.IsLimitNumber == 0 {
 			//查询之前是否领取过
 			userLotteryList := []entity.UserPrize{}
 			err = orm.Table("user_prize").
@@ -73,6 +87,8 @@ func (service *ActivityService) LotteryReceive(data *activity.LotteryOperation,
 				return entity.ErrorCode, "你领取奖券数量已达上限"
 			}
 		}
+
+
 		//5、领取奖券
 		userLettry := entity.UserPrize{}
 		userLettry.AppId = data.AppId