Commit 55333ac4 by 徐高华

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

群统计

See merge request !567
parents 3bcce2d5 da900c73
......@@ -32,7 +32,9 @@ public interface GroupChatMapper {
public int updateData(@Param("groupChatId") Long groupChatId, @Param("totalCount") int totalCount,
@Param("totalMemberCount") int totalMemberCount, @Param("addMemberCount") int addMemberCount,
@Param("addCount") int addCount, @Param("quitCount") int quitCount,
@Param("quitMemberCount") int quitMemberCount, @Param("updateType") int updateType);
@Param("quitMemberCount") int quitMemberCount);
public int addMemberCount(@Param("groupChatId")Long groupChatId) ;
// 更新群状态
public int updateChatStatus(@Param("groupChatId") Long groupChatId, @Param("chatStatus") int chatStatus);
......
......@@ -32,7 +32,25 @@ public interface GroupChatUserMapper {
public List<TabGroupChatUser> listAllChatUser(@Param("wxEnterpriseId") String wxEnterpriseId,
@Param("groupChatId") Long groupChatId);
public List<GroupChatUserDTO> listPage(GroupChatUserSearchQDTO qdto);
/**
*
* @Title: listByExternalUseridForMatch
* @Description: 通过外部联系人查询需要匹配gic会员的列表
* @author xugh
* @param wxEnterpriseId
* @param enterpriseId
* @param externalUserid
* @return
* @throws
*/
public List<TabGroupChatUser> listByExternalUseridForMatch(@Param("wxEnterpriseId") String wxEnterpriseId,
@Param("enterpriseId") String enterpriseId, @Param("externalUserid") String externalUserid);
public void updateToGicMember(@Param("wxEnterpriseId") String wxEnterpriseId,
@Param("enterpriseId") String enterpriseId, @Param("externalUserid") String externalUserid,
@Param("memberId") String memberId);
}
\ No newline at end of file
......@@ -52,8 +52,18 @@ public class TabGroupChatUser implements Serializable{
/**入群说明*/
private String joinRemark;
private String joinState;
// 0 成员 1群主 2管理员
private Integer adminFlag ;
public String getInvitorUserName() {
public Integer getAdminFlag() {
return adminFlag;
}
public void setAdminFlag(Integer adminFlag) {
this.adminFlag = adminFlag;
}
public String getInvitorUserName() {
return invitorUserName;
}
......
......@@ -91,7 +91,7 @@ public interface GroupChatService {
* @throws
*/
public List<GroupChatOwnerHistoryDTO> listOwnerHistory(Long groupChatId, String WxEnterpriseId);
/**
*
* @Title: transfer
......@@ -103,6 +103,18 @@ public interface GroupChatService {
* @return
* @throws
*/
public void transfer(String wxEnterpriseId , String staffId , List<Long> groupChatIdList) ;
public void transfer(String wxEnterpriseId, String staffId, List<Long> groupChatIdList);
/**
*
* @Title: matchMemberId
* @Description: 加好友匹配客户
* @author xugh
* @param wxEnterpriseId
* @param memberId
* @param externalUserId
* @throws
*/
public void matchGicMember(String wxEnterpriseId, String enterpriseId, String memberId, String externalUserId);
}
\ No newline at end of file
......@@ -8,5 +8,5 @@ import com.gic.haoban.manage.api.dto.qdto.chat.GroupChatUserSearchQDTO;
public interface GroupChatUserService {
Page<GroupChatUserDTO> listPage(GroupChatUserSearchQDTO qdto, BasePageInfo basePageInfo);
}
\ No newline at end of file
......@@ -185,9 +185,10 @@ public class GroupChatServiceImpl implements GroupChatService {
@Override
public void refreshChatInfo(Long groupChatId) {
logger.info("刷新群信息={}", groupChatId);
TabGroupChat chat = this.groupChatMapper.selectById(groupChatId);
if (null == chat) {
logger.info("群主变更事件,群不存在");
logger.info("群不存在");
return;
}
String wxEnterpriseId = chat.getWxEnterpriseId();
......@@ -409,7 +410,11 @@ public class GroupChatServiceImpl implements GroupChatService {
String enterpriseId = chat.getEnterpriseId();
ServiceResponse<GroupChatDetailDTO> detailResp = this.qywxChatApiService
.groupchatDetail3th(qwDTO.getThirdCorpid(), config.getWxSuiteid(), chat.getWxChatId(), 1);
logger.info("从企微获取群详情={}", JSON.toJSON(detailResp));
if (!detailResp.isSuccess()) {
logger.info("从企微获取群详情失败");
return;
}
GroupChatDetailDTO detail = detailResp.getResult();
chat.setGroupChatId(groupChatId);
chat.setChatAddTime(new Date(detail.getCreate_time() * 1000));
......@@ -482,7 +487,7 @@ public class GroupChatServiceImpl implements GroupChatService {
String userId = member.getUserid();
TabGroupChatUser user = userMap.get(userId);
if (null != user) {
logger.info("更新用户");
logger.info("更新用户,id={}", userId);
if (StringUtils.isEmpty(user.getMemberId())) {
this.matchGicMember(wxEnterpriseId, enterpriseId, member.getUnionid(), userId, user);
}
......@@ -553,15 +558,15 @@ public class GroupChatServiceImpl implements GroupChatService {
}
}
}
this.updateDate(groupChatId, totalCount, totalMemberCount, addMemberCount, addCount, quitCount, quitMemberCount,
0);
this.updateDate(groupChatId, totalCount, totalMemberCount, addMemberCount, addCount, quitCount,
quitMemberCount);
}
private void updateDate(Long groupChatId, int totalCount, int totalMemberCount, int addMemberCount, int addCount,
int quitCount, int quitMemberCount, int updateType) {
logger.info("更新群的统计");
int quitCount, int quitMemberCount) {
logger.info("更新群的统计,groupChatId={}", groupChatId);
this.groupChatMapper.updateData(groupChatId, totalCount, totalMemberCount, addMemberCount, addCount, quitCount,
quitMemberCount, updateType);
quitMemberCount);
}
private void saveOwnerHistory(String wxEnterpriseId, Long groupChatId, String newStaffId, String oldStaffId) {
......@@ -613,6 +618,21 @@ public class GroupChatServiceImpl implements GroupChatService {
}
}
@Override
public void matchGicMember(String wxEnterpriseId, String enterpriseId, String memberId, String externalUserId) {
logger.info("加好友匹配群客户,memberId={},externalUserId={}", memberId, externalUserId);
List<TabGroupChatUser> list = this.groupChatUserMapper.listByExternalUseridForMatch(wxEnterpriseId,
enterpriseId, externalUserId);
if (CollectionUtils.isNotEmpty(list)) {
this.groupChatUserMapper.updateToGicMember(wxEnterpriseId, enterpriseId, externalUserId, memberId);
Set<Long> groupChatIdList = list.stream().map(dto -> dto.getGroupChatId()).collect(Collectors.toSet());
groupChatIdList.forEach(groupChatId -> {
logger.info("群加会员数={}", groupChatId);
this.groupChatMapper.addMemberCount(groupChatId);
});
}
}
private String getWxEnterpriesId(String corpid) {
TabHaobanWxEnterprise wxEnterprise = this.wxEnterpriseService.getEnterpriseBycorpId(corpid);
if (wxEnterprise == null) {
......
......@@ -101,6 +101,7 @@ import com.gic.haoban.manage.service.service.StaffService;
import com.gic.haoban.manage.service.service.WelcomeService;
import com.gic.haoban.manage.service.service.WxEnterpriseRelatedService;
import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.haoban.manage.service.service.chat.GroupChatService;
import com.gic.haoban.manage.service.service.hm.HmLinkService;
import com.gic.haoban.manage.service.service.hm.WxUserAddLogService;
import com.gic.haoban.manage.service.util.CommonUtil;
......@@ -211,6 +212,8 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
private MemberEntranceApiService memberEntranceApiService;
@Autowired
private QywxSendService qywxSendService ;
@Autowired
private GroupChatService groupChatService ;
@Override
......@@ -527,6 +530,9 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
wxUserAddLogQDTO.setStaffName(staffName);
wxUserAddLogQDTO.setClerkId(hyClerkId);
this.wxUserAddLogService.save(wxUserAddLogQDTO);
if(StringUtils.isNotBlank(memberId)) {
this.groupChatService.matchGicMember(wxEnterpriseId, enterpriseId, memberId, externalUserId);
}
}
// 获取hm关联的导购
......
......@@ -36,8 +36,6 @@ import com.gic.haoban.manage.service.service.WxEnterpriseRelatedService;
import com.gic.haoban.manage.service.service.chat.GroupChatService;
import com.gic.haoban.manage.service.service.chat.GroupChatUserService;
import cn.hutool.json.JSONArray;
@Service("groupChatApiService")
public class GroupChatApiServiceImpl implements GroupChatApiService {
......
......@@ -115,6 +115,7 @@
chat_status=#{chatStatus},
update_time=now(),
gic_flag=#{gicFlag},
original_staff_id = #{originalStaffId} ,
init_flag = 1
where group_chat_id = #{groupChatId}
]]>
......@@ -132,6 +133,13 @@
where group_chat_id = #{groupChatId}
</update>
<update id="addMemberCount">
update tab_haoban_group_chat set
total_member_count = 1 + total_member_count,
add_member_count = 1 + add_member_count
where group_chat_id = #{groupChatId}
</update>
<update id="updateWxChatIdDk">
update tab_haoban_group_chat set wx_chat_id_dk=#{wxChatIdDk} where staff_id = #{staffId} and chat_add_time=#{chatAddTime} and name=#{name}
</update>
......
......@@ -26,6 +26,7 @@
<result column="join_scene" property="joinScene" />
<result column="join_remark" property="joinRemark" />
<result column="join_state" property="joinState" />
<result column="admin_flag" property="adminFlag"/>
</resultMap>
<sql id="Base_Column_List">
chat_user_id,
......@@ -48,7 +49,7 @@
quit_scene,
join_scene,
join_remark,
join_state , invitor_user_name
join_state , invitor_user_name , admin_flag
</sql>
<!-- ===================== 新增 ======================== -->
<insert id="insert"
......@@ -75,7 +76,7 @@
quit_scene,
join_scene,
join_remark,
join_state , invitor_user_name
join_state , invitor_user_name , admin_flag
)VALUES(
#{chatUserId},
#{wxEnterpriseId},
......@@ -97,7 +98,7 @@
#{quitScene},
#{joinScene},
#{joinRemark},
#{joinState} , #{invitorUserName}
#{joinState} , #{invitorUserName} , #{adminFlag}
)
]]>
</insert>
......@@ -126,12 +127,10 @@
invitor_user_id=#{invitorUserId},
update_time=now(),
group_chat_id=#{groupChatId},
status_flag=#{statusFlag},
user_quit_time=#{userQuitTime},
quit_scene=#{quitScene},
join_scene=#{joinScene},
join_remark=#{joinRemark},
join_state=#{joinState}
join_state=#{joinState} ,
admin_flag = #{adminFlag}
where chat_user_id = #{chatUserId}
]]>
</update>
......@@ -154,6 +153,23 @@
select <include refid="Base_Column_List" /> from tab_haoban_group_chat_user where group_chat_id = #{groupChatId} and wx_enterprise_id = #{wxEnterpriseId} and status_flag = 1 and delete_flag = 0
</select>
<select id="listByExternalUseridForMatch" resultMap="result-map-tabHaobanGroupChatUser">
select <include refid="Base_Column_List" /> from tab_haoban_group_chat_user where user_id = #{externalUserid}
and wx_enterprise_id = #{wxEnterpriseId} and enterprise_id = #{enterpriseId}
and user_type != 3
and status_flag = 1 and delete_flag = 0
</select>
<update id="updateToGicMember">
update tab_haoban_group_chat_user set user_type = 3 , member_id = #{memberId} , update_time =now() where user_id = #{externalUserid}
and wx_enterprise_id = #{wxEnterpriseId} and enterprise_id = #{enterpriseId}
and user_type != 3
and status_flag = 1 and delete_flag = 0
</update>
<select id="listPage" parameterType="com.gic.haoban.manage.api.dto.qdto.chat.GroupChatUserSearchQDTO" resultType="com.gic.haoban.manage.api.dto.chat.GroupChatUserDTO">
select
b.name chatName ,
......
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