Pārlūkot izejas kodu

邀请码修改

ouyang 3 gadi atpakaļ
vecāks
revīzija
fa570f1963

+ 36 - 26
src/main/java/com/izouma/nineth/service/UserService.java

@@ -60,29 +60,29 @@ import java.util.stream.Collectors;
 @Slf4j
 @Slf4j
 @AllArgsConstructor
 @AllArgsConstructor
 public class UserService {
 public class UserService {
-    private UserRepo                      userRepo;
-    private WxMaService                   wxMaService;
-    private WxMpService                   wxMpService;
-    private SmsService                    smsService;
-    private StorageService                storageService;
-    private JwtTokenUtil                  jwtTokenUtil;
-    private FollowService                 followService;
-    private FollowRepo                    followRepo;
-    private IdentityAuthRepo              identityAuthRepo;
-    private SysConfigService              sysConfigService;
-    private UserBankCardRepo              userBankCardRepo;
-    private InviteRepo                    inviteRepo;
-    private NFTService                    nftService;
-    private CacheService                  cacheService;
-    private TokenHistoryRepo              tokenHistoryRepo;
-    private CollectionRepo                collectionRepo;
-    private AdapayMerchantService         adapayMerchantService;
-    private Environment                   env;
-    private RocketMQTemplate              rocketMQTemplate;
-    private GeneralProperties             generalProperties;
+    private UserRepo userRepo;
+    private WxMaService wxMaService;
+    private WxMpService wxMpService;
+    private SmsService smsService;
+    private StorageService storageService;
+    private JwtTokenUtil jwtTokenUtil;
+    private FollowService followService;
+    private FollowRepo followRepo;
+    private IdentityAuthRepo identityAuthRepo;
+    private SysConfigService sysConfigService;
+    private UserBankCardRepo userBankCardRepo;
+    private InviteRepo inviteRepo;
+    private NFTService nftService;
+    private CacheService cacheService;
+    private TokenHistoryRepo tokenHistoryRepo;
+    private CollectionRepo collectionRepo;
+    private AdapayMerchantService adapayMerchantService;
+    private Environment env;
+    private RocketMQTemplate rocketMQTemplate;
+    private GeneralProperties generalProperties;
     private RedisTemplate<String, Object> redisTemplate;
     private RedisTemplate<String, Object> redisTemplate;
-    private PasswordEncoder               passwordEncoder;
-    private AssetRepo                     assetRepo;
+    private PasswordEncoder passwordEncoder;
+    private AssetRepo assetRepo;
 
 
     public User update(User user) {
     public User update(User user) {
         if (!SecurityUtils.hasRole(AuthorityName.ROLE_ADMIN)) {
         if (!SecurityUtils.hasRole(AuthorityName.ROLE_ADMIN)) {
@@ -273,7 +273,7 @@ public class UserService {
         identityAuthRepo.softDeleteByUserId(id);
         identityAuthRepo.softDeleteByUserId(id);
     }
     }
 
 
-    public User loginByPhone(String phone, String code) {
+    public User loginByPhone(String phone, String code, String inviteCode) {
         User user = userRepo.findByPhoneAndDelFalse(phone).orElse(null);
         User user = userRepo.findByPhoneAndDelFalse(phone).orElse(null);
         smsService.verify(phone, code);
         smsService.verify(phone, code);
         if (user == null) {
         if (user == null) {
@@ -285,6 +285,16 @@ public class UserService {
                     .avatar(Constants.DEFAULT_AVATAR)
                     .avatar(Constants.DEFAULT_AVATAR)
                     .phone(phone)
                     .phone(phone)
                     .build());
                     .build());
+            Invite invite = null;
+            if (StringUtils.isNotBlank(inviteCode)) {
+                invite = inviteRepo.findFirstByCode(inviteCode).orElse(null);
+            }
+            user.setInvitorPhone(Optional.ofNullable(invite).map(Invite::getPhone).orElse(null));
+            user.setInvitorName(Optional.ofNullable(invite).map(Invite::getName).orElse(null));
+            user.setInviteCode(Optional.ofNullable(invite).map(Invite::getCode).orElse(null));
+            if (invite != null) {
+                inviteRepo.increaseNum(invite.getId());
+            }
         }
         }
         return user;
         return user;
     }
     }
@@ -524,7 +534,7 @@ public class UserService {
             throw new BusinessException("用户不存在或未认证");
             throw new BusinessException("用户不存在或未认证");
         }
         }
         String realName = identityAuthRepo.findFirstByUserIdAndStatusAndDelFalseOrderByCreatedAtDesc(
         String realName = identityAuthRepo.findFirstByUserIdAndStatusAndDelFalseOrderByCreatedAtDesc(
-                user.getId(), AuthStatus.SUCCESS)
+                        user.getId(), AuthStatus.SUCCESS)
                 .map(IdentityAuth::getRealName).orElse("").replaceAll(".*(?=.)", "**");
                 .map(IdentityAuth::getRealName).orElse("").replaceAll(".*(?=.)", "**");
         Map<String, Object> map = new HashMap<>();
         Map<String, Object> map = new HashMap<>();
         map.put("id", user.getId());
         map.put("id", user.getId());
@@ -537,8 +547,8 @@ public class UserService {
 
 
     public Map<String, Object> searchByPhoneAdmin(String phoneStr) {
     public Map<String, Object> searchByPhoneAdmin(String phoneStr) {
         List<String> phone = Arrays.stream(phoneStr.replaceAll("\n", " ")
         List<String> phone = Arrays.stream(phoneStr.replaceAll("\n", " ")
-                .replaceAll("\r\n", " ")
-                .split(" "))
+                        .replaceAll("\r\n", " ")
+                        .split(" "))
                 .map(String::trim)
                 .map(String::trim)
                 .filter(s -> !StringUtils.isEmpty(s))
                 .filter(s -> !StringUtils.isEmpty(s))
                 .collect(Collectors.toList());
                 .collect(Collectors.toList());

+ 2 - 2
src/main/java/com/izouma/nineth/web/AuthenticationController.java

@@ -47,8 +47,8 @@ public class AuthenticationController {
 
 
     @PostMapping("/phoneLogin")
     @PostMapping("/phoneLogin")
     @ApiOperation(value = "手机号验证码登录")
     @ApiOperation(value = "手机号验证码登录")
-    public String phoneLogin(String phone, String code) {
-        User user = userService.loginByPhone(phone, code);
+    public String phoneLogin(String phone, String code, String inviteCode) {
+        User user = userService.loginByPhone(phone, code ,inviteCode);
         return jwtTokenUtil.generateToken(JwtUserFactory.create(user));
         return jwtTokenUtil.generateToken(JwtUserFactory.create(user));
     }
     }
 
 

+ 1 - 1
src/main/vue/src/views/InviteList.vue

@@ -240,7 +240,7 @@ export default {
                 });
                 });
         },
         },
         showCode(row) {
         showCode(row) {
-            this.codeValue = 'https://www.raex.vip/9th/?inviteCode=' + row.code;
+            this.codeValue = 'https://www.lasuo.cc/9th/?inviteCode=' + row.code;
             this.showCodeDialog = true;
             this.showCodeDialog = true;
         },
         },
         downloadPhone() {
         downloadPhone() {