统计接口完善
This commit is contained in:
parent
af8bceb495
commit
bb7c854203
@ -12,7 +12,7 @@ public class ModuleUser implements Serializable {
|
||||
private Integer id;
|
||||
|
||||
@TableField("user_id")
|
||||
private Integer userId;
|
||||
private String userId;
|
||||
|
||||
@TableField("module_id")
|
||||
private Integer moduleId;
|
||||
@ -40,11 +40,11 @@ public class ModuleUser implements Serializable {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getUserId() {
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Integer userId) {
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
|
||||
@ -5,7 +5,6 @@ import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.syzb.business.entity.AppOrder;
|
||||
@ -15,9 +14,6 @@ import com.syzb.business.mapper.ModuleUserMapper;
|
||||
import com.syzb.business.vo.BusinessModuleUserVO;
|
||||
import com.syzb.business.vo.BusinessOrderVO;
|
||||
import com.syzb.common.constant.IsOrNot;
|
||||
import com.syzb.common.util.logger.LoggerUtil;
|
||||
import com.syzb.group.entity.GroupInfo;
|
||||
import com.syzb.group.mapper.GroupInfoMapper;
|
||||
import com.syzb.group.service.common.GroupCommonService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -25,7 +21,10 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@ -151,7 +150,7 @@ public class BusinessDataService {
|
||||
private ModuleUser convertModuleUser(BusinessModuleUserVO moduleUserVO, boolean isNew) {
|
||||
ModuleUser moduleUser = new ModuleUser();
|
||||
moduleUser.setId(moduleUserVO.getId());
|
||||
moduleUser.setUserId(moduleUserVO.getUserId());
|
||||
moduleUser.setUserId(String.valueOf(moduleUserVO.getUserId()));
|
||||
moduleUser.setModuleId(moduleUserVO.getModuleId());
|
||||
moduleUser.setEndTime(LocalDateTimeUtil.parse(moduleUserVO.getEndTime(), DatePattern.NORM_DATETIME_FORMATTER));
|
||||
moduleUser.setCreateTime(LocalDateTimeUtil.parse(moduleUserVO.getCreateTime(), DatePattern.NORM_DATETIME_FORMATTER));
|
||||
|
||||
@ -202,13 +202,6 @@ public class CommentBlackService {
|
||||
return new Pager<>(voList, page.getTotal());
|
||||
}
|
||||
|
||||
private void clearCache(String... cacheKeys) {
|
||||
IMap<String, Object> cacheMap = hazelcastInstance.getMap(COMMENT_BLACK);
|
||||
for (String key : cacheKeys) {
|
||||
cacheMap.remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验是否禁言
|
||||
*/
|
||||
@ -258,4 +251,30 @@ public class CommentBlackService {
|
||||
});
|
||||
}
|
||||
|
||||
public Set<String> getBlackUserIds(Integer productId, Integer productType) {
|
||||
Set<String> blackUsers = new HashSet<>();
|
||||
List<CommentBlack> blackComments = getAllBlackComment();
|
||||
for (CommentBlack commentBlack : blackComments) {
|
||||
if (CommentBlackScope.PRODUCT.value.equals(commentBlack.getScope())) {
|
||||
if (commentBlack.getProductId().equals(productId) && commentBlack.getProductType().equals(productType)) {
|
||||
blackUsers.add(commentBlack.getPhone());
|
||||
}
|
||||
} else if (CommentBlackScope.PRODUCT_TYPE.value.equals(commentBlack.getScope())) {
|
||||
if (commentBlack.getProductType().equals(productType)) {
|
||||
blackUsers.add(commentBlack.getPhone());
|
||||
}
|
||||
} else if (CommentBlackScope.GLOBAL.value.equals(commentBlack.getScope())) {
|
||||
blackUsers.add(commentBlack.getPhone());
|
||||
}
|
||||
}
|
||||
return blackUsers;
|
||||
}
|
||||
|
||||
private void clearCache(String... cacheKeys) {
|
||||
IMap<String, Object> cacheMap = hazelcastInstance.getMap(COMMENT_BLACK);
|
||||
for (String key : cacheKeys) {
|
||||
cacheMap.remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,19 @@
|
||||
package com.syzb.group.constant;
|
||||
|
||||
// 客户状态 1:在期 2:已到期 3:即将到期 4:新学员
|
||||
public enum GroupCustomerStatus {
|
||||
|
||||
IN_PERIOD(1, "在期"),
|
||||
EXPIRED(2, "已到期"),
|
||||
WILL_EXPIRED(3, "即将到期"),
|
||||
NEW_STUDENT(4, "新学员");
|
||||
|
||||
public final Integer value;
|
||||
public final String name;
|
||||
|
||||
GroupCustomerStatus(Integer value, String name) {
|
||||
this.value = value;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,54 @@
|
||||
package com.syzb.group.controller.admin;
|
||||
|
||||
import com.syzb.common.query.OnlyIdQuery;
|
||||
import com.syzb.common.result.CommonResult;
|
||||
import com.syzb.common.result.Pager;
|
||||
import com.syzb.common.vo.BackendUserVO;
|
||||
import com.syzb.group.query.ListGroupCustomerQuery;
|
||||
import com.syzb.group.query.QueryGroupCollectQuery;
|
||||
import com.syzb.group.service.admin.AdminGroupCollectService;
|
||||
import com.syzb.group.vo.GroupCollectVO;
|
||||
import com.syzb.group.vo.GroupCustomerVO;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Api(tags = "交易圈admin接口")
|
||||
@RestController
|
||||
public class AdminGroupCollectController {
|
||||
|
||||
@Resource
|
||||
private AdminGroupCollectService adminGroupCollectService;
|
||||
|
||||
@ApiOperation("后台查询交易圈统计")
|
||||
@PostMapping("/admin/group/collect/query")
|
||||
public CommonResult<List<GroupCollectVO>> queryCollect(@Validated @RequestBody @ApiParam(required = true) QueryGroupCollectQuery query,
|
||||
@RequestAttribute(value = "backendUser", required = false) BackendUserVO backendUserVO) {
|
||||
List<GroupCollectVO> list = adminGroupCollectService.queryCollect(query, backendUserVO);
|
||||
return CommonResult.success(list);
|
||||
}
|
||||
|
||||
@ApiOperation("后台查询交易圈当日统计")
|
||||
@PostMapping("/admin/group/collect/queryToday")
|
||||
public CommonResult<GroupCollectVO> queryTodayCollect(@Validated @RequestBody @ApiParam(required = true) OnlyIdQuery query,
|
||||
@RequestAttribute(value = "backendUser", required = false) BackendUserVO backendUserVO) {
|
||||
GroupCollectVO vo = adminGroupCollectService.queryTodayCollect(query, backendUserVO);
|
||||
return CommonResult.success(vo);
|
||||
}
|
||||
|
||||
@ApiOperation("后台查询学院列表")
|
||||
@PostMapping("/admin/group/college/listCustomer")
|
||||
public CommonResult<Pager<GroupCustomerVO>> listCustomer(@Validated @RequestBody @ApiParam(required = true) ListGroupCustomerQuery query,
|
||||
@RequestAttribute(value = "backendUser", required = false) BackendUserVO backendUserVO) {
|
||||
Pager<GroupCustomerVO> page = adminGroupCollectService.listCustomer(query, backendUserVO);
|
||||
return CommonResult.success(page);
|
||||
}
|
||||
}
|
||||
@ -7,10 +7,8 @@ import com.syzb.common.result.CommonResult;
|
||||
import com.syzb.common.result.Pager;
|
||||
import com.syzb.common.vo.BackendUserVO;
|
||||
import com.syzb.common.vo.InsertIdVO;
|
||||
import com.syzb.group.query.QueryGroupCollectQuery;
|
||||
import com.syzb.group.query.info.*;
|
||||
import com.syzb.group.service.GroupInfoService;
|
||||
import com.syzb.group.vo.GroupCollectVO;
|
||||
import com.syzb.group.service.admin.AdminGroupInfoService;
|
||||
import com.syzb.group.vo.GroupVO;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@ -22,21 +20,20 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Api(tags = "交易圈admin接口")
|
||||
@RestController
|
||||
public class AdminGroupInfoController {
|
||||
|
||||
@Resource
|
||||
private GroupInfoService groupInfoService;
|
||||
private AdminGroupInfoService adminGroupInfoService;
|
||||
|
||||
@ApiOperation("后台保存交易圈")
|
||||
@PostMapping("/admin/group/info/save")
|
||||
@Operation(module = ProductType.GROUP)
|
||||
public CommonResult<InsertIdVO> save(@Validated @RequestBody @ApiParam(required = true) SaveGroupQuery query,
|
||||
@RequestAttribute(value = "backendUser", required = false) BackendUserVO backendUserVO) {
|
||||
InsertIdVO vo = groupInfoService.save(query, backendUserVO);
|
||||
InsertIdVO vo = adminGroupInfoService.save(query, backendUserVO);
|
||||
return CommonResult.success(vo);
|
||||
}
|
||||
|
||||
@ -45,7 +42,7 @@ public class AdminGroupInfoController {
|
||||
@Operation(module = ProductType.GROUP, statusKey = "event")
|
||||
public CommonResult<Void> update(@Validated @RequestBody @ApiParam(required = true) UpdateGroupQuery query,
|
||||
@RequestAttribute(value = "backendUser", required = false) BackendUserVO backendUserVO) {
|
||||
groupInfoService.update(query, backendUserVO);
|
||||
adminGroupInfoService.update(query, backendUserVO);
|
||||
return CommonResult.success();
|
||||
}
|
||||
|
||||
@ -54,7 +51,7 @@ public class AdminGroupInfoController {
|
||||
@Operation(module = ProductType.GROUP, statusKey = "event")
|
||||
public CommonResult<Void> updateStatus(@Validated @RequestBody @ApiParam(required = true) UpdateGroupStatusQuery query,
|
||||
@RequestAttribute(value = "backendUser", required = false) BackendUserVO backendUserVO) {
|
||||
groupInfoService.updateStatus(query, backendUserVO);
|
||||
adminGroupInfoService.updateStatus(query, backendUserVO);
|
||||
return CommonResult.success();
|
||||
}
|
||||
|
||||
@ -62,7 +59,7 @@ public class AdminGroupInfoController {
|
||||
@PostMapping("/admin/group/info/list")
|
||||
public CommonResult<Pager<GroupVO>> list(@Validated @RequestBody @ApiParam(required = true) ListGroupQuery query,
|
||||
@RequestAttribute(value = "backendUser", required = false) BackendUserVO backendUserVO) {
|
||||
Pager<GroupVO> page = groupInfoService.list(query, backendUserVO);
|
||||
Pager<GroupVO> page = adminGroupInfoService.list(query, backendUserVO);
|
||||
return CommonResult.success(page);
|
||||
}
|
||||
|
||||
@ -70,7 +67,7 @@ public class AdminGroupInfoController {
|
||||
@PostMapping("/admin/group/info/get")
|
||||
public CommonResult<GroupVO> get(@Validated @RequestBody @ApiParam(required = true) OnlyIdQuery query,
|
||||
@RequestAttribute(value = "backendUser", required = false) BackendUserVO backendUserVO) {
|
||||
GroupVO vo = groupInfoService.get(query, backendUserVO);
|
||||
GroupVO vo = adminGroupInfoService.get(query, backendUserVO);
|
||||
return CommonResult.success(vo);
|
||||
}
|
||||
|
||||
@ -78,23 +75,8 @@ public class AdminGroupInfoController {
|
||||
@PostMapping("/admin/group/info/setNotice")
|
||||
public CommonResult<Void> setNotice(@Validated @RequestBody @ApiParam(required = true) SetNoticeQuery query,
|
||||
@RequestAttribute(value = "backendUser", required = false) BackendUserVO backendUserVO) {
|
||||
groupInfoService.setNotice(query, backendUserVO);
|
||||
adminGroupInfoService.setNotice(query, backendUserVO);
|
||||
return CommonResult.success();
|
||||
}
|
||||
|
||||
@ApiOperation("后台查询交易圈统计")
|
||||
@PostMapping("/admin/group/collect/query")
|
||||
public CommonResult<List<GroupCollectVO>> queryCollect(@Validated @RequestBody @ApiParam(required = true) QueryGroupCollectQuery query,
|
||||
@RequestAttribute(value = "backendUser", required = false) BackendUserVO backendUserVO) {
|
||||
List<GroupCollectVO> list = groupInfoService.queryCollect(query, backendUserVO);
|
||||
return CommonResult.success(list);
|
||||
}
|
||||
|
||||
@ApiOperation("后台查询交易圈当日统计")
|
||||
@PostMapping("/admin/group/collect/queryToday")
|
||||
public CommonResult<GroupCollectVO> queryTodayCollect(@Validated @RequestBody @ApiParam(required = true) OnlyIdQuery query,
|
||||
@RequestAttribute(value = "backendUser", required = false) BackendUserVO backendUserVO) {
|
||||
GroupCollectVO vo = groupInfoService.queryTodayCollect(query, backendUserVO);
|
||||
return CommonResult.success(vo);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,73 @@
|
||||
package com.syzb.group.query;
|
||||
|
||||
import com.syzb.common.query.PageQuery;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
public class ListGroupCustomerQuery extends PageQuery {
|
||||
|
||||
@ApiModelProperty("交易圈ID")
|
||||
private Integer groupId;
|
||||
|
||||
@ApiModelProperty("用户ID")
|
||||
private String userId;
|
||||
|
||||
@ApiModelProperty("昵称")
|
||||
private Integer nickName;
|
||||
|
||||
@ApiModelProperty("在线状态 1:在线 2:不在线")
|
||||
private Integer isOnline;
|
||||
|
||||
@ApiModelProperty("客户状态 1:在期 2:已到期 3:即将到期 4:新学员")
|
||||
private Integer customerStatus;
|
||||
|
||||
@ApiModelProperty("禁言状态 1:已禁言 2:未禁言")
|
||||
private Integer commentBlackStatus;
|
||||
|
||||
public Integer getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public void setGroupId(Integer groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Integer getNickName() {
|
||||
return nickName;
|
||||
}
|
||||
|
||||
public void setNickName(Integer nickName) {
|
||||
this.nickName = nickName;
|
||||
}
|
||||
|
||||
public Integer getIsOnline() {
|
||||
return isOnline;
|
||||
}
|
||||
|
||||
public void setIsOnline(Integer isOnline) {
|
||||
this.isOnline = isOnline;
|
||||
}
|
||||
|
||||
public Integer getCustomerStatus() {
|
||||
return customerStatus;
|
||||
}
|
||||
|
||||
public void setCustomerStatus(Integer customerStatus) {
|
||||
this.customerStatus = customerStatus;
|
||||
}
|
||||
|
||||
public Integer getCommentBlackStatus() {
|
||||
return commentBlackStatus;
|
||||
}
|
||||
|
||||
public void setCommentBlackStatus(Integer commentBlackStatus) {
|
||||
this.commentBlackStatus = commentBlackStatus;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,162 @@
|
||||
package com.syzb.group.service.admin;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.hazelcast.map.IMap;
|
||||
import com.syzb.business.entity.ModuleUser;
|
||||
import com.syzb.business.mapper.ModuleUserMapper;
|
||||
import com.syzb.common.config.cache.CacheKey;
|
||||
import com.syzb.common.constant.IsOrNot;
|
||||
import com.syzb.common.constant.ProductType;
|
||||
import com.syzb.common.query.OnlyIdQuery;
|
||||
import com.syzb.common.result.Pager;
|
||||
import com.syzb.common.service.CommentBlackService;
|
||||
import com.syzb.common.vo.BackendUserVO;
|
||||
import com.syzb.group.constant.GroupCustomerStatus;
|
||||
import com.syzb.group.entity.GroupCollect;
|
||||
import com.syzb.group.mapper.GroupCollectMapper;
|
||||
import com.syzb.group.query.ListGroupCustomerQuery;
|
||||
import com.syzb.group.query.QueryGroupCollectQuery;
|
||||
import com.syzb.group.service.common.GroupCacheService;
|
||||
import com.syzb.group.service.common.GroupCommonService;
|
||||
import com.syzb.group.vo.GroupCollectVO;
|
||||
import com.syzb.group.vo.GroupCustomerVO;
|
||||
import com.syzb.rbac.entity.WxUser;
|
||||
import com.syzb.rbac.mapper.WxUserMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Service
|
||||
public class AdminGroupCollectService {
|
||||
|
||||
@Resource
|
||||
private IMap<String, Object> groupCache;
|
||||
|
||||
@Resource
|
||||
private GroupCollectMapper groupCollectMapper;
|
||||
|
||||
@Resource
|
||||
private GroupCommonService groupCommonService;
|
||||
|
||||
@Resource
|
||||
private ModuleUserMapper moduleUserMapper;
|
||||
|
||||
@Resource
|
||||
private WxUserMapper wxUserMapper;
|
||||
|
||||
@Resource
|
||||
private CommentBlackService commentBlackService;
|
||||
@Autowired
|
||||
private GroupCacheService groupCacheService;
|
||||
|
||||
public List<GroupCollectVO> queryCollect(QueryGroupCollectQuery query, BackendUserVO backendUserVO) {
|
||||
Integer groupId = query.getGroupId();
|
||||
LocalDate startDate = query.getStartDate();
|
||||
LocalDate endDate = query.getEndDate();
|
||||
LambdaQueryWrapper<GroupCollect> wrapper = Wrappers.<GroupCollect>lambdaQuery()
|
||||
.eq(groupId != null && groupId != 0, GroupCollect::getGroupId, groupId)
|
||||
.ge(startDate != null, GroupCollect::getDate, startDate)
|
||||
.le(endDate != null, GroupCollect::getDate, endDate);
|
||||
List<GroupCollect> list = groupCollectMapper.selectList(wrapper);
|
||||
return list.stream().map(GroupCollectVO::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public void clearCache(Integer id) {
|
||||
groupCache.delete(CacheKey.GroupKey.GROUP_INFO + id);
|
||||
}
|
||||
|
||||
public GroupCollectVO queryTodayCollect(OnlyIdQuery query, BackendUserVO backendUserVO) {
|
||||
Integer groupId = query.getId();
|
||||
LocalDate date = LocalDate.now();
|
||||
GroupCollect groupCollect = groupCollectMapper.selectOne(Wrappers.<GroupCollect>lambdaQuery()
|
||||
.eq(GroupCollect::getGroupId, groupId)
|
||||
.eq(GroupCollect::getDate, date));
|
||||
return groupCollect == null ? new GroupCollectVO(groupId, date) : new GroupCollectVO(groupCollect);
|
||||
}
|
||||
|
||||
public Pager<GroupCustomerVO> listCustomer(ListGroupCustomerQuery query, BackendUserVO backendUserVO) {
|
||||
Integer groupId = query.getGroupId();
|
||||
String userId = query.getUserId();
|
||||
Integer nickName = query.getNickName();
|
||||
Integer isOnline = query.getIsOnline();
|
||||
Integer customerStatus = query.getCustomerStatus();
|
||||
Integer commentBlackStatus = query.getCommentBlackStatus();
|
||||
Set<Integer> moduleIdSet = groupCommonService.getModuleIds(groupId);
|
||||
if (CollUtil.isEmpty(moduleIdSet)) {
|
||||
return Pager.emptyPager();
|
||||
}
|
||||
LambdaQueryWrapper<ModuleUser> wrapper = Wrappers.<ModuleUser>lambdaQuery()
|
||||
.in(ModuleUser::getModuleId, moduleIdSet);
|
||||
List<ModuleUser> moduleUserList = moduleUserMapper.selectList(wrapper);
|
||||
if (CollUtil.isEmpty(moduleUserList)) {
|
||||
return Pager.emptyPager();
|
||||
}
|
||||
Set<String> userIdSet = moduleUserList.stream().map(ModuleUser::getUserId).collect(Collectors.toSet());
|
||||
List<WxUser> wxUserList = wxUserMapper.selectList(Wrappers.<WxUser>lambdaQuery()
|
||||
.in(WxUser::getId, userIdSet));
|
||||
if (CollUtil.isEmpty(wxUserList)) {
|
||||
return Pager.emptyPager();
|
||||
}
|
||||
Map<String, WxUser> wxUserMap = wxUserList.stream().collect(Collectors.toMap(WxUser::getId, Function.identity()));
|
||||
Set<String> blackUserIds = commentBlackService.getBlackUserIds(groupId, ProductType.GROUP.value);
|
||||
Set<String> onlineUserIds = groupCacheService.getOnlineUserIds(groupId);
|
||||
Stream<ModuleUser> stream = moduleUserList.stream();
|
||||
if (StrUtil.isNotEmpty(userId)) {
|
||||
stream = stream.filter(m -> userId.equals(m.getUserId()));
|
||||
}
|
||||
List<GroupCustomerVO> list = stream.map(moduleUser -> {
|
||||
GroupCustomerVO vo = new GroupCustomerVO(moduleUser);
|
||||
WxUser wxUser = wxUserMap.get(moduleUser.getUserId());
|
||||
vo.setNickName(wxUser == null ? null : wxUser.getNickName());
|
||||
vo.setIsOnline(onlineUserIds.contains(moduleUser.getUserId()) ? IsOrNot.IS.value : IsOrNot.NOT.value);
|
||||
vo.setCommentBlackStatus(blackUserIds.contains(moduleUser.getUserId()) ? IsOrNot.IS.value : IsOrNot.NOT.value);
|
||||
vo.setCustomerStatus(calCustomerStatus(moduleUser).value);
|
||||
return vo;
|
||||
}).collect(Collectors.toList());
|
||||
Stream<GroupCustomerVO> voStream = list.stream();
|
||||
if (nickName != null) {
|
||||
voStream = voStream.filter(vo -> nickName.equals(vo.getNickName()));
|
||||
}
|
||||
if (isOnline != null) {
|
||||
voStream = voStream.filter(vo -> isOnline.equals(vo.getIsOnline()));
|
||||
}
|
||||
if (customerStatus != null) {
|
||||
voStream = voStream.filter(vo -> customerStatus.equals(vo.getCustomerStatus()));
|
||||
}
|
||||
if (commentBlackStatus != null) {
|
||||
voStream = voStream.filter(vo -> commentBlackStatus.equals(vo.getCommentBlackStatus()));
|
||||
}
|
||||
List<GroupCustomerVO> voList = voStream.collect(Collectors.toList());
|
||||
List<GroupCustomerVO> pageList = CollUtil.page(query.getCurrent(), query.getSize(), voList);
|
||||
return new Pager<>(pageList, voList.size());
|
||||
}
|
||||
|
||||
public GroupCustomerStatus calCustomerStatus(ModuleUser moduleUser) {
|
||||
LocalDateTime endTime = moduleUser.getEndTime();
|
||||
LocalDateTime createTime = moduleUser.getCreateTime();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
if (endTime.isBefore(now)) {
|
||||
return GroupCustomerStatus.EXPIRED;
|
||||
}
|
||||
if (createTime.isBefore(now.minusDays(7))) {
|
||||
return GroupCustomerStatus.NEW_STUDENT;
|
||||
}
|
||||
if (endTime.isBefore(now.plusDays(7))) {
|
||||
return GroupCustomerStatus.WILL_EXPIRED;
|
||||
}
|
||||
return GroupCustomerStatus.IN_PERIOD;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package com.syzb.group.service;
|
||||
package com.syzb.group.service.admin;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@ -23,14 +23,10 @@ import com.syzb.common.vo.FrontUserVO;
|
||||
import com.syzb.common.vo.InsertIdVO;
|
||||
import com.syzb.course.service.PageService;
|
||||
import com.syzb.group.constant.GroupInfoStatus;
|
||||
import com.syzb.group.entity.GroupCollect;
|
||||
import com.syzb.group.entity.GroupInfo;
|
||||
import com.syzb.group.entity.GroupSortEntity;
|
||||
import com.syzb.group.mapper.GroupCollectMapper;
|
||||
import com.syzb.group.mapper.GroupInfoMapper;
|
||||
import com.syzb.group.query.QueryGroupCollectQuery;
|
||||
import com.syzb.group.query.info.*;
|
||||
import com.syzb.group.vo.GroupCollectVO;
|
||||
import com.syzb.group.vo.GroupVO;
|
||||
import com.syzb.rbac.entity.UserDept;
|
||||
import com.syzb.rbac.service.AuthService;
|
||||
@ -40,13 +36,12 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class GroupInfoService {
|
||||
public class AdminGroupInfoService {
|
||||
|
||||
@Resource
|
||||
private GroupInfoMapper groupInfoMapper;
|
||||
@ -78,9 +73,6 @@ public class GroupInfoService {
|
||||
@Resource
|
||||
private IMap<String, Object> groupCache;
|
||||
|
||||
@Resource
|
||||
private GroupCollectMapper groupCollectMapper;
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public InsertIdVO save(SaveGroupQuery query, BackendUserVO backendUserVO) {
|
||||
sensitiveWordService.check(query.getName(), query.getRemark(), query.getDetail());
|
||||
@ -300,28 +292,8 @@ public class GroupInfoService {
|
||||
return advisorId;
|
||||
}
|
||||
|
||||
public List<GroupCollectVO> queryCollect(QueryGroupCollectQuery query, BackendUserVO backendUserVO) {
|
||||
Integer groupId = query.getGroupId();
|
||||
LocalDate startDate = query.getStartDate();
|
||||
LocalDate endDate = query.getEndDate();
|
||||
LambdaQueryWrapper<GroupCollect> wrapper = Wrappers.<GroupCollect>lambdaQuery()
|
||||
.eq(groupId != null && groupId != 0, GroupCollect::getGroupId, groupId)
|
||||
.ge(startDate != null, GroupCollect::getDate, startDate)
|
||||
.le(endDate != null, GroupCollect::getDate, endDate);
|
||||
List<GroupCollect> list = groupCollectMapper.selectList(wrapper);
|
||||
return list.stream().map(GroupCollectVO::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public void clearCache(Integer id) {
|
||||
groupCache.delete(CacheKey.GroupKey.GROUP_INFO + id);
|
||||
}
|
||||
|
||||
public GroupCollectVO queryTodayCollect(OnlyIdQuery query, BackendUserVO backendUserVO) {
|
||||
Integer groupId = query.getId();
|
||||
LocalDate date = LocalDate.now();
|
||||
GroupCollect groupCollect = groupCollectMapper.selectOne(Wrappers.<GroupCollect>lambdaQuery()
|
||||
.eq(GroupCollect::getGroupId, groupId)
|
||||
.eq(GroupCollect::getDate, date));
|
||||
return groupCollect == null ? new GroupCollectVO(groupId, date) : new GroupCollectVO(groupCollect);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -24,7 +24,6 @@ import com.syzb.group.entity.GroupMessage;
|
||||
import com.syzb.group.mapper.GroupInfoMapper;
|
||||
import com.syzb.group.mapper.GroupMessageMapper;
|
||||
import com.syzb.group.query.message.*;
|
||||
import com.syzb.group.service.GroupInfoService;
|
||||
import com.syzb.group.service.common.GroupCacheService;
|
||||
import com.syzb.group.service.common.GroupMessageService;
|
||||
import com.syzb.group.vo.message.GroupMessageVO;
|
||||
@ -59,7 +58,7 @@ public class AdminGroupMessageService {
|
||||
private AdvisorInfoService advisorInfoService;
|
||||
|
||||
@Resource
|
||||
private GroupInfoService groupInfoService;
|
||||
private AdminGroupInfoService adminGroupInfoService;
|
||||
|
||||
@Resource
|
||||
private CommentBlackService commentBlackService;
|
||||
@ -219,7 +218,7 @@ public class AdminGroupMessageService {
|
||||
|
||||
groupMessageService.publishGroupMessage(GroupMessageChannel.ALL, GroupMessageType.OPEN_INTERACTIVE, groupId, query.getStatus());
|
||||
|
||||
groupInfoService.clearCache(groupId);
|
||||
adminGroupInfoService.clearCache(groupId);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -237,7 +236,7 @@ public class AdminGroupMessageService {
|
||||
|
||||
groupMessageService.publishGroupMessage(GroupMessageChannel.ALL, GroupMessageType.OPEN_PRIVATE_CHAT, groupId, query.getStatus());
|
||||
|
||||
groupInfoService.clearCache(groupId);
|
||||
adminGroupInfoService.clearCache(groupId);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -255,7 +254,7 @@ public class AdminGroupMessageService {
|
||||
|
||||
groupMessageService.publishGroupMessage(GroupMessageChannel.ALL, GroupMessageType.SHOW_GROUP_MEMBER_COUNT, groupId, query.getStatus());
|
||||
|
||||
groupInfoService.clearCache(groupId);
|
||||
adminGroupInfoService.clearCache(groupId);
|
||||
}
|
||||
|
||||
public void setShowNickName(GroupMessageStatusQuery query, BackendUserVO backendUser) {
|
||||
@ -270,7 +269,7 @@ public class AdminGroupMessageService {
|
||||
|
||||
groupMessageService.publishGroupMessage(GroupMessageChannel.ALL, GroupMessageType.SHOW_FULL_NICKNAME, groupId, query.getStatus());
|
||||
|
||||
groupInfoService.clearCache(groupId);
|
||||
adminGroupInfoService.clearCache(groupId);
|
||||
}
|
||||
|
||||
public void setFirstAudit(GroupMessageStatusQuery query, BackendUserVO backendUser) {
|
||||
@ -285,7 +284,7 @@ public class AdminGroupMessageService {
|
||||
|
||||
groupMessageService.publishGroupMessage(GroupMessageChannel.ALL, GroupMessageType.PRE_CHECK_SEND, groupId, query.getStatus());
|
||||
|
||||
groupInfoService.clearCache(groupId);
|
||||
adminGroupInfoService.clearCache(groupId);
|
||||
}
|
||||
|
||||
private void clearCache(Integer messageId) {
|
||||
|
||||
@ -0,0 +1,107 @@
|
||||
package com.syzb.group.service.app;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.hazelcast.map.IMap;
|
||||
import com.syzb.common.config.cache.CacheKey;
|
||||
import com.syzb.common.query.OnlyIdQuery;
|
||||
import com.syzb.common.result.AppPager;
|
||||
import com.syzb.common.service.AppUserService;
|
||||
import com.syzb.common.service.CacheService;
|
||||
import com.syzb.common.vo.AuthResultVO;
|
||||
import com.syzb.common.vo.FrontUserVO;
|
||||
import com.syzb.course.service.PageService;
|
||||
import com.syzb.group.constant.GroupInfoStatus;
|
||||
import com.syzb.group.entity.GroupInfo;
|
||||
import com.syzb.group.entity.GroupSortEntity;
|
||||
import com.syzb.group.mapper.GroupInfoMapper;
|
||||
import com.syzb.group.query.info.ListGroupAppQuery;
|
||||
import com.syzb.group.service.admin.AdminGroupInfoService;
|
||||
import com.syzb.group.vo.GroupVO;
|
||||
import com.syzb.rbac.service.AuthService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
public class AppGroupInfoService {
|
||||
|
||||
@Resource
|
||||
private AdminGroupInfoService adminGroupInfoService;
|
||||
|
||||
@Resource
|
||||
private GroupInfoMapper groupInfoMapper;
|
||||
|
||||
@Resource
|
||||
private AuthService authService;
|
||||
|
||||
@Resource
|
||||
private PageService pageService;
|
||||
|
||||
@Resource
|
||||
private CacheService cacheService;
|
||||
|
||||
@Resource
|
||||
private AppUserService appUserService;
|
||||
|
||||
@Resource
|
||||
private IMap<String, Object> groupCache;
|
||||
|
||||
/**
|
||||
* APP端查询交易圈详情
|
||||
*/
|
||||
public GroupVO getForApp(OnlyIdQuery query, FrontUserVO frontUserVO) {
|
||||
GroupVO vo = cacheService.get(groupCache, CacheKey.GroupKey.GROUP_INFO + query.getId(), () -> adminGroupInfoService.get(query, null));
|
||||
if (vo == null) {
|
||||
return null;
|
||||
}
|
||||
// 防止落地页修改后,未更新缓存
|
||||
if (vo.getPage() != null) {
|
||||
vo.setPage(pageService.getForApp(vo.getPage().getId()));
|
||||
}
|
||||
if (frontUserVO != null) {
|
||||
AuthResultVO authResultVo = appUserService.checkAuth(vo.getAuthorityId(), frontUserVO);
|
||||
vo.setAuthResultVo(authResultVo);
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* APP端查询交易圈列表
|
||||
*/
|
||||
public AppPager<GroupVO> listForApp(ListGroupAppQuery query) {
|
||||
Integer id = query.getId();
|
||||
Integer lastId = query.getLastId();
|
||||
LocalDateTime lastPublishTime = query.getLastPublishTime();
|
||||
Integer lastWeight = query.getLastWeight();
|
||||
Integer size = query.getSize();
|
||||
NavigableSet<GroupSortEntity> sortedSet = cacheService.get(groupCache, CacheKey.GroupKey.MAIN_GROUP_LIST + id, () -> {
|
||||
LambdaQueryWrapper<GroupInfo> wrapper = Wrappers.<GroupInfo>lambdaQuery()
|
||||
.eq(GroupInfo::getAdvisorId, id)
|
||||
.eq(GroupInfo::getStatus, GroupInfoStatus.AUDITED.value)
|
||||
// .eq(GroupInfo::getIsDisplay, IsDisplay.YES.value)
|
||||
.orderByDesc(GroupInfo::getIsRecommend, GroupInfo::getAuditTime);
|
||||
List<GroupInfo> list = groupInfoMapper.selectList(wrapper);
|
||||
NavigableSet<GroupSortEntity> set = new TreeSet<>();
|
||||
list.stream().map(GroupSortEntity::new).forEach(set::add);
|
||||
return set;
|
||||
});
|
||||
GroupSortEntity lastEntity = lastId == null || lastWeight == null || lastPublishTime == null ? null : new GroupSortEntity(lastId, lastWeight, lastPublishTime);
|
||||
if (lastEntity != null) {
|
||||
sortedSet = sortedSet.tailSet(lastEntity, false);
|
||||
}
|
||||
List<GroupVO> voList = new ArrayList<>(size);
|
||||
Iterator<GroupSortEntity> iterator = sortedSet.iterator();
|
||||
while (iterator.hasNext() && voList.size() < size) {
|
||||
GroupSortEntity entity = iterator.next();
|
||||
GroupVO vo = getForApp(new OnlyIdQuery(entity.getId()), null);
|
||||
if (vo != null) {
|
||||
voList.add(vo);
|
||||
}
|
||||
}
|
||||
return new AppPager<>(voList, iterator.hasNext());
|
||||
}
|
||||
|
||||
}
|
||||
@ -23,7 +23,6 @@ import com.syzb.group.query.message.ListGroupMessageAppQuery;
|
||||
import com.syzb.group.query.message.QueryUnreadCountAppQuery;
|
||||
import com.syzb.group.query.message.ReadGroupMessageAppQuery;
|
||||
import com.syzb.group.query.message.SendGroupMessageAppQuery;
|
||||
import com.syzb.group.service.GroupInfoService;
|
||||
import com.syzb.group.service.common.GroupCacheService;
|
||||
import com.syzb.group.service.common.GroupMessageService;
|
||||
import com.syzb.group.vo.GroupVO;
|
||||
@ -47,7 +46,7 @@ public class AppGroupMessageService {
|
||||
private GroupMessageService groupMessageService;
|
||||
|
||||
@Resource
|
||||
private GroupInfoService groupInfoService;
|
||||
private AppGroupInfoService appGroupInfoService;
|
||||
|
||||
@Resource
|
||||
private GroupCacheService groupCacheService;
|
||||
@ -67,7 +66,7 @@ public class AppGroupMessageService {
|
||||
Integer type = query.getType();
|
||||
Integer size = query.getSize();
|
||||
LocalDate date = query.getDate();
|
||||
GroupVO groupVO = groupInfoService.getForApp(new OnlyIdQuery(groupId), null);
|
||||
GroupVO groupVO = appGroupInfoService.getForApp(new OnlyIdQuery(groupId), null);
|
||||
if (groupVO == null) {
|
||||
throw new BizException(ResponseStatus.ID_NOT_EXIST_ERROR, "交易圈不存在");
|
||||
} else if (QueryGroupMessageType.PRIVATE.value.equals(type) && !IsOrNot.IS.value.equals(groupVO.getPrivateChatStatus())) {
|
||||
@ -113,7 +112,7 @@ public class AppGroupMessageService {
|
||||
sensitiveWordService.check(content);
|
||||
|
||||
// 检查交易圈状态
|
||||
GroupVO groupVO = groupInfoService.getForApp(new OnlyIdQuery(groupId), null);
|
||||
GroupVO groupVO = appGroupInfoService.getForApp(new OnlyIdQuery(groupId), null);
|
||||
if (groupVO == null) {
|
||||
throw new BizException(ResponseStatus.ID_NOT_EXIST_ERROR, "交易圈不存在");
|
||||
}
|
||||
|
||||
@ -175,9 +175,9 @@ public class GroupCommonService {
|
||||
GroupCollect collect = new GroupCollect();
|
||||
collect.setGroupId(groupId);
|
||||
collect.setDate(date);
|
||||
collect.setTotalMembers(getModuleMembers(groupId, false));
|
||||
collect.setTotalMembers(getModuleMemberCount(groupId, false));
|
||||
collect.setVisitedMembers(visitMemberMap.getOrDefault(groupId, 0));
|
||||
collect.setNewMembers(getModuleMembers(groupId, true));
|
||||
collect.setNewMembers(getModuleMemberCount(groupId, true));
|
||||
collect.setInteractionMembers(0);
|
||||
collect.setPrivateChatMembers(0);
|
||||
List<GroupMessage> messageMemberList = groupMessageMemberMap.get(groupId);
|
||||
@ -261,7 +261,7 @@ public class GroupCommonService {
|
||||
return moduleIdSet;
|
||||
}
|
||||
|
||||
private Integer getModuleMembers(Integer groupId, boolean isNew) {
|
||||
private Integer getModuleMemberCount(Integer groupId, boolean isNew) {
|
||||
Set<Integer> moduleIds = getModuleIds(groupId);
|
||||
if (CollUtil.isEmpty(moduleIds)) {
|
||||
return 0;
|
||||
|
||||
125
src/main/java/com/syzb/group/vo/GroupCustomerVO.java
Normal file
125
src/main/java/com/syzb/group/vo/GroupCustomerVO.java
Normal file
@ -0,0 +1,125 @@
|
||||
package com.syzb.group.vo;
|
||||
|
||||
import com.syzb.business.entity.ModuleUser;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class GroupCustomerVO {
|
||||
|
||||
@ApiModelProperty("用户ID")
|
||||
private String userId;
|
||||
|
||||
@ApiModelProperty("昵称")
|
||||
private String nickName;
|
||||
|
||||
@ApiModelProperty("头像")
|
||||
private String headPicUrl;
|
||||
|
||||
@ApiModelProperty("加入时间")
|
||||
private LocalDateTime joinTime;
|
||||
|
||||
@ApiModelProperty("到期时间")
|
||||
private LocalDateTime expireTime;
|
||||
|
||||
@ApiModelProperty("在线状态 1:在线 2:不在线")
|
||||
private Integer isOnline;
|
||||
|
||||
@ApiModelProperty("客户状态 1:在期 2:已到期 3:即将到期 4:新学员")
|
||||
private Integer customerStatus;
|
||||
|
||||
@ApiModelProperty("禁言状态 0生效中 1已解除 2自然过期")
|
||||
private Integer commentBlackStatus;
|
||||
|
||||
@ApiModelProperty("最近一次访问时间")
|
||||
private LocalDateTime lastVisitTime;
|
||||
|
||||
@ApiModelProperty("最近一次发言时间")
|
||||
private LocalDateTime lastChatTime;
|
||||
|
||||
public GroupCustomerVO(ModuleUser moduleUser) {
|
||||
this.userId = moduleUser.getUserId();
|
||||
this.joinTime = moduleUser.getCreateTime();
|
||||
this.expireTime = moduleUser.getEndTime();
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getNickName() {
|
||||
return nickName;
|
||||
}
|
||||
|
||||
public void setNickName(String nickName) {
|
||||
this.nickName = nickName;
|
||||
}
|
||||
|
||||
public String getHeadPicUrl() {
|
||||
return headPicUrl;
|
||||
}
|
||||
|
||||
public void setHeadPicUrl(String headPicUrl) {
|
||||
this.headPicUrl = headPicUrl;
|
||||
}
|
||||
|
||||
public LocalDateTime getJoinTime() {
|
||||
return joinTime;
|
||||
}
|
||||
|
||||
public void setJoinTime(LocalDateTime joinTime) {
|
||||
this.joinTime = joinTime;
|
||||
}
|
||||
|
||||
public LocalDateTime getExpireTime() {
|
||||
return expireTime;
|
||||
}
|
||||
|
||||
public void setExpireTime(LocalDateTime expireTime) {
|
||||
this.expireTime = expireTime;
|
||||
}
|
||||
|
||||
public Integer getIsOnline() {
|
||||
return isOnline;
|
||||
}
|
||||
|
||||
public void setIsOnline(Integer isOnline) {
|
||||
this.isOnline = isOnline;
|
||||
}
|
||||
|
||||
public Integer getCustomerStatus() {
|
||||
return customerStatus;
|
||||
}
|
||||
|
||||
public void setCustomerStatus(Integer customerStatus) {
|
||||
this.customerStatus = customerStatus;
|
||||
}
|
||||
|
||||
public Integer getCommentBlackStatus() {
|
||||
return commentBlackStatus;
|
||||
}
|
||||
|
||||
public void setCommentBlackStatus(Integer commentBlackStatus) {
|
||||
this.commentBlackStatus = commentBlackStatus;
|
||||
}
|
||||
|
||||
public LocalDateTime getLastVisitTime() {
|
||||
return lastVisitTime;
|
||||
}
|
||||
|
||||
public void setLastVisitTime(LocalDateTime lastVisitTime) {
|
||||
this.lastVisitTime = lastVisitTime;
|
||||
}
|
||||
|
||||
public LocalDateTime getLastChatTime() {
|
||||
return lastChatTime;
|
||||
}
|
||||
|
||||
public void setLastChatTime(LocalDateTime lastChatTime) {
|
||||
this.lastChatTime = lastChatTime;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user