Commit f2c822a0 by 徐高华

Merge branch 'feature/社群' into 'developer'

Feature/社群

See merge request !541
parents 4decf938 1bc2f213
......@@ -44,6 +44,7 @@ import com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise;
import com.gic.haoban.manage.service.entity.chat.TabChatNotice;
import com.gic.haoban.manage.service.entity.chat.TabGroupChat;
import com.gic.haoban.manage.service.entity.chat.TabGroupChatOwner;
import com.gic.haoban.manage.service.entity.chat.TabGroupChatOwnerHistory;
import com.gic.haoban.manage.service.entity.chat.TabGroupChatUser;
import com.gic.haoban.manage.service.pojo.bo.chat.GroupChatBO;
import com.gic.haoban.manage.service.service.SecretSettingService;
......@@ -394,10 +395,14 @@ public class GroupChatServiceImpl implements GroupChatService {
// 处理群主
String owner = detail.getOwner();
TabHaobanStaff staff = this.staffMapper.selectByUserIdAndEnterpriseId(owner, wxEnterpriseId);
String newStaffId = null;
String oldStaffId = chat.getStaffId();
if (null != staff) {
// 更新staff
newStaffId = staff.getStaffId();
chat.setStaffId(staff.getStaffId());
} else {
chat.setStaffId(null);
logger.info("群主未关联好办,不同步群成员,userid={}", owner);
}
if (StringUtils.isBlank(enterpriseId) && null != staff) {
......@@ -418,6 +423,9 @@ public class GroupChatServiceImpl implements GroupChatService {
if (StringUtils.isNotEmpty(chat.getEnterpriseId())) {
chat.setGicFlag(1);
}
// 判断是否更新群主
this.saveOwnerHistory(wxEnterpriseId, groupChatId, newStaffId, oldStaffId);
chat.setOriginalStaffId(oldStaffId);
this.groupChatMapper.update(chat);
if (null == staff) {
logger.info("不同步群成员信息,群主未关联好办,owner={}", owner);
......@@ -487,6 +495,27 @@ public class GroupChatServiceImpl implements GroupChatService {
// this.groupChatMapper.updateData();
}
private void saveOwnerHistory(String wxEnterpriseId, Long groupChatId, String newStaffId, String oldStaffId) {
if (null == newStaffId && null == oldStaffId) {
return;
}
if (null != newStaffId && null != oldStaffId && newStaffId.equals(oldStaffId)) {
return;
}
if (null != newStaffId) {
TabGroupChatOwnerHistory entity = new TabGroupChatOwnerHistory();
entity.setOwnerHistoryId(UniqueIdUtils.uniqueLong());
entity.setWxEnterpriseId(wxEnterpriseId);
entity.setGroupChatId(groupChatId);
entity.setStaffId(newStaffId);
entity.setCreateTime(new Date());
this.groupChatOwnerHistoryMapper.insert(entity);
}
if (null != oldStaffId) {
this.groupChatOwnerHistoryMapper.updateOwnerEnd(groupChatId, oldStaffId);
}
}
// 初始化群信息-不包括群状态
private void updateGroupChatDetail(WxEnterpriseQwDTO qwDTO, Long groupChatId, boolean syncMember) {
TabGroupChat chat = this.groupChatMapper.selectById(groupChatId);
......@@ -582,10 +611,19 @@ public class GroupChatServiceImpl implements GroupChatService {
Page<GroupChatOwnerDTO> retPage = PageHelperUtils.changePageHelperToCurrentPage(list, GroupChatOwnerDTO.class);
return retPage;
}
@Override
public List<GroupChatOwnerHistoryDTO> listOwnerHistory(Long groupChatId , String WxEnterpriseId) {
List<GroupChatOwnerHistoryDTO> list = this.groupChatOwnerHistoryMapper.listAll(groupChatId,WxEnterpriseId);
public List<GroupChatOwnerHistoryDTO> listOwnerHistory(Long groupChatId, String WxEnterpriseId) {
TabGroupChat chat = this.groupChatMapper.selectById(groupChatId);
if (null == chat || org.apache.commons.lang3.StringUtils.isEmpty(chat.getStaffId())) {
return null;
}
List<GroupChatOwnerHistoryDTO> list = this.groupChatOwnerHistoryMapper.listAll(groupChatId, WxEnterpriseId);
for (GroupChatOwnerHistoryDTO item : list) {
if (chat.getStaffId().equals(item.getStaffId())) {
item.setEndTime(null);
}
}
return list;
}
}
\ No newline at end of file
......@@ -74,7 +74,7 @@
quit_count,
quit_member_count,
enterprise_id,
gic_flag , init_flag , original_staff_id ,
gic_flag , init_flag , original_staff_id
)VALUES(
#{groupChatId},
#{wxEnterpriseId},
......
......@@ -49,6 +49,6 @@
<select id="listAll" resultType="com.gic.haoban.manage.api.dto.chat.GroupChatOwnerHistoryDTO">
select a.staff_id staffId , b.staff_name staffName , a.create_time createTime , a.end_time endTime from tab_haoban_group_chat_owner_history a LEFT JOIN tab_haoban_staff b on a.staff_id = b.staff_id
where a.group_chat_id=#{groupChatId} and a.wx_enterprise_id=#{wxEnterpriseId}
where a.group_chat_id=#{groupChatId} and a.wx_enterprise_id=#{wxEnterpriseId} order by a.create_time desc
</select>
</mapper>
\ No newline at end of file
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