Bläddra i källkod

fix : 导量插入渠道变更记录, 修改手机号加限制

bilingfeng 1 år sedan
förälder
incheckning
da332db334

+ 1 - 1
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/ManageApplication.java

@@ -23,7 +23,7 @@ public class ManageApplication {
 
     public static void main(String[] args) {
         SpringApplication.run(ManageApplication.class, args);
-        System.out.println("赞象Manage服务启动成功 <导量逻辑> ( ´・・)ノ(._.`) \n" +
+        System.out.println("赞象Manage服务启动成功 <导量插入渠道变更记录, 修改手机号加限制> ( ´・・)ノ(._.`) \n" +
                 "___  ___  ___   _   _   ___  _____  _____ \n" +
                 "|  \\/  | / _ \\ | \\ | | / _ \\|  __ \\|  ___|\n" +
                 "| .  . |/ /_\\ \\|  \\| |/ /_\\ \\ |  \\/| |__  \n" +

+ 21 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/IUserAgentLogService.java

@@ -0,0 +1,21 @@
+package com.zanxiang.game.module.manage.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.zanxiang.game.module.mybatis.entity.User;
+import com.zanxiang.game.module.mybatis.entity.UserAgentLog;
+
+/**
+ * @author : lingfeng
+ * @time : 2023-07-20
+ * @description : 用户渠道记录
+ */
+public interface IUserAgentLogService extends IService<UserAgentLog> {
+
+    /**
+     * 注册代理日志
+     *
+     * @param user 用户
+     * @return boolean
+     */
+    boolean regAgentLog(User user);
+}

+ 44 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/UserAgentLogServiceImpl.java

@@ -0,0 +1,44 @@
+package com.zanxiang.game.module.manage.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.zanxiang.game.module.manage.service.IUserAgentLogService;
+import com.zanxiang.game.module.mybatis.entity.Agent;
+import com.zanxiang.game.module.mybatis.entity.User;
+import com.zanxiang.game.module.mybatis.entity.UserAgentLog;
+import com.zanxiang.game.module.mybatis.mapper.UserAgentLogMapper;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.logging.log4j.util.Strings;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author : lingfeng
+ * @time : 2023-07-20
+ * @description : 用户渠道记录
+ */
+@Slf4j
+@Service
+public class UserAgentLogServiceImpl extends ServiceImpl<UserAgentLogMapper, UserAgentLog> implements IUserAgentLogService {
+
+    @Override
+    public boolean regAgentLog(User user) {
+        if (Agent.DEFAULT_AGENT.equals(user.getAgentId()) || Strings.isBlank(user.getChannel())) {
+            return Boolean.FALSE;
+        }
+        try {
+            return super.save(this.transform(user));
+        } catch (Exception e) {
+            log.error("用户注册渠道记录保存异常, userId : {}, e : {}", user.getId(), e.getMessage());
+        }
+        return Boolean.FALSE;
+    }
+
+    private UserAgentLog transform(User user) {
+        return UserAgentLog.builder()
+                .userId(user.getId())
+                .newAgentId(user.getAgentId())
+                .newChannel(user.getChannel())
+                .createTime(user.getCreateTime())
+                .updateTime(user.getCreateTime())
+                .build();
+    }
+}

+ 16 - 1
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/UserServiceImpl.java

@@ -83,6 +83,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
     @Autowired
     private IGameAuthService gameAuthService;
 
+    @Autowired
+    private IUserAgentLogService userAgentLogService;
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Boolean appletToH5(Long userId, String mobile, Integer type) {
@@ -179,10 +182,12 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
         ).collect(Collectors.toList());
         gameUserRoleService.saveBatch(h5GameUserRoleList);
         //用户更新
-        return super.update(new LambdaUpdateWrapper<User>()
+        super.update(new LambdaUpdateWrapper<User>()
                 .set(User::getRelationUserId, h5User.getId())
                 .set(User::getRelationCreateTime, LocalDateTime.now())
                 .eq(User::getId, userId));
+        //添加导量用户的渠道变更记录
+        return userAgentLogService.regAgentLog(h5User);
     }
 
     @Override
@@ -304,6 +309,16 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Boolean userUpdate(UserUpdateParam param) {
+        if (Strings.isNotBlank(param.getMobile()) && !param.getMobile().contains("*")) {
+            User user = super.getById(param.getUserId());
+            //判断手机号是否被该游戏其他用户绑定
+            if (super.count(new LambdaQueryWrapper<User>()
+                    .eq(User::getGameId, user.getGameId())
+                    .eq(User::getMobile, param.getMobile())
+            ) > 0) {
+                throw new BaseException("手机号已被同游戏其他玩家绑定, 禁止修改");
+            }
+        }
         //用户信息更新
         if (Strings.isNotBlank(param.getMobile()) || Strings.isNotBlank(param.getAliPay()) || Strings.isNotBlank(param.getPassword())) {
             super.update(new LambdaUpdateWrapper<User>()