licailing 4 years ago
parent
commit
3160aa6150

+ 6 - 0
src/main/java/com/izouma/nineth/domain/User.java

@@ -128,4 +128,10 @@ public class User extends BaseEntity implements Serializable {
     private String inviteCode;
 
     private int minterProjectId;
+
+    @ApiModelProperty(value = "邀请得空投")
+    private Long invitor;
+
+    @ApiModelProperty(value = "邀请数量")
+    private int inviteNum;
 }

+ 2 - 0
src/main/java/com/izouma/nineth/dto/UserRegister.java

@@ -46,4 +46,6 @@ public class UserRegister {
     private int minterProjectId;
 
     private String intro;
+
+    private Long invitor;
 }

+ 47 - 23
src/main/java/com/izouma/nineth/service/UserService.java

@@ -10,11 +10,9 @@ import com.huifu.adapay.model.AdapayCommon;
 import com.huifu.adapay.model.SettleAccount;
 import com.izouma.nineth.config.AdapayProperties;
 import com.izouma.nineth.config.Constants;
-import com.izouma.nineth.domain.Follow;
-import com.izouma.nineth.domain.IdentityAuth;
-import com.izouma.nineth.domain.Invite;
-import com.izouma.nineth.domain.User;
+import com.izouma.nineth.domain.*;
 import com.izouma.nineth.dto.*;
+import com.izouma.nineth.enums.AirDropType;
 import com.izouma.nineth.enums.AuthStatus;
 import com.izouma.nineth.enums.AuthorityName;
 import com.izouma.nineth.event.AccountCreatedEvent;
@@ -57,24 +55,24 @@ import java.util.stream.Collectors;
 @Slf4j
 @AllArgsConstructor
 public class UserService {
-    private UserRepo          userRepo;
-    private WxMaService       wxMaService;
-    private WxMpService       wxMpService;
-    private SmsService        smsService;
-    private StorageService    storageService;
-    private JwtTokenUtil      jwtTokenUtil;
-    private CaptchaService    captchaService;
-    private FollowService     followService;
-    private FollowRepo        followRepo;
-    private IdentityAuthRepo  identityAuthRepo;
-    private SysConfigService  sysConfigService;
-    private CollectionService collectionService;
-    private AdapayService     adapayService;
-    private UserBankCardRepo  userBankCardRepo;
-    private CacheService      cacheService;
-    private InviteRepo        inviteRepo;
-    private NFTService        nftService;
-    private AdapayProperties  adapayProperties;
+    private UserRepo         userRepo;
+    private WxMaService      wxMaService;
+    private WxMpService      wxMpService;
+    private SmsService       smsService;
+    private StorageService   storageService;
+    private JwtTokenUtil     jwtTokenUtil;
+    private CaptchaService   captchaService;
+    private FollowService    followService;
+    private FollowRepo       followRepo;
+    private IdentityAuthRepo identityAuthRepo;
+    private SysConfigService sysConfigService;
+    private AirDropService   airDropService;
+    private AdapayService    adapayService;
+    private UserBankCardRepo userBankCardRepo;
+    private CacheService     cacheService;
+    private InviteRepo       inviteRepo;
+    private NFTService       nftService;
+    private AdapayProperties adapayProperties;
 
     @CacheEvict(value = "user", key = "#user.username")
     public User update(User user) {
@@ -155,7 +153,7 @@ public class UserService {
         return user;
     }
 
-    public User phoneRegister(String phone, String code, String password, String inviteCode) {
+    public User phoneRegister(String phone, String code, String password, String inviteCode, Long invitor) {
         String name = "9th_" + RandomStringUtils.randomAlphabetic(8);
         Invite invite = null;
         if (StringUtils.isNotBlank(inviteCode)) {
@@ -172,10 +170,36 @@ public class UserService {
                 .invitorPhone(Optional.ofNullable(invite).map(Invite::getPhone).orElse(null))
                 .invitorName(Optional.ofNullable(invite).map(Invite::getName).orElse(null))
                 .inviteCode(Optional.ofNullable(invite).map(Invite::getCode).orElse(null))
+                .invitor(invitor)
                 .build());
         if (invite != null) {
             inviteRepo.increaseNum(invite.getId());
         }
+        if (invitor != null) {
+            userRepo.findByIdAndDelFalse(invitor).ifPresent(user1 -> {
+                user1.setInviteNum(user1.getInviteNum() + 1);
+                userRepo.save(user1);
+                if (user1.getInviteNum() >= 15) {
+                    airDropService.create(AirDrop.builder()
+                            .name("宇宙熊-致敬奥运-纯金款")
+                            .type(AirDropType.asset)
+                            .collectionId(8472L)
+                            .phone(List.of(user1.getPhone()))
+                            .userIds(List.of(invitor))
+                            .projectId(1)
+                            .build());
+                } else if (user1.getInviteNum() >= 5) {
+                    airDropService.create(AirDrop.builder()
+                            .name("宇宙熊-致敬奥运-纯黄款")
+                            .type(AirDropType.asset)
+                            .collectionId(8406L)
+                            .phone(List.of(user1.getPhone()))
+                            .userIds(List.of(invitor))
+                            .projectId(1)
+                            .build());
+                }
+            });
+        }
         return user;
     }
 

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

@@ -65,8 +65,8 @@ public class AuthenticationController {
 
     @PostMapping("/phoneRegister")
     @ApiOperation(value = "手机号密码注册")
-    public String phonePwdLogin(String phone, String code, String password, String inviteCode) {
-        User user = userService.phoneRegister(phone, code, password, inviteCode);
+    public String phonePwdLogin(String phone, String code, String password, String inviteCode, Long invitor) {
+        User user = userService.phoneRegister(phone, code, password, inviteCode, invitor);
         return jwtTokenUtil.generateToken(JwtUserFactory.create(user));
     }