Commit e064d6c7 by huangZW

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

parents c4ded71b c5a8df19
...@@ -37,6 +37,8 @@ public interface StaffClerkRelationApiService { ...@@ -37,6 +37,8 @@ public interface StaffClerkRelationApiService {
* @return * @return
*/ */
String delByStoreIdAndCode(String storeId,String clerkCode); String delByStoreIdAndCode(String storeId,String clerkCode);
List<StaffClerkRelationDTO> listByClerkIds(List<String> clerkIds); List<StaffClerkRelationDTO> listByClerkIds(List<String> clerkIds);
...@@ -48,4 +50,12 @@ public interface StaffClerkRelationApiService { ...@@ -48,4 +50,12 @@ public interface StaffClerkRelationApiService {
*/ */
List<StaffClerkRelationDTO>listByStoreId(String storeId); List<StaffClerkRelationDTO>listByStoreId(String storeId);
/**
* 解绑
* @param staffId
* @param clerkId
* @return
*/
boolean unbindByStaffAndClerkId(String staffId,String clerkId);
} }
...@@ -64,4 +64,6 @@ public interface TabHaobanStaffClerkRelationMapper { ...@@ -64,4 +64,6 @@ public interface TabHaobanStaffClerkRelationMapper {
* 解绑 * 解绑
*/ */
int cleanStaffDepart( @Param("wxEnterpriseId")String wxEnterpriseId,@Param("staffIds")List<String> staffIds); int cleanStaffDepart( @Param("wxEnterpriseId")String wxEnterpriseId,@Param("staffIds")List<String> staffIds);
TabHaobanStaffClerkRelation getOneBindCodeNoStatus(@Param("enterpriseId")String enterpriseId, @Param("clerkCode")String clerkCode);
} }
\ No newline at end of file
...@@ -47,4 +47,6 @@ public interface StaffClerkRelationService { ...@@ -47,4 +47,6 @@ public interface StaffClerkRelationService {
public int cleanStaffClerk( String wxEnterpriseId, List<String> staffIds); public int cleanStaffClerk( String wxEnterpriseId, List<String> staffIds);
StaffClerkRelationDTO getOneBindCodeNoStatus(String enterpriseId, String clerkCode);
} }
...@@ -90,4 +90,9 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService ...@@ -90,4 +90,9 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService
public int cleanStaffClerk(String wxEnterpriseId, List<String> staffIds) { public int cleanStaffClerk(String wxEnterpriseId, List<String> staffIds) {
return mapper.cleanStaffDepart(wxEnterpriseId,staffIds); return mapper.cleanStaffDepart(wxEnterpriseId,staffIds);
} }
@Override
public StaffClerkRelationDTO getOneBindCodeNoStatus(String enterpriseId, String clerkCode) {
return EntityUtil.changeEntityByJSON(StaffClerkRelationDTO.class,mapper.getOneBindCodeNoStatus(enterpriseId,clerkCode));
}
} }
...@@ -320,33 +320,36 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -320,33 +320,36 @@ public class StaffApiServiceImpl implements StaffApiService {
return res; return res;
} }
TabHaobanStaff staff = staffService.selectByUserIdAndEnterpriseId(userId,wxEnterpriseId); TabHaobanStaff staff = staffService.selectByUserIdAndEnterpriseId(userId,wxEnterpriseId);
staff = (staff==null?new TabHaobanStaff():staff);
staff.setWxUserId(userId);
staff.setUpdateTime(new Date());
staff.setStatusFlag(1);
staff.setWxEnterpriseId(wxEnterpriseId);
if(StringUtils.isNotBlank(user.getAvatar())){
staff.setHeadImg(changeHeaderImageUrl(user.getAvatar()));
}
staff.setPhoneNumber(user.getMobile());
if (StringUtils.isNotBlank(user.getName())) {
user.setName(EmojiParser.removeAllEmojis(user.getName()));
staff.setStaffName((user.getName()));
}
if (StringUtils.isNotBlank(user.getAlias())) {
user.setAlias(EmojiParser.removeAllEmojis(user.getAlias()));
staff.setNickName((user.getAlias()));
}
staff.setNationCode("86");
staff.setSex(user.getGender() == null ? 1:Integer.parseInt(user.getGender()));
staff.setActiveFlag(1);
staff.setPostion(user.getPosition());
staff.setExtendPostion(user.getExternal_position());
//成员更改或更新
if(staff == null) { if(staff == null) {
logger.info("新增成员"); logger.info("新增成员");
staff = new TabHaobanStaff();
staff.setWxUserId(userId);
staff.setCreateTime(new Date());
staff.setUpdateTime(new Date());
staff.setStatusFlag(1);
staff.setWxEnterpriseId(wxEnterpriseId);
if(StringUtils.isNotBlank(user.getAvatar())){
staff.setHeadImg(changeHeaderImageUrl(user.getAvatar()));
}
staff.setPhoneNumber(user.getMobile());
if (StringUtils.isNotBlank(user.getName())) {
user.setName(EmojiParser.removeAllEmojis(user.getName()));
staff.setStaffName((user.getName()));
}
if (StringUtils.isNotBlank(user.getAlias())) {
user.setAlias(EmojiParser.removeAllEmojis(user.getAlias()));
staff.setNickName((user.getAlias()));
}
staff.setNationCode("86");
staff.setSex(user.getGender() == null ? 1:Integer.parseInt(user.getGender()));
staff.setActiveFlag(1);
staff.setPostion(user.getPosition());
staff.setExtendPostion(user.getExternal_position());
staff.setActiveFlag(0); staff.setActiveFlag(0);
String staffId = staffService.add(staff); staff.setCreateTime(new Date());
staffService.add(staff);
}else{
staffService.updateByPrimaryKey(staff);
} }
logger.info("门店变更保存:{}",JSONObject.toJSONString(user)); logger.info("门店变更保存:{}",JSONObject.toJSONString(user));
staffDepartChange(staff,wxEnterpriseId,user); staffDepartChange(staff,wxEnterpriseId,user);
......
...@@ -145,4 +145,10 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe ...@@ -145,4 +145,10 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
List<StaffClerkRelationDTO> result = EntityUtil.changeEntityListByJSON(StaffClerkRelationDTO.class, list); List<StaffClerkRelationDTO> result = EntityUtil.changeEntityListByJSON(StaffClerkRelationDTO.class, list);
return result; return result;
} }
@Override
public boolean unbindByStaffAndClerkId(String staffId, String clerkId) {
boolean b = staffClerkRelatinService.delBind(clerkId);
return b;
}
} }
...@@ -4,19 +4,20 @@ import com.alibaba.fastjson.JSONObject; ...@@ -4,19 +4,20 @@ import com.alibaba.fastjson.JSONObject;
import com.gic.binlog.base.entity.GicField; import com.gic.binlog.base.entity.GicField;
import com.gic.binlog.base.entity.GicRecord; import com.gic.binlog.base.entity.GicRecord;
import com.gic.binlog.base.entity.enums.GicRecordType; import com.gic.binlog.base.entity.enums.GicRecordType;
import com.gic.commons.util.BeanUtil;
import com.gic.commons.util.EntityUtil; import com.gic.commons.util.EntityUtil;
import com.gic.haoban.contacts.manage.api.enums.StatusEnum;
import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import com.gic.haoban.manage.service.pojo.BinlogBasePojo; import com.gic.haoban.manage.service.pojo.BinlogBasePojo;
import com.gic.haoban.manage.service.pojo.ClerkSyncPojo; import com.gic.haoban.manage.service.pojo.ClerkSyncPojo;
import com.gic.haoban.manage.service.service.StaffClerkRelationService; import com.gic.haoban.manage.service.service.StaffClerkRelationService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateUtils;
import org.apache.kafka.clients.consumer.ConsumerRecord; import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.listener.MessageListener; import org.springframework.kafka.listener.MessageListener;
import java.util.ArrayList; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -58,7 +59,32 @@ public class KafkaMessageServiceImpl implements MessageListener<String, GicRecor ...@@ -58,7 +59,32 @@ public class KafkaMessageServiceImpl implements MessageListener<String, GicRecor
if(gicRecordType.equals(GicRecordType.DELETE)){ if(gicRecordType.equals(GicRecordType.DELETE)){
staffClerkRelationService.delBind(syncPojo.getClerkId()); staffClerkRelationService.delBind(syncPojo.getClerkId());
}else if (gicRecordType.equals(GicRecordType.INSERT)) { }else if (gicRecordType.equals(GicRecordType.INSERT)) {
StaffClerkRelationDTO relationDTO = staffClerkRelationService.getOneBindCodeNoStatus(syncPojo.getEnterpriseId(), syncPojo.getClerkCode());
if (null == relationDTO) {
logger.info("没有关联导购,不需要新增");
return;
}
//正常的时候
if (relationDTO.getStatusFlag() != StatusEnum.DEL.getValue()) {
staffClerkRelationService.delBind(relationDTO.getClerkId());
relationDTO.setClerkId(syncPojo.getClerkId());
relationDTO.setStoreId(syncPojo.getStoreId());
staffClerkRelationService.bind(relationDTO);
}else {//删除状态 需要判断是否近段时间有操作删除 2分组内有更新 判断是转移操作
Date timeDiff = DateUtils.addMinutes(new Date(), -2);
if(relationDTO.getUpdateTime().after(timeDiff)){
staffClerkRelationService.delBind(relationDTO.getClerkId());
relationDTO.setClerkId(syncPojo.getClerkId());
relationDTO.setStoreId(syncPojo.getStoreId());
staffClerkRelationService.bind(relationDTO);
}
}
}else if (gicRecordType.equals(GicRecordType.UPDATE)) {
StaffClerkRelationDTO relationDTO = new StaffClerkRelationDTO();
relationDTO.setClerkId(syncPojo.getClerkId());
relationDTO.setStoreId(syncPojo.getStoreId());
relationDTO.setClerkCode(syncPojo.getClerkCode());
staffClerkRelationService.updateByClerkId(relationDTO);
} }
} }
......
...@@ -274,4 +274,14 @@ ...@@ -274,4 +274,14 @@
#{item} #{item}
</foreach> </foreach>
</update> </update>
<select id="getOneBindCodeNoStatus" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
<include refid="Base_Column_List" />
from tab_haoban_staff_clerk_relation
where enterprise_id = #{enterpriseId,jdbcType=VARCHAR}
and clerk_code = #{clerkCode}
order by update_time desc limit 1
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -285,6 +285,21 @@ public class StaffController extends WebBaseController{ ...@@ -285,6 +285,21 @@ public class StaffController extends WebBaseController{
} }
/** /**
* 成员关联关系接口
* @param staffId
* @return
*/
@RequestMapping("del-clerk-relation")
public HaobanResponse delStaffClerkList(String staffId,String clerkId){
StaffDTO staff = staffApiService.selectById(staffId);
if(staff == null) {
return resultResponse(HaoBanErrCode.ERR_10007);
}
boolean b = staffClerkRelationApiService.unbindByStaffAndClerkId(staffId, clerkId);
return resultResponse(HaoBanErrCode.ERR_1,b);
}
/**
* 成员关联关系搜索接口 * 成员关联关系搜索接口
* @param search * @param search
* @return * @return
......
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