Browse Source

奖券判断处理

WH01243 2 years ago
parent
commit
9c06f1d2ee

+ 16 - 12
rpc/internal/logic/getallactivitylogic.go

@@ -33,7 +33,7 @@ func (l *GetAllActivityLogic) GetAllActivity(in *activity.Request) (*activity.Ac
 	var activityArr []*activity.ActivityJson
 	for _, activityValue := range activityData {
 		activityEntity := activity.ActivityJson{}
-		timeBool := util.ActivityTime(activityValue.BeginDate) && !util.ActivityTimeOther(activityValue.EndDate)
+		timeBool := util.ActivityTime(activityValue.BeginDate) && !util.ActivityTimeOther(activityValue.EndDate) && util.ActivityTime(activityValue.PreheatingTime)
 		var lotteryList []*activity.LotteryJson
 		for _, value := range activityValue.LotteryData {
 			lottery := activity.LotteryJson{}
@@ -43,25 +43,29 @@ func (l *GetAllActivityLogic) GetAllActivity(in *activity.Request) (*activity.Ac
 			//IsReceive  是否可以领取true可以领取false不可领取
 			//IsUser  是否使用 true 使用 false未使用
 			if activityValue.ActivityType < 2 {
-				if util.ActivityTime(activityValue.PreheatingTime) {
-					//活动已开始 时间判断  剩余量判断
-					if timeBool {
-						if value.StockNumber == 0 {
-							//库存不足
-							lottery.IsReceive = false
-						} else {
-							//还有库存
-							if value.IsLimitNumber == 0 {
+				//活动已开始 时间判断  剩余量判断
+				if timeBool {
+					if value.StockNumber == 0 {
+						//库存不足
+						lottery.IsReceive = false
+					} else {
+						//还有库存
+						if value.IsLimitNumber == 0 {
+							if value.Count > 0 {
+								lottery.IsReceive = false
+							} else {
 								if value.AllUserCount >= common.Int64All(value.LimitNumber) {
 									lottery.IsReceive = false
 								} else {
 									if value.UserCount >= common.Int64All(value.LimitNumber) {
-										lottery.IsReceive = false
+
 									} else {
 										lottery.IsReceive = true
 									}
 								}
-							} else {
+							}
+						} else {
+							if value.Count > 0 {
 								if value.UserCount == 0 {
 									lottery.IsReceive = true
 								}

+ 5 - 0
service/activityService.go

@@ -835,6 +835,11 @@ func activityPartakeHandle(id int64, userId string, limitQuantity, limitType, fi
 		}
 		return true
 	}
+	//判断手里的奖券是否使用了
+	count, _ = orm.Table("user_prize").Where("activityId=? and  userId=?  and  prizeType!=1 ", id, userId).Count()
+	if int64(count) >= 0 {
+		return false
+	}
 	//活动是否已达上限
 	switch limitType {
 	case 1:

+ 7 - 1
service/activityServiceNew.go

@@ -59,7 +59,13 @@ func (service *ActivityServiceNew) GetAllActivity(in *activity.Request) (int64,
 			//赠品、限时活动之外的活动
 			//2、先查找活动下的奖品Id
 			err = orm.Table("activity").Alias("a").
-				Select("l.discount,( SELECT count( up.id ) FROM user_prize up WHERE up.lotteryId = l.id  and  up.prizeId!=0 and   up.userId ='"+in.UserId+"' and up.prizeType=0 ) AS usercount,( SELECT count( up.id ) FROM user_prize up WHERE up.lotteryId = l.id  and  up.prizeId!=0 and   up.userId ='\"+in.UserId+\"'  ) AS allUsercount,p.prizeType as lotteryType,l.full,l.reduce, p.beginDate,p.endDate,l.stockNumber,l.receiveNumber,p.limitNumber,( select  count(up.id) FROM user_prize up where  up.lotteryId = l.id  and  up.prizeId!=0 AND up.userId ='"+in.UserId+"' ) AS count,( select  count(up.id) FROM user_prize up where  up.lotteryId = l.id  and  up.prizeId!=0 AND up.userId ='"+in.UserId+"' and  to_days(createTime) = to_days(now())) AS daycount,p.isLimitNumber,p.validityTimeType,p.validityDates,p.instructions,p.remark,l.id as lotteryId ,l.name ").
+				Select("l.discount,"+
+					"( SELECT count( up.id ) FROM user_prize up WHERE up.lotteryId = l.id  and  up.prizeId!=0 and   up.userId ='"+in.UserId+"' and up.prizeType=0 ) AS usercount,"+
+					"( SELECT count( up.id ) FROM user_prize up WHERE up.lotteryId = l.id  and  up.prizeId!=0 and   up.userId ='"+in.UserId+"'  ) AS allUsercount,"+
+					"p.prizeType as lotteryType,l.full,l.reduce, p.beginDate,p.endDate,l.stockNumber,l.receiveNumber,p.limitNumber,"+
+					"( select  count(up.id) FROM user_prize up where  up.lotteryId = l.id  and  up.prizeId!=0 AND  up.prizeType!=1 and up.userId ='"+in.UserId+"' ) AS count,"+
+					"( select  count(up.id) FROM user_prize up where  up.lotteryId = l.id  and  up.prizeId!=0 AND up.userId ='"+in.UserId+"' and  to_days(createTime) = to_days(now())) AS daycount,"+
+					"p.isLimitNumber,p.validityTimeType,p.validityDates,p.instructions,p.remark,l.id as lotteryId ,l.name ").
 				Join("left", "discount d", "d.activityId=a.id and  d.state=1").
 				Join("left", "prize p", "d.prizeId=p.id").
 				Join("left", "lottery l", " l.id = d.lotteryId  ").