Commit a4af1381 by 墨竹

fix:代码优化

parent 3b9cdcb8
......@@ -10,8 +10,6 @@ import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import java.util.List;
import java.util.Set;
import org.apache.ibatis.annotations.Param;
public interface StaffClerkRelationApiService {
/**
* 绑定日志
......@@ -37,7 +35,7 @@ public interface StaffClerkRelationApiService {
*
* @return
*/
ServiceResponse bindStaffClerk(StaffClerkRelationDTO staffClerkRelationDTO, String optStaffId, int chanelCode);
ServiceResponse bindStaffClerk(StaffClerkRelationDTO staffClerkRelationDTO, String optStaffId, int channelCode);
StaffClerkRelationDTO getByCodeAndEnterpriseId(String clerkCode, String enterpriseId);
......@@ -45,9 +43,9 @@ public interface StaffClerkRelationApiService {
* 审核绑定
* @param staffClerkRelation
* @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;
import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import com.gic.haoban.manage.service.entity.MemberClerkChatConfig;
import com.gic.haoban.manage.service.entity.TabHaobanStaffClerkRelation;
import java.util.List;
import java.util.Set;
......@@ -30,17 +29,7 @@ public interface StaffClerkRelationService {
* @param storeIds
* @return
*/
boolean delBindByStoreIds(String wxEnterpriseId, Set<String> storeIds, String optStaffId, int chanelCode);
/**
* 删除绑定
*
* @param wxEnterpriseId 可以不传
* @param enterpriseId
* @param storeIds 解除除了这些门店之外的绑定的门店
* @return
*/
boolean delBindNotInStoreIds(String wxEnterpriseId, String enterpriseId, Set<String> storeIds, String optStaffId, int chanelCode);
boolean delBindByStoreIds(String wxEnterpriseId, Set<String> storeIds, String optStaffId, int channelCode);
/**
* 绑定
......@@ -48,7 +37,7 @@ public interface StaffClerkRelationService {
* @param dto
* @return
*/
String bind(StaffClerkRelationDTO dto, String optStaffId, int chanelCode);
String bind(StaffClerkRelationDTO dto, String optStaffId, int channelCode);
/**
* 根据clerkId 更新数据
......
......@@ -94,7 +94,7 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService
}
@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)) {
logger.info("没有传门店列表:{}", wxEnterpriseId);
return true;
......@@ -112,37 +112,17 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService
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) {
//废弃活码
hmClerkRelationApiService.delByClerkId(clerkRelation.getClerkId(), clerkRelation.getEnterpriseId(), wxEnterpriseId, chanelCode);
hmClerkRelationApiService.delByClerkId(clerkRelation.getClerkId(), clerkRelation.getEnterpriseId(), wxEnterpriseId, channelCode);
}
return true;
}
@Override
public boolean delBindNotInStoreIds(String wxEnterpriseId, String enterpriseId, Set<String> storeIds, String optStaffId, int chanelCode) {
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) {
public String bind(StaffClerkRelationDTO dto, String optStaffId, int channelCode) {
Date now = new Date();
dto.setStaffClerkRelationId(ToolUtil.randomUUID());
dto.setStatusFlag(1);
......@@ -157,7 +137,7 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService
String wxEnterpriseId = dto.getWxEnterpriseId();
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();
......@@ -168,7 +148,7 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService
hmQrcodeQDTO.setPassFlag(1);
hmQrcodeQDTO.setStoreId(dto.getStoreId());
hmQrcodeQDTO.setClerkIdList(Collections.singletonList(dto.getClerkId()));
hmQrcodeQDTO.setInvokingType(chanelCode);
hmQrcodeQDTO.setInvokingType(channelCode);
hmQrcodeApiService.add(hmQrcodeQDTO);
}
return s;
......
......@@ -112,6 +112,7 @@ public class StoreRangeServiceImpl implements StoreRangeService {
return true;
}
String enterpriseId = list.get(0).getEnterpriseId();
String wxEnterpriseId = list.get(0).getWxEnterpriseId();
//更新前绑定门店列表
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())));
......@@ -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);
return true;
......@@ -217,9 +218,6 @@ public class StoreRangeServiceImpl implements StoreRangeService {
Map<String, Set<String>> ret = new HashMap<>();
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) {
wxEnterpriseIds.addAll(oldStoreIdBywxEnterpriseMap.keySet());
}
......
......@@ -73,8 +73,6 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
@Autowired
private QywxUserApiService qywxUserApiService;
@Autowired
private SecretSettingService secretSettingService;
@Autowired
private WxEnterpriseService wxEnterpriseService;
@Autowired
private HmClerkRelationApiService hmClerkRelationApiService;
......@@ -168,7 +166,7 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
}
@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));
ServiceResponse<Object> response = new ServiceResponse<>();
StaffClerkRelationDTO relationDTO = staffClerkRelationService.getBindByClerkId(staffClerkRelationDTO.getClerkId(), staffClerkRelationDTO.getWxEnterpriseId());
......@@ -199,7 +197,7 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
return response;
}
String relationId = staffClerkRelationService.bind(staffClerkRelationDTO, optStaffId, chanelCode);
String relationId = staffClerkRelationService.bind(staffClerkRelationDTO, optStaffId, channelCode);
response.setResult(relationId);
return response;
}
......@@ -231,7 +229,7 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
public List<StaffClerkRelationDTO> listByStoreId(String storeId) {
List<TabHaobanStaffClerkRelation> list = tabHaobanStaffClerkRelationMapper.listByStoreId(storeId);
if (CollectionUtil.isEmpty(list)) {
return new ArrayList<StaffClerkRelationDTO>();
return new ArrayList<>();
}
List<StaffClerkRelationDTO> result = EntityUtil.changeEntityListByJSON(StaffClerkRelationDTO.class, list);
return result;
......@@ -271,14 +269,14 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
}
@Override
public void delAndInsert(StaffClerkRelationDTO staffClerkRelation, String optStaffId, int chanelCode) {
public void delAndInsert(StaffClerkRelationDTO staffClerkRelation, String optStaffId, int channelCode) {
if (StringUtils.isNotBlank(staffClerkRelation.getStaffClerkRelationId())) {
TabHaobanStaffClerkRelation oldStaffClerkRelation = tabHaobanStaffClerkRelationMapper.selectByPrimaryKey(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());
}
staffClerkRelationService.bind(staffClerkRelation, optStaffId, chanelCode);
staffClerkRelationService.bind(staffClerkRelation, optStaffId, channelCode);
}
@Override
......@@ -288,6 +286,21 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
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
public List<StaffClerkRelationDTO> listByEnterpriseIdAndStaffid(String enterpriseId, String staffid) {
List<TabHaobanStaffClerkRelation> list = tabHaobanStaffClerkRelationMapper.listByEnterpriseIdAndStaffid(enterpriseId, staffid);
......@@ -367,21 +380,6 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
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
public ServiceResponse<String> getClerkMemberChatConfig(String clerkId) {
ServiceResponse response = new ServiceResponse();
......@@ -516,8 +514,7 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
@Override
public int getCanAddHmCount(String wxEnterpriseId, String enterpriseId, String clerkId) {
int count = this.hmQrcodeService.getCanAddCount(wxEnterpriseId, enterpriseId, clerkId);
return count;
return this.hmQrcodeService.getCanAddCount(wxEnterpriseId, enterpriseId, clerkId);
}
@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