Browse Source

feat(user): 添加供应商伙伴商客户ID字段及认证功能

- 在LoginUser模型中新增supplierId、customerId、partnerId字段
- 实现供应商用户登录时的状态验证机制
- 集成供应商、伙伴商、客户信息远程服务接口
- 完善用户登录时根据用户子类型设置相应ID的逻辑
- 优化订单流程服务中的审核状态更新逻辑
- 改进产品基础服务中的ID查询方式
- 扩展供应商联系人和资质管理功能
- 更新系统用户控制器中的用户信息返回结构
肖路 3 tuần trước cách đây
mục cha
commit
e7feed7950
16 tập tin đã thay đổi với 150 bổ sung7 xóa
  1. 4 0
      ruoyi-api/ruoyi-api-customer/src/main/java/org/dromara/customer/api/RemotePartnerInfoService.java
  2. 11 0
      ruoyi-api/ruoyi-api-customer/src/main/java/org/dromara/customer/api/RemoteSupplierInfoService.java
  3. 8 1
      ruoyi-api/ruoyi-api-system/src/main/java/org/dromara/system/api/model/LoginUser.java
  4. 10 0
      ruoyi-auth/src/main/java/org/dromara/auth/service/impl/PasswordAuthStrategy.java
  5. 5 0
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/SupplierQualification.java
  6. 5 0
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/bo/SupplierQualificationBo.java
  7. 5 0
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/vo/SupplierQualificationVo.java
  8. 24 0
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/dubbo/RemotePartnerInfoServiceImpl.java
  9. 34 4
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/dubbo/RemoteSupplierInfoServiceImpl.java
  10. 1 0
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/service/impl/SupplierContactServiceImpl.java
  11. 2 0
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/service/impl/SupplierQualificationServiceImpl.java
  12. 0 1
      ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/service/impl/OrderCustomerFlowServiceImpl.java
  13. 1 1
      ruoyi-modules/ruoyi-product/src/main/java/org/dromara/product/service/impl/ProductBaseServiceImpl.java
  14. 2 0
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/system/SysUserController.java
  15. 16 0
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/vo/UserInfoVo.java
  16. 22 0
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/dubbo/RemoteUserServiceImpl.java

+ 4 - 0
ruoyi-api/ruoyi-api-customer/src/main/java/org/dromara/customer/api/RemotePartnerInfoService.java

@@ -9,4 +9,8 @@ public interface RemotePartnerInfoService {
      * 根据ids查询伙伴商名称
      */
     Map<Long, String> selectPartnerNameByIds(Set<Long> ids);
+    /**
+     * 根据userId查询伙伴商id
+     */
+    Long selectPartnerIdByUserId(Long userId);
 }

+ 11 - 0
ruoyi-api/ruoyi-api-customer/src/main/java/org/dromara/customer/api/RemoteSupplierInfoService.java

@@ -58,4 +58,15 @@ public interface RemoteSupplierInfoService {
     Map<Long, SupplierAreaDTO> selectSupplierInfoByContractIds(List<Long> contractSupplyIds);
 
     int updateExpiredAuthorizedStatus();
+
+    /**
+    * 根据用户id查询供应商id
+    * */
+    Long selectSupplierIdByUserId(Long userId);
+    /**
+     * 单体查询供应商审核状态
+     *
+     * @param supplierId
+     */
+    Long selectSupplierStatusById(Long supplierId);
 }

+ 8 - 1
ruoyi-api/ruoyi-api-system/src/main/java/org/dromara/system/api/model/LoginUser.java

@@ -139,11 +139,18 @@ public class LoginUser implements Serializable {
      * 用户子类型 用户子类型(0=平台用户,1=供应商,2=伙伴商,3=商城用户)
      */
     private String userSonType;
+    /**
+     * 供应商ID
+     */
+    private Long supplierId;
     /**
      * 客户ID
      */
     private Long customerId;
-
+    /**
+     * 伙伴商ID
+     */
+    private Long partnerId;
     /**
      * 获取登录id
      */

+ 10 - 0
ruoyi-auth/src/main/java/org/dromara/auth/service/impl/PasswordAuthStrategy.java

@@ -29,6 +29,7 @@ import org.dromara.common.redis.utils.RedisUtils;
 import org.dromara.common.satoken.utils.LoginHelper;
 import org.dromara.common.tenant.helper.TenantHelper;
 import org.dromara.customer.api.RemoteCustomerService;
+import org.dromara.customer.api.RemoteSupplierInfoService;
 import org.dromara.customer.api.domain.dto.CustomerInfoDTO;
 import org.dromara.system.api.RemoteClientService;
 import org.dromara.system.api.RemoteUserService;
@@ -61,6 +62,9 @@ public class PasswordAuthStrategy implements IAuthStrategy {
     @DubboReference
     private RemoteCustomerService remoteCustomerService;
 
+    @DubboReference
+    private RemoteSupplierInfoService remoteSupplierInfoService;
+
     @Override
     public LoginVo login(String body, RemoteClientVo client) {
         PasswordLoginBody loginBody = JsonUtils.parseObject(body, PasswordLoginBody.class);
@@ -80,6 +84,12 @@ public class PasswordAuthStrategy implements IAuthStrategy {
             loginService.checkLogin(LoginType.PASSWORD, tenantId, username, () -> !BCrypt.checkpw(password, user.getPassword()));
             return user;
         });
+        if(ObjectUtil.isNotEmpty(loginUser.getSupplierId())) {
+            Long supplierStatus = remoteSupplierInfoService.selectSupplierStatusById(loginUser.getSupplierId());
+            if(!Objects.equals(supplierStatus,1L)){
+                throw new ServiceException("供应商用户未审核通过");
+            }
+        }
         loginUser.setClientKey(client.getClientKey());
         loginUser.setDeviceType(client.getDeviceType());
         SaLoginParameter model = new SaLoginParameter();

+ 5 - 0
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/SupplierQualification.java

@@ -29,6 +29,11 @@ public class SupplierQualification extends TenantEntity {
     @TableId(value = "id")
     private Long id;
 
+    /**
+     * 供应商ID
+     */
+    private Long supplierId;
+
     /**
      * 资质名称(对应表单“资质名称”)
      */

+ 5 - 0
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/bo/SupplierQualificationBo.java

@@ -27,6 +27,11 @@ public class SupplierQualificationBo extends BaseEntity {
      */
     private Long id;
 
+    /**
+     * 供应商ID
+     */
+    private Long supplierId;
+
     /**
      * 资质名称(对应表单“资质名称”)
      */

+ 5 - 0
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/vo/SupplierQualificationVo.java

@@ -36,6 +36,11 @@ public class SupplierQualificationVo implements Serializable {
     @ExcelProperty(value = "主键ID")
     private Long id;
 
+    /**
+     * 供应商ID
+     */
+    private Long supplierId;
+
     /**
      * 资质名称(对应表单“资质名称”)
      */

+ 24 - 0
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/dubbo/RemotePartnerInfoServiceImpl.java

@@ -1,10 +1,15 @@
 package org.dromara.customer.dubbo;
 
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.config.annotation.DubboService;
 import org.dromara.customer.api.RemotePartnerInfoService;
+import org.dromara.customer.domain.PartnerContacts;
+import org.dromara.customer.domain.PartnerUser;
+import org.dromara.customer.service.IPartnerContactsService;
 import org.dromara.customer.service.IPartnerInfoService;
+import org.dromara.customer.service.IPartnerUserService;
 import org.springframework.stereotype.Service;
 
 import java.util.Map;
@@ -18,8 +23,27 @@ public class RemotePartnerInfoServiceImpl implements RemotePartnerInfoService {
 
     private final IPartnerInfoService partnerInfoService;
 
+    private final IPartnerUserService partnerUserService;
+
     @Override
     public Map<Long, String> selectPartnerNameByIds(Set<Long> ids) {
         return partnerInfoService.selectPartnerNameByIds(ids);
     }
+
+    /**
+     * 根据userId查询伙伴商id
+     *
+     * @param userId
+     */
+    @Override
+    public Long selectPartnerIdByUserId(Long userId) {
+        PartnerUser one = partnerUserService.getOne(Wrappers.lambdaQuery(PartnerUser.class)
+            .eq(PartnerUser::getSysUserId, userId)
+            .last("limit 1")
+        );
+        if (one != null) {
+            return one.getPartnerId();
+        }
+        return null;
+    }
 }

+ 34 - 4
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/dubbo/RemoteSupplierInfoServiceImpl.java

@@ -10,12 +10,11 @@ import org.dromara.customer.api.RemoteSupplierInfoService;
 import org.dromara.customer.api.domain.dto.SupplierAreaDTO;
 import org.dromara.customer.api.domain.dto.SupplierAuthorizeDTO;
 import org.dromara.customer.domain.ContractSupply;
+import org.dromara.customer.domain.SupplierContact;
+import org.dromara.customer.domain.SupplierInfo;
 import org.dromara.customer.domain.SupplyArea;
 import org.dromara.customer.domain.vo.SupplyAreaVo;
-import org.dromara.customer.service.IContractSupplyService;
-import org.dromara.customer.service.ISupplierAuthorizeService;
-import org.dromara.customer.service.ISupplierInfoService;
-import org.dromara.customer.service.ISupplyAreaService;
+import org.dromara.customer.service.*;
 import org.springframework.stereotype.Service;
 
 import java.util.*;
@@ -33,6 +32,8 @@ public class RemoteSupplierInfoServiceImpl implements RemoteSupplierInfoService
 
     private final ISupplierInfoService supplierInfoService;
 
+    private final ISupplierContactService supplierContactService;
+
     private final ISupplierAuthorizeService supplierAuthorizeService;
 
     private final ISupplyAreaService supplyAreaService;
@@ -193,4 +194,33 @@ public class RemoteSupplierInfoServiceImpl implements RemoteSupplierInfoService
     public int updateExpiredAuthorizedStatus() {
         return supplierAuthorizeService.updateExpiredAuthorizedStatus();
     }
+
+    /**
+     * 根据用户id查询供应商id
+     *
+     * @param userId
+     */
+    @Override
+    public Long selectSupplierIdByUserId(Long userId) {
+        SupplierContact one = supplierContactService.getOne(Wrappers.lambdaQuery(SupplierContact.class)
+            .eq(SupplierContact::getUserId, userId)
+            .select(SupplierContact::getSupplierId)
+            .last("limit 1")
+        );
+        if (one != null) {
+            return one.getSupplierId();
+        }
+        return null;
+    }
+
+    /**
+     * 单体查询供应商审核状态
+     *
+     * @param supplierId
+     */
+    @Override
+    public Long selectSupplierStatusById(Long supplierId) {
+
+        return supplierInfoService.getSupplierStatus(supplierId);
+    }
 }

+ 1 - 0
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/service/impl/SupplierContactServiceImpl.java

@@ -193,6 +193,7 @@ public class SupplierContactServiceImpl extends ServiceImpl<SupplierContactMappe
         remoteUserBo.setPassword(BCrypt.hashpw(password));
         remoteUserBo.setUserSonType("1");
         remoteUserBo.setTenantId(LoginHelper.getTenantId());
+        remoteUserBo.setRoleId(1996815844478320642L);
         Long userId = remoteUserService.addUser(remoteUserBo);
 
         remoteUserBo.setUserId(userId);

+ 2 - 0
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/service/impl/SupplierQualificationServiceImpl.java

@@ -1,5 +1,6 @@
 package org.dromara.customer.service.impl;
 
+import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.dromara.common.core.utils.MapstructUtils;
 import org.dromara.common.core.utils.StringUtils;
@@ -75,6 +76,7 @@ public class SupplierQualificationServiceImpl  extends ServiceImpl<SupplierQuali
         Map<String, Object> params = bo.getParams();
         LambdaQueryWrapper<SupplierQualification> lqw = Wrappers.lambdaQuery();
         lqw.orderByAsc(SupplierQualification::getId);
+        lqw.eq(ObjectUtil.isNotEmpty(bo.getSupplierId()), SupplierQualification::getSupplierId, bo.getSupplierId());
         lqw.like(StringUtils.isNotBlank(bo.getQualificationName()), SupplierQualification::getQualificationName, bo.getQualificationName());
         lqw.eq(StringUtils.isNotBlank(bo.getQualificationLevel()), SupplierQualification::getQualificationLevel, bo.getQualificationLevel());
         lqw.eq(StringUtils.isNotBlank(bo.getCertificateNo()), SupplierQualification::getCertificateNo, bo.getCertificateNo());

+ 0 - 1
ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/service/impl/OrderCustomerFlowServiceImpl.java

@@ -325,7 +325,6 @@ public class OrderCustomerFlowServiceImpl extends ServiceImpl<OrderCustomerFlowM
         // 5. 更新流程链接表的当前节点信息
         OrderCustomerFlowLink updateLink = new OrderCustomerFlowLink();
         updateLink.setId(currentLink.getId());
-        updateLink.setReviewStatus(bo.getReviewStatus());
         updateLink.setReason(bo.getReason());
         updateLink.setRemark(bo.getRemark());
 

+ 1 - 1
ruoyi-modules/ruoyi-product/src/main/java/org/dromara/product/service/impl/ProductBaseServiceImpl.java

@@ -1533,7 +1533,7 @@ public class ProductBaseServiceImpl extends ServiceImpl<ProductBaseMapper, Produ
         try {
             LambdaEsQueryWrapper<ProductBaseVo> esQueryWrapper = buildEsQueryWrapperForPc(bo);
             if(ObjectUtil.isNotEmpty(bo.getIds())){
-                esQueryWrapper.in(ProductBaseVo::getId, bo.getIds());
+                esQueryWrapper.in(ProductBaseVo::getId, bo.getIds().split(","));
             }
             if (ObjectUtil.isNotEmpty(bo.getBrandIds())){
                 esQueryWrapper.in(ProductBaseVo::getBrandId, bo.getBrandIds().split(","));

+ 2 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/system/SysUserController.java

@@ -123,6 +123,8 @@ public class SysUserController extends BaseController {
         userInfoVo.setUser(user);
         userInfoVo.setPermissions(loginUser.getMenuPermission());
         userInfoVo.setRoles(loginUser.getRolePermission());
+        userInfoVo.setSupplierId(loginUser.getSupplierId());
+        userInfoVo.setPartnerId(loginUser.getPartnerId());
         if (ObjectUtil.isNotEmpty(loginUser.getCustomerId())) {
             userInfoVo.setCompanyName(remoteCustomerService.selectCompanyNameByCustomerId(loginUser.getCustomerId()));
             userInfoVo.setCustomerName(remoteCustomerService.selectCustomerInfoById(loginUser.getCustomerId()).getCustomerName());

+ 16 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/vo/UserInfoVo.java

@@ -22,6 +22,11 @@ public class UserInfoVo implements Serializable {
      */
     private SysUserVo user;
 
+    /**
+    * 客户id
+    * */
+    private Long customerId;
+
     /**
      * 所属公司名称
      */
@@ -32,6 +37,17 @@ public class UserInfoVo implements Serializable {
      */
     private String customerName;
 
+    /**
+    * 供应商id
+    * */
+    private Long supplierId;
+
+    /**
+    * 伙伴商id
+    * */
+    private Long partnerId;
+
+
     /**
      * 菜单权限
      */

+ 22 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/dubbo/RemoteUserServiceImpl.java

@@ -6,6 +6,7 @@ import cn.hutool.core.lang.Opt;
 import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import lombok.RequiredArgsConstructor;
+import org.apache.dubbo.config.annotation.DubboReference;
 import org.apache.dubbo.config.annotation.DubboService;
 import org.dromara.common.core.constant.SystemConstants;
 import org.dromara.common.core.enums.UserStatus;
@@ -17,6 +18,9 @@ import org.dromara.common.core.utils.StreamUtils;
 import org.dromara.common.core.utils.StringUtils;
 import org.dromara.common.mybatis.helper.DataPermissionHelper;
 import org.dromara.common.tenant.helper.TenantHelper;
+import org.dromara.customer.api.RemoteCustomerService;
+import org.dromara.customer.api.RemotePartnerInfoService;
+import org.dromara.customer.api.RemoteSupplierInfoService;
 import org.dromara.system.api.RemoteUserService;
 import org.dromara.system.api.domain.bo.RemoteUserBo;
 import org.dromara.system.api.domain.vo.RemoteUserVo;
@@ -63,6 +67,12 @@ public class RemoteUserServiceImpl implements RemoteUserService {
     private final SysUserRoleMapper userRoleMapper;
     private final SysUserPostMapper userPostMapper;
 
+    @DubboReference
+    private RemoteCustomerService remoteCustomerService;
+    @DubboReference
+    private RemotePartnerInfoService remotePartnerInfoService;
+    @DubboReference
+    private RemoteSupplierInfoService remoteSupplierInfoService;
     /**
      * 通过用户名查询用户信息
      *
@@ -286,6 +296,18 @@ public class RemoteUserServiceImpl implements RemoteUserService {
         List<SysPostVo> posts = postService.selectPostsByUserId(userId);
         loginUser.setRoles(BeanUtil.copyToList(roles, RoleDTO.class));
         loginUser.setPosts(BeanUtil.copyToList(posts, PostDTO.class));
+        //用户子类型 用户子类型(0=平台用户,1=供应商,2=伙伴商,3=商城用户)
+        if(Objects.equals(userVo.getUserSonType(),"1")){
+            Long supplierId = remoteSupplierInfoService.selectSupplierIdByUserId(userVo.getUserId());
+
+            loginUser.setSupplierId(supplierId);
+        }else if(Objects.equals(userVo.getUserSonType(),"2")){
+            Long partnerId = remotePartnerInfoService.selectPartnerIdByUserId(userVo.getUserId());
+            loginUser.setPartnerId(partnerId);
+        }else if(Objects.equals(userVo.getUserSonType(),"3")){
+            Long customerId = remoteCustomerService.selectCustomerIdByUserId(userVo.getUserId());
+            loginUser.setCustomerId(customerId);
+        }
         return loginUser;
     }