Commit f58de234 by fudahua

feat:先查看user是否存在再看手机号是否存在

parent 813fac7b
...@@ -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,27 @@ public class StaffServiceImpl implements StaffService { ...@@ -72,6 +76,27 @@ 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.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)) {
return staffMap.get(relationStaffIds.get(0));
}
}
return this.selectByPhoneNumberAndEnterpriseId(phoneNumber, wxEnterpriseId);
}
@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);
} }
......
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