Commit 889a0101 by huangZW

Merge branch 'developer' of http://115.159.76.241/haoban3.0/haoban-manage3.0.git into developer

parents ae267256 542d08a1
......@@ -61,4 +61,11 @@ public interface StaffApiService {
public List<StaffDTO> listByUserIdsAndWxEnterpriseId(List<String> userIds, String wxEnterpriseId);
/**
* 保存gic成员
*
* @param clerkDTO
* @return
*/
public ServiceResponse saveSyncStaffByGic(GicClerkDTO clerkDTO);
}
......@@ -844,8 +844,131 @@ public class StaffApiServiceImpl implements StaffApiService {
}
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;
// return mobile;
// }
......
......@@ -79,6 +79,7 @@ public class ClerkSyncOperation implements BaseSyncOperation {
public void dealSingleByMq(DealParamMqDTO dealParamMqDTO, TabHaobanPreDealLog dataPre) {
logger.info("成员处理:{}", JSONObject.toJSONString(dealParamMqDTO));
ClerkDTO clerkDTO = clerkService.getClerkByClerkIdNodel(dealParamMqDTO.getData());
String reason = "";
boolean dealFlag = true;
if (clerkDTO == null) {
logger.info("成员不存在:t:{},d:{}", dealParamMqDTO.getTaskId(), dealParamMqDTO.getData());
......@@ -100,14 +101,19 @@ public class ClerkSyncOperation implements BaseSyncOperation {
gicClerkDTO.setClerkName(clerkDTO.getClerkName());
gicClerkDTO.setStoreId(clerkDTO.getStoreId());
gicClerkDTO.setEnterpriseId(clerkDTO.getEnterpriseId());
staffApiService.addGicClerk(gicClerkDTO);
ServiceResponse response = staffApiService.saveSyncStaffByGic(gicClerkDTO);
if (response.getCode() != 1) {
reason = response.getMessage();
dealFlag = false;
}
} catch (Exception e) {
e.printStackTrace();
logger.info("同步失败:", JSONObject.toJSONString(dataPre));
reason = "成员处理异常";
dealFlag = false;
} finally {
if (!dealFlag) {
dealException(dealParamMqDTO.getTaskId(), dealParamMqDTO.getData(), dataPre.getEnterpriseId(), "成员处理异常");
dealException(dealParamMqDTO.getTaskId(), dealParamMqDTO.getData(), dataPre.getEnterpriseId(), reason);
} else {
dealSuccess(dealParamMqDTO.getTaskId(), dealParamMqDTO.getData(), dataPre.getEnterpriseId(), dataPre.getWxEnterpriseId());
}
......
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