Commit d177f468 by qwmqiuwenmin

fix

parent 37c5bb6a
......@@ -16,6 +16,7 @@ import org.springframework.stereotype.Service;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.gic.api.base.commons.JSONResponse;
import com.gic.api.base.commons.Page;
import com.gic.clerk.api.dto.ClerkDTO;
......@@ -26,10 +27,12 @@ import com.gic.enterprise.api.service.StoreService;
import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.common.utils.PageUtil;
import com.gic.haoban.common.utils.StringUtil;
import com.gic.haoban.common.utils.UuidUtil;
import com.gic.haoban.manage.api.dto.DepartmentDTO;
import com.gic.haoban.manage.api.dto.StaffDTO;
import com.gic.haoban.manage.api.dto.StaffDepartmentRelatedDTO;
import com.gic.haoban.manage.api.dto.SyncJsonColumnDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.service.dao.mapper.StaffDepartmentRelatedMapper;
......@@ -414,8 +417,154 @@ public class StaffApiServiceImpl implements StaffApiService {
@Override
public void syncGicClerk(String fieldListString) {
// TODO Auto-generated method stub
logger.info("【同步店员】fieldList={}",fieldListString);
List<SyncJsonColumnDTO> fieldList = JSONArray.parseArray(fieldListString,SyncJsonColumnDTO.class);
if(fieldList.isEmpty()){
return;
}
String gicEnterpriseId = "";
String gicStoreId = "";
String gicClerkId = "";
String code = "";
String staffName = "";
String phoneNumber = "";
String nationcode = "";
Integer sex = null;
String headPic = "";
Integer status = null;
String postion = "";
for (SyncJsonColumnDTO syncJsonColumnDTO:fieldList){
String name = StringUtil.camelName(syncJsonColumnDTO.getName());
String value = syncJsonColumnDTO.getValue();
if("clerkId".equals(name)){
gicClerkId = value;
continue;
}
if("enterpriseId".equals(name)){
gicEnterpriseId = value;
continue;
}
if("storeId".equals(name)){
gicStoreId = value;
if(StringUtils.isBlank(gicStoreId)){
return;
}
continue;
}
if("clerkName".equals(name)){
staffName = value;
continue;
}
if("clerkCode".equals(name)){
code = value;
continue;
}
if("clerkGender".equals(name)){
sex = value == null?null:Integer.parseInt(value);
continue;
}
if("status".equals(name)){
status = value == null?null:Integer.parseInt(value);
continue;
}
if("headImgUrl".equals(name)){
headPic = value;
continue;
}
if("postionName".equals(postion)){
postion = value;
continue;
}
if("nationcode".equals(name)){
if(StringUtils.isBlank(value)){
nationcode = "86";
}else{
nationcode = value;
}
continue;
}
}
if(StringUtils.isBlank(gicStoreId)){
logger.info("【店员同步】gicStoreId为空");
return;
}
TabHaobanDepartment department = departmentService.selectByRelatedId(gicStoreId);
if(department == null){
logger.info("【店员同步】gicStoreId为空");
return;
}
String departmentId = department.getDepartmentId();
String wxEnterpriseId = department.getWxEnterpriseId();
StaffDTO staff = this.selectByNationcodeAndPhoneNumber(wxEnterpriseId, nationcode, phoneNumber);
if(staff == null){
if(status != 1){
return;
}else{
staff = new StaffDTO();
staff.setWxEnterpriseId(wxEnterpriseId);
staff.setClerkCode(code);
staff.setActiveFlag(1);
staff.setDepartmentIds(departmentId);
staff.setHeadImg(headPic);
staff.setNationCode(nationcode);
staff.setPhoneNumber(phoneNumber);
staff.setNickName(staffName);
staff.setPostion(postion);
staff.setSex(sex);
staff.setStaffName(staffName);
staff.setSyncPostionFlag(1);
HaobanResponse hr = this.add(staff, department.getDepartmentId());
if(hr.getErrorCode() == 1){
StaffDepartmentRelatedDTO staffRelated = this.getDepartmentIdAndStaffId(departmentId, hr.getResult().toString());
if(staffRelated != null){
staffRelated.setClerkCode(code);
staffDepartmentRelatedMapper.updateByPrimaryKey(EntityUtil.changeEntityByJSON(TabHaobanStaffDepartmentRelated.class, staffRelated));
}
}
}
}else{
String staffId = staff.getStaffId();
//删除
if(status == 0){
StaffDepartmentRelatedDTO staffRelated = this.getDepartmentIdAndStaffId(departmentId, staffId);
if(staffRelated != null){
staffRelated.setClerkCode(null);
staffDepartmentRelatedMapper.updateByPrimaryKey(EntityUtil.changeEntityByJSON(TabHaobanStaffDepartmentRelated.class, staffRelated));
}
//修改
}else{
List<StaffDepartmentRelatedDTO> relatedList = this.listStaffDepartmentByStaffId(staffId);
String departmentIds = departmentId;
for (StaffDepartmentRelatedDTO staffDepartmentRelatedDTO : relatedList) {
departmentIds += "," + staffDepartmentRelatedDTO.getDepartmentId();
}
Map<String,StaffDepartmentRelatedDTO> map = com.gic.commons.util.CollectionUtil.toMap(relatedList, "departmentId");
if(map.get(departmentId) == null){
this.staffEdit(staff, departmentIds);
}
StaffDepartmentRelatedDTO staffRelated = this.getDepartmentIdAndStaffId(departmentId, staffId);
//如果这个人是未绑定的 则绑定clerk
if(StringUtils.isBlank(staffRelated.getClerkCode())){
staffRelated.setClerkCode(code);
staffDepartmentRelatedMapper.updateByPrimaryKey(EntityUtil.changeEntityByJSON(TabHaobanStaffDepartmentRelated.class, staffRelated));
}
}
}
}
}
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