Commit a4af1381 by 墨竹

fix:代码优化

parent 3b9cdcb8
...@@ -10,8 +10,6 @@ import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO; ...@@ -10,8 +10,6 @@ import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.apache.ibatis.annotations.Param;
public interface StaffClerkRelationApiService { public interface StaffClerkRelationApiService {
/** /**
* 绑定日志 * 绑定日志
...@@ -37,7 +35,7 @@ public interface StaffClerkRelationApiService { ...@@ -37,7 +35,7 @@ public interface StaffClerkRelationApiService {
* *
* @return * @return
*/ */
ServiceResponse bindStaffClerk(StaffClerkRelationDTO staffClerkRelationDTO, String optStaffId, int chanelCode); ServiceResponse bindStaffClerk(StaffClerkRelationDTO staffClerkRelationDTO, String optStaffId, int channelCode);
StaffClerkRelationDTO getByCodeAndEnterpriseId(String clerkCode, String enterpriseId); StaffClerkRelationDTO getByCodeAndEnterpriseId(String clerkCode, String enterpriseId);
...@@ -45,9 +43,9 @@ public interface StaffClerkRelationApiService { ...@@ -45,9 +43,9 @@ public interface StaffClerkRelationApiService {
* 审核绑定 * 审核绑定
* @param staffClerkRelation * @param staffClerkRelation
* @param optStaffId * @param optStaffId
* @param chanelCode * @param channelCode
*/ */
void delAndInsert(StaffClerkRelationDTO staffClerkRelation, String optStaffId, int chanelCode); void delAndInsert(StaffClerkRelationDTO staffClerkRelation, String optStaffId, int channelCode);
/** /**
* 解绑 * 解绑
......
...@@ -4,7 +4,6 @@ import com.gic.api.base.commons.Page; ...@@ -4,7 +4,6 @@ import com.gic.api.base.commons.Page;
import com.gic.haoban.base.api.common.BasePageInfo; import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO; import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import com.gic.haoban.manage.service.entity.MemberClerkChatConfig; import com.gic.haoban.manage.service.entity.MemberClerkChatConfig;
import com.gic.haoban.manage.service.entity.TabHaobanStaffClerkRelation;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
...@@ -30,17 +29,7 @@ public interface StaffClerkRelationService { ...@@ -30,17 +29,7 @@ public interface StaffClerkRelationService {
* @param storeIds * @param storeIds
* @return * @return
*/ */
boolean delBindByStoreIds(String wxEnterpriseId, Set<String> storeIds, String optStaffId, int chanelCode); boolean delBindByStoreIds(String wxEnterpriseId, Set<String> storeIds, String optStaffId, int channelCode);
/**
* 删除绑定
*
* @param wxEnterpriseId 可以不传
* @param enterpriseId
* @param storeIds 解除除了这些门店之外的绑定的门店
* @return
*/
boolean delBindNotInStoreIds(String wxEnterpriseId, String enterpriseId, Set<String> storeIds, String optStaffId, int chanelCode);
/** /**
* 绑定 * 绑定
...@@ -48,7 +37,7 @@ public interface StaffClerkRelationService { ...@@ -48,7 +37,7 @@ public interface StaffClerkRelationService {
* @param dto * @param dto
* @return * @return
*/ */
String bind(StaffClerkRelationDTO dto, String optStaffId, int chanelCode); String bind(StaffClerkRelationDTO dto, String optStaffId, int channelCode);
/** /**
* 根据clerkId 更新数据 * 根据clerkId 更新数据
......
...@@ -94,7 +94,7 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService ...@@ -94,7 +94,7 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService
} }
@Override @Override
public boolean delBindByStoreIds(String wxEnterpriseId, Set<String> storeIds, String optStaffId, int chanelCode) { public boolean delBindByStoreIds(String wxEnterpriseId, Set<String> storeIds, String optStaffId, int channelCode) {
if (CollectionUtils.isEmpty(storeIds)) { if (CollectionUtils.isEmpty(storeIds)) {
logger.info("没有传门店列表:{}", wxEnterpriseId); logger.info("没有传门店列表:{}", wxEnterpriseId);
return true; return true;
...@@ -112,37 +112,17 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService ...@@ -112,37 +112,17 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService
List<String> need = needUnbind.stream().map(tab -> tab.getStaffClerkRelationId()).collect(Collectors.toList()); List<String> need = needUnbind.stream().map(tab -> tab.getStaffClerkRelationId()).collect(Collectors.toList());
//放入队列 //放入队列
staffClerkBindLogService.pushToMqBatch(optStaffId, BindTypeEnum.UNBIND.getVal(), chanelCode, need); staffClerkBindLogService.pushToMqBatch(optStaffId, BindTypeEnum.UNBIND.getVal(), channelCode, need);
for (TabHaobanStaffClerkRelation clerkRelation : needUnbind) { for (TabHaobanStaffClerkRelation clerkRelation : needUnbind) {
//废弃活码 //废弃活码
hmClerkRelationApiService.delByClerkId(clerkRelation.getClerkId(), clerkRelation.getEnterpriseId(), wxEnterpriseId, chanelCode); hmClerkRelationApiService.delByClerkId(clerkRelation.getClerkId(), clerkRelation.getEnterpriseId(), wxEnterpriseId, channelCode);
} }
return true; return true;
} }
@Override @Override
public boolean delBindNotInStoreIds(String wxEnterpriseId, String enterpriseId, Set<String> storeIds, String optStaffId, int chanelCode) { public String bind(StaffClerkRelationDTO dto, String optStaffId, int channelCode) {
if (CollectionUtils.isEmpty(storeIds)) {
logger.info("没有传门店列表:{}", wxEnterpriseId);
return true;
}
List<TabHaobanStaffClerkRelation> needUnbind = mapper.listBindNotInStoreIds(wxEnterpriseId, enterpriseId, storeIds);
if (CollectionUtils.isEmpty(needUnbind)) {
logger.info("没有门店绑定了需要解绑的:{}", wxEnterpriseId);
}
Set<String> needDelStoreIds = needUnbind.stream().map(tab -> tab.getStoreId()).collect(Collectors.toSet());
//清除绑定
mapper.delByStoreIds(needDelStoreIds);
List<String> need = needUnbind.stream().map(tab -> tab.getStaffClerkRelationId()).collect(Collectors.toList());
//放入队列
staffClerkBindLogService.pushToMqBatch(optStaffId, BindTypeEnum.UNBIND.getVal(), chanelCode, need);
return true;
}
@Override
public String bind(StaffClerkRelationDTO dto, String optStaffId, int chanelCode) {
Date now = new Date(); Date now = new Date();
dto.setStaffClerkRelationId(ToolUtil.randomUUID()); dto.setStaffClerkRelationId(ToolUtil.randomUUID());
dto.setStatusFlag(1); dto.setStatusFlag(1);
...@@ -157,7 +137,7 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService ...@@ -157,7 +137,7 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService
String wxEnterpriseId = dto.getWxEnterpriseId(); String wxEnterpriseId = dto.getWxEnterpriseId();
clerkMainStoreRelatedService.getMainStoreByStaffId(staffId, wxEnterpriseId); clerkMainStoreRelatedService.getMainStoreByStaffId(staffId, wxEnterpriseId);
//推入日志 //推入日志
staffClerkBindLogService.pushToMq(staffId, optStaffId, BindTypeEnum.BIND.getVal(), chanelCode, dto.getStaffClerkRelationId()); staffClerkBindLogService.pushToMq(staffId, optStaffId, BindTypeEnum.BIND.getVal(), channelCode, dto.getStaffClerkRelationId());
// 绑定自动创建活码 // 绑定自动创建活码
HmQrcodeQDTO hmQrcodeQDTO = new HmQrcodeQDTO(); HmQrcodeQDTO hmQrcodeQDTO = new HmQrcodeQDTO();
...@@ -168,7 +148,7 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService ...@@ -168,7 +148,7 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService
hmQrcodeQDTO.setPassFlag(1); hmQrcodeQDTO.setPassFlag(1);
hmQrcodeQDTO.setStoreId(dto.getStoreId()); hmQrcodeQDTO.setStoreId(dto.getStoreId());
hmQrcodeQDTO.setClerkIdList(Collections.singletonList(dto.getClerkId())); hmQrcodeQDTO.setClerkIdList(Collections.singletonList(dto.getClerkId()));
hmQrcodeQDTO.setInvokingType(chanelCode); hmQrcodeQDTO.setInvokingType(channelCode);
hmQrcodeApiService.add(hmQrcodeQDTO); hmQrcodeApiService.add(hmQrcodeQDTO);
} }
return s; return s;
......
...@@ -112,6 +112,7 @@ public class StoreRangeServiceImpl implements StoreRangeService { ...@@ -112,6 +112,7 @@ public class StoreRangeServiceImpl implements StoreRangeService {
return true; return true;
} }
String enterpriseId = list.get(0).getEnterpriseId(); String enterpriseId = list.get(0).getEnterpriseId();
String wxEnterpriseId = list.get(0).getWxEnterpriseId();
//更新前绑定门店列表 //更新前绑定门店列表
List<TabStoreRelation> storeRelations = tabHaobanStoreRelationMapper.listStoreRange(enterpriseId); List<TabStoreRelation> storeRelations = tabHaobanStoreRelationMapper.listStoreRange(enterpriseId);
Map<String, Set<String>> oldStoreIdByMap = storeRelations.stream().collect(Collectors.groupingBy(TabStoreRelation::getWxEnterpriseId, Collectors.mapping(dto -> dto.getStoreId(), Collectors.toSet()))); Map<String, Set<String>> oldStoreIdByMap = storeRelations.stream().collect(Collectors.groupingBy(TabStoreRelation::getWxEnterpriseId, Collectors.mapping(dto -> dto.getStoreId(), Collectors.toSet())));
...@@ -155,7 +156,7 @@ public class StoreRangeServiceImpl implements StoreRangeService { ...@@ -155,7 +156,7 @@ public class StoreRangeServiceImpl implements StoreRangeService {
} }
}); });
//这些门店解除绑定 //这些门店解除绑定
staffClerkRelationService.delBindByStoreIds(null, needUnBindStoreIds, optStaffId, channelCode); staffClerkRelationService.delBindByStoreIds(wxEnterpriseId, needUnBindStoreIds, optStaffId, channelCode);
//批量处理关联关系 //批量处理关联关系
dealStoreRelation(list, enterpriseId, needUnBindStoreIds, needAddStoreIds); dealStoreRelation(list, enterpriseId, needUnBindStoreIds, needAddStoreIds);
return true; return true;
...@@ -217,9 +218,6 @@ public class StoreRangeServiceImpl implements StoreRangeService { ...@@ -217,9 +218,6 @@ public class StoreRangeServiceImpl implements StoreRangeService {
Map<String, Set<String>> ret = new HashMap<>(); Map<String, Set<String>> ret = new HashMap<>();
Set<String> wxEnterpriseIds = new HashSet<>(); Set<String> wxEnterpriseIds = new HashSet<>();
// //更新前绑定门店列表
// List<TabStoreRelation> storeRelations = tabHaobanStoreRelationMapper.listStoreRange(enterpriseId);
// Map<String, Set<String>> oldStoreIdBywxEnterpriseMap = storeRelations.stream().collect(Collectors.groupingBy(TabStoreRelation::getWxEnterpriseId, Collectors.mapping(dto -> dto.getStoreId(), Collectors.toSet())));
if (oldStoreIdBywxEnterpriseMap != null && oldStoreIdBywxEnterpriseMap.size() > 0) { if (oldStoreIdBywxEnterpriseMap != null && oldStoreIdBywxEnterpriseMap.size() > 0) {
wxEnterpriseIds.addAll(oldStoreIdBywxEnterpriseMap.keySet()); wxEnterpriseIds.addAll(oldStoreIdBywxEnterpriseMap.keySet());
} }
......
...@@ -73,8 +73,6 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe ...@@ -73,8 +73,6 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
@Autowired @Autowired
private QywxUserApiService qywxUserApiService; private QywxUserApiService qywxUserApiService;
@Autowired @Autowired
private SecretSettingService secretSettingService;
@Autowired
private WxEnterpriseService wxEnterpriseService; private WxEnterpriseService wxEnterpriseService;
@Autowired @Autowired
private HmClerkRelationApiService hmClerkRelationApiService; private HmClerkRelationApiService hmClerkRelationApiService;
...@@ -168,7 +166,7 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe ...@@ -168,7 +166,7 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
} }
@Override @Override
public ServiceResponse bindStaffClerk(StaffClerkRelationDTO staffClerkRelationDTO, String optStaffId, int chanelCode) { public ServiceResponse bindStaffClerk(StaffClerkRelationDTO staffClerkRelationDTO, String optStaffId, int channelCode) {
logger.info("绑定clerk:{}", JSONObject.toJSONString(staffClerkRelationDTO)); logger.info("绑定clerk:{}", JSONObject.toJSONString(staffClerkRelationDTO));
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());
...@@ -199,7 +197,7 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe ...@@ -199,7 +197,7 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
return response; return response;
} }
String relationId = staffClerkRelationService.bind(staffClerkRelationDTO, optStaffId, chanelCode); String relationId = staffClerkRelationService.bind(staffClerkRelationDTO, optStaffId, channelCode);
response.setResult(relationId); response.setResult(relationId);
return response; return response;
} }
...@@ -231,7 +229,7 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe ...@@ -231,7 +229,7 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
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<>();
} }
List<StaffClerkRelationDTO> result = EntityUtil.changeEntityListByJSON(StaffClerkRelationDTO.class, list); List<StaffClerkRelationDTO> result = EntityUtil.changeEntityListByJSON(StaffClerkRelationDTO.class, list);
return result; return result;
...@@ -271,14 +269,14 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe ...@@ -271,14 +269,14 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
} }
@Override @Override
public void delAndInsert(StaffClerkRelationDTO staffClerkRelation, String optStaffId, int chanelCode) { public void delAndInsert(StaffClerkRelationDTO staffClerkRelation, String optStaffId, int channelCode) {
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(), channelCode, staffClerkRelation.getStaffClerkRelationId());
clerkMainStoreRelatedService.delMainStore(oldStaffClerkRelation.getStaffId(), oldStaffClerkRelation.getStoreId(), oldStaffClerkRelation.getWxEnterpriseId()); clerkMainStoreRelatedService.delMainStore(oldStaffClerkRelation.getStaffId(), oldStaffClerkRelation.getStoreId(), oldStaffClerkRelation.getWxEnterpriseId());
} }
staffClerkRelationService.bind(staffClerkRelation, optStaffId, chanelCode); staffClerkRelationService.bind(staffClerkRelation, optStaffId, channelCode);
} }
@Override @Override
...@@ -288,6 +286,21 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe ...@@ -288,6 +286,21 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
delSetMainStore(staffClerkRelation, ChannelCodeEnum.AUDIT_UNBIND.getCode()); delSetMainStore(staffClerkRelation, ChannelCodeEnum.AUDIT_UNBIND.getCode());
} }
private void delSetMainStore(TabHaobanStaffClerkRelation staffClerkRelation, Integer channelCode) {
if (staffClerkRelation == null) {
logger.info("staffClerkRelation为空");
return;
}
String staffId = staffClerkRelation.getStaffId();
String wxEnterpriseId = staffClerkRelation.getWxEnterpriseId();
String clerkId = staffClerkRelation.getClerkId();
externalClerkRelatedService.delByClerkIdAndStaffId(clerkId, staffId);
//删除主门店
clerkMainStoreRelatedService.delMainStore(staffId, staffClerkRelation.getStoreId(), wxEnterpriseId);
//废弃活码
hmClerkRelationApiService.delByClerkId(clerkId, staffClerkRelation.getEnterpriseId(), wxEnterpriseId, channelCode);
}
@Override @Override
public List<StaffClerkRelationDTO> listByEnterpriseIdAndStaffid(String enterpriseId, String staffid) { public List<StaffClerkRelationDTO> listByEnterpriseIdAndStaffid(String enterpriseId, String staffid) {
List<TabHaobanStaffClerkRelation> list = tabHaobanStaffClerkRelationMapper.listByEnterpriseIdAndStaffid(enterpriseId, staffid); List<TabHaobanStaffClerkRelation> list = tabHaobanStaffClerkRelationMapper.listByEnterpriseIdAndStaffid(enterpriseId, staffid);
...@@ -367,21 +380,6 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe ...@@ -367,21 +380,6 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
staffClerkBindLogService.pushToMq(staffId, optStaffId, optType, channelCode, relationId); staffClerkBindLogService.pushToMq(staffId, optStaffId, optType, channelCode, relationId);
} }
private void delSetMainStore(TabHaobanStaffClerkRelation staffClerkRelation, Integer channelCode) {
if (staffClerkRelation == null) {
logger.info("staffClerkRelation为空");
return;
}
String staffId = staffClerkRelation.getStaffId();
String wxEnterpriseId = staffClerkRelation.getWxEnterpriseId();
String clerkId = staffClerkRelation.getClerkId();
externalClerkRelatedService.delByClerkIdAndStaffId(clerkId, staffId);
//删除主门店
clerkMainStoreRelatedService.delMainStore(staffId, staffClerkRelation.getStoreId(), wxEnterpriseId);
//废弃活码
hmClerkRelationApiService.delByClerkId(clerkId, staffClerkRelation.getEnterpriseId(), wxEnterpriseId, channelCode);
}
@Override @Override
public ServiceResponse<String> getClerkMemberChatConfig(String clerkId) { public ServiceResponse<String> getClerkMemberChatConfig(String clerkId) {
ServiceResponse response = new ServiceResponse(); ServiceResponse response = new ServiceResponse();
...@@ -516,8 +514,7 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe ...@@ -516,8 +514,7 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
@Override @Override
public int getCanAddHmCount(String wxEnterpriseId, String enterpriseId, String clerkId) { public int getCanAddHmCount(String wxEnterpriseId, String enterpriseId, String clerkId) {
int count = this.hmQrcodeService.getCanAddCount(wxEnterpriseId, enterpriseId, clerkId); return this.hmQrcodeService.getCanAddCount(wxEnterpriseId, enterpriseId, clerkId);
return count;
} }
@Override @Override
......
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