Commit da900c73 by 徐高华

群统计

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