|
@@ -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 ").
|