Jelajahi Sumber

fix : 新增过事件指定用户的方法

bilingfeng 6 bulan lalu
induk
melakukan
a817613529

+ 45 - 0
game-module/game-module-mybatis/src/main/java/com/zanxiang/game/module/mybatis/entity/UserEvent.java

@@ -0,0 +1,45 @@
+package com.zanxiang.game.module.mybatis.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.*;
+
+import java.io.Serializable;
+
+/**
+ * @author : lingfeng
+ * @time : 2024-09-27
+ * @description : APP过事件
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@ToString
+@Builder
+@TableName("t_user_event")
+public class UserEvent implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * id
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 游戏id
+     */
+    private Long gameId;
+
+    /**
+     * 用户名
+     */
+    private String username;
+
+    /**
+     * 绑定手机号码
+     */
+    private String mobile;
+}

+ 12 - 0
game-module/game-module-mybatis/src/main/java/com/zanxiang/game/module/mybatis/mapper/UserEventMapper.java

@@ -0,0 +1,12 @@
+package com.zanxiang.game.module.mybatis.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.zanxiang.game.module.mybatis.entity.UserEvent;
+
+/**
+ * @author : lingfeng
+ * @time : 2024-09-27
+ * @description :  ${description}
+ */
+public interface UserEventMapper extends BaseMapper<UserEvent> {
+}

+ 1 - 1
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/SDKApplication.java

@@ -23,7 +23,7 @@ public class SDKApplication {
 
     public static void main(String[] args) {
         SpringApplication.run(SDKApplication.class, args);
-        System.out.println("赞象SDK服务启动成功 <修正蜀山cpOrderId前端不正确问题> ( ´・・)ノ(._.`) \n" +
+        System.out.println("赞象SDK服务启动成功 <新增过事件指定用户的方法> ( ´・・)ノ(._.`) \n" +
                 " ___________ _   __\n" +
                 "/  ___|  _  \\ | / /\n" +
                 "\\ `--.| | | | |/ / \n" +

+ 12 - 0
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/IUserEventService.java

@@ -0,0 +1,12 @@
+package com.zanxiang.game.module.sdk.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.zanxiang.game.module.mybatis.entity.UserEvent;
+
+/**
+ * @author : lingfeng
+ * @time : 2024-09-27
+ * @description : APP过事件
+ */
+public interface IUserEventService extends IService<UserEvent> {
+}

+ 19 - 1
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/impl/CallBackServiceImpl.java

@@ -77,6 +77,9 @@ public class CallBackServiceImpl implements ICallBackService {
     @Autowired
     private IDistributedLockComponent distributedLockComponent;
 
+    @Autowired
+    private IUserEventService userEventService;
+
     @Override
     public Map<String, Object> callBackJudge(CallBackControlParam param, UserData userData) {
         log.error("事件回传判断请求, param : {},  userData : {}", JsonUtil.toString(param), JsonUtil.toString(userData));
@@ -88,7 +91,7 @@ public class CallBackServiceImpl implements ICallBackService {
         CallBackTypeEnum callBackTypeEnum = param.getCallBackTypeEnum();
         Game game = gameService.getById(userData.getGameId());
         //判断游戏状态, 对接上包过程中, 全量回传
-        if (Objects.equals(game.getStatus(), 2)) {
+        if (this.isUserEvent(game, userData.getUserId())) {
             resultMap.put("callBack", Boolean.TRUE);
             if (Objects.equals(callBackTypeEnum, CallBackTypeEnum.CALL_BACK_PAY_ORDER)) {
                 PlatformOrderDTO platformOrderDTO = orderService.getByOrderId(param.getOrderId());
@@ -132,6 +135,21 @@ public class CallBackServiceImpl implements ICallBackService {
         return resultMap;
     }
 
+    private boolean isUserEvent(Game game, Long userId) {
+        if (Objects.equals(game.getStatus(), 2)) {
+            return true;
+        }
+        //查询玩家
+        User user = userService.getById(userId);
+        //判断是否测试过事件用户
+        return userEventService.count(new LambdaQueryWrapper<UserEvent>()
+                .eq(UserEvent::getGameId, game.getId())
+                .and(qw -> qw.eq(UserEvent::getUsername, user.getUsername())
+                        .or().eq(UserEvent::getMobile, user.getMobile())
+                )
+        ) > 0;
+    }
+
     private void checkCallBack(Long userId, Agent agent, CallBackTypeEnum callBackTypeEnum, Map<String, Object> resultMap,
                                CallBackControlParam param) {
         switch (callBackTypeEnum) {

+ 18 - 0
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/impl/UserEventServiceImpl.java

@@ -0,0 +1,18 @@
+package com.zanxiang.game.module.sdk.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.zanxiang.game.module.mybatis.entity.UserEvent;
+import com.zanxiang.game.module.mybatis.mapper.UserEventMapper;
+import com.zanxiang.game.module.sdk.service.IUserEventService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author : lingfeng
+ * @time : 2024-09-27
+ * @description : APP过事件
+ */
+@Slf4j
+@Service
+public class UserEventServiceImpl extends ServiceImpl<UserEventMapper, UserEvent> implements IUserEventService {
+}