|
@@ -83,19 +83,18 @@ public class GameBackLogMediaSdkServiceImpl extends ServiceImpl<GameBackLogMedia
|
|
|
|
|
|
@Override
|
|
|
public Map<String, Object> callBackJudge(CallBackControlParam param, UserData userData) {
|
|
|
- Map<String, Object> resultMap = new HashMap<>(7);
|
|
|
- resultMap.put("callBackTypeEnum", param.getCallBackTypeEnum().getValue());
|
|
|
- resultMap.put("userId", userData.getUserId());
|
|
|
- resultMap.put("gameId", userData.getGameId());
|
|
|
- resultMap.put("callBack", Boolean.FALSE);
|
|
|
- //参数判断, 检测不通过
|
|
|
- if (!this.callBackParamCheck(param, resultMap)) {
|
|
|
- return resultMap;
|
|
|
- }
|
|
|
//线程锁, 避免重复请求
|
|
|
String lockKey = this.getLockKey(param, userData.getUserId());
|
|
|
- if (!distributedLockComponent.doLock(lockKey, 0L, 1L, TimeUnit.MINUTES)) {
|
|
|
+ if (!distributedLockComponent.doLock(lockKey, 0L, 20L, TimeUnit.SECONDS)) {
|
|
|
log.error("重复请求触发线程锁, 直接返回false, lockKey : {}", lockKey);
|
|
|
+ Map<String, Object> resultMap = this.getResultMap(param, userData);
|
|
|
+ resultMap.put("backMsg", "重复请求触发线程锁, 直接返回false, lockKey : " + lockKey);
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+ //判断结果返回对象
|
|
|
+ Map<String, Object> resultMap = this.getResultMap(param, userData);
|
|
|
+ //参数判断, 检测不通过
|
|
|
+ if (!this.callBackParamCheck(param, resultMap)) {
|
|
|
return resultMap;
|
|
|
}
|
|
|
try {
|
|
@@ -117,12 +116,24 @@ public class GameBackLogMediaSdkServiceImpl extends ServiceImpl<GameBackLogMedia
|
|
|
JsonUtil.toString(userData), e.getMessage(), e);
|
|
|
resultMap.put("backMsg", "事件回传判断, 出现异常");
|
|
|
} finally {
|
|
|
- distributedLockComponent.unlock(lockKey);
|
|
|
+ //等级提升以外的事件释放锁, 等级变化20秒以内不更新, 不回传, 因为包含了战力变化
|
|
|
+ if (!Objects.equals(param.getCallBackTypeEnum(), CallBackTypeEnum.CALL_BACK_UPDATE_LEVEL)) {
|
|
|
+ distributedLockComponent.unlock(lockKey);
|
|
|
+ }
|
|
|
}
|
|
|
//返回结果
|
|
|
return resultMap;
|
|
|
}
|
|
|
|
|
|
+ private Map<String, Object> getResultMap(CallBackControlParam param, UserData userData) {
|
|
|
+ Map<String, Object> resultMap = new HashMap<>(10);
|
|
|
+ resultMap.put("callBackTypeEnum", param.getCallBackTypeEnum().getValue());
|
|
|
+ resultMap.put("userId", userData.getUserId());
|
|
|
+ resultMap.put("gameId", userData.getGameId());
|
|
|
+ resultMap.put("callBack", Boolean.FALSE);
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+
|
|
|
private String getLockKey(CallBackControlParam param, Long userId) {
|
|
|
//回传枚举
|
|
|
CallBackTypeEnum callBackTypeEnum = param.getCallBackTypeEnum();
|