Ver código fonte

调整用户申请商户入驻商城

Yangzw 7 meses atrás
pai
commit
42cc4672cd

+ 7 - 0
feifan-module-mall/feifan-module-sale-biz/src/main/java/cn/newfeifan/mall/module/sale/controller/app/merchantapply/MerchantApplyController.java

@@ -90,4 +90,11 @@ public class MerchantApplyController {
 //        PageResult<MerchantApplyDO> pageResult = merchantApplyService.getMerchantApplyPage(pageReqVO);
 //        return success(BeanUtils.toBean(pageResult, MerchantApplyRespVO.class));
 //    }
+
+    @GetMapping("/isSystemUserByMobile")
+    @Operation(summary = "判断是否是系统用户并且没有商户申请")
+    @PreAuthenticated
+    public CommonResult<Boolean> isSystemUserByMobile() {
+        return success(merchantApplyService.isSystemUserByMobile());
+    }
 }

+ 6 - 0
feifan-module-mall/feifan-module-sale-biz/src/main/java/cn/newfeifan/mall/module/sale/service/merchantapply/MerchantApplyService.java

@@ -58,4 +58,10 @@ public interface MerchantApplyService {
      * @return 商户申请
      */
     MerchantApplyDO getMerchantApplyBYUserId(Long loginUserId);
+
+    /**
+     * 判断是否是系统用户
+     * @return
+     */
+    Boolean isSystemUserByMobile();
 }

+ 23 - 5
feifan-module-mall/feifan-module-sale-biz/src/main/java/cn/newfeifan/mall/module/sale/service/merchantapply/MerchantApplyServiceImpl.java

@@ -1,13 +1,17 @@
 package cn.newfeifan.mall.module.sale.service.merchantapply;
 
 import cn.newfeifan.mall.framework.common.exception.ErrorCode;
+import cn.newfeifan.mall.module.member.api.user.MemberUserApi;
+import cn.newfeifan.mall.module.member.api.user.dto.MemberUserRespDTO;
 import cn.newfeifan.mall.module.member.enums.DictTypeConstants;
 import cn.newfeifan.mall.module.sale.controller.app.merchantapply.vo.MerchantApplyPageReqVO;
 import cn.newfeifan.mall.module.sale.controller.app.merchantapply.vo.MerchantApplySaveReqVO;
 import cn.newfeifan.mall.module.sale.enums.MerchantApplyCheckStatusEnum;
 import cn.newfeifan.mall.module.system.service.user.AdminUserService;
 import org.springframework.stereotype.Service;
+
 import javax.annotation.Resource;
+
 import org.springframework.validation.annotation.Validated;
 
 import cn.newfeifan.mall.module.sale.dal.dataobject.merchantapply.MerchantApplyDO;
@@ -36,11 +40,14 @@ public class MerchantApplyServiceImpl implements MerchantApplyService {
     @Resource
     private AdminUserService usersService;
 
+    @Resource
+    private MemberUserApi memberUserApi;
+
     @Override
     public Long createMerchantApply(MerchantApplySaveReqVO createReqVO) {
 
         // 校验存在
-        if(usersService.getUserByMobile(createReqVO.getContactNumber()) != null){
+        if (usersService.getUserByMobile(createReqVO.getContactNumber()) != null) {
             ErrorCode ERROR = new ErrorCode(1_002_029_003, "联络人账户已存在");
             throw exception(ERROR);
         }
@@ -50,8 +57,8 @@ public class MerchantApplyServiceImpl implements MerchantApplyService {
         merchantApply.setApplyMemberUserId(getLoginUserId());
 
         // 默认log
-        if(createReqVO.getLogoUrl() == null || createReqVO.getLogoUrl().isEmpty()){
-            createReqVO.setLogoUrl(DictTypeConstants.DEFAULT_AVATAR);
+        if (createReqVO.getLogoUrl() == null || createReqVO.getLogoUrl().isEmpty()) {
+            merchantApply.setLogoUrl(DictTypeConstants.DEFAULT_AVATAR);
         }
 
         merchantApplyMapper.insert(merchantApply);
@@ -65,7 +72,7 @@ public class MerchantApplyServiceImpl implements MerchantApplyService {
         MerchantApplyDO merchantApplyDO = merchantApplyMapper.selectById(updateReqVO.getId());
 
         // 联系人手机号校验
-        if(!merchantApplyDO.getContactNumber().equals(updateReqVO.getContactNumber()) && usersService.getUserByMobile(updateReqVO.getContactNumber()) != null){
+        if (!merchantApplyDO.getContactNumber().equals(updateReqVO.getContactNumber()) && usersService.getUserByMobile(updateReqVO.getContactNumber()) != null) {
             ErrorCode ERROR = new ErrorCode(1_002_029_003, "联络人账户已存在");
             throw exception(ERROR);
         }
@@ -77,7 +84,7 @@ public class MerchantApplyServiceImpl implements MerchantApplyService {
         MerchantApplyDO updateObj = BeanUtils.toBean(updateReqVO, MerchantApplyDO.class);
 
         // 默认log
-        if(updateObj.getLogoUrl() == null || updateObj.getLogoUrl().isEmpty()){
+        if (updateObj.getLogoUrl() == null || updateObj.getLogoUrl().isEmpty()) {
             updateObj.setLogoUrl(DictTypeConstants.DEFAULT_AVATAR);
         }
 
@@ -116,4 +123,15 @@ public class MerchantApplyServiceImpl implements MerchantApplyService {
         return merchantApplyMapper.selectOne(MerchantApplyDO::getApplyMemberUserId, loginUserId);
     }
 
+    @Override
+    public Boolean isSystemUserByMobile() {
+        // 获取消费者手机号
+        MemberUserRespDTO user = memberUserApi.getUser(getLoginUserId());
+        // 获取申请入驻信息
+        MerchantApplyDO merchantApplyDO = merchantApplyMapper.selectOne(MerchantApplyDO::getApplyMemberUserId, getLoginUserId());
+
+        // 判断是否有系统用户
+        return usersService.getUserByMobile(user.getMobile()) != null && merchantApplyDO == null;
+    }
+
 }