|
@@ -21,6 +21,7 @@ import com.qs.mp.common.utils.DateUtils;
|
|
|
import com.qs.mp.common.utils.StringUtils;
|
|
|
import com.qs.mp.framework.redis.RedisLockKey;
|
|
|
import com.qs.mp.framework.security.handle.HostHolder;
|
|
|
+import com.qs.mp.framework.service.IWxSubscribeMessage;
|
|
|
import com.qs.mp.system.domain.SysUser;
|
|
|
import com.qs.mp.system.service.ISysUserService;
|
|
|
import com.qs.mp.user.domain.MarketingHitPrize;
|
|
@@ -86,6 +87,9 @@ public class MarketingController extends BaseApiController {
|
|
|
@Autowired
|
|
|
private ISysUserService sysUserService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IWxSubscribeMessage wxSubscribeMessage;
|
|
|
+
|
|
|
@PostMapping("/generateCode/{marketingId}")
|
|
|
@ApiOperation("立即获取抽奖码")
|
|
|
public AjaxResult generateCode(@PathVariable("marketingId") Long marketingId) {
|
|
@@ -117,7 +121,8 @@ public class MarketingController extends BaseApiController {
|
|
|
}
|
|
|
|
|
|
String lockKey = RedisLockKey.build(RedisLockKey.MARKETING_REAL_NUM_LOCK, marketingId);
|
|
|
- if (!distributedLocker.tryLock(lockKey)) {
|
|
|
+ // 自动续期,等待3秒
|
|
|
+ if (!distributedLocker.tryLock(lockKey, 3, -1, TimeUnit.SECONDS)) {
|
|
|
return AjaxResult.error("活动太火爆了,请稍后重试!");
|
|
|
}
|
|
|
|
|
@@ -213,7 +218,8 @@ public class MarketingController extends BaseApiController {
|
|
|
|
|
|
String lockKey = RedisLockKey.build(RedisLockKey.MARKETING_REAL_NUM_LOCK, marketingHelpParam.getMarketingId());
|
|
|
|
|
|
- if (!distributedLocker.tryLock(lockKey)) {
|
|
|
+ // 自动续期,等待3秒
|
|
|
+ if (!distributedLocker.tryLock(lockKey, 3, -1, TimeUnit.SECONDS)) {
|
|
|
return AjaxResult.error("活动太火爆了,请稍后重试!");
|
|
|
}
|
|
|
|
|
@@ -222,6 +228,8 @@ public class MarketingController extends BaseApiController {
|
|
|
}finally {
|
|
|
distributedLocker.unlock(lockKey);
|
|
|
}
|
|
|
+ // 异步给被助力人发送成功消息
|
|
|
+ wxSubscribeMessage.sendMarketingHelp(helpedUserId, marketing);
|
|
|
|
|
|
|
|
|
return AjaxResult.success("助力成功");
|