Commit 96fff103 by 墨竹

Merge branch 'fixbug_0525' into developer

# Conflicts:
#	haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/out/impl/StaffClerkRelationApiServiceImpl.java
parents b16bf3ec 489bfb20
...@@ -183,4 +183,15 @@ public interface DepartmentApiService { ...@@ -183,4 +183,15 @@ public interface DepartmentApiService {
*/ */
List<DepartmentShortDTO> listAllDepartment(String wxEnterpriseId); List<DepartmentShortDTO> listAllDepartment(String wxEnterpriseId);
/**
* 获取子部门ids
*
* @param departmentId 部门id设置
* @param wxEnterpriseId wx企业标识
* @return {@link List }<{@link String }>
* @author mozhu
* @date 2022-05-24 17:45:57
*/
List<String> listSonDeptIdsByDepartmentId(String departmentId, String wxEnterpriseId);
} }
...@@ -23,7 +23,8 @@ public interface StaffApiService { ...@@ -23,7 +23,8 @@ public interface StaffApiService {
List<StaffDepartmentRelatedDTO> listStaffDepartmentByStaffId(String staffId); List<StaffDepartmentRelatedDTO> listStaffDepartmentByStaffId(String staffId);
Page<StaffDTO> pageStaff(List<String> departmentId, Integer activeFlag, String keyword, BasePageInfo pageInfo, Integer relationFlag); Page<StaffDTO> pageStaff(List<String> departmentId, Integer activeFlag,
String keyword, BasePageInfo pageInfo, Integer relationFlag,String wxEnterpriseId);
@Deprecated @Deprecated
void del(String staffDepartmentStaffRelatedId); void del(String staffDepartmentStaffRelatedId);
......
...@@ -5,7 +5,6 @@ import com.github.pagehelper.Page; ...@@ -5,7 +5,6 @@ import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
import java.util.Set;
public interface StaffMapper { public interface StaffMapper {
int deleteByPrimaryKey(String staffId); int deleteByPrimaryKey(String staffId);
...@@ -24,7 +23,12 @@ public interface StaffMapper { ...@@ -24,7 +23,12 @@ public interface StaffMapper {
List<TabHaobanStaff> listLikeName(@Param("staffName") String staffName, @Param("wxEnterpriseId") String wxEnterpriseId); List<TabHaobanStaff> listLikeName(@Param("staffName") String staffName, @Param("wxEnterpriseId") String wxEnterpriseId);
Page<TabHaobanStaff> pageStaff(@Param("staffIds") Set<String> staffIds, @Param("activeFlag") Integer activeFlag, @Param("keyword") String keyword); Page<TabHaobanStaff> pageStaff(@Param("staffIds") List<String> staffIds,
@Param("activeFlag") Integer activeFlag,
@Param("keyword") String keyword,
@Param("departmentIds") List<String> departmentIds,
@Param("wxEnterpriseId") String wxEnterpriseId,
@Param("relationFlag") Integer relationFlag);
/** /**
* 选择用户id和企业标识 * 选择用户id和企业标识
......
...@@ -82,7 +82,7 @@ public interface StaffClerkRelationService { ...@@ -82,7 +82,7 @@ public interface StaffClerkRelationService {
List<StaffClerkRelationDTO> listByClerkIds(List<String> clerkList); List<StaffClerkRelationDTO> listByClerkIds(List<String> clerkList);
List<StaffClerkRelationDTO> lisByStaffId(String wxEnterpriseId, String staffId); List<StaffClerkRelationDTO> listByStaffId(String wxEnterpriseId, String staffId);
/** /**
* 保存 * 保存
......
...@@ -23,6 +23,13 @@ public interface StaffDepartmentRelatedService { ...@@ -23,6 +23,13 @@ public interface StaffDepartmentRelatedService {
int countByDepartmentId(String departmentId); int countByDepartmentId(String departmentId);
/**
* 效率很低
* @param departmentId
* @param keyword
* @return
*/
@Deprecated
List<TabHaobanStaffDepartmentRelated> listByDepartmentIdByKeyword(List<String> departmentId, String keyword); List<TabHaobanStaffDepartmentRelated> listByDepartmentIdByKeyword(List<String> departmentId, String keyword);
List<TabHaobanStaffDepartmentRelated> listByWxUserId(String wxUserId); List<TabHaobanStaffDepartmentRelated> listByWxUserId(String wxUserId);
......
...@@ -5,7 +5,6 @@ import com.gic.haoban.manage.service.entity.TabHaobanStaff; ...@@ -5,7 +5,6 @@ import com.gic.haoban.manage.service.entity.TabHaobanStaff;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import java.util.List; import java.util.List;
import java.util.Set;
public interface StaffService { public interface StaffService {
...@@ -15,7 +14,8 @@ public interface StaffService { ...@@ -15,7 +14,8 @@ public interface StaffService {
String add(TabHaobanStaff tab); String add(TabHaobanStaff tab);
Page<TabHaobanStaff> pageStaff(Set<String> staffIds, Integer activeFlag, String keyword); Page<TabHaobanStaff> pageStaff(List<String> staffIds, Integer activeFlag,
String keyword,List<String> departmentIds,String wxEnterpriseId,Integer relationFlag);
void updateByPrimaryKey(TabHaobanStaff tab); void updateByPrimaryKey(TabHaobanStaff tab);
......
...@@ -99,7 +99,7 @@ public class ClerkMainStoreRelatedServiceImpl implements ClerkMainStoreRelatedSe ...@@ -99,7 +99,7 @@ public class ClerkMainStoreRelatedServiceImpl implements ClerkMainStoreRelatedSe
* @return * @return
*/ */
private TabHaobanClerkMainStoreRelated setStaffMainStore(String staffId, String wxEnterpriseId) { private TabHaobanClerkMainStoreRelated setStaffMainStore(String staffId, String wxEnterpriseId) {
List<StaffClerkRelationDTO> clerkRelationDTOS = staffClerkRelationService.lisByStaffId(wxEnterpriseId, staffId); List<StaffClerkRelationDTO> clerkRelationDTOS = staffClerkRelationService.listByStaffId(wxEnterpriseId, staffId);
if (CollectionUtils.isEmpty(clerkRelationDTOS)) { if (CollectionUtils.isEmpty(clerkRelationDTOS)) {
return null; return null;
} }
......
...@@ -138,7 +138,7 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService ...@@ -138,7 +138,7 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService
} }
String staffId = staffClerkRelation.getStaffId(); String staffId = staffClerkRelation.getStaffId();
String wxEnterpriseId = staffClerkRelation.getWxEnterpriseId(); String wxEnterpriseId = staffClerkRelation.getWxEnterpriseId();
List<StaffClerkRelationDTO> list = this.lisByStaffId(wxEnterpriseId, staffId); List<StaffClerkRelationDTO> list = this.listByStaffId(wxEnterpriseId, staffId);
if (list != null && list.size() == 1) { if (list != null && list.size() == 1) {
clerkMainStoreRelatedService.setMainStore(staffId, staffClerkRelation.getStoreId(), wxEnterpriseId); clerkMainStoreRelatedService.setMainStore(staffId, staffClerkRelation.getStoreId(), wxEnterpriseId);
} }
...@@ -240,7 +240,7 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService ...@@ -240,7 +240,7 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService
} }
@Override @Override
public List<StaffClerkRelationDTO> lisByStaffId(String wxEnterpriseId, String staffId) { public List<StaffClerkRelationDTO> listByStaffId(String wxEnterpriseId, String staffId) {
return EntityUtil.changeEntityListByJSON(StaffClerkRelationDTO.class, mapper.lisByStaffId(wxEnterpriseId, staffId)); return EntityUtil.changeEntityListByJSON(StaffClerkRelationDTO.class, mapper.lisByStaffId(wxEnterpriseId, staffId));
} }
......
...@@ -16,7 +16,10 @@ import org.apache.logging.log4j.Logger; ...@@ -16,7 +16,10 @@ 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.*; import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
...@@ -61,8 +64,8 @@ public class StaffServiceImpl implements StaffService { ...@@ -61,8 +64,8 @@ public class StaffServiceImpl implements StaffService {
} }
@Override @Override
public Page<TabHaobanStaff> pageStaff(Set<String> staffIds, Integer activeFlag, String keyword) { public Page<TabHaobanStaff> pageStaff(List<String> staffIds, Integer activeFlag, String keyword,List<String> departmentIds,String wxEnterpriseId,Integer relationFlag) {
return mapper.pageStaff(staffIds, activeFlag, keyword); return mapper.pageStaff(staffIds, activeFlag, keyword,departmentIds,wxEnterpriseId,relationFlag);
} }
@Override @Override
......
...@@ -532,4 +532,21 @@ public class DepartmentApiServiceImpl implements DepartmentApiService { ...@@ -532,4 +532,21 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
List<DepartmentShortDTO> list = departmentService.listAllDepartment(wxEnterpriseId); List<DepartmentShortDTO> list = departmentService.listAllDepartment(wxEnterpriseId);
return list; return list;
} }
@Override
public List<String> listSonDeptIdsByDepartmentId(String departmentId, String wxEnterpriseId) {
List<String> list = new ArrayList<>();
String chainId = "";
TabHaobanDepartment department = departmentService.selectById(departmentId);
if (department != null) {
chainId = department.getChainId() + Constant.ID_SEPARATOR + departmentId;
}
list.add(departmentId);
if (StringUtils.isNotBlank(chainId)) {
List<TabHaobanDepartment> tabList = departmentService.listByChainId(chainId, wxEnterpriseId);
List<String> departmentIds = tabList.stream().map(TabHaobanDepartment::getDepartmentId).collect(Collectors.toList());
list.addAll(departmentIds);
}
return list;
}
} }
...@@ -51,7 +51,6 @@ import org.springframework.stereotype.Service; ...@@ -51,7 +51,6 @@ import org.springframework.stereotype.Service;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
...@@ -211,46 +210,23 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -211,46 +210,23 @@ public class StaffApiServiceImpl implements StaffApiService {
} }
@Override @Override
public Page<StaffDTO> pageStaff(List<String> departmentIds, Integer activeFlag, String keyword, BasePageInfo pageInfo, Integer relationFlag) { public Page<StaffDTO> pageStaff(List<String> departmentIds, Integer activeFlag, String keyword, BasePageInfo pageInfo, Integer relationFlag,String wxEnterpriseId) {
// 部门 员工列表 List<String> staffIds = new ArrayList<>();
List<TabHaobanStaffDepartmentRelated> list = staffDepartmentRelatedService.listByDepartmentIdByKeyword(departmentIds, keyword); if (relationFlag != null) {
List<TabHaobanStaffClerkRelation> relationList = staffClerkRelationService.listByWxEnterpriseId(wxEnterpriseId);
if (CollectionUtils.isEmpty(list)) { staffIds = relationList.stream().map(TabHaobanStaffClerkRelation::getStaffId).collect(Collectors.toList());
return new Page<>();
} }
// 当前部门的所有员工id列表
Set<String> staffIdSet = list.stream().map(TabHaobanStaffDepartmentRelated::getStaffId).collect(Collectors.toSet());
// 查询当前部门所有已关联导购的员工id列表
List<String> relationsStaffIdList = staffClerkRelationService.listRelationsStaffId(staffIdSet);
Set<String> relationStaffSet = new HashSet<>(relationsStaffIdList);
logger.info("已关联的员工id列表:{}", JSON.toJSONString(relationStaffSet));
Set<String> queryStaffSet = filterByRelationFlag(staffIdSet, relationStaffSet, relationFlag);
if (CollectionUtils.isEmpty(queryStaffSet)) {
return new Page<>();
}
// 分页
PageHelper.startPage(pageInfo.getPageNum(), pageInfo.getPageSize()); PageHelper.startPage(pageInfo.getPageNum(), pageInfo.getPageSize());
Page<StaffDTO> page = PageUtil.changePageHelperToCurrentPage(staffService.pageStaff(queryStaffSet, activeFlag, ""), StaffDTO.class); Page<StaffDTO> page = PageUtil.changePageHelperToCurrentPage(staffService.pageStaff(staffIds, activeFlag, keyword,departmentIds,wxEnterpriseId,relationFlag), StaffDTO.class);
List<StaffDTO> staffDTOList = page.getResult();
if (CollectionUtils.isEmpty(page.getResult())) { if (CollectionUtils.isEmpty(staffDTOList)) {
return new Page<>(); return new Page<>();
} }
staffDTOList.forEach(one -> {
Map<String, TabHaobanStaffDepartmentRelated> map = list.stream() //one.setDepartmentIds(Objects.isNull(related) ? null : related.getDepartmentId());
.collect(Collectors.toMap(TabHaobanStaffDepartmentRelated::getStaffId, Function.identity(), (s1, s2) -> s2));
page.getResult().forEach(one -> {
TabHaobanStaffDepartmentRelated related = map.get(one.getStaffId());
one.setDepartmentIds(Objects.isNull(related) ? null : related.getDepartmentId());
// 关联状态 // 关联状态
one.setRelationFlag(relationStaffSet.contains(one.getStaffId()) ? 1 : 0); List<StaffClerkRelationDTO> staffClerkRelationDTOS = staffClerkRelationService.listByStaffId(wxEnterpriseId, one.getStaffId());
one.setRelationFlag(CollectionUtils.isNotEmpty(staffClerkRelationDTOS) ? 1 : 0);
}); });
return page; return page;
......
package com.gic.haoban.manage.service.service.out.impl; package com.gic.haoban.manage.service.service.out.impl;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.Page; import com.gic.api.base.commons.Page;
import com.gic.clerk.api.dto.ClerkDTO; import com.gic.clerk.api.dto.ClerkDTO;
import com.gic.clerk.api.service.ClerkService; import com.gic.clerk.api.service.ClerkService;
import com.gic.commons.util.EntityUtil; import com.gic.commons.util.EntityUtil;
import com.gic.enterprise.api.dto.EnterpriseDTO; import com.gic.enterprise.api.dto.EnterpriseDTO;
import com.gic.enterprise.api.dto.StoreDTO; import com.gic.enterprise.api.dto.StoreDTO;
import com.gic.enterprise.api.service.EnterpriseService; import com.gic.enterprise.api.service.EnterpriseService;
import com.gic.enterprise.api.service.StoreService; import com.gic.enterprise.api.service.StoreService;
import com.gic.haoban.base.api.common.BasePageInfo; import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.base.api.common.ServiceResponse; import com.gic.haoban.base.api.common.ServiceResponse;
import com.gic.haoban.manage.api.dto.*; import com.gic.haoban.manage.api.dto.*;
import com.gic.haoban.manage.api.enums.AuditType; import com.gic.haoban.manage.api.enums.AuditType;
import com.gic.haoban.manage.api.enums.BindTypeEnum; import com.gic.haoban.manage.api.enums.BindTypeEnum;
import com.gic.haoban.manage.api.enums.ChannelCodeEnum; import com.gic.haoban.manage.api.enums.ChannelCodeEnum;
import com.gic.haoban.manage.api.enums.SecretTypeEnum; import com.gic.haoban.manage.api.enums.SecretTypeEnum;
import com.gic.haoban.manage.api.service.AuditApiService; import com.gic.haoban.manage.api.service.AuditApiService;
import com.gic.haoban.manage.api.service.StaffClerkRelationApiService; import com.gic.haoban.manage.api.service.StaffClerkRelationApiService;
import com.gic.haoban.manage.service.dao.mapper.TabHaobanStaffClerkRelationMapper; import com.gic.haoban.manage.service.dao.mapper.TabHaobanStaffClerkRelationMapper;
import com.gic.haoban.manage.service.entity.*; import com.gic.haoban.manage.service.entity.*;
import com.gic.haoban.manage.service.service.*; import com.gic.haoban.manage.service.service.*;
import com.gic.wechat.api.dto.qywx.welcome.QywxExternalcontactDTO; import com.gic.wechat.api.dto.qywx.welcome.QywxExternalcontactDTO;
import com.gic.wechat.api.service.qywx.QywxUserApiService; import com.gic.wechat.api.service.qywx.QywxUserApiService;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
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.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiService { public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiService {
private static final Logger logger = LoggerFactory.getLogger(StaffClerkRelationApiServiceImpl.class); private static final Logger logger = LoggerFactory.getLogger(StaffClerkRelationApiServiceImpl.class);
@Autowired @Autowired
private StaffClerkRelationService staffClerkRelatinService; private StaffClerkRelationService staffClerkRelatinService;
@Autowired @Autowired
private EnterpriseService enterpriseService; private EnterpriseService enterpriseService;
@Autowired @Autowired
private ClerkService clerkService; private ClerkService clerkService;
@Autowired @Autowired
private StoreService storeService; private StoreService storeService;
@Autowired @Autowired
private TabHaobanStaffClerkRelationMapper tabHaobanStaffClerkRelationMapper; private TabHaobanStaffClerkRelationMapper tabHaobanStaffClerkRelationMapper;
@Autowired @Autowired
private AuditApiService auditApiService; private AuditApiService auditApiService;
@Autowired @Autowired
private ClerkMainStoreRelatedService clerkMainStoreRelatedService; private ClerkMainStoreRelatedService clerkMainStoreRelatedService;
@Autowired @Autowired
private StaffClerkBindLogService staffClerkBindLogService; private StaffClerkBindLogService staffClerkBindLogService;
@Autowired @Autowired
private WxEnterpriseRelatedService wxEnterpriseRelatedService; private WxEnterpriseRelatedService wxEnterpriseRelatedService;
@Autowired @Autowired
private StaffService staffService; private StaffService staffService;
@Autowired @Autowired
private ExternalClerkRelatedService externalClerkRelatedService; private ExternalClerkRelatedService externalClerkRelatedService;
@Autowired @Autowired
private QywxUserApiService qywxUserApiService; private QywxUserApiService qywxUserApiService;
@Autowired @Autowired
private SecretSettingService secretSettingService; private SecretSettingService secretSettingService;
@Autowired @Autowired
private WxEnterpriseService wxEnterpriseService; private WxEnterpriseService wxEnterpriseService;
@Override @Override
public void bindLogMq(String params) { public void bindLogMq(String params) {
logger.info("绑定日志mq:{}", params); logger.info("绑定日志mq:{}", params);
StaffClerkBindLogInfoDTO infoDTO = JSONObject.parseObject(params, StaffClerkBindLogInfoDTO.class); StaffClerkBindLogInfoDTO infoDTO = JSONObject.parseObject(params, StaffClerkBindLogInfoDTO.class);
if (null == infoDTO) { if (null == infoDTO) {
logger.info("数据不存在"); logger.info("数据不存在");
return; return;
} }
TabHaobanStaffClerkRelation clerkRelation = tabHaobanStaffClerkRelationMapper.selectByPrimaryKey(infoDTO.getRelationId()); TabHaobanStaffClerkRelation clerkRelation = tabHaobanStaffClerkRelationMapper.selectByPrimaryKey(infoDTO.getRelationId());
if (null == clerkRelation) { if (null == clerkRelation) {
logger.info("不存在绑定数据"); logger.info("不存在绑定数据");
return; return;
} }
ClerkDTO clerkDTO = clerkService.getClerkByClerkIdNoStatus(clerkRelation.getClerkId()); ClerkDTO clerkDTO = clerkService.getClerkByClerkIdNoStatus(clerkRelation.getClerkId());
String phoneNumber = ""; String phoneNumber = "";
if (null != clerkDTO) { if (null != clerkDTO) {
phoneNumber = clerkDTO.getPhoneNumber(); phoneNumber = clerkDTO.getPhoneNumber();
} }
TabHaobanStaffClerkBindLog staffClerkRelation = new TabHaobanStaffClerkBindLog(); TabHaobanStaffClerkBindLog staffClerkRelation = new TabHaobanStaffClerkBindLog();
staffClerkRelation.setClerkId(clerkRelation.getClerkId()); staffClerkRelation.setClerkId(clerkRelation.getClerkId());
staffClerkRelation.setChannelCode(infoDTO.getChannelCode()); staffClerkRelation.setChannelCode(infoDTO.getChannelCode());
staffClerkRelation.setClerkCode(clerkRelation.getClerkCode()); staffClerkRelation.setClerkCode(clerkRelation.getClerkCode());
staffClerkRelation.setCreateTime(new Date()); staffClerkRelation.setCreateTime(new Date());
staffClerkRelation.setEnterpriseId(clerkRelation.getEnterpriseId()); staffClerkRelation.setEnterpriseId(clerkRelation.getEnterpriseId());
staffClerkRelation.setOptStaffId(infoDTO.getOptStaffId()); staffClerkRelation.setOptStaffId(infoDTO.getOptStaffId());
staffClerkRelation.setOptType(infoDTO.getOptType()); staffClerkRelation.setOptType(infoDTO.getOptType());
staffClerkRelation.setStatusFlag(1); staffClerkRelation.setStatusFlag(1);
staffClerkRelation.setStaffId(clerkRelation.getStaffId()); staffClerkRelation.setStaffId(clerkRelation.getStaffId());
staffClerkRelation.setWxEnterpriseId(clerkRelation.getWxEnterpriseId()); staffClerkRelation.setWxEnterpriseId(clerkRelation.getWxEnterpriseId());
staffClerkRelation.setRelationId(infoDTO.getRelationId()); staffClerkRelation.setRelationId(infoDTO.getRelationId());
staffClerkRelation.setClerkPhone(phoneNumber); staffClerkRelation.setClerkPhone(phoneNumber);
staffClerkRelation.setUpdateTime(new Date()); staffClerkRelation.setUpdateTime(new Date());
staffClerkBindLogService.insert(staffClerkRelation); staffClerkBindLogService.insert(staffClerkRelation);
} }
@Override @Override
public List<StaffClerkRelationDTO> listBindCode(String enterpriseId, Set<String> clerkCodeList) { public List<StaffClerkRelationDTO> listBindCode(String enterpriseId, Set<String> clerkCodeList) {
return staffClerkRelatinService.listBindCode(enterpriseId, clerkCodeList); return staffClerkRelatinService.listBindCode(enterpriseId, clerkCodeList);
} }
@Override @Override
public List<StaffClerkRelationDTO> listBindCodeByStaffId(List<String> enterpriseIdList, String staffId) { public List<StaffClerkRelationDTO> listBindCodeByStaffId(List<String> enterpriseIdList, String staffId) {
return staffClerkRelatinService.listBindCodeByStaffId(enterpriseIdList, staffId); return staffClerkRelatinService.listBindCodeByStaffId(enterpriseIdList, staffId);
} }
@Override @Override
public List<StaffClerkInfoDTO> listBindDetailByStaffId(String staffId) { public List<StaffClerkInfoDTO> listBindDetailByStaffId(String staffId) {
List<StaffClerkRelationDTO> list = staffClerkRelatinService.listBindCodeByStaffId(null, staffId); List<StaffClerkRelationDTO> list = staffClerkRelatinService.listBindCodeByStaffId(null, staffId);
if (CollectionUtils.isEmpty(list)) { if (CollectionUtils.isEmpty(list)) {
return null; return null;
} }
List<StaffClerkInfoDTO> infoDTOS = EntityUtil.changeEntityListByJSON(StaffClerkInfoDTO.class, list); List<StaffClerkInfoDTO> infoDTOS = EntityUtil.changeEntityListByJSON(StaffClerkInfoDTO.class, list);
Map<String, String> nameMap = new HashMap<>(); Map<String, String> nameMap = new HashMap<>();
infoDTOS.forEach(infoDTO -> { infoDTOS.forEach(infoDTO -> {
//企业 //企业
if (!nameMap.containsKey(infoDTO.getEnterpriseId())) { if (!nameMap.containsKey(infoDTO.getEnterpriseId())) {
EnterpriseDTO enterpriseDTO = enterpriseService.getEnterpriseById(infoDTO.getEnterpriseId()); EnterpriseDTO enterpriseDTO = enterpriseService.getEnterpriseById(infoDTO.getEnterpriseId());
if (null != enterpriseDTO) { if (null != enterpriseDTO) {
nameMap.put(infoDTO.getEnterpriseId(), enterpriseDTO.getEnterpriseName() + "_" + enterpriseDTO.getBrandName()); nameMap.put(infoDTO.getEnterpriseId(), enterpriseDTO.getEnterpriseName() + "_" + enterpriseDTO.getBrandName());
} else { } else {
nameMap.put(infoDTO.getEnterpriseId(), "未知商户"); nameMap.put(infoDTO.getEnterpriseId(), "未知商户");
} }
} }
//门店店员名称 //门店店员名称
if (!nameMap.containsKey(infoDTO.getClerkId())) { if (!nameMap.containsKey(infoDTO.getClerkId())) {
ClerkDTO clerkDTO = clerkService.getClerkByClerkId(infoDTO.getClerkId()); ClerkDTO clerkDTO = clerkService.getClerkByClerkId(infoDTO.getClerkId());
if (null != clerkDTO) { if (null != clerkDTO) {
nameMap.put(infoDTO.getClerkId(), clerkDTO.getClerkName()); nameMap.put(infoDTO.getClerkId(), clerkDTO.getClerkName());
nameMap.put(infoDTO.getStoreId(), clerkDTO.getStoreName()); nameMap.put(infoDTO.getStoreId(), clerkDTO.getStoreName());
infoDTO.setClerkPhoneNumber(clerkDTO.getPhoneNumber()); infoDTO.setClerkPhoneNumber(clerkDTO.getPhoneNumber());
} else { } else {
nameMap.put(infoDTO.getClerkId(), "未知店员"); nameMap.put(infoDTO.getClerkId(), "未知店员");
} }
} }
//门店店员名称 //门店店员名称
if (!nameMap.containsKey(infoDTO.getStoreId())) { if (!nameMap.containsKey(infoDTO.getStoreId())) {
StoreDTO storeDTO = storeService.getStore(infoDTO.getStoreId()); StoreDTO storeDTO = storeService.getStore(infoDTO.getStoreId());
if (null != storeDTO) { if (null != storeDTO) {
nameMap.put(infoDTO.getStoreId(), storeDTO.getStoreName()); nameMap.put(infoDTO.getStoreId(), storeDTO.getStoreName());
} else { } else {
nameMap.put(infoDTO.getStoreId(), "未知门店"); nameMap.put(infoDTO.getStoreId(), "未知门店");
} }
} }
infoDTO.setClerkName(nameMap.get(infoDTO.getClerkId())); infoDTO.setClerkName(nameMap.get(infoDTO.getClerkId()));
infoDTO.setStoreName(nameMap.get(infoDTO.getStoreId())); infoDTO.setStoreName(nameMap.get(infoDTO.getStoreId()));
if ((nameMap.get(infoDTO.getEnterpriseId())) != null) { if ((nameMap.get(infoDTO.getEnterpriseId())) != null) {
String EnterpriseandBrandName = nameMap.get(infoDTO.getEnterpriseId()); String EnterpriseandBrandName = nameMap.get(infoDTO.getEnterpriseId());
String[] split = EnterpriseandBrandName.split("_"); String[] split = EnterpriseandBrandName.split("_");
infoDTO.setEnterpriseName(split[0]); infoDTO.setEnterpriseName(split[0]);
if (split[1] != null) { if (split[1] != null) {
infoDTO.setBrandName(split[1]); infoDTO.setBrandName(split[1]);
} }
} }
}); });
return infoDTOS; return infoDTOS;
} }
@Override @Override
public ServiceResponse bindStaffClerk(StaffClerkRelationDTO staffClerkRelationDTO, String optStaffId, int chanelCode) { public ServiceResponse bindStaffClerk(StaffClerkRelationDTO staffClerkRelationDTO, String optStaffId, int chanelCode) {
logger.info("绑定clerk:{}", JSONObject.toJSONString(staffClerkRelationDTO)); logger.info("绑定clerk:{}", JSONObject.toJSONString(staffClerkRelationDTO));
ServiceResponse<Object> response = new ServiceResponse<>(); ServiceResponse<Object> response = new ServiceResponse<>();
StaffClerkRelationDTO relationDTO = staffClerkRelatinService.getBindByClerkId(staffClerkRelationDTO.getClerkId(), staffClerkRelationDTO.getWxEnterpriseId()); StaffClerkRelationDTO relationDTO = staffClerkRelatinService.getBindByClerkId(staffClerkRelationDTO.getClerkId(), staffClerkRelationDTO.getWxEnterpriseId());
if (null != relationDTO) { if (null != relationDTO) {
response.setCode(2); response.setCode(2);
response.setMessage("已经被绑定,不能绑定"); response.setMessage("已经被绑定,不能绑定");
return response; return response;
} }
AuditDTO auditDTO = auditApiService.findByBindRelatedIdAndAuditType(staffClerkRelationDTO.getClerkId(), AuditType.CLERK_BIND.getCode()); AuditDTO auditDTO = auditApiService.findByBindRelatedIdAndAuditType(staffClerkRelationDTO.getClerkId(), AuditType.CLERK_BIND.getCode());
if (null != auditDTO) { if (null != auditDTO) {
response.setCode(4); response.setCode(4);
response.setMessage("该导购已经被被申请绑定,请审核处理后再绑定"); response.setMessage("该导购已经被被申请绑定,请审核处理后再绑定");
return response; return response;
} }
List<AuditDTO> list = auditApiService.listByStoreId(staffClerkRelationDTO.getStoreId()); List<AuditDTO> list = auditApiService.listByStoreId(staffClerkRelationDTO.getStoreId());
if (CollectionUtils.isNotEmpty(list)) { if (CollectionUtils.isNotEmpty(list)) {
Set<String> staffIds = list.stream().map(AuditDTO::getCommitStaffId).collect(Collectors.toSet()); Set<String> staffIds = list.stream().map(AuditDTO::getCommitStaffId).collect(Collectors.toSet());
if (staffIds.contains(staffClerkRelationDTO.getStaffId())) { if (staffIds.contains(staffClerkRelationDTO.getStaffId())) {
response.setCode(5); response.setCode(5);
response.setMessage("该成员已经已经在该门店下申请了绑定,请审核处理后再绑定"); response.setMessage("该成员已经已经在该门店下申请了绑定,请审核处理后再绑定");
return response; return response;
} }
} }
StaffClerkRelationDTO storeHasBind = staffClerkRelatinService.getOneBindByStoreId(staffClerkRelationDTO.getStaffId(), staffClerkRelationDTO.getStoreId()); StaffClerkRelationDTO storeHasBind = staffClerkRelatinService.getOneBindByStoreId(staffClerkRelationDTO.getStaffId(), staffClerkRelationDTO.getStoreId());
if (storeHasBind != null) { if (storeHasBind != null) {
response.setCode(3); response.setCode(3);
response.setMessage("该导购已在该门店下有其它成员绑定"); response.setMessage("该导购已在该门店下有其它成员绑定");
return response; return response;
} }
String relationId = staffClerkRelatinService.bind(staffClerkRelationDTO, optStaffId, chanelCode); String relationId = staffClerkRelatinService.bind(staffClerkRelationDTO, optStaffId, chanelCode);
response.setResult(relationId); response.setResult(relationId);
return response; return response;
} }
@Override @Override
public StaffClerkRelationDTO getByCodeAndEnterpriseId(String clerkCode, String enterpriseId) { public StaffClerkRelationDTO getByCodeAndEnterpriseId(String clerkCode, String enterpriseId) {
return staffClerkRelatinService.getByCodeAndEnterpriseId(clerkCode, enterpriseId); return staffClerkRelatinService.getByCodeAndEnterpriseId(clerkCode, enterpriseId);
} }
@Override @Override
public String delByStoreIdAndCode(String storeId, String clerkCode) { public String delByStoreIdAndCode(String storeId, String clerkCode) {
TabHaobanStaffClerkRelation staffClerkRelation = tabHaobanStaffClerkRelationMapper.getByCodeAndStoreId(clerkCode, storeId); TabHaobanStaffClerkRelation staffClerkRelation = tabHaobanStaffClerkRelationMapper.getByCodeAndStoreId(clerkCode, storeId);
tabHaobanStaffClerkRelationMapper.delByStoreIdAndCode(storeId, clerkCode); tabHaobanStaffClerkRelationMapper.delByStoreIdAndCode(storeId, clerkCode);
delSetMainStore(staffClerkRelation); delSetMainStore(staffClerkRelation);
return null; return null;
} }
@Override @Override
public List<StaffClerkRelationDTO> listByClerkIds(List<String> clerkIds) { public List<StaffClerkRelationDTO> listByClerkIds(List<String> clerkIds) {
if (CollectionUtil.isEmpty(clerkIds)) { if (CollectionUtil.isEmpty(clerkIds)) {
return Collections.EMPTY_LIST; return Collections.EMPTY_LIST;
} }
return tabHaobanStaffClerkRelationMapper.listByClerkIds(clerkIds); return tabHaobanStaffClerkRelationMapper.listByClerkIds(clerkIds);
} }
@Override @Override
public List<StaffClerkRelationDTO> listByStoreId(String storeId) { public List<StaffClerkRelationDTO> listByStoreId(String storeId) {
List<TabHaobanStaffClerkRelation> list = tabHaobanStaffClerkRelationMapper.listByStoreId(storeId); List<TabHaobanStaffClerkRelation> list = tabHaobanStaffClerkRelationMapper.listByStoreId(storeId);
if (CollectionUtil.isEmpty(list)) { if (CollectionUtil.isEmpty(list)) {
return new ArrayList<StaffClerkRelationDTO>(); return new ArrayList<StaffClerkRelationDTO>();
} }
List<StaffClerkRelationDTO> result = EntityUtil.changeEntityListByJSON(StaffClerkRelationDTO.class, list); List<StaffClerkRelationDTO> result = EntityUtil.changeEntityListByJSON(StaffClerkRelationDTO.class, list);
return result; return result;
} }
@Override @Override
public boolean unbindByStaffAndClerkId(String staffId, String clerkId) { public boolean unbindByStaffAndClerkId(String staffId, String clerkId) {
return staffClerkRelatinService.delBind(clerkId, staffId, ChannelCodeEnum.ADMIN_UNBIND.getCode()); return staffClerkRelatinService.delBind(clerkId, staffId, ChannelCodeEnum.ADMIN_UNBIND.getCode());
} }
@Override @Override
public StaffClerkRelationDTO getOneByClerkId(String clerkId) { public StaffClerkRelationDTO getOneByClerkId(String clerkId) {
TabHaobanStaffClerkRelation tab = tabHaobanStaffClerkRelationMapper.getOneByClerkId(clerkId); TabHaobanStaffClerkRelation tab = tabHaobanStaffClerkRelationMapper.getOneByClerkId(clerkId);
StaffClerkRelationDTO result = EntityUtil.changeEntityByJSON(StaffClerkRelationDTO.class, tab); StaffClerkRelationDTO result = EntityUtil.changeEntityByJSON(StaffClerkRelationDTO.class, tab);
return result; return result;
} }
@Override @Override
public StaffClerkRelationDTO getByClerkId(String clerkId) { public StaffClerkRelationDTO getByClerkId(String clerkId) {
StaffClerkRelationDTO staffRelation = staffClerkRelatinService.getByClerkId(clerkId); StaffClerkRelationDTO staffRelation = staffClerkRelatinService.getByClerkId(clerkId);
return staffRelation; return staffRelation;
} }
@Override @Override
public StaffClerkRelationDTO getOneByStoreIdAndStaffId(String storeId, public StaffClerkRelationDTO getOneByStoreIdAndStaffId(String storeId,
String staffId) { String staffId) {
TabHaobanStaffClerkRelation tab = tabHaobanStaffClerkRelationMapper.getOneByStoreIdAndStaffId(storeId, staffId); TabHaobanStaffClerkRelation tab = tabHaobanStaffClerkRelationMapper.getOneByStoreIdAndStaffId(storeId, staffId);
if (tab == null) { if (tab == null) {
return null; return null;
} }
return EntityUtil.changeEntity(StaffClerkRelationDTO.class, tab); return EntityUtil.changeEntity(StaffClerkRelationDTO.class, tab);
} }
@Override @Override
public void delAndInsert(StaffClerkRelationDTO staffClerkRelation, String optStaffId, int chanelCode) { public void delAndInsert(StaffClerkRelationDTO staffClerkRelation, String optStaffId, int chanelCode) {
if (StringUtils.isNotBlank(staffClerkRelation.getStaffClerkRelationId())) { if (StringUtils.isNotBlank(staffClerkRelation.getStaffClerkRelationId())) {
TabHaobanStaffClerkRelation oldStaffClerkRelation = tabHaobanStaffClerkRelationMapper.selectByPrimaryKey(staffClerkRelation.getStaffClerkRelationId()); TabHaobanStaffClerkRelation oldStaffClerkRelation = tabHaobanStaffClerkRelationMapper.selectByPrimaryKey(staffClerkRelation.getStaffClerkRelationId());
tabHaobanStaffClerkRelationMapper.delByPrimaryKey(staffClerkRelation.getStaffClerkRelationId()); tabHaobanStaffClerkRelationMapper.delByPrimaryKey(staffClerkRelation.getStaffClerkRelationId());
staffClerkBindLogService.pushToMq(oldStaffClerkRelation.getStaffId(), optStaffId, BindTypeEnum.UNBIND.getVal(), chanelCode, staffClerkRelation.getStaffClerkRelationId()); staffClerkBindLogService.pushToMq(oldStaffClerkRelation.getStaffId(), optStaffId, BindTypeEnum.UNBIND.getVal(), chanelCode, staffClerkRelation.getStaffClerkRelationId());
clerkMainStoreRelatedService.delMainStore(oldStaffClerkRelation.getStaffId(), oldStaffClerkRelation.getStoreId(), oldStaffClerkRelation.getWxEnterpriseId()); clerkMainStoreRelatedService.delMainStore(oldStaffClerkRelation.getStaffId(), oldStaffClerkRelation.getStoreId(), oldStaffClerkRelation.getWxEnterpriseId());
} }
String relationId = staffClerkRelatinService.insert(staffClerkRelation); String relationId = staffClerkRelatinService.insert(staffClerkRelation);
staffClerkBindLogService.pushToMq(staffClerkRelation.getStaffId(), optStaffId, BindTypeEnum.BIND.getVal(), chanelCode, relationId); staffClerkBindLogService.pushToMq(staffClerkRelation.getStaffId(), optStaffId, BindTypeEnum.BIND.getVal(), chanelCode, relationId);
//设置主门店 //设置主门店
clerkMainStoreRelatedService.getMainStoreByStaffId(staffClerkRelation.getStaffId(), staffClerkRelation.getWxEnterpriseId()); clerkMainStoreRelatedService.getMainStoreByStaffId(staffClerkRelation.getStaffId(), staffClerkRelation.getWxEnterpriseId());
} }
@Override @Override
public void delByClerkId(String clerkId) { public void delByClerkId(String clerkId) {
TabHaobanStaffClerkRelation staffClerkRelation = tabHaobanStaffClerkRelationMapper.getOneByClerkId(clerkId); TabHaobanStaffClerkRelation staffClerkRelation = tabHaobanStaffClerkRelationMapper.getOneByClerkId(clerkId);
tabHaobanStaffClerkRelationMapper.delByClerkId(clerkId); tabHaobanStaffClerkRelationMapper.delByClerkId(clerkId);
delSetMainStore(staffClerkRelation); delSetMainStore(staffClerkRelation);
} }
@Override @Override
public List<StaffClerkRelationDTO> listByEnterpriseIdAndWxUserId(String enterpriseId, String wxUserId) { public List<StaffClerkRelationDTO> listByEnterpriseIdAndWxUserId(String enterpriseId, String wxUserId) {
List<TabHaobanStaffClerkRelation> list = tabHaobanStaffClerkRelationMapper.listByEnterpriseIdAndWxUserId(enterpriseId, wxUserId); List<TabHaobanStaffClerkRelation> list = tabHaobanStaffClerkRelationMapper.listByEnterpriseIdAndWxUserId(enterpriseId, wxUserId);
return EntityUtil.changeEntityListByJSON(StaffClerkRelationDTO.class, list); return EntityUtil.changeEntityListByJSON(StaffClerkRelationDTO.class, list);
} }
@Override @Override
public Page<StaffClerkBindLogDetailDTO> pageStaffClerkBindLog(String wxEnterpriseId, String search, String enterpriseId, int optType, BasePageInfo pageInfo) { public Page<StaffClerkBindLogDetailDTO> pageStaffClerkBindLog(String wxEnterpriseId, String search, String enterpriseId, int optType, BasePageInfo pageInfo) {
List<TabHaobanWxEnterpriseRelated> wxEnterpriseRelateds = wxEnterpriseRelatedService.getByWxEnterpriseId(wxEnterpriseId); List<TabHaobanWxEnterpriseRelated> wxEnterpriseRelateds = wxEnterpriseRelatedService.getByWxEnterpriseId(wxEnterpriseId);
if (CollectionUtils.isEmpty(wxEnterpriseRelateds)) { if (CollectionUtils.isEmpty(wxEnterpriseRelateds)) {
logger.info("没有关联企业"); logger.info("没有关联企业");
return null; return null;
} }
List<String> enterpriseList = wxEnterpriseRelateds.stream().map(TabHaobanWxEnterpriseRelated::getEnterpriseId) List<String> enterpriseList = wxEnterpriseRelateds.stream().map(TabHaobanWxEnterpriseRelated::getEnterpriseId)
.filter(eid -> { .filter(eid -> {
if (StringUtils.isBlank(enterpriseId)) { if (StringUtils.isBlank(enterpriseId)) {
return true; return true;
} else { } else {
return enterpriseId.equals(eid); return enterpriseId.equals(eid);
} }
}).collect(Collectors.toList()); }).collect(Collectors.toList());
if (CollectionUtils.isEmpty(enterpriseList)) { if (CollectionUtils.isEmpty(enterpriseList)) {
logger.info("没有有效的企业"); logger.info("没有有效的企业");
return null; return null;
} }
List<String> clerkIds = null; List<String> clerkIds = null;
Page<StaffClerkBindLogDetailDTO> retList = staffClerkBindLogService.pageBindLog(wxEnterpriseId, clerkIds, null, enterpriseList, optType, search, pageInfo); Page<StaffClerkBindLogDetailDTO> retList = staffClerkBindLogService.pageBindLog(wxEnterpriseId, clerkIds, null, enterpriseList, optType, search, pageInfo);
if (CollectionUtils.isNotEmpty(retList.getResult())) { if (CollectionUtils.isNotEmpty(retList.getResult())) {
retList.getResult().forEach(staffClerkBindLogDetailDTO -> { retList.getResult().forEach(staffClerkBindLogDetailDTO -> {
TabHaobanStaff haobanStaff = staffService.selectById(staffClerkBindLogDetailDTO.getStaffId()); TabHaobanStaff haobanStaff = staffService.selectById(staffClerkBindLogDetailDTO.getStaffId());
if (null != haobanStaff) { if (null != haobanStaff) {
staffClerkBindLogDetailDTO.setStaffName(haobanStaff.getStaffName()); staffClerkBindLogDetailDTO.setStaffName(haobanStaff.getStaffName());
staffClerkBindLogDetailDTO.setWxUserId(haobanStaff.getWxUserId()); staffClerkBindLogDetailDTO.setWxUserId(haobanStaff.getWxUserId());
} else { } else {
staffClerkBindLogDetailDTO.setStaffName("未知成员"); staffClerkBindLogDetailDTO.setStaffName("未知成员");
} }
if ("-1".equals(staffClerkBindLogDetailDTO.getOptStaffId())) { if ("-1".equals(staffClerkBindLogDetailDTO.getOptStaffId())) {
staffClerkBindLogDetailDTO.setOptStaffName("系统"); staffClerkBindLogDetailDTO.setOptStaffName("系统");
} else { } else {
haobanStaff = staffService.selectById(staffClerkBindLogDetailDTO.getOptStaffId()); haobanStaff = staffService.selectById(staffClerkBindLogDetailDTO.getOptStaffId());
if (null != haobanStaff) { if (null != haobanStaff) {
staffClerkBindLogDetailDTO.setOptStaffName(haobanStaff.getStaffName()); staffClerkBindLogDetailDTO.setOptStaffName(haobanStaff.getStaffName());
} else { } else {
staffClerkBindLogDetailDTO.setOptStaffName("未知成员"); staffClerkBindLogDetailDTO.setOptStaffName("未知成员");
} }
} }
ClerkDTO clerkDTO = clerkService.getClerkByClerkIdNoStatus(staffClerkBindLogDetailDTO.getClerkId()); ClerkDTO clerkDTO = clerkService.getClerkByClerkIdNoStatus(staffClerkBindLogDetailDTO.getClerkId());
if (null != clerkDTO) { if (null != clerkDTO) {
staffClerkBindLogDetailDTO.setClerkName(clerkDTO.getClerkName()); staffClerkBindLogDetailDTO.setClerkName(clerkDTO.getClerkName());
} }
staffClerkBindLogDetailDTO.setClerkPhoneNumber(staffClerkBindLogDetailDTO.getClerkPhone()); staffClerkBindLogDetailDTO.setClerkPhoneNumber(staffClerkBindLogDetailDTO.getClerkPhone());
}); });
} }
return retList; return retList;
} }
@Override @Override
public Page<StaffClerkBindLogDetailDTO> pageStaffClerkUnBindLog(String wxEnterpriseId, String clerkId, String enterpriseId, int optType, BasePageInfo pageInfo) { public Page<StaffClerkBindLogDetailDTO> pageStaffClerkUnBindLog(String wxEnterpriseId, String clerkId, String enterpriseId, int optType, BasePageInfo pageInfo) {
if (wxEnterpriseId == null) { if (wxEnterpriseId == null) {
logger.info("没有关联企业"); logger.info("没有关联企业");
return null; return null;
} }
Page<StaffClerkBindLogDetailDTO> retList = staffClerkBindLogService.pageUnBindLog(wxEnterpriseId, clerkId, enterpriseId, optType, pageInfo); Page<StaffClerkBindLogDetailDTO> retList = staffClerkBindLogService.pageUnBindLog(wxEnterpriseId, clerkId, enterpriseId, optType, pageInfo);
if (CollectionUtils.isNotEmpty(retList.getResult())) { if (CollectionUtils.isNotEmpty(retList.getResult())) {
retList.getResult().forEach(staffClerkBindLogDetailDTO -> { retList.getResult().forEach(staffClerkBindLogDetailDTO -> {
TabHaobanStaff haobanStaff = staffService.selectById(staffClerkBindLogDetailDTO.getStaffId()); TabHaobanStaff haobanStaff = staffService.selectById(staffClerkBindLogDetailDTO.getStaffId());
if (null != haobanStaff) { if (null != haobanStaff) {
staffClerkBindLogDetailDTO.setStaffName(haobanStaff.getStaffName()); staffClerkBindLogDetailDTO.setStaffName(haobanStaff.getStaffName());
staffClerkBindLogDetailDTO.setWxUserId(haobanStaff.getWxUserId()); staffClerkBindLogDetailDTO.setWxUserId(haobanStaff.getWxUserId());
} else { } else {
staffClerkBindLogDetailDTO.setStaffName("未知成员"); staffClerkBindLogDetailDTO.setStaffName("未知成员");
} }
if ("-1".equals(staffClerkBindLogDetailDTO.getOptStaffId())) { if ("-1".equals(staffClerkBindLogDetailDTO.getOptStaffId())) {
staffClerkBindLogDetailDTO.setOptStaffName("系统"); staffClerkBindLogDetailDTO.setOptStaffName("系统");
} else { } else {
haobanStaff = staffService.selectById(staffClerkBindLogDetailDTO.getOptStaffId()); haobanStaff = staffService.selectById(staffClerkBindLogDetailDTO.getOptStaffId());
if (null != haobanStaff) { if (null != haobanStaff) {
staffClerkBindLogDetailDTO.setOptStaffName(haobanStaff.getStaffName()); staffClerkBindLogDetailDTO.setOptStaffName(haobanStaff.getStaffName());
} else { } else {
staffClerkBindLogDetailDTO.setOptStaffName("未知成员"); staffClerkBindLogDetailDTO.setOptStaffName("未知成员");
} }
} }
ClerkDTO clerkDTO = clerkService.getClerkByClerkIdNoStatus(staffClerkBindLogDetailDTO.getClerkId()); ClerkDTO clerkDTO = clerkService.getClerkByClerkIdNoStatus(staffClerkBindLogDetailDTO.getClerkId());
if (null != clerkDTO) { if (null != clerkDTO) {
staffClerkBindLogDetailDTO.setClerkName(clerkDTO.getClerkName()); staffClerkBindLogDetailDTO.setClerkName(clerkDTO.getClerkName());
} }
staffClerkBindLogDetailDTO.setClerkPhoneNumber(staffClerkBindLogDetailDTO.getClerkPhone()); staffClerkBindLogDetailDTO.setClerkPhoneNumber(staffClerkBindLogDetailDTO.getClerkPhone());
}); });
} }
return retList; return retList;
} }
@Override @Override
public void pushToBindLog(String staffId, String optStaffId, int optType, int channelCode, String relationId) { public void pushToBindLog(String staffId, String optStaffId, int optType, int channelCode, String relationId) {
staffClerkBindLogService.pushToMq(staffId, optStaffId, optType, channelCode, relationId); staffClerkBindLogService.pushToMq(staffId, optStaffId, optType, channelCode, relationId);
} }
private void setMainStore(StaffClerkRelationDTO staffClerkRelation) { private void setMainStore(StaffClerkRelationDTO staffClerkRelation) {
if (staffClerkRelation == null) { if (staffClerkRelation == null) {
logger.info("staffClerkRelation为空"); logger.info("staffClerkRelation为空");
return; return;
} }
String staffId = staffClerkRelation.getStaffId(); String staffId = staffClerkRelation.getStaffId();
String wxEnterpriseId = staffClerkRelation.getWxEnterpriseId(); String wxEnterpriseId = staffClerkRelation.getWxEnterpriseId();
List<StaffClerkRelationDTO> list = staffClerkRelatinService.lisByStaffId(wxEnterpriseId, staffId); List<StaffClerkRelationDTO> list = staffClerkRelatinService.listByStaffId(wxEnterpriseId, staffId);
if (list != null && list.size() == 1) { if (list != null && list.size() == 1) {
clerkMainStoreRelatedService.setMainStore(staffId, staffClerkRelation.getStoreId(), wxEnterpriseId); clerkMainStoreRelatedService.setMainStore(staffId, staffClerkRelation.getStoreId(), wxEnterpriseId);
} }
} }
private void delSetMainStore(TabHaobanStaffClerkRelation staffClerkRelation) { private void delSetMainStore(TabHaobanStaffClerkRelation staffClerkRelation) {
if (staffClerkRelation == null) { if (staffClerkRelation == null) {
logger.info("staffClerkRelation为空"); logger.info("staffClerkRelation为空");
return; return;
} }
String staffId = staffClerkRelation.getStaffId(); String staffId = staffClerkRelation.getStaffId();
String wxEnterpriseId = staffClerkRelation.getWxEnterpriseId(); String wxEnterpriseId = staffClerkRelation.getWxEnterpriseId();
externalClerkRelatedService.delByClerkIdAndStaffId(staffClerkRelation.getClerkId(), staffId); externalClerkRelatedService.delByClerkIdAndStaffId(staffClerkRelation.getClerkId(), staffId);
//删除主门店 //删除主门店
clerkMainStoreRelatedService.delMainStore(staffId, staffClerkRelation.getStoreId(), wxEnterpriseId); clerkMainStoreRelatedService.delMainStore(staffId, staffClerkRelation.getStoreId(), wxEnterpriseId);
} }
@Override @Override
public ServiceResponse<String> getClerkMemberChatConfig(String clerkId) { public ServiceResponse<String> getClerkMemberChatConfig(String clerkId) {
ServiceResponse response = new ServiceResponse(); ServiceResponse response = new ServiceResponse();
StaffClerkRelationDTO relationDTO = staffClerkRelatinService.getByClerkId(clerkId); StaffClerkRelationDTO relationDTO = staffClerkRelatinService.getByClerkId(clerkId);
if (null == relationDTO) { if (null == relationDTO) {
logger.info("导购没有关联企业微信:{}", clerkId); logger.info("导购没有关联企业微信:{}", clerkId);
response.setCode(2); response.setCode(2);
response.setMessage("导购没有关联企业微信"); response.setMessage("导购没有关联企业微信");
return response; return response;
} }
MemberClerkChatConfig chatConfig = staffClerkRelatinService.getChatConfig(relationDTO.getStaffId(), "-1"); MemberClerkChatConfig chatConfig = staffClerkRelatinService.getChatConfig(relationDTO.getStaffId(), "-1");
if (chatConfig != null) { if (chatConfig != null) {
response.setResult(chatConfig.getConfigId()); response.setResult(chatConfig.getConfigId());
return response; return response;
} }
QywxExternalcontactDTO send = new QywxExternalcontactDTO(); QywxExternalcontactDTO send = new QywxExternalcontactDTO();
send.setType(1); send.setType(1);
send.setScene(1); send.setScene(1);
send.setRemark("导购:" + relationDTO.getClerkCode()); send.setRemark("导购:" + relationDTO.getClerkCode());
List<String> userIds = new ArrayList<>(); List<String> userIds = new ArrayList<>();
userIds.add(relationDTO.getWxUserId()); userIds.add(relationDTO.getWxUserId());
send.setUser(userIds); send.setUser(userIds);
SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(relationDTO.getWxEnterpriseId(), SecretTypeEnum.HAOBAN_HELP.getVal()); SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(relationDTO.getWxEnterpriseId(), SecretTypeEnum.HAOBAN_HELP.getVal());
if (null == secretSetting || secretSetting.getCheckFlag() == 0) { if (null == secretSetting || secretSetting.getCheckFlag() == 0) {
logger.info("没有配置secret:{}", relationDTO.getWxEnterpriseId()); logger.info("没有配置secret:{}", relationDTO.getWxEnterpriseId());
response.setCode(3); response.setCode(3);
response.setMessage("企业微信配置异常"); response.setMessage("企业微信配置异常");
return response; return response;
} }
WxEnterpriseDTO enterpriseDTO = wxEnterpriseService.selectById(relationDTO.getWxEnterpriseId()); WxEnterpriseDTO enterpriseDTO = wxEnterpriseService.selectById(relationDTO.getWxEnterpriseId());
String configId = qywxUserApiService.getExternalcontactByUserId(enterpriseDTO.getCorpid(), secretSetting.getSecretVal(), send); String configId = qywxUserApiService.getExternalcontactByUserId(enterpriseDTO.getCorpid(), secretSetting.getSecretVal(), send);
logger.info("configId:{}", configId); logger.info("configId:{}", configId);
if (StringUtils.isBlank(configId)) { if (StringUtils.isBlank(configId)) {
logger.info("staff:{}", configId, JSONObject.toJSONString(relationDTO)); logger.info("staff:{}", configId, JSONObject.toJSONString(relationDTO));
response.setCode(4); response.setCode(4);
response.setMessage("创建config失败"); response.setMessage("创建config失败");
return response; return response;
} }
MemberClerkChatConfig clerkChatConfig = new MemberClerkChatConfig(); MemberClerkChatConfig clerkChatConfig = new MemberClerkChatConfig();
clerkChatConfig.setConfigId(configId); clerkChatConfig.setConfigId(configId);
clerkChatConfig.setEnterpriseId(relationDTO.getEnterpriseId()); clerkChatConfig.setEnterpriseId(relationDTO.getEnterpriseId());
clerkChatConfig.setMemberId("-1"); clerkChatConfig.setMemberId("-1");
clerkChatConfig.setStaffId(relationDTO.getStaffId()); clerkChatConfig.setStaffId(relationDTO.getStaffId());
staffClerkRelatinService.saveChatConfig(clerkChatConfig); staffClerkRelatinService.saveChatConfig(clerkChatConfig);
response.setResult(clerkChatConfig.getConfigId()); response.setResult(clerkChatConfig.getConfigId());
return response; return response;
} }
@Override @Override
public Page<StaffClerkRelationDTO> pageByWxEnterpriseId(String wxEnterpriseId, BasePageInfo pageInfo) { public Page<StaffClerkRelationDTO> pageByWxEnterpriseId(String wxEnterpriseId, BasePageInfo pageInfo) {
return staffClerkRelatinService.pageByWxEnterpriseId(wxEnterpriseId, pageInfo); return staffClerkRelatinService.pageByWxEnterpriseId(wxEnterpriseId, pageInfo);
} }
@Override @Override
public List<StaffClerkRelationDTO> listAll() { public List<StaffClerkRelationDTO> listAll() {
return staffClerkRelatinService.listAll(); return staffClerkRelatinService.listAll();
} }
} }
...@@ -276,20 +276,33 @@ ...@@ -276,20 +276,33 @@
<select id="pageStaff" resultMap="BaseResultMap"> <select id="pageStaff" resultMap="BaseResultMap">
select select
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
from tab_haoban_staff from tab_haoban_staff a
where status_flag = 1 left join tab_haoban_staff_department_related b on a.staff_id = b.staff_id
where a.status_flag = 1 and a.wx_enterprise_id = #{wxEnterpriseId}
<if test="keyword != null and keyword != ''"> <if test="keyword != null and keyword != ''">
and (staff_name like CONCAT('%',#{keyword},'%') or phone_number like CONCAT('%',#{keyword},'%')) and (a.staff_name like CONCAT('%',#{keyword},'%') or a.phone_number like CONCAT('%',#{keyword},'%'))
</if> </if>
<if test="activeFlag != null"> <if test="activeFlag != null">
and active_flag = #{activeFlag} and a.active_flag = #{activeFlag}
</if> </if>
<if test="staffIds != null and staffIds.size() > 0"> <if test="staffIds != null and staffIds.size() > 0 and relationFlag != null and relationFlag == 1 ">
and staff_id IN and a.staff_id IN
<foreach collection="staffIds" item="id" index="index" open="(" close=")" separator=","> <foreach collection="staffIds" item="id" index="index" open="(" close=")" separator=",">
#{id,jdbcType=VARCHAR} #{id,jdbcType=VARCHAR}
</foreach> </foreach>
</if> </if>
<if test="staffIds != null and staffIds.size() > 0 and relationFlag != null and relationFlag == 0 ">
and a.staff_id not in
<foreach collection="staffIds" item="id" index="index" open="(" close=")" separator=",">
#{id,jdbcType=VARCHAR}
</foreach>
</if>
<if test="departmentIds != null and departmentIds.size() > 0">
and b.department_id IN
<foreach collection="departmentIds" item="id" index="index" open="(" close=")" separator=",">
#{id,jdbcType=VARCHAR}
</foreach>
</if>
order by create_time desc order by create_time desc
</select> </select>
<select id="listByIds" resultMap="BaseResultMap"> <select id="listByIds" resultMap="BaseResultMap">
......
...@@ -145,11 +145,11 @@ public class StaffController extends WebBaseController { ...@@ -145,11 +145,11 @@ public class StaffController extends WebBaseController {
return this.resultResponse(HaoBanErrCode.ERR_10030) ; return this.resultResponse(HaoBanErrCode.ERR_10030) ;
} }
WebLoginDTO login = AuthWebRequestUtil.getLoginUser(); WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
// 部门 // 部门
List<DepartmentDTO> sonDepartmentList = departmentApiService.listSonByDepartmentIds(Lists.newArrayList(departmentId), login.getWxEnterpriseId()); List<String> departmentIds = departmentApiService.listSonDeptIdsByDepartmentId(departmentId, wxEnterpriseId);
List<String> departmentIds = sonDepartmentList.stream().map(DepartmentDTO::getDepartmentId).collect(Collectors.toList());
//员工 //员工
Page<StaffDTO> page = staffApiService.pageStaff(departmentIds, activeFlag, keyWord, pageInfo, relationFlag); Page<StaffDTO> page = staffApiService.pageStaff(departmentIds, activeFlag, keyWord, pageInfo, relationFlag,wxEnterpriseId);
logger.info("pages={},totalPage={}", page.getCurrentPage(), page.getTotalPage()); logger.info("pages={},totalPage={}", page.getCurrentPage(), page.getTotalPage());
...@@ -470,7 +470,7 @@ public class StaffController extends WebBaseController { ...@@ -470,7 +470,7 @@ public class StaffController extends WebBaseController {
int pageNum = 1; int pageNum = 1;
while (true) { while (true) {
pageInfo.setPageNum(pageNum); pageInfo.setPageNum(pageNum);
Page<StaffDTO> page = staffApiService.pageStaff(departmentIds, activeFlag, keyWord, pageInfo, relationFlag); Page<StaffDTO> page = staffApiService.pageStaff(departmentIds, activeFlag, keyWord, pageInfo, relationFlag,wxEnterpriseId);
List<StaffDTO> list = page.getResult(); List<StaffDTO> list = page.getResult();
if (CollectionUtils.isEmpty(list)) { if (CollectionUtils.isEmpty(list)) {
break; break;
......
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