Commit c0e8f8bd by fudahua

同步通讯录 新增成员

parent 1a16783d
...@@ -60,4 +60,12 @@ public interface StaffApiService { ...@@ -60,4 +60,12 @@ public interface StaffApiService {
public List<StaffDTO> listByPhoneNumber(String phoneNumber); public List<StaffDTO> listByPhoneNumber(String phoneNumber);
public List<StaffDTO> listByUserIdsAndWxEnterpriseId(List<String> userIds, String wxEnterpriseId); public List<StaffDTO> listByUserIdsAndWxEnterpriseId(List<String> userIds, String wxEnterpriseId);
/**
* 保存gic成员
*
* @param clerkDTO
* @return
*/
public ServiceResponse saveSyncStaffByGic(GicClerkDTO clerkDTO);
} }
...@@ -828,8 +828,131 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -828,8 +828,131 @@ public class StaffApiServiceImpl implements StaffApiService {
} }
return list; return list;
} }
// private String getMobile(String phoneNumber,String nationcode){ @Override
public ServiceResponse saveSyncStaffByGic(GicClerkDTO clerkDTO) {
ServiceResponse response = new ServiceResponse();
if (clerkDTO == null) {
response.setCode(0);
response.setMessage("参数错误");
return response;
}
if (StringUtils.isBlank(clerkDTO.getStoreId())) {
logger.info("【店员同步】gicStoreId为空");
response.setCode(0);
response.setMessage("【店员同步】gicStoreId为空");
return response;
}
TabHaobanDepartment department = departmentService.selectByRelatedId(clerkDTO.getStoreId());
if (department == null) {
logger.info("【店员同步】失败====department为空:{}", clerkDTO.getStoreId());
response.setCode(0);
response.setMessage("部门门店不存在");
return response;
}
String departmentId = department.getDepartmentId();
String wxEnterpriseId = department.getWxEnterpriseId();
// StaffDTO staff = this.selectByNationcodeAndPhoneNumber(wxEnterpriseId, nationcode, phoneNumber);
StaffDTO staff = geCcheckAndInitUser(wxEnterpriseId, clerkDTO.getNationcode(), clerkDTO.getPhoneNumber());
if (staff == null) {
if (clerkDTO.getStatus() != 1) {
response.setCode(0);
response.setMessage("成员当前状态非正常" + clerkDTO.getStatus());
return response;
}
staff = new StaffDTO();
staff.setWxEnterpriseId(wxEnterpriseId);
staff.setClerkCode(clerkDTO.getClerkCode());
staff.setActiveFlag(1);
staff.setDepartmentIds(departmentId);
staff.setHeadImg(clerkDTO.getHeadImgUrl());
staff.setNationCode(clerkDTO.getNationcode());
staff.setPhoneNumber(clerkDTO.getPhoneNumber());
staff.setPostion(clerkDTO.getPostionName());
staff.setSex(clerkDTO.getClerkGender());
staff.setStaffName(clerkDTO.getClerkName());
staff.setNickName(clerkDTO.getClerkName());
staff.setSyncPostionFlag(1);
StaffDepartmentRelatedDTO isCodeExist = this.getDepartmentIdAndCode(departmentId, clerkDTO.getClerkCode());
logger.info("【gic导购新增】isCodeExist={}", JSON.toJSONString(isCodeExist));
//如果这个code已经绑定了 先解绑
if (isCodeExist != null) {
isCodeExist.setClerkCode(null);
staffDepartmentRelatedMapper.updateByPrimaryKey(EntityUtil.changeEntityByJSON(TabHaobanStaffDepartmentRelated.class, isCodeExist));
}
ServiceResponse hr = this.add(staff, department.getDepartmentId());
if (hr.getCode() == 1) {
StaffDepartmentRelatedDTO staffRelated = this.getDepartmentIdAndStaffId(departmentId, hr.getResult().toString());
logger.info("【gic导购新增】staffRelated={}", JSON.toJSONString(staffRelated));
//绑定
if (staffRelated != null) {
staffRelated.setClerkCode(clerkDTO.getClerkCode());
staffDepartmentRelatedMapper.updateByPrimaryKey(EntityUtil.changeEntityByJSON(TabHaobanStaffDepartmentRelated.class, staffRelated));
}
} else {
response.setCode(0);
response.setMessage(hr.getMessage());
return response;
}
} else {
String staffId = staff.getStaffId();
logger.info("【员工修改】staff={},status={}", JSON.toJSONString(staff), clerkDTO.getStatus());
//删除
if (clerkDTO.getStatus() == 0) {
StaffDepartmentRelatedDTO staffRelated = this.getDepartmentIdAndStaffId(departmentId, staffId);
if (staffRelated != null) {
staffRelated.setUpdateTime(new Date());
staffRelated.setClerkCode(null);
staffDepartmentRelatedMapper.updateByPrimaryKey(EntityUtil.changeEntityByJSON(TabHaobanStaffDepartmentRelated.class, staffRelated));
}
//修改
} else {
staff.setHeadImg(clerkDTO.getHeadImgUrl());
staff.setSex(clerkDTO.getClerkGender());
//staff.setPostion(postion);
// staff.setStaffName(staffName);
if (staff.getActiveFlag() != null && staff.getActiveFlag() != 1) {
staff.setStaffName(clerkDTO.getClerkName());
}
List<StaffDepartmentRelatedDTO> relatedList = this.listStaffDepartmentByStaffId(staffId);
Map<String, StaffDepartmentRelatedDTO> map = com.gic.commons.util.CollectionUtil.toMap(relatedList, "departmentId");
String departmentIds = "";
if (map.get(departmentId) == null) {
departmentIds = departmentId;
}
for (StaffDepartmentRelatedDTO staffDepartmentRelatedDTO : relatedList) {
departmentIds += "," + staffDepartmentRelatedDTO.getDepartmentId();
}
if (departmentIds.startsWith(",")) {
departmentIds = departmentIds.substring(1, departmentIds.length());
}
if (map.get(departmentId) == null) {
this.staffEdit(staff, departmentIds);
}
StaffDepartmentRelatedDTO staffRelated = this.getDepartmentIdAndStaffId(departmentId, staffId);
StaffDepartmentRelatedDTO isCodeExist = this.getDepartmentIdAndCode(departmentId, clerkDTO.getClerkCode());
//如果这个人已经绑定了 先解绑
if (isCodeExist != null) {
staffRelated.setUpdateTime(new Date());
isCodeExist.setClerkCode(null);
staffDepartmentRelatedMapper.updateByPrimaryKey(EntityUtil.changeEntityByJSON(TabHaobanStaffDepartmentRelated.class, isCodeExist));
}
//如果这个人是未绑定的 则绑定clerk
if (staffRelated != null) {
staffRelated.setUpdateTime(new Date());
staffRelated.setClerkCode(clerkDTO.getClerkCode());
staffDepartmentRelatedMapper.updateByPrimaryKey(EntityUtil.changeEntityByJSON(TabHaobanStaffDepartmentRelated.class, staffRelated));
}
this.staffEdit(staff, departmentIds);
}
}
return response;
}
// private String getMobile(String phoneNumber,String nationcode){
// String mobile = nationcode + phoneNumber; // String mobile = nationcode + phoneNumber;
// return mobile; // return mobile;
// } // }
......
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