Commit 0cfc26d9 by 墨竹

fix:绑定审核修改

parent 14921100
package com.gic.haoban.manage.api.service; package com.gic.haoban.manage.api.service;
import com.gic.api.base.commons.Page; import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
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.manage.api.dto.StaffClerkBindLogDetailDTO; import com.gic.haoban.manage.api.dto.StaffClerkBindLogDetailDTO;
import com.gic.haoban.manage.api.dto.StaffClerkInfoDTO; import com.gic.haoban.manage.api.dto.StaffClerkInfoDTO;
import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO; import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
...@@ -37,18 +37,18 @@ public interface StaffClerkRelationApiService { ...@@ -37,18 +37,18 @@ public interface StaffClerkRelationApiService {
*/ */
ServiceResponse bindStaffClerk(StaffClerkRelationDTO staffClerkRelationDTO, String optStaffId, int channelCode); ServiceResponse bindStaffClerk(StaffClerkRelationDTO staffClerkRelationDTO, String optStaffId, int channelCode);
StaffClerkRelationDTO getByCodeAndEnterpriseId(String clerkCode, String enterpriseId);
/** /**
* 审核绑定 * 小程序-审核绑定
* *
* @param staffClerkRelation * @param staffClerkRelation
* @param optStaffId * @param optStaffId
* @param channelCode * @param channelCode
*/ */
void delAndInsert(StaffClerkRelationDTO staffClerkRelation, String optStaffId, int channelCode); ServiceResponse wxBindStaffClerk(StaffClerkRelationDTO staffClerkRelation, String optStaffId, int channelCode);
StaffClerkRelationDTO getByCodeAndEnterpriseId(String clerkCode, String enterpriseId);
/** /**
* 解绑导购 * 解绑导购
* @param staffId * @param staffId
...@@ -145,7 +145,7 @@ public interface StaffClerkRelationApiService { ...@@ -145,7 +145,7 @@ public interface StaffClerkRelationApiService {
* @param clerkId * @param clerkId
* @return * @return
*/ */
ServiceResponse<String> getClerkMemberChatConfig(String clerkId); com.gic.haoban.base.api.common.ServiceResponse<String> getClerkMemberChatConfig(String clerkId);
/** /**
* @return 返回值类型: <pre> * @return 返回值类型: <pre>
......
...@@ -255,4 +255,14 @@ public interface TabHaobanStaffClerkRelationMapper { ...@@ -255,4 +255,14 @@ public interface TabHaobanStaffClerkRelationMapper {
void deleteByEnterpriseId(@Param("enterpriseId") String enterpriseId) ; void deleteByEnterpriseId(@Param("enterpriseId") String enterpriseId) ;
/**
* 获取区经
*
* @param enterpriseId 企业标识
* @return int
*/
int getBindByManage(@Param("enterpriseId") String enterpriseId);
int getBindByStaffIdAndEnterpriseId(@Param("enterpriseId") String enterpriseId, @Param("staffId") String staffId);
} }
\ No newline at end of file
...@@ -10,179 +10,199 @@ import java.util.Set; ...@@ -10,179 +10,199 @@ import java.util.Set;
public interface StaffClerkRelationService { public interface StaffClerkRelationService {
List<StaffClerkRelationDTO> listBindCode(String enterpriseId, Set<String> clerkCodeList); List<StaffClerkRelationDTO> listBindCode(String enterpriseId, Set<String> clerkCodeList);
List<StaffClerkRelationDTO> listBindCodeByStaffId(List<String> enterpriseIdList, String staffId); List<StaffClerkRelationDTO> listBindCodeByStaffId(List<String> enterpriseIdList, String staffId);
/** /**
* 解绑-删除绑定(导购级别) * 解绑-删除绑定(导购级别)
* *
* @param clerkId * @param clerkId
* @return * @return
*/ */
boolean delBind(String clerkId, String optStaffId, int channelCode); boolean delBind(String clerkId, String optStaffId, int channelCode);
/** /**
* 解绑-删除绑定(门店级别) * 解绑-删除绑定(门店级别)
* *
* @param wxEnterpriseId 可以不传 * @param wxEnterpriseId 可以不传
* @param storeIds * @param storeIds
* @return * @return
*/ */
boolean delBindByStoreIds(String wxEnterpriseId, Set<String> storeIds, String optStaffId, int channelCode); boolean delBindByStoreIds(String wxEnterpriseId, Set<String> storeIds, String optStaffId, int channelCode);
/** /**
* 绑定 * 绑定
* *
* @param dto * @param dto
* @return * @return
*/ */
String bind(StaffClerkRelationDTO dto, String optStaffId, int channelCode); String bind(StaffClerkRelationDTO dto, String optStaffId, int channelCode);
/** /**
* 根据clerkId 更新数据 * 根据clerkId 更新数据
* @param dto *
* @return * @param dto
*/ * @return
boolean updateByClerkId(StaffClerkRelationDTO dto); */
boolean updateByClerkId(StaffClerkRelationDTO dto);
/**
* 查询绑定根据clerkId /**
* * 查询绑定根据clerkId
* @param clerkId *
* @param wxEnterpriseId * @param clerkId
* @return * @param wxEnterpriseId
*/ * @return
StaffClerkRelationDTO getBindByClerkId(String clerkId, String wxEnterpriseId); */
StaffClerkRelationDTO getBindByClerkId(String clerkId, String wxEnterpriseId);
StaffClerkRelationDTO getByCodeAndEnterpriseId(String clerkCode, String enterpriseId);
StaffClerkRelationDTO getByCodeAndEnterpriseId(String clerkCode, String enterpriseId);
String insert(StaffClerkRelationDTO staffClerkRelation);
String insert(StaffClerkRelationDTO staffClerkRelation);
int cleanStaffClerk(String wxEnterpriseId, List<String> staffIds);
int cleanStaffClerk(String wxEnterpriseId, List<String> staffIds);
StaffClerkRelationDTO getOneBindCodeNoStatus(String enterpriseId, String clerkCode);
StaffClerkRelationDTO getOneBindCodeNoStatus(String enterpriseId, String clerkCode);
StaffClerkRelationDTO getOneBindByStoreId(String staffId, String storeId);
StaffClerkRelationDTO getOneBindByStoreId(String staffId, String storeId);
StaffClerkRelationDTO getByClerkId(String clerkId);
StaffClerkRelationDTO getByClerkId(String clerkId);
StaffClerkRelationDTO getByClerkIdForWxUserId(String clerkId);
StaffClerkRelationDTO getByClerkIdForWxUserId(String clerkId);
StaffClerkRelationDTO getByClerkIdNoStatus(String clerkId);
StaffClerkRelationDTO getByClerkIdNoStatus(String clerkId);
List<StaffClerkRelationDTO> listByClerkIds(List<String> clerkList);
List<StaffClerkRelationDTO> listByClerkIds(List<String> clerkList);
List<StaffClerkRelationDTO> listByStaffId(String wxEnterpriseId, String staffId);
List<StaffClerkRelationDTO> listByStaffId(String wxEnterpriseId, String staffId);
List<StaffClerkRelationDTO> listByStaffId(String wxEnterpriseId, String staffId , List<String> storeIdList);
List<StaffClerkRelationDTO> listByStaffId(String wxEnterpriseId, String staffId, List<String> storeIdList);
/**
* 保存 /**
* @param memberClerkChatConfig * 保存
*/ *
void saveChatConfig(MemberClerkChatConfig memberClerkChatConfig); * @param memberClerkChatConfig
*/
/** void saveChatConfig(MemberClerkChatConfig memberClerkChatConfig);
* @param staffId
* @param memberId /**
* @return * @param staffId
*/ * @param memberId
MemberClerkChatConfig getChatConfig(String staffId, String memberId); * @return
*/
/** MemberClerkChatConfig getChatConfig(String staffId, String memberId);
* 根据企业查询
* @param wxEnterpriseId /**
* @return * 根据企业查询
*/ *
List<String> listByWxEnterpriseId(String wxEnterpriseId); * @param wxEnterpriseId
* @return
Page<StaffClerkRelationDTO> pageByWxEnterpriseId(String wxEnterpriseId, BasePageInfo pageInfo); */
List<String> listByWxEnterpriseId(String wxEnterpriseId);
/**
* 根据门店获取门店的绑定列表 Page<StaffClerkRelationDTO> pageByWxEnterpriseId(String wxEnterpriseId, BasePageInfo pageInfo);
*
* @param wxEnterpriseId /**
* @param storeId * 根据门店获取门店的绑定列表
* @return *
*/ * @param wxEnterpriseId
List<StaffClerkRelationDTO> listBindByStoreId(String wxEnterpriseId, String storeId); * @param storeId
* @return
/** */
* 查询门店列表 List<StaffClerkRelationDTO> listBindByStoreId(String wxEnterpriseId, String storeId);
*
* @param enterpriseId /**
* @return * 查询门店列表
*/ *
List<StaffClerkRelationDTO> listBindStoreIdByEnterpriseId(String enterpriseId); * @param enterpriseId
* @return
/** */
* 查询有关联的员工id列表 List<StaffClerkRelationDTO> listBindStoreIdByEnterpriseId(String enterpriseId);
*
* @param staffIdList 员工id列表 /**
* @author: YongEn * 查询有关联的员工id列表
* @return {@link Set<String>} *
*/ * @param staffIdList 员工id列表
List<String> listRelationsStaffId(Set<String> staffIdList); * @return {@link Set<String>}
* @author: YongEn
*/
/** List<String> listRelationsStaffId(Set<String> staffIdList);
* 根据导购查询wxuserid
*
* @param clerkList 职员名单 /**
* @param wxEnterpriseId wx企业标识 * 根据导购查询wxuserid
* @return {@link List }<{@link String }> *
* @author mozhu * @param clerkList 职员名单
* @date 2022-07-07 15:25:55 * @param wxEnterpriseId wx企业标识
*/ * @return {@link List }<{@link String }>
List<String> listWxUserIdByClerkIds(List<String> clerkList,String wxEnterpriseId); * @author mozhu
* @date 2022-07-07 15:25:55
/** */
* 通过userid 查询id List<String> listWxUserIdByClerkIds(List<String> clerkList, String wxEnterpriseId);
*
* @param wxUserIds wx开放用户id /**
* @param wxEnterpriseId wx企业标识 * 通过userid 查询id
* @param enterpriseId 企业标识 *
* @return {@link List }<{@link StaffClerkRelationDTO }> * @param wxUserIds wx开放用户id
* @author mozhu * @param wxEnterpriseId wx企业标识
* @date 2022-08-08 22:01:59 * @param enterpriseId 企业标识
*/ * @return {@link List }<{@link StaffClerkRelationDTO }>
List<StaffClerkRelationDTO> listIdsByWxUserIds(List<String> wxUserIds, String wxEnterpriseId, String enterpriseId); * @author mozhu
* @date 2022-08-08 22:01:59
*/
/** List<StaffClerkRelationDTO> listIdsByWxUserIds(List<String> wxUserIds, String wxEnterpriseId, String enterpriseId);
* 通过userid 不在范围内 查询id
*
* @param wxUserIds wx开放用户id /**
* @param wxEnterpriseId wx企业标识 * 通过userid 不在范围内 查询id
* @param enterpriseId 企业标识 *
* @return {@link List }<{@link StaffClerkRelationDTO }> * @param wxUserIds wx开放用户id
* @author mozhu * @param wxEnterpriseId wx企业标识
* @date 2022-08-08 21:51:52 * @param enterpriseId 企业标识
*/ * @return {@link List }<{@link StaffClerkRelationDTO }>
List<StaffClerkRelationDTO> listIdsByNotInWxUserIds(List<String> wxUserIds, String wxEnterpriseId, String enterpriseId); * @author mozhu
* @date 2022-08-08 21:51:52
*/
/** List<StaffClerkRelationDTO> listIdsByNotInWxUserIds(List<String> wxUserIds, String wxEnterpriseId, String enterpriseId);
* 更新联系我状态
*
* @param openConcatFlag 打开concat国旗 /**
* @param staffClerkRelationId 员工职员关系id * 更新联系我状态
* @return int *
* @author mozhu * @param openConcatFlag 打开concat国旗
* @date 2022-07-07 15:34:27 * @param staffClerkRelationId 员工职员关系id
*/ * @return int
int updateOpenConcatFlagById(Integer openConcatFlag,String staffClerkRelationId); * @author mozhu
* @date 2022-07-07 15:34:27
*/
/** int updateOpenConcatFlagById(Integer openConcatFlag, String staffClerkRelationId);
* 通过职员id 查询职员id列表
*
* @param clerkIds 职员id /**
* @param wxEnterpriseId wx企业标识 * 通过职员id 查询职员id列表
* @return {@link List }<{@link StaffClerkRelationDTO }> *
* @author mozhu * @param clerkIds 职员id
* @date 2022-07-07 16:41:35 * @param wxEnterpriseId wx企业标识
*/ * @return {@link List }<{@link StaffClerkRelationDTO }>
List<StaffClerkRelationDTO> listClerkIdConcatFlagByClerkIds(List<String> clerkIds,String wxEnterpriseId); * @author mozhu
* @date 2022-07-07 16:41:35
*/
List<StaffClerkRelationDTO> listClerkIdConcatFlagByClerkIds(List<String> clerkIds, String wxEnterpriseId);
/**
* 是否有区经
*
* @param enterpriseId 企业标识
* @return {@link StaffClerkRelationDTO}
*/
boolean getBindByManage(String enterpriseId);
/**
* 是否绑定过
*
* @param enterpriseId 企业标识
* @param staffId 员工id
* @return boolean
*/
boolean getBindByStaffIdAndEnterpriseId(String enterpriseId, String staffId);
} }
...@@ -138,7 +138,7 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService ...@@ -138,7 +138,7 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService
String staffId = dto.getStaffId(); String staffId = dto.getStaffId();
TabHaobanStaff tabHaobanStaff = staffService.selectById(staffId); TabHaobanStaff tabHaobanStaff = staffService.selectById(staffId);
if (tabHaobanStaff == null) { if (tabHaobanStaff == null) {
logger.error("员工不存在:{}",staffId); logger.error("员工不存在:{}", staffId);
return ""; return "";
} }
Date now = new Date(); Date now = new Date();
...@@ -355,4 +355,14 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService ...@@ -355,4 +355,14 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService
public List<StaffClerkRelationDTO> listClerkIdConcatFlagByClerkIds(List<String> clerkIds, String wxEnterpriseId) { public List<StaffClerkRelationDTO> listClerkIdConcatFlagByClerkIds(List<String> clerkIds, String wxEnterpriseId) {
return mapper.listClerkIdConcatFlagByClerkIds(clerkIds, wxEnterpriseId); return mapper.listClerkIdConcatFlagByClerkIds(clerkIds, wxEnterpriseId);
} }
@Override
public boolean getBindByManage(String enterpriseId) {
return mapper.getBindByManage(enterpriseId) > 0;
}
@Override
public boolean getBindByStaffIdAndEnterpriseId(String enterpriseId, String staffId) {
return mapper.getBindByStaffIdAndEnterpriseId(enterpriseId, staffId) > 0;
}
} }
...@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil; ...@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
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.api.base.commons.ServiceResponse;
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;
...@@ -13,7 +14,6 @@ import com.gic.enterprise.api.dto.StoreDTO; ...@@ -13,7 +14,6 @@ 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.manage.api.dto.*; import com.gic.haoban.manage.api.dto.*;
import com.gic.haoban.manage.api.dto.qdto.ClerkSyncQDTO; import com.gic.haoban.manage.api.dto.qdto.ClerkSyncQDTO;
import com.gic.haoban.manage.api.enums.AuditType; import com.gic.haoban.manage.api.enums.AuditType;
...@@ -171,30 +171,29 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe ...@@ -171,30 +171,29 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
ServiceResponse<Object> response = new ServiceResponse<>(); ServiceResponse<Object> response = new ServiceResponse<>();
StaffClerkRelationDTO relationDTO = staffClerkRelationService.getBindByClerkId(staffClerkRelationDTO.getClerkId(), staffClerkRelationDTO.getWxEnterpriseId()); StaffClerkRelationDTO relationDTO = staffClerkRelationService.getBindByClerkId(staffClerkRelationDTO.getClerkId(), staffClerkRelationDTO.getWxEnterpriseId());
if (null != relationDTO) { if (null != relationDTO) {
response.setCode(2); return ServiceResponse.failure("2","已经被绑定,不能绑定");
response.setMessage("已经被绑定,不能绑定");
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); return ServiceResponse.failure("4","该导购已经被被申请绑定,请审核处理后再绑定");
response.setMessage("该导购已经被被申请绑定,请审核处理后再绑定");
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); return ServiceResponse.failure("5","该成员已经已经在该门店下申请了绑定,请审核处理后再绑定");
response.setMessage("该成员已经已经在该门店下申请了绑定,请审核处理后再绑定");
return response;
} }
} }
StaffClerkRelationDTO storeHasBind = staffClerkRelationService.getOneBindByStoreId(staffClerkRelationDTO.getStaffId(), staffClerkRelationDTO.getStoreId()); StaffClerkRelationDTO storeHasBind = staffClerkRelationService.getOneBindByStoreId(staffClerkRelationDTO.getStaffId(), staffClerkRelationDTO.getStoreId());
if (storeHasBind != null) { if (storeHasBind != null) {
response.setCode(3); return ServiceResponse.failure("3","该导购已在该门店下有其它成员绑定");
response.setMessage("该导购已在该门店下有其它成员绑定"); }
return response; Integer manageFlag = staffClerkRelationDTO.getManageFlag();
if (manageFlag != null && manageFlag == 1) {
ServiceResponse serviceResponse = getManageFlagBind(staffClerkRelationDTO);
if (!serviceResponse.isSuccess()) {
return serviceResponse;
}
} }
String relationId = staffClerkRelationService.bind(staffClerkRelationDTO, optStaffId, channelCode); String relationId = staffClerkRelationService.bind(staffClerkRelationDTO, optStaffId, channelCode);
...@@ -209,7 +208,7 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe ...@@ -209,7 +208,7 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
@Override @Override
public void delBindByStoreId(String wxEnterpriseId,String storeId, String staffId,int channelCode) { public void delBindByStoreId(String wxEnterpriseId, String storeId, String staffId, int channelCode) {
Set<String> needUnBindStoreIds = new HashSet<>(); Set<String> needUnBindStoreIds = new HashSet<>();
needUnBindStoreIds.add(storeId); needUnBindStoreIds.add(storeId);
staffClerkRelationService.delBindByStoreIds(wxEnterpriseId, needUnBindStoreIds, staffId, ChannelCodeEnum.SELF_UNBIND.getCode()); staffClerkRelationService.delBindByStoreIds(wxEnterpriseId, needUnBindStoreIds, staffId, ChannelCodeEnum.SELF_UNBIND.getCode());
...@@ -234,7 +233,7 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe ...@@ -234,7 +233,7 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
} }
@Override @Override
public boolean unbindByStaffAndClerkId(String staffId, String clerkId,int channelCode) { public boolean unbindByStaffAndClerkId(String staffId, String clerkId, int channelCode) {
return staffClerkRelationService.delBind(clerkId, staffId, channelCode); return staffClerkRelationService.delBind(clerkId, staffId, channelCode);
} }
...@@ -267,14 +266,36 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe ...@@ -267,14 +266,36 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
} }
@Override @Override
public void delAndInsert(StaffClerkRelationDTO staffClerkRelation, String optStaffId, int channelCode) { public ServiceResponse wxBindStaffClerk(StaffClerkRelationDTO staffClerkRelation, String optStaffId, int channelCode) {
Integer manageFlag = staffClerkRelation.getManageFlag();
if (manageFlag != null && manageFlag ==1) {
ServiceResponse serviceResponse = getManageFlagBind(staffClerkRelation);
if (!serviceResponse.isSuccess()) {
return serviceResponse;
}
}
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(), channelCode, staffClerkRelation.getStaffClerkRelationId()); staffClerkBindLogService.pushToMq(oldStaffClerkRelation.getStaffId(), optStaffId, BindTypeEnum.UNBIND.getVal(), channelCode, staffClerkRelation.getStaffClerkRelationId());
clerkMainStoreRelatedService.delMainStore(oldStaffClerkRelation.getStaffId(), oldStaffClerkRelation.getStoreId(), oldStaffClerkRelation.getWxEnterpriseId()); clerkMainStoreRelatedService.delMainStore(oldStaffClerkRelation.getStaffId(), oldStaffClerkRelation.getStoreId(), oldStaffClerkRelation.getWxEnterpriseId());
} }
staffClerkRelationService.bind(staffClerkRelation, optStaffId, channelCode); staffClerkRelationService.bind(staffClerkRelation, optStaffId, channelCode);
return ServiceResponse.success();
}
private ServiceResponse getManageFlagBind(StaffClerkRelationDTO staffClerkRelation) {
boolean bindFlag = staffClerkRelationService.getBindByStaffIdAndEnterpriseId(staffClerkRelation.getWxEnterpriseId(), staffClerkRelation.getStaffId());
if (bindFlag) {
return ServiceResponse.failure("3","该员工已经绑定过导购,不允许再次绑定区经/督导");
}
boolean flag = staffClerkRelationService.getBindByManage(staffClerkRelation.getEnterpriseId());
if (flag) {
return ServiceResponse.failure("3","一个商户只能一个区经/督导");
}
return ServiceResponse.success();
} }
@Override @Override
...@@ -357,8 +378,8 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe ...@@ -357,8 +378,8 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
} }
@Override @Override
public ServiceResponse<String> getClerkMemberChatConfig(String clerkId) { public com.gic.haoban.base.api.common.ServiceResponse<String> getClerkMemberChatConfig(String clerkId) {
ServiceResponse response = new ServiceResponse(); com.gic.haoban.base.api.common.ServiceResponse response = new com.gic.haoban.base.api.common.ServiceResponse();
StaffClerkRelationDTO relationDTO = staffClerkRelationService.getByClerkIdForWxUserId(clerkId); StaffClerkRelationDTO relationDTO = staffClerkRelationService.getByClerkIdForWxUserId(clerkId);
if (null == relationDTO) { if (null == relationDTO) {
logger.info("导购没有关联企业微信:{}", clerkId); logger.info("导购没有关联企业微信:{}", clerkId);
......
...@@ -4,31 +4,27 @@ import com.alibaba.fastjson.JSONObject; ...@@ -4,31 +4,27 @@ import com.alibaba.fastjson.JSONObject;
import com.gic.binlog.base.entity.GicField; import com.gic.binlog.base.entity.GicField;
import com.gic.binlog.base.entity.GicRecord; import com.gic.binlog.base.entity.GicRecord;
import com.gic.binlog.base.entity.enums.GicRecordType; import com.gic.binlog.base.entity.enums.GicRecordType;
import com.gic.clerk.api.service.ClerkService;
import com.gic.commons.util.EntityUtil; import com.gic.commons.util.EntityUtil;
import com.gic.dubbo.entity.ProviderLocalTag; import com.gic.dubbo.entity.ProviderLocalTag;
import com.gic.haoban.base.api.common.ServiceResponse;
import com.gic.haoban.manage.api.dto.FlushStoreMqDTO; import com.gic.haoban.manage.api.dto.FlushStoreMqDTO;
import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import com.gic.haoban.manage.api.enums.ChannelCodeEnum; import com.gic.haoban.manage.api.enums.ChannelCodeEnum;
import com.gic.haoban.manage.api.enums.StatusEnum;
import com.gic.haoban.manage.api.service.StaffClerkRelationApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService; import com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService;
import com.gic.haoban.manage.service.pojo.BinlogBasePojo; import com.gic.haoban.manage.service.pojo.BinlogBasePojo;
import com.gic.haoban.manage.service.pojo.ClerkSyncPojo; import com.gic.haoban.manage.service.pojo.ClerkSyncPojo;
import com.gic.haoban.manage.service.pojo.GroupSyncPojo; import com.gic.haoban.manage.service.pojo.GroupSyncPojo;
import com.gic.haoban.manage.service.pojo.StoreSyncPojo; import com.gic.haoban.manage.service.pojo.StoreSyncPojo;
import com.gic.haoban.manage.service.service.StaffClerkRelationService;
import com.gic.haoban.manage.service.service.StoreRangeService; import com.gic.haoban.manage.service.service.StoreRangeService;
import com.gic.haoban.manage.service.service.hm.HmQrcodeService; import com.gic.haoban.manage.service.service.hm.HmQrcodeService;
import org.apache.commons.lang3.time.DateUtils;
import org.apache.kafka.clients.consumer.ConsumerRecord; import org.apache.kafka.clients.consumer.ConsumerRecord;
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.kafka.listener.MessageListener; import org.springframework.kafka.listener.MessageListener;
import java.util.*; import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/** /**
* Created 2019/4/10. * Created 2019/4/10.
...@@ -46,15 +42,6 @@ public class KafkaMessageServiceImpl implements MessageListener<String, GicRecor ...@@ -46,15 +42,6 @@ public class KafkaMessageServiceImpl implements MessageListener<String, GicRecor
private final String GROUP = "tab_gic_store_group"; private final String GROUP = "tab_gic_store_group";
@Autowired @Autowired
private StaffClerkRelationService staffClerkRelationService;
@Autowired
private StaffClerkRelationApiService staffClerkRelationApiService;
@Autowired
private ClerkService clerkService;
@Autowired
private StoreRangeService storeRangeService; private StoreRangeService storeRangeService;
@Autowired @Autowired
...@@ -92,72 +79,6 @@ public class KafkaMessageServiceImpl implements MessageListener<String, GicRecor ...@@ -92,72 +79,6 @@ public class KafkaMessageServiceImpl implements MessageListener<String, GicRecor
} }
} }
private void dealClerk(ClerkSyncPojo syncPojo) {
GicRecordType gicRecordType = GicRecordType.valueOf(syncPojo.getRecordType());
if (gicRecordType.equals(GicRecordType.DELETE)) {
staffClerkRelationService.delBind(syncPojo.getClerkId(), "-1", ChannelCodeEnum.SYNC_UNBIND.getCode());
} else if (gicRecordType.equals(GicRecordType.INSERT)) {
StaffClerkRelationDTO relationDTO = staffClerkRelationService.getOneBindCodeNoStatus(syncPojo.getEnterpriseId(), syncPojo.getClerkCode());
if (syncPojo.getStatus() != 0) {
// 过滤掉状态为0的同步导购数据
moveOrAddClerk(syncPojo, relationDTO);
}
} else if (gicRecordType.equals(GicRecordType.UPDATE)) {
StaffClerkRelationDTO relationDTO = new StaffClerkRelationDTO();
relationDTO.setClerkId(syncPojo.getClerkId());
relationDTO.setStoreId(syncPojo.getStoreId());
relationDTO.setClerkCode(syncPojo.getClerkCode());
//非正常状态 删除
if (!syncPojo.getStatus().equals(1)) {
logger.info("删除操作:{}", syncPojo.getClerkId());
staffClerkRelationService.delBind(syncPojo.getClerkId(), "-1", ChannelCodeEnum.SYNC_UNBIND.getCode());
} else {
List<String> clerkIds = new ArrayList<>();
clerkIds.add(syncPojo.getClerkId());
StaffClerkRelationDTO clerkRelationDTO = staffClerkRelationService.getByClerkId(syncPojo.getClerkId());
if (clerkRelationDTO != null) {
logger.info("更新关联信息1:{}", syncPojo.getClerkId());
staffClerkRelationService.updateByClerkId(relationDTO);
return;
}
StaffClerkRelationDTO bindRelationDTO = staffClerkRelationService.getOneBindCodeNoStatus(syncPojo.getEnterpriseId(), syncPojo.getClerkCode());
if (null == bindRelationDTO) {
logger.info("没有关联导购,不需要操作:{}", syncPojo.getClerkId());
return;
}
logger.info("走新增逻辑:{}", syncPojo.getClerkId());
//走新增逻辑
moveOrAddClerk(syncPojo, bindRelationDTO);
}
}
}
private void moveOrAddClerk(ClerkSyncPojo syncPojo, StaffClerkRelationDTO relationDTO) {
if (null == relationDTO) {
logger.info("没有关联导购,不需要新增");
return;
}
//正常的时候
if (relationDTO.getStatusFlag() != StatusEnum.DEL.getValue()) {
staffClerkRelationService.delBind(relationDTO.getClerkId(), "-1", ChannelCodeEnum.SYNC_UNBIND.getCode());
relationDTO.setClerkId(syncPojo.getClerkId());
relationDTO.setStoreId(syncPojo.getStoreId());
ServiceResponse response = staffClerkRelationApiService.bindStaffClerk(relationDTO, "-1", ChannelCodeEnum.SYNC_BIND.getCode());
logger.info("绑定结果正常:{},{}", JSONObject.toJSONString(response), relationDTO.getClerkId());
} else {
//删除状态 需要判断是否近段时间有操作删除 2分组内有更新 判断是转移操作
Date timeDiff = DateUtils.addMinutes(new Date(), -2);
if (relationDTO.getUpdateTime().after(timeDiff)) {
staffClerkRelationService.delBind(relationDTO.getClerkId(), "-1", ChannelCodeEnum.SYNC_UNBIND.getCode());
relationDTO.setClerkId(syncPojo.getClerkId());
relationDTO.setStoreId(syncPojo.getStoreId());
ServiceResponse response = staffClerkRelationApiService.bindStaffClerk(relationDTO, "-1", ChannelCodeEnum.SYNC_BIND.getCode());
logger.info("绑定结果:{},{}", JSONObject.toJSONString(response), relationDTO.getClerkId());
}
}
}
private BinlogBasePojo binlogChange(GicRecord record) { private BinlogBasePojo binlogChange(GicRecord record) {
ClerkSyncPojo pojo = new ClerkSyncPojo(); ClerkSyncPojo pojo = new ClerkSyncPojo();
pojo.setRecordType(record.getRecordType().value()); pojo.setRecordType(record.getRecordType().value());
......
...@@ -388,7 +388,7 @@ ...@@ -388,7 +388,7 @@
</foreach> </foreach>
and a.status_flag = 1 and a.status_flag = 1
group by a.staff_id, a.clerk_id) as scr on scr.staff_id = ecr.staff_id group by a.staff_id, a.clerk_id) as scr on scr.staff_id = ecr.staff_id
where ecr.status_flag = 1 AND ecr.`external_status` = 1 where ecr.status_flag = 1 AND ecr.`external_status` = 1
and ecr.enterprise_id = #{enterpriseId,jdbcType=VARCHAR} and ecr.enterprise_id = #{enterpriseId,jdbcType=VARCHAR}
and ecr.wx_enterprise_id=#{wxEnterpriseId} and ecr.wx_enterprise_id=#{wxEnterpriseId}
and ecr.member_id in and ecr.member_id in
...@@ -542,4 +542,18 @@ ...@@ -542,4 +542,18 @@
update tab_haoban_staff_clerk_relation set status_flag = 0 , update_time=now() where enterprise_id = #{enterpriseId} update tab_haoban_staff_clerk_relation set status_flag = 0 , update_time=now() where enterprise_id = #{enterpriseId}
</update> </update>
<select id="getBindByManage" resultType="java.lang.Integer">
select
count(*)
from tab_haoban_staff_clerk_relation
where status_flag=1 and enterprise_id = #{enterpriseId} and manage_flag = 1
</select>
<select id="getBindByStaffIdAndEnterpriseId" resultType="java.lang.Integer">
select
count(*)
from tab_haoban_staff_clerk_relation
where status_flag=1 and enterprise_id = #{enterpriseId} and staff_id = #{staffId}
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil; ...@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
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.api.base.commons.ServiceResponse;
import com.gic.clerk.api.dto.ClerkDTO; import com.gic.clerk.api.dto.ClerkDTO;
import com.gic.clerk.api.service.ClerkNewService; import com.gic.clerk.api.service.ClerkNewService;
import com.gic.clerk.api.service.ClerkService; import com.gic.clerk.api.service.ClerkService;
...@@ -13,7 +14,6 @@ import com.gic.enterprise.api.dto.StoreDTO; ...@@ -13,7 +14,6 @@ import com.gic.enterprise.api.dto.StoreDTO;
import com.gic.enterprise.api.service.StoreService; import com.gic.enterprise.api.service.StoreService;
import com.gic.enterprise.api.service.StoreWidgetService; import com.gic.enterprise.api.service.StoreWidgetService;
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.pojo.dto.WebLoginDTO; import com.gic.haoban.base.api.common.pojo.dto.WebLoginDTO;
import com.gic.haoban.common.utils.AuthWebRequestUtil; import com.gic.haoban.common.utils.AuthWebRequestUtil;
import com.gic.haoban.common.utils.EntityUtil; import com.gic.haoban.common.utils.EntityUtil;
...@@ -275,7 +275,7 @@ public class StaffController extends WebBaseController { ...@@ -275,7 +275,7 @@ public class StaffController extends WebBaseController {
/** /**
* 成员关联关系接口 * 成员关联关系接口
* *
* @param staffId * @param clerkId
* @return * @return
*/ */
@RequestMapping("del-clerk-relation") @RequestMapping("del-clerk-relation")
...@@ -377,7 +377,7 @@ public class StaffController extends WebBaseController { ...@@ -377,7 +377,7 @@ public class StaffController extends WebBaseController {
ServiceResponse response = staffClerkRelationApiService.bindStaffClerk(relationDTO, login.getClerkId(), ChannelCodeEnum.ADMIN_BIND.getCode()); ServiceResponse response = staffClerkRelationApiService.bindStaffClerk(relationDTO, login.getClerkId(), ChannelCodeEnum.ADMIN_BIND.getCode());
logger.info("返回信息:{}", JSONObject.toJSONString(response)); logger.info("返回信息:{}", JSONObject.toJSONString(response));
if (response.getCode() == 1) { if (response.isSuccess()) {
return resultResponse(HaoBanErrCode.ERR_1); return resultResponse(HaoBanErrCode.ERR_1);
} else { } else {
HaoBanErrCode errDefine = HaoBanErrCode.ERR_DEFINE; HaoBanErrCode errDefine = HaoBanErrCode.ERR_DEFINE;
......
...@@ -4,6 +4,7 @@ package com.gic.haoban.manage.web.controller; ...@@ -4,6 +4,7 @@ package com.gic.haoban.manage.web.controller;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
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.api.base.commons.ServiceResponse;
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;
...@@ -269,14 +270,15 @@ public class AuditController extends WebBaseController { ...@@ -269,14 +270,15 @@ public class AuditController extends WebBaseController {
staffClerkRelation.setClerkId(clerkId); staffClerkRelation.setClerkId(clerkId);
staffClerkRelation.setStoreId(storeId); staffClerkRelation.setStoreId(storeId);
staffClerkRelation.setWxEnterpriseId(wxEnterpriseId); staffClerkRelation.setWxEnterpriseId(wxEnterpriseId);
// staffClerkRelation.setWxUserId(wxUserId);
staffClerkRelation.setStaffId(auditStaffId); staffClerkRelation.setStaffId(auditStaffId);
staffClerkRelationApiService.delAndInsert(staffClerkRelation, staffId, ChannelCodeEnum.AUDIT_BIND.getCode()); ServiceResponse serviceResponse = staffClerkRelationApiService.wxBindStaffClerk(staffClerkRelation, staffId, ChannelCodeEnum.AUDIT_BIND.getCode());
if (!serviceResponse.isSuccess()) {
return resultResponse(HaoBanErrCode.ERR_DEFINE,serviceResponse.getMessage());
}
audit.setAuditStatus(1); audit.setAuditStatus(1);
//发送消息 //发送消息
staffDepartmentRelatedApiService.sendBindAuditMessage(auditId, auditStaffId, clerkId, "", false); staffDepartmentRelatedApiService.sendBindAuditMessage(auditId, auditStaffId, clerkId, "", false);
// staffDepartmentRelatedApiService.sendClerkBind(auditStaffId, clerkCode, storeId, auditStatus, auditReason);
} }
} }
} }
...@@ -287,7 +289,6 @@ public class AuditController extends WebBaseController { ...@@ -287,7 +289,6 @@ public class AuditController extends WebBaseController {
return resultResponse(HaoBanErrCode.ERR_10010); return resultResponse(HaoBanErrCode.ERR_10010);
} }
audit.setAuditStatus(1); audit.setAuditStatus(1);
// ClerkDTO clerkDTO = clerkService.getClerkByClerkCode(enterpriseId, clerkCode);
staffDepartmentRelatedApiService.sendClerkAdd(clerkName, clerkCode, storeId, auditStatus, auditReason); staffDepartmentRelatedApiService.sendClerkAdd(clerkName, clerkCode, storeId, auditStatus, auditReason);
} }
......
...@@ -832,7 +832,10 @@ public class ClerkController extends WebBaseController { ...@@ -832,7 +832,10 @@ public class ClerkController extends WebBaseController {
staffClerkRelation.setStaffId(staffId); staffClerkRelation.setStaffId(staffId);
staffClerkRelation.setManageFlag(manageFlag); staffClerkRelation.setManageFlag(manageFlag);
staffClerkRelationApiService.delAndInsert(staffClerkRelation, staffId, ChannelCodeEnum.SELF_BIND.getCode()); ServiceResponse serviceResponse = staffClerkRelationApiService.wxBindStaffClerk(staffClerkRelation, staffId, ChannelCodeEnum.SELF_BIND.getCode());
if (!serviceResponse.isSuccess()) {
return resultResponse(HaoBanErrCode.ERR_DEFINE,serviceResponse.getMessage());
}
//无需审核 //无需审核
AuditDTO audit = new AuditDTO(); AuditDTO audit = new AuditDTO();
......
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