Commit 6a0c704c by xugaojun

Merge branch 'fix-20220222' of http://git.gicdev.com/haoban3.0/haoban-manage3.0

parents b752fd0f a50001c0
...@@ -56,6 +56,14 @@ public interface StaffApiService { ...@@ -56,6 +56,14 @@ public interface StaffApiService {
*/ */
StaffDTO selectByUserIdAndEnterpriseId(String userId, String wxEnterpriseId); StaffDTO selectByUserIdAndEnterpriseId(String userId, String wxEnterpriseId);
/**
* 没手机号的时候需要重新刷
* @param userId
* @param wxEnterpriseId
* @return
*/
StaffDTO getByUserIdAndReflushWhenNoPhone(String userId, String wxEnterpriseId);
StaffDepartmentRelatedDTO getDepartmentIdAndStaffId(String departmentId, String staffId); StaffDepartmentRelatedDTO getDepartmentIdAndStaffId(String departmentId, String staffId);
int countByDepartmentId(String departmentId); int countByDepartmentId(String departmentId);
......
...@@ -44,6 +44,17 @@ public interface StaffService { ...@@ -44,6 +44,17 @@ public interface StaffService {
*/ */
TabHaobanStaff selectByPhoneNumberAndEnterpriseId(String phoneNumber, String wxEnterpriseId); TabHaobanStaff selectByPhoneNumberAndEnterpriseId(String phoneNumber, String wxEnterpriseId);
/**
* 选择userId跟手机号查询数据 userid优先级高
*
* @param phoneNumber 电话号码
* @param wxEnterpriseId wx企业标识
* @return {@link TabHaobanStaff }
* @author mozhu
* @date 2022-01-12 17:19:28
*/
TabHaobanStaff selectByPhoneNumberOrUserIdAndEnterpriseId(String phoneNumber,String userId, String wxEnterpriseId);
List<StaffDTO> listByUserIdsAndWxEnterpriseId(List<String> userIds, String wxEnterpriseId); List<StaffDTO> listByUserIdsAndWxEnterpriseId(List<String> userIds, String wxEnterpriseId);
/** /**
......
...@@ -6,17 +6,18 @@ import com.gic.haoban.manage.api.dto.StaffDTO; ...@@ -6,17 +6,18 @@ import com.gic.haoban.manage.api.dto.StaffDTO;
import com.gic.haoban.manage.service.dao.mapper.StaffMapper; import com.gic.haoban.manage.service.dao.mapper.StaffMapper;
import com.gic.haoban.manage.service.entity.TabHaobanStaff; import com.gic.haoban.manage.service.entity.TabHaobanStaff;
import com.gic.haoban.manage.service.service.MemberUnionRelatedService; import com.gic.haoban.manage.service.service.MemberUnionRelatedService;
import com.gic.haoban.manage.service.service.StaffClerkRelationService;
import com.gic.haoban.manage.service.service.StaffService; import com.gic.haoban.manage.service.service.StaffService;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Date; import java.util.*;
import java.util.List; import java.util.stream.Collectors;
import java.util.Set;
@Service @Service
public class StaffServiceImpl implements StaffService { public class StaffServiceImpl implements StaffService {
...@@ -27,6 +28,9 @@ public class StaffServiceImpl implements StaffService { ...@@ -27,6 +28,9 @@ public class StaffServiceImpl implements StaffService {
@Autowired @Autowired
private MemberUnionRelatedService memberUnionRelatedService; private MemberUnionRelatedService memberUnionRelatedService;
@Autowired
private StaffClerkRelationService staffClerkRelationService;
@Override @Override
public TabHaobanStaff selectById(String id) { public TabHaobanStaff selectById(String id) {
return mapper.selectByPrimaryKey(id); return mapper.selectByPrimaryKey(id);
...@@ -72,6 +76,34 @@ public class StaffServiceImpl implements StaffService { ...@@ -72,6 +76,34 @@ public class StaffServiceImpl implements StaffService {
} }
@Override @Override
public TabHaobanStaff selectByPhoneNumberOrUserIdAndEnterpriseId(String phoneNumber, String userId, String wxEnterpriseId) {
if (StringUtils.isBlank(userId)) {
return null;
}
//存在多条
List<String> userIds=new ArrayList<>();
userIds.add(userId);
List<TabHaobanStaff> staffs = mapper.listByUserIdsAndWxEnterpriseId(userIds, wxEnterpriseId);
if (CollectionUtils.isEmpty(staffs)) {
return this.selectByPhoneNumberAndEnterpriseId(phoneNumber, wxEnterpriseId);
}
if (staffs.size()==1) {
return staffs.get(0);
//需要去除多余的
}else if (staffs.size()>1) {
Map<String, TabHaobanStaff> staffMap = staffs.stream().collect(Collectors.toMap(dto -> dto.getStaffId(), dto -> dto,(o,n)->n));
List<String> relationStaffIds = staffClerkRelationService.listRelationsStaffId(staffMap.keySet());
if (CollectionUtils.isNotEmpty(relationStaffIds)) {
return staffMap.get(relationStaffIds.get(0));
}else{
return staffs.get(0);
}
}
return null;
}
@Override
public void updateByPrimaryKey(TabHaobanStaff tab) { public void updateByPrimaryKey(TabHaobanStaff tab) {
tab.setUpdateTime(new Date()); tab.setUpdateTime(new Date());
mapper.updateByPrimaryKeySelective(tab); mapper.updateByPrimaryKeySelective(tab);
......
...@@ -389,7 +389,7 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -389,7 +389,7 @@ public class StaffApiServiceImpl implements StaffApiService {
String[] arr = getNationCodeAndPhoneNumber(mobile); String[] arr = getNationCodeAndPhoneNumber(mobile);
String nationCode = arr[0]; String nationCode = arr[0];
String phoneNumber = arr[1]; String phoneNumber = arr[1];
TabHaobanStaff staff = staffService.selectByPhoneNumberAndEnterpriseId(phoneNumber, wxEnterpriseId); TabHaobanStaff staff = staffService.selectByPhoneNumberOrUserIdAndEnterpriseId(phoneNumber,userId, wxEnterpriseId);
if (staff != null) { if (staff != null) {
staffService.delOtherStaffByWxUserId(staff.getWxUserId(), staff.getStaffId(), wxEnterpriseId); staffService.delOtherStaffByWxUserId(staff.getWxUserId(), staff.getStaffId(), wxEnterpriseId);
} }
...@@ -893,6 +893,36 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -893,6 +893,36 @@ public class StaffApiServiceImpl implements StaffApiService {
} }
@Override @Override
public StaffDTO getByUserIdAndReflushWhenNoPhone(String userId, String wxEnterpriseId) {
StaffDTO staffDTO = EntityUtil.changeEntityByJSON(StaffDTO.class, staffService.selectByUserIdAndEnterpriseId(userId, wxEnterpriseId));
if (staffDTO == null) {
return null;
}
if (StringUtils.isBlank(staffDTO.getPhoneNumber())) {
this.wxGetAdd(userId,wxEnterpriseId);
return EntityUtil.changeEntityByJSON(StaffDTO.class, staffService.selectByUserIdAndEnterpriseId(userId, wxEnterpriseId));
}
//todo 历史数据 相同的id需要删除 后续这个逻辑可以删除
//存在多条
List<String> userIds=new ArrayList<>();
userIds.add(userId);
List<TabHaobanStaff> staffs = staffMapper.listByUserIdsAndWxEnterpriseId(userIds, wxEnterpriseId);
//需要去除多余的
if (CollectionUtils.isNotEmpty(staffs)&&staffs.size()>1) {
Map<String, TabHaobanStaff> staffMap = staffs.stream().collect(Collectors.toMap(dto -> dto.getStaffId(), dto -> dto,(o,n)->n));
List<String> relationStaffIds = staffClerkRelationService.listRelationsStaffId(staffMap.keySet());
if (CollectionUtils.isNotEmpty(relationStaffIds)) {
TabHaobanStaff staff = staffMap.get(relationStaffIds.get(0));
staffService.delOtherStaffByWxUserId(staff.getWxUserId(), staff.getStaffId(), wxEnterpriseId);
}
staffDTO = EntityUtil.changeEntityByJSON(StaffDTO.class, staffService.selectByUserIdAndEnterpriseId(userId, wxEnterpriseId));
}
return staffDTO;
}
@Override
public StaffDepartmentRelatedDTO getDepartmentIdAndStaffId(String departmentId, String staffId) { public StaffDepartmentRelatedDTO getDepartmentIdAndStaffId(String departmentId, String staffId) {
TabHaobanStaffDepartmentRelated tab = staffDepartmentRelatedService.getDepartmentIdAndStaffId(departmentId, staffId); TabHaobanStaffDepartmentRelated tab = staffDepartmentRelatedService.getDepartmentIdAndStaffId(departmentId, staffId);
return EntityUtil.changeEntityByJSON(StaffDepartmentRelatedDTO.class, tab); return EntityUtil.changeEntityByJSON(StaffDepartmentRelatedDTO.class, tab);
......
...@@ -110,8 +110,9 @@ public class WxEnterpriseInfoController extends WebBaseController { ...@@ -110,8 +110,9 @@ public class WxEnterpriseInfoController extends WebBaseController {
WxEnterpriseDTO enterprise = wxEnterpriseApiService.getEnterpriseBycorpId(corpId); WxEnterpriseDTO enterprise = wxEnterpriseApiService.getEnterpriseBycorpId(corpId);
StaffDTO loginStaff = null; StaffDTO loginStaff = null;
if (enterprise != null) { if (enterprise != null) {
loginStaff = staffApiService.selectByUserIdAndEnterpriseId(userId, enterprise.getWxEnterpriseId()); loginStaff = staffApiService.getByUserIdAndReflushWhenNoPhone(userId, enterprise.getWxEnterpriseId());
} }
//手机号不存在
if (loginStaff == null) { if (loginStaff == null) {
if (enterprise != null) { if (enterprise != null) {
staffApiService.wxGetAdd(userId, enterprise.getWxEnterpriseId()); staffApiService.wxGetAdd(userId, enterprise.getWxEnterpriseId());
......
...@@ -190,7 +190,7 @@ public enum HaoBanErrCode { ...@@ -190,7 +190,7 @@ public enum HaoBanErrCode {
ERR_500001(500001, "该企业没关联好办"), ERR_500001(500001, "该企业没关联好办"),
ERR_500003(500003, "企业corpid不对应,需要重新登录传code"), ERR_500003(500003, "企业corpid不对应,需要重新登录传code"),
ERR_600001(600001, "成员不存在,请联系管理员后台授权通讯录权限"), ERR_600001(600001, "成员不存在,请联系管理员后台授权通讯录权限"),
ERR_600002(600002, "成员无手机号,请在企业微信绑定手机号"), ERR_600002(600002, "成员验证失败,请先确认成员企微后台是否绑定手机号,如已绑定,请退出重新授权登录"),
ERR_600003(600003, "未获取成员openid"), ERR_600003(600003, "未获取成员openid"),
ERR_10004(10004,"成员名称不能为空"), ERR_10004(10004,"成员名称不能为空"),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment