Commit a848fb00 by qwmqiuwenmin

fix

parent 6301845f
......@@ -9,7 +9,9 @@ import com.alibaba.fastjson.JSONObject;
import com.gic.commons.util.ToolUtil;
import com.gic.haoban.manage.api.enums.BindTypeEnum;
import com.gic.haoban.manage.api.enums.ChannelCodeEnum;
import com.gic.haoban.manage.service.entity.TabHaobanClerkMainStoreRelated;
import com.gic.haoban.manage.service.entity.TabHaobanStaffClerkRelation;
import com.gic.haoban.manage.service.service.ClerkMainStoreRelatedService;
import com.gic.haoban.manage.service.service.ExternalClerkRelatedService;
import com.gic.haoban.manage.service.service.StaffClerkBindLogService;
import com.gic.haoban.manage.service.service.StaffService;
......@@ -44,6 +46,12 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService
@Autowired
private StaffService staffService;
@Autowired
private TabHaobanStaffClerkRelationMapper tabHaobanStaffClerkRelationMapper;
@Autowired
private ClerkMainStoreRelatedService clerkMainStoreRelatedService;
@Override
public List<StaffClerkRelationDTO> listBindCode(String enterpriseId, Set<String> clerkCodeList) {
......@@ -61,7 +69,9 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService
logger.info("已经不存在:{},{}",clerkId,optStaffId);
return true;
}
TabHaobanStaffClerkRelation staffClerkRelation = tabHaobanStaffClerkRelationMapper.getOneByClerkId(clerkId);
int i = mapper.changeStatusByClerkId(clerkId, 0);
delSetMainStore(staffClerkRelation);
boolean b = i >= 0;
if (b) {
//推入日志
......@@ -69,6 +79,36 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService
}
return b;
}
private void delSetMainStore(TabHaobanStaffClerkRelation staffClerkRelation){
if(staffClerkRelation == null){
logger.info("staffClerkRelation为空");
return;
}
String staffId = staffClerkRelation.getStaffId();
String wxEnterpriseId = staffClerkRelation.getWxEnterpriseId();
TabHaobanClerkMainStoreRelated r = clerkMainStoreRelatedService.selectByWxEnterpriseIdAndStoreId(staffId, wxEnterpriseId);
r.setStatusFlag(0);
clerkMainStoreRelatedService.update(r);
externalClerkRelatedService.delByClerkIdAndStaffId(staffClerkRelation.getClerkId(), staffId);
List<StaffClerkRelationDTO> list = this.lisByStaffId(wxEnterpriseId, staffId);
if(list != null && list.size() >= 1){
clerkMainStoreRelatedService.setMainStore(staffId, list.get(list.size()-1).getStoreId(), wxEnterpriseId);
}
}
private void setMainStore(StaffClerkRelationDTO staffClerkRelation){
if(staffClerkRelation == null){
logger.info("staffClerkRelation为空");
return;
}
String staffId = staffClerkRelation.getStaffId();
String wxEnterpriseId = staffClerkRelation.getWxEnterpriseId();
List<StaffClerkRelationDTO> list = this.lisByStaffId(wxEnterpriseId, staffId);
if(list != null && list.size() == 1){
clerkMainStoreRelatedService.setMainStore(staffId, staffClerkRelation.getStoreId(), wxEnterpriseId);
}
}
@Override
public String bind(StaffClerkRelationDTO dto,String optStaffId,int chanelCode) {
......@@ -78,6 +118,7 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService
dto.setUpdateTime(new Date());
int insert = mapper.insert(EntityUtil.changeEntityByJSON(TabHaobanStaffClerkRelation.class, dto));
setMainStore(dto);
String s = insert > 0 ? dto.getStaffClerkRelationId() : null;
if (null != s) {
//推入日志
......@@ -95,6 +136,8 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService
int i = mapper.updateByClerkId(EntityUtil.changeEntityByJSON(TabHaobanStaffClerkRelation.class, dto));
return i>=0;
}
@Override
public StaffClerkRelationDTO getBindByClerkId(String clerkId, String wxEnterpriseId) {
......
......@@ -203,8 +203,6 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
String relationId = staffClerkRelatinService.bind(staffClerkRelationDTO,optStaffId,chanelCode);
response.setResult(relationId);
//设置主门店
setMainStore(staffClerkRelationDTO);
return response;
}
......@@ -245,9 +243,7 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
@Override
public boolean unbindByStaffAndClerkId(String staffId, String clerkId) {
TabHaobanStaffClerkRelation staffClerkRelation = tabHaobanStaffClerkRelationMapper.getOneByClerkId(clerkId);
boolean b = staffClerkRelatinService.delBind(clerkId,staffId, ChannelCodeEnum.ADMIN_UNBIND.getCode());
delSetMainStore(staffClerkRelation);
return b;
}
@Override
......@@ -384,7 +380,7 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
externalClerkRelatedService.delByClerkIdAndStaffId(staffClerkRelation.getClerkId(), staffId);
List<StaffClerkRelationDTO> list = staffClerkRelatinService.lisByStaffId(wxEnterpriseId, staffId);
if(list != null && list.size() >= 1){
clerkMainStoreRelatedService.setMainStore(staffId, list.get(0).getStoreId(), wxEnterpriseId);
clerkMainStoreRelatedService.setMainStore(staffId, list.get(list.size()-1).getStoreId(), wxEnterpriseId);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment