licailing пре 5 година
родитељ
комит
fc416f8738

+ 17 - 16
src/main/java/com/izouma/dingdong/service/UserService.java

@@ -69,23 +69,24 @@ public class UserService {
 
     public User merUser(MerchantDTO merchantDTO) {
         User user = userRepo.findByPhone(merchantDTO.getPhone());
-        if (ObjectUtil.isNull(user)) {
-            user = User.builder()
-                    .avatar(merchantDTO.getLogo())
-                    .username(merchantDTO.getPhone())
-                    .identity(MERCHANT)
-                    .phone(merchantDTO.getPhone())
-                    .nickname(merchantDTO.getShowName())
-                    .password(new BCryptPasswordEncoder().encode(merchantDTO.getPassword()))
-                    .authorities(Collections.singleton(Authority.getInstance(Authority.NAMES.ROLE_USER)))
-                    .blacklist(false)
-                    .enabled(true)
-                    .money(BigDecimal.ZERO)
-                    .build();
-            user = userRepo.save(user);
-
+        if (ObjectUtil.isNotEmpty(user)) {
+            throw new BusinessException("此手机号已注册");
         }
-        return user;
+
+        user = User.builder()
+                .avatar(merchantDTO.getLogo())
+                .username(merchantDTO.getPhone())
+                .identity(MERCHANT)
+                .phone(merchantDTO.getPhone())
+                .nickname(merchantDTO.getShowName())
+                .password(new BCryptPasswordEncoder().encode(merchantDTO.getPassword()))
+                .authorities(Collections.singleton(Authority.getInstance(Authority.NAMES.ROLE_USER)))
+                .blacklist(false)
+                .enabled(true)
+                .money(BigDecimal.ZERO)
+                .build();
+
+        return userRepo.save(user);
     }
 
     public User loginByPhone(String phone) {

+ 8 - 5
src/main/java/com/izouma/dingdong/service/merchant/MerchantService.java

@@ -71,12 +71,12 @@ public class MerchantService {
 
         if (ObjectUtil.isNotNull(merchant1)) {
             if (merchant1.getStatus().equals(ApplyStatus.PENDING)) {
-                return merchantDTO;
-                //throw new BusinessException("申请中");
+                //return merchantDTO;
+                throw new BusinessException("申请中");
             }
             if (merchant1.getStatus().equals(ApplyStatus.PASS)) {
-                return merchantDTO;
-                //throw new BusinessException("已申请");
+                //return merchantDTO;
+                throw new BusinessException("该手机号已申请");
             }
         }
 
@@ -130,6 +130,7 @@ public class MerchantService {
                 .isOpen(false)
                 .isShow(true)
                 .type(1)
+                .enabled(true)
                 .build());
         merchantClassificationRepo.save(MerchantClassification.builder()
                 .merchantId(merchant.getId())
@@ -138,6 +139,7 @@ public class MerchantService {
                 .isOpen(true)
                 .isShow(false)
                 .type(2)
+                .enabled(true)
                 .build());
         merchantClassificationRepo.save(MerchantClassification.builder()
                 .merchantId(merchant.getId())
@@ -146,6 +148,7 @@ public class MerchantService {
                 .isOpen(true)
                 .isShow(false)
                 .type(3)
+                .enabled(true)
                 .build());
 
         return merchantDTO;
@@ -368,7 +371,7 @@ public class MerchantService {
     /*
     距离排序
      */
-    public List<Merchant> distanceSorting(Double longitude, Double latitude){
+    public List<Merchant> distanceSorting(Double longitude, Double latitude) {
         List<Merchant> merchants = merchantRepo.findAll();
 
         //所有商家要按距离排序规则

+ 1 - 1
src/test/java/com/izouma/dingdong/contorller/OrderInfoControllerTest.java

@@ -53,7 +53,7 @@ public class OrderInfoControllerTest {
         MerchantDTO merchantDTO = MerchantDTO.builder()
                 .name("测试的店店店")
                 .showName("测试的店店店")
-                .phone("145111")
+                .phone("12")
                 .password("123")
                 .qualification("https%3A%2F%2Fidingdong.oss-cn-hangzhou.aliyuncs.com%2Fimage%2F2020-06-10-17-11-42qXdpsfqA.png%2Chttps%3A%2F%2Fidingdong.oss-cn-hangzhou.aliyuncs.com%2Fimage%2F2020-06-10-17-11-45pluNBzOF.png")
                 .doorHeadImg("https%3A%2F%2Fidingdong.oss-cn-hangzhou.aliyuncs.com%2Fimage%2F2020-06-10-17-11-52kTVlWTJi.png&img=https%3A%2F%2Fidingdong.oss-cn-hangzhou.aliyuncs.com%2Fimage%2F2020-06-10-17-11-55CJthQhYR.png")