Commit 88972b8e by 淡漠

统计修改,新客拉群API

1 parent 9398c04a
......@@ -12,6 +12,9 @@ import com.linkwechat.wecom.domain.WeEmpleCode;
import com.linkwechat.wecom.domain.dto.WeCommunityNewGroupDto;
import com.linkwechat.wecom.domain.vo.WeCommunityNewGroupVo;
import com.linkwechat.wecom.service.IWeCommunityNewGroupService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
......@@ -28,6 +31,7 @@ import java.util.stream.Collectors;
* @author kewen
* @date 2021-02-19
*/
@Api(description = "新客自动拉群 Controller")
@Controller
@RequestMapping(value = "communityNewGroup")
public class WeCommunityNewGroupController extends BaseController {
......@@ -38,6 +42,7 @@ public class WeCommunityNewGroupController extends BaseController {
/**
* 查询新客自动拉群列表
*/
@ApiOperation(value = "查询新客自动拉群列表",httpMethod = "GET")
@PreAuthorize("@ss.hasPermi('wecom:communityNewGroup:list')")
@GetMapping("/list")
public TableDataInfo list(WeCommunityNewGroup communityNewGroup) {
......@@ -49,15 +54,17 @@ public class WeCommunityNewGroupController extends BaseController {
/**
* 获取新客自动拉群详细信息
*/
@ApiOperation(value = "获取新客自动拉群详细信息",httpMethod = "GET")
@PreAuthorize("@ss.hasPermi('wecom:communityNewGroup:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("newGroupId") Long newGroupId) {
public AjaxResult getInfo(@PathVariable("newGroupId") @ApiParam("主键ID") Long newGroupId) {
return AjaxResult.success(weCommunityNewGroupService.selectWeCommunityNewGroupById(newGroupId));
}
/**
* 修改新客自动拉群
*/
@ApiOperation(value = "修改新客自动拉群",httpMethod = "PUT")
@PreAuthorize("@ss.hasPermi('wecom:communityNewGroup:edit')")
@Log(title = "新客自动拉群", businessType = BusinessType.UPDATE)
@PutMapping("/update")
......@@ -70,6 +77,7 @@ public class WeCommunityNewGroupController extends BaseController {
/**
* 删除新客自动拉群
*/
@ApiOperation(value = "删除新客自动拉群",httpMethod = "DELETE")
@PreAuthorize("@ss.hasPermi('wecom:communityNewGroup:remove')")
@Log(title = "新客自动拉群", businessType = BusinessType.DELETE)
@DeleteMapping("/delete/{ids}")
......@@ -82,6 +90,7 @@ public class WeCommunityNewGroupController extends BaseController {
/**
* 新增新客自动拉群
*/
@ApiOperation(value = "新增新客自动拉群",httpMethod = "POST")
@PreAuthorize("@ss.hasPermi('wecom:communityNewGroup:add')")
@Log(title = "新客自动拉群", businessType = BusinessType.INSERT)
@PostMapping("/add")
......
......@@ -55,7 +55,7 @@ public class GroupChatStatisticTask {
idList.add(weGroup.getOwner());
ownerFilter.setUserid_list(idList);
query.setOwnerFilter(ownerFilter);
GroupChatStatisticDto groupChatStatistic = weCustomerClient.getGroupChatStatistic(query);
GroupChatStatisticDto groupChatStatistic = weCustomerClient.getGroupChatStatisticGroupByDay(query);
List<GroupChatStatisticDto.GroupchatStatisticData> items = groupChatStatistic.getItems();
if(CollectionUtil.isNotEmpty(items)){
items.forEach(groupchatStatisticData -> {
......
......@@ -95,12 +95,12 @@ public class PageHomeDataTask {
String today = DateUtil.today();
String yesterday = DateUtil.yesterday().toDateStr();
//客户统计
WePageCountDto newTime = weUserBehaviorDataService.getCountDataByDay(today,"d");
WePageCountDto newTime = weUserBehaviorDataService.getCountDataByDay(today,"day");
/**
* 昨日
*/
//客户统计
WePageCountDto lastTime = weUserBehaviorDataService.getCountDataByDay(yesterday,"d");
WePageCountDto lastTime = weUserBehaviorDataService.getCountDataByDay(yesterday,"day");
WePageStaticDataDto.PageStaticData pageStaticData = setPageStaticData(newTime, lastTime);
......@@ -120,12 +120,12 @@ public class PageHomeDataTask {
* 本周
*/
//客户统计
WePageCountDto newTime = weUserBehaviorDataService.getCountDataByDay(DateUtil.today(),"w");
WePageCountDto newTime = weUserBehaviorDataService.getCountDataByDay(DateUtil.today(),"week");
/**
* 上周
*/
//客户统计
WePageCountDto lastTime = weUserBehaviorDataService.getCountDataByDay(DateUtil.lastWeek().toDateStr(),"w");
WePageCountDto lastTime = weUserBehaviorDataService.getCountDataByDay(DateUtil.lastWeek().toDateStr(),"week");
WePageStaticDataDto.PageStaticData pageStaticData = setPageStaticData(newTime, lastTime);
......@@ -142,12 +142,12 @@ public class PageHomeDataTask {
* 本周
*/
//客户统计
WePageCountDto newTime = weUserBehaviorDataService.getCountDataByDay(DateUtil.today(),"m");
WePageCountDto newTime = weUserBehaviorDataService.getCountDataByDay(DateUtil.today(),"month");
/**
* 上周
*/
//客户统计
WePageCountDto lastTime = weUserBehaviorDataService.getCountDataByDay(DateUtil.lastMonth().toDateStr(),"m");
WePageCountDto lastTime = weUserBehaviorDataService.getCountDataByDay(DateUtil.lastMonth().toDateStr(),"month");
WePageStaticDataDto.PageStaticData pageStaticData = setPageStaticData(newTime, lastTime);
......
......@@ -100,10 +100,18 @@ public interface WeCustomerClient {
UserBehaviorDataDto getUserBehaviorData(@JSONBody UserBehaviorDataQuery query);
/**
* 联系客户统计
* 群聊数据统计(按群主聚合的方式)
* @return
*/
@Request(url = "/externalcontact/groupchat/statistic",
type = "POST")
GroupChatStatisticDto getGroupChatStatistic(@JSONBody GroupChatStatisticQuery query);
/**
* 群聊数据统计(按自然日聚合的方式)
* @return
*/
@Request(url = "/externalcontact/groupchat/statistic_group_by_day",
type = "POST")
GroupChatStatisticDto getGroupChatStatisticGroupByDay(@JSONBody GroupChatStatisticQuery query);
}
......@@ -2,6 +2,8 @@ package com.linkwechat.wecom.domain;
import com.linkwechat.common.core.domain.BaseEntity;
import com.linkwechat.common.utils.SnowFlakeUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
......@@ -10,6 +12,7 @@ import lombok.Data;
* @author kewen
* @date 2021-02-19
*/
@ApiModel
@Data
public class WeCommunityNewGroup extends BaseEntity {
......@@ -21,46 +24,55 @@ public class WeCommunityNewGroup extends BaseEntity {
/**
* 员工活码名称
*/
@ApiModelProperty("员工活码名称")
private String empleCodeName;
/**
* 活动场景
*/
@ApiModelProperty("活动场景")
private String activityScene;
/**
* 欢迎语
*/
@ApiModelProperty("欢迎语")
private String welcomeMsg;
/**
* 二维码链接
*/
@ApiModelProperty("二维码链接")
private String qrCode;
/**
* 客户添加时无需经过确认自动成为好友:1:是;0:否
*/
@ApiModelProperty("客户添加时无需经过确认自动成为好友:1:是;0:否")
private Boolean isJoinConfirmFriends;
/**
* 添加好友数
*/
@ApiModelProperty("添加好友数")
private Integer joinFriendNums;
/**
* 群活码ID
*/
@ApiModelProperty("群活码ID")
private Long groupCodeId;
/**
* 素材的id
*/
@ApiModelProperty("素材的id")
private Long mediaId;
/**
* 0 未删除 1 已删除
*/
@ApiModelProperty("0 未删除 1 已删除")
private int delFlag;
}
......@@ -46,7 +46,7 @@ public class WeGroupStatistic implements Serializable {
* 数据日期
*/
@Excel(name = "数据日期", width = 30, dateFormat = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd")
private Date statTime;
/**
......
......@@ -45,7 +45,7 @@ public class WeUserBehaviorData implements Serializable {
* 数据日期,为当日0点的时间戳
*/
@Excel(name = "数据日期,为当日0点的时间戳", width = 30, dateFormat = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd")
private Date statTime;
/**
......
......@@ -23,10 +23,12 @@ public class GroupChatStatisticDto {
/**
* 数据日期,为当日0点的时间戳
*/
@JSONField(format="unixtime")
@JsonFormat(pattern = "yyyy-MM-dd")
private Date statTime;
public void setStatTime(Long statTime) {
this.statTime = new Date(statTime * 1000);
}
private StatisticData data;
......
package com.linkwechat.wecom.domain.dto;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
......@@ -12,8 +10,7 @@ import java.util.List;
* @author danmo
*/
@Data
public class UserBehaviorDataDto {
public class UserBehaviorDataDto{
private List<BehaviorData> behaviorData;
......@@ -23,37 +20,40 @@ public class UserBehaviorDataDto {
/**
* 数据日期,为当日0点的时间戳
*/
@JSONField(format="unixtime")
@JsonFormat(pattern = "yyyy-MM-dd")
private Date statTime;
public void setStatTime(Long statTime) {
this.statTime = new Date(statTime * 1000);
}
/**
* 聊天总数, 成员有主动发送过消息的单聊总数。
*/
private Integer chatCnt;
private Integer chatCnt = 0;
/**
* 发送消息数,成员在单聊中发送的消息总数。
*/
private Integer messageCnt;
private Integer messageCnt = 0;
/**
* 已回复聊天占比,浮点型,客户主动发起聊天后,成员在一个自然日内有回复过消息的聊天数/客户主动发起的聊天数比例,不包括群聊,仅在确有聊天时返回。
*/
private Float replyPercentage;
private Float replyPercentage = 0.00f;
/**
* 平均首次回复时长,单位为分钟,即客户主动发起聊天后,成员在一个自然日内首次回复的时长间隔为首次回复时长,所有聊天的首次回复总时长/已回复的聊天总数即为平均首次回复时长,不包括群聊,仅在确有聊天时返回。
*/
private Integer avgReplyTime;
private Integer avgReplyTime = 0;
/**
* 删除/拉黑成员的客户数,即将成员删除或加入黑名单的客户数。
*/
private Integer negativeFeedbackCnt;
private Integer negativeFeedbackCnt = 0;
/**
* 主动向客户发起的好友申请数量
*/
private Integer newApplyCnt;
private Integer newApplyCnt = 0;
/**
* 新增客户数,成员新添加的客户数量。
*/
private Integer newContactCnt;
private Integer newContactCnt = 0;
}
}
......@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linkwechat.wecom.domain.WeUserBehaviorData;
import com.linkwechat.wecom.domain.dto.WePageCountDto;
import com.linkwechat.wecom.domain.query.WePageStateQuery;
import org.apache.ibatis.annotations.Param;
import java.util.List;
......@@ -20,7 +21,7 @@ public interface WeUserBehaviorDataMapper extends BaseMapper<WeUserBehaviorData>
* @param dateTime
* @return WeUserBehaviorDataDto
*/
public WePageCountDto getCountDataByDay(String dateTime,String type);
public WePageCountDto getCountDataByDay(@Param("dateTime") String dateTime, @Param("type") String type);
/**
* 按天维度查询数据统计
......
......@@ -19,25 +19,25 @@
<select id="getCountDataByDay" resultType="com.linkwechat.wecom.domain.dto.WePageCountDto">
select
date_format(stat_time, '%Y-%m-%d') as x_time
sum(new_apply_cnt) as new_apply_cnt,
sum(new_contact_cnt) as new_contact_cnt
sum(chat_cnt) as chat_cnt
sum(new_contact_cnt) as message_cnt
sum(new_contact_cnt) as reply_percentage
sum(new_contact_cnt) as avg_reply_time
sum(new_contact_cnt) as negative_feedback_cnt
date_format(stat_time, '%Y-%m-%d') as x_time,
IFNULL(sum(new_apply_cnt),0) as new_apply_cnt,
IFNULL(sum(new_contact_cnt),0) as new_contact_cnt,
IFNULL(sum(chat_cnt),0) as chat_cnt,
IFNULL(sum(message_cnt),0) as message_cnt,
IFNULL(sum(reply_percentage),0) as reply_percentage,
IFNULL(sum(avg_reply_time),0) as avg_reply_time,
IFNULL(sum(negative_feedback_cnt),0) as negative_feedback_cnt
from we_user_behavior_data
<where>
<choose>
<when test="type !=null and type == 'd'">
<when test="type !=null and type == 'day'">
date_format(stat_time, '%Y-%m-%d') = date_format(#{dateTime}, '%Y-%m-%d');
</when>
<when test="type !=null and type == 'w'">
YEARWEEK(date_format(stat_time,'%Y-%m-%d')) = YEARWEEK(date_format(#{dateTime}, '%Y-%m-%d')});
<when test="type !=null and type == 'week'">
YEARWEEK(date_format(stat_time,'%Y-%m-%d')) = YEARWEEK(date_format(#{dateTime}, '%Y-%m-%d'));
</when>
<when test="type !=null and type == 'm'">
DATE_FORMAT(date_format(stat_time,'%Y-%m')) = DATE_FORMAT(date_format(#{dateTime}, '%Y-%m'));
<when test="type !=null and type == 'month'">
DATE_FORMAT(stat_time,'%Y-%m') = DATE_FORMAT(#{dateTime}, '%Y-%m');
</when>
<!--查询今年-->
<otherwise>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!