|
@@ -7,8 +7,10 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fs.common.constant.LiveKeysConstant;
|
|
import com.fs.common.constant.LiveKeysConstant;
|
|
|
import com.fs.common.core.domain.R;
|
|
import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.core.redis.RedisCache;
|
|
import com.fs.common.core.redis.RedisCache;
|
|
|
|
|
+import com.fs.common.utils.SecurityUtils;
|
|
|
import com.fs.common.utils.StringUtils;
|
|
import com.fs.common.utils.StringUtils;
|
|
|
import com.fs.framework.aspectj.lock.DistributeLock;
|
|
import com.fs.framework.aspectj.lock.DistributeLock;
|
|
|
|
|
+import com.fs.framework.datasource.DynamicDataSourceContextHolder;
|
|
|
import com.fs.erp.service.FsJstAftersalePushService;
|
|
import com.fs.erp.service.FsJstAftersalePushService;
|
|
|
import com.fs.his.service.IFsUserService;
|
|
import com.fs.his.service.IFsUserService;
|
|
|
import com.fs.live.domain.*;
|
|
import com.fs.live.domain.*;
|
|
@@ -299,13 +301,16 @@ public class Task {
|
|
|
redisCache.redisTemplate.opsForZSet()
|
|
redisCache.redisTemplate.opsForZSet()
|
|
|
.removeRangeByScore(liveKey, 0, currentTime);
|
|
.removeRangeByScore(liveKey, 0, currentTime);
|
|
|
try {
|
|
try {
|
|
|
|
|
+ // 从 key(如 live:red_task:129)中提取 liveId
|
|
|
|
|
+ String liveIdStr = liveKey.substring(liveKey.lastIndexOf(':') + 1);
|
|
|
|
|
+ Long liveId = Long.valueOf(liveIdStr);
|
|
|
// 广播红包关闭消息
|
|
// 广播红包关闭消息
|
|
|
SendMsgVo sendMsgVo = new SendMsgVo();
|
|
SendMsgVo sendMsgVo = new SendMsgVo();
|
|
|
- sendMsgVo.setLiveId(Long.valueOf(liveKey));
|
|
|
|
|
|
|
+ sendMsgVo.setLiveId(liveId);
|
|
|
sendMsgVo.setCmd("red");
|
|
sendMsgVo.setCmd("red");
|
|
|
sendMsgVo.setStatus(-1);
|
|
sendMsgVo.setStatus(-1);
|
|
|
- liveService.asyncToCacheLiveConfig(Long.parseLong(liveKey));
|
|
|
|
|
- webSocketServer.broadcastMessage(Long.valueOf(liveKey), JSONObject.toJSONString(R.ok().put("data", sendMsgVo)));
|
|
|
|
|
|
|
+ liveService.asyncToCacheLiveConfig(liveId);
|
|
|
|
|
+ webSocketServer.broadcastMessage(liveId, JSONObject.toJSONString(R.ok().put("data", sendMsgVo)));
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
log.error("更新红包状态异常", e);
|
|
log.error("更新红包状态异常", e);
|
|
|
}
|
|
}
|
|
@@ -524,6 +529,10 @@ public class Task {
|
|
|
|
|
|
|
|
@PostConstruct
|
|
@PostConstruct
|
|
|
public void initLiveDatasOnStartup() {
|
|
public void initLiveDatasOnStartup() {
|
|
|
|
|
+ if (saasTaskEnabled) {
|
|
|
|
|
+ log.info("SaaS模式跳过启动时点赞数据初始化,由租户定时任务 syncLiveDataToDB 处理");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
log.info("项目启动,开始初始化直播点赞数据...");
|
|
log.info("项目启动,开始初始化直播点赞数据...");
|
|
|
try {
|
|
try {
|
|
|
List<LiveData> liveDatas = liveDataService.getAllLiveDatas();
|
|
List<LiveData> liveDatas = liveDataService.getAllLiveDatas();
|
|
@@ -653,10 +662,12 @@ public class Task {
|
|
|
Set<String> keys = redisCache.redisTemplate.keys(String.format(LIVE_COUPON_NUM, "*"));
|
|
Set<String> keys = redisCache.redisTemplate.keys(String.format(LIVE_COUPON_NUM, "*"));
|
|
|
if (keys != null && !keys.isEmpty()) {
|
|
if (keys != null && !keys.isEmpty()) {
|
|
|
for (String key : keys) {
|
|
for (String key : keys) {
|
|
|
- Object o = redisCache.redisTemplate.opsForValue().get(String.format(LIVE_COUPON_NUM, key));
|
|
|
|
|
|
|
+ Object o = redisCache.getCacheObject(key);
|
|
|
if (o != null) {
|
|
if (o != null) {
|
|
|
|
|
+ // key 格式: live:coupon:num:5,提取末尾的优惠券ID
|
|
|
|
|
+ String couponIdStr = key.substring(key.lastIndexOf(':') + 1);
|
|
|
LiveCouponIssue updateEntity = new LiveCouponIssue();
|
|
LiveCouponIssue updateEntity = new LiveCouponIssue();
|
|
|
- updateEntity.setId(Long.valueOf(key));
|
|
|
|
|
|
|
+ updateEntity.setId(Long.valueOf(couponIdStr));
|
|
|
updateEntity.setRemainCount(Long.parseLong(o.toString()));
|
|
updateEntity.setRemainCount(Long.parseLong(o.toString()));
|
|
|
liveCouponIssueService.updateLiveCouponIssue(updateEntity);
|
|
liveCouponIssueService.updateLiveCouponIssue(updateEntity);
|
|
|
}
|
|
}
|