|
|
@ -129,23 +129,42 @@ public class TiktokUserServiceImpl implements TiktokUserService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public boolean checkUserCanDownload(Long userId, String platform, String appType) { |
|
|
public boolean checkUserCanDownload(Long userId, String platform, String appType,String adType) { |
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
String date = df.format(new Date()); |
|
|
String date = df.format(new Date()); |
|
|
String hashKey = appType+":"+platform+":"+userId; |
|
|
String hashKey = appType+":"+platform+":"+userId; |
|
|
String redisKey = RedisKeyConstant.PLATFORM_USER_DOWNLOAD_KEY + date; |
|
|
if(adType.equals("0")){ |
|
|
if(redisService.hasHashKey(redisKey,hashKey)){ |
|
|
//下载图片广告最多每天5次
|
|
|
//存在键,判断次数,次数达标则不可下载
|
|
|
String downloadKey = RedisKeyConstant.PLATFORM_USER_DOWNLOAD_KEY + date; |
|
|
Integer downloadNum = redisService.getCacheMapValue(redisKey, hashKey); |
|
|
if(redisService.hasHashKey(downloadKey,hashKey)){ |
|
|
if(downloadNum >= 10){ |
|
|
//存在键,判断次数,次数达标则不可下载
|
|
|
return true; |
|
|
Integer downloadNum = redisService.getCacheMapValue(downloadKey, hashKey); |
|
|
|
|
|
if(downloadNum >= 5){ |
|
|
|
|
|
return true; |
|
|
|
|
|
}else{ |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
}else{ |
|
|
}else{ |
|
|
|
|
|
//不存在键则可下载
|
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
}else{ |
|
|
}else{ |
|
|
//不存在键则可下载
|
|
|
//看广告获取绘画奖励广告最多每天3次
|
|
|
return false; |
|
|
String rewardKey = RedisKeyConstant.PLATFORM_USER_PAINT_REWARD_KEY + date; |
|
|
|
|
|
if(redisService.hasHashKey(rewardKey,hashKey)){ |
|
|
|
|
|
//存在键,判断次数,次数达标则不可再获取奖励
|
|
|
|
|
|
Integer rewardNum = redisService.getCacheMapValue(rewardKey, hashKey); |
|
|
|
|
|
if(rewardNum >= 3){ |
|
|
|
|
|
return true; |
|
|
|
|
|
}else{ |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
}else{ |
|
|
|
|
|
//不存在键则可获取奖励
|
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
@ -201,4 +220,34 @@ public class TiktokUserServiceImpl implements TiktokUserService { |
|
|
public int getUserGoldNum(Long id) { |
|
|
public int getUserGoldNum(Long id) { |
|
|
return tiktokUserMapper.queryGoldNum(id); |
|
|
return tiktokUserMapper.queryGoldNum(id); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public int getUserDownloadNumOrRewardNum(Long userId, String platform, String appType, String adType) { |
|
|
|
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
|
|
String date = df.format(new Date()); |
|
|
|
|
|
String hashKey = appType+":"+platform+":"+userId; |
|
|
|
|
|
if(adType.equals("0")){ |
|
|
|
|
|
//下载图片广告最多每天5次
|
|
|
|
|
|
String downloadKey = RedisKeyConstant.PLATFORM_USER_DOWNLOAD_KEY + date; |
|
|
|
|
|
if(redisService.hasHashKey(downloadKey,hashKey)){ |
|
|
|
|
|
//存在键,判断次数,次数达标则不可下载
|
|
|
|
|
|
Integer downloadNum = redisService.getCacheMapValue(downloadKey, hashKey); |
|
|
|
|
|
return 5 - downloadNum; |
|
|
|
|
|
}else{ |
|
|
|
|
|
//不存在键则可下载次数为最大值
|
|
|
|
|
|
return 5; |
|
|
|
|
|
} |
|
|
|
|
|
}else{ |
|
|
|
|
|
//看广告获取绘画奖励广告最多每天3次
|
|
|
|
|
|
String rewardKey = RedisKeyConstant.PLATFORM_USER_PAINT_REWARD_KEY + date; |
|
|
|
|
|
if(redisService.hasHashKey(rewardKey,hashKey)){ |
|
|
|
|
|
//存在键,判断次数,次数达标则不可再获取奖励
|
|
|
|
|
|
Integer rewardNum = redisService.getCacheMapValue(rewardKey, hashKey); |
|
|
|
|
|
return 3 - rewardNum; |
|
|
|
|
|
}else{ |
|
|
|
|
|
//不存在键则可得到获取奖励最大值
|
|
|
|
|
|
return 3; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|