后台-api-giftMq

This commit is contained in:
khalil
2024-10-19 18:47:46 +08:00
parent 1ab15ff10b
commit 5645c2c3e4
2 changed files with 45 additions and 0 deletions

View File

@@ -27,10 +27,12 @@ import com.accompany.business.service.room.RoomSendRankingService;
import com.accompany.business.service.room.RoomService;
import com.accompany.business.service.user.UsersService;
import com.accompany.business.vo.RoomVo;
import com.accompany.common.constant.Constant;
import com.accompany.common.redis.RedisKey;
import com.accompany.common.status.BusiStatus;
import com.accompany.common.utils.CommonUtil;
import com.accompany.common.utils.DateTimeUtil;
import com.accompany.common.utils.GsonUtil;
import com.accompany.common.utils.StringUtils;
import com.accompany.core.base.SpringContextHolder;
import com.accompany.core.enumeration.PartitionEnum;
@@ -383,4 +385,38 @@ public class MyApiService {
familyDiamondSettlementService.settlement(null);
}
public void giftMq() {
log.info("retryGiftQueue start ...");
Map<String, String> map = jedisService.hgetAll(RedisKey.mq_gift_status.getKey());
if (map == null || map.size() == 0) {
return;
}
Set<String> keySet = map.keySet();
long curTime = System.currentTimeMillis();
long gapTime = 1000 * 60 * 10; // 十分钟内没被消费
Map<String, Long> a = new HashMap<>();
Map<String, Long> b = new HashMap<>();
Map<String, Long> c = new HashMap<>();
for (String key : keySet) {
try {
String val = map.get(key);
GiftMessage giftMessage = GsonUtil.getGson().fromJson(val, GiftMessage.class);
Integer partitionId = giftMessage.getPartitionId();
String type = Constant.GiftType.LUCKY_24 == giftMessage.getGiftType() || Constant.GiftType.SUPER_LUCKY == giftMessage.getGiftType()?
"2" : "1";
String mapKey = partitionId.toString() + "_" + type;
a.put(mapKey, a.getOrDefault(mapKey, 0L) + giftMessage.getGoldNum());
b.put(mapKey, b.getOrDefault(mapKey, 0L) + 1L);
} catch (Exception e) {
log.error("retryGiftQueue error", e);
}
}
log.info("[giftmq] 金币 {}", JSONObject.toJSONString(a));
log.info("[giftmq] 数量 {}", JSONObject.toJSONString(b));
log.info("retryGiftQueue end ...");
}
}

View File

@@ -151,4 +151,13 @@ public class MyApiController {
return BusiResult.success();
}
@GetMapping("/giftMq")
public BusiResult<Void> giftmq(Long roomId) {
if (null == roomId || !roomId.equals(603L)) {
throw new AdminServiceException(BusiStatus.PARAMERROR);
}
myApiService.giftMq();
return BusiResult.success();
}
}