pom-清理flow-team模块-清理业务入侵
This commit is contained in:
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
* 文 件 名: FlowTeamEditInviteUserParams
|
||||
* 版 权:
|
||||
* 描 述: <描述>
|
||||
* 创建人: H1
|
||||
* 创建时间: 2022/4/25
|
||||
* 修改人:
|
||||
* 修改内容:
|
||||
* 修改时间:
|
||||
*/
|
||||
package com.accompany.admin.params.flowteam;
|
||||
|
||||
import com.xuanyin.flowteam.model.FlowTeamMemberInviteUser;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* <br>类描述:
|
||||
* <br>功能详细描述:
|
||||
*
|
||||
* @author H1
|
||||
* @date [2022/4/25]
|
||||
*/
|
||||
@Data
|
||||
public class FlowTeamEditInviteUserParams extends FlowTeamMemberInviteUser {
|
||||
private Byte optType;
|
||||
private Long optUid;
|
||||
}
|
@@ -1,65 +0,0 @@
|
||||
package com.accompany.admin.params.flowteam;
|
||||
|
||||
import com.accompany.common.utils.AppUtils;
|
||||
import com.accompany.common.utils.StringUtils;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class FlowTeamStatisticParams {
|
||||
|
||||
/**
|
||||
* 组别
|
||||
*/
|
||||
private String teamId;
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
private String startDate;
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
private String endDate;
|
||||
|
||||
/**
|
||||
* 成员id
|
||||
*/
|
||||
private Long memberId;
|
||||
|
||||
/**
|
||||
* 应用筛选
|
||||
*/
|
||||
private String app;
|
||||
|
||||
/**
|
||||
* 充值开始时间
|
||||
*/
|
||||
private String chargeStartTime;
|
||||
/**
|
||||
* 充值结束时间
|
||||
*/
|
||||
private String chargeEndTime;
|
||||
|
||||
/**
|
||||
* 由“app”参数转化成的AppEnum中的组合(如果app=PlanetStar,则这里对应PlanetStar和PlanetStar66)
|
||||
*/
|
||||
private List<String> groupApps;
|
||||
|
||||
public void setApp(String app) {
|
||||
this.app = app;
|
||||
this.groupApps = AppUtils.getGroupApps(app);
|
||||
}
|
||||
|
||||
public List<String> getGroupApps() {
|
||||
if (groupApps == null && StringUtils.isNotBlank(app)) {
|
||||
return AppUtils.getGroupApps(app);
|
||||
}
|
||||
return groupApps;
|
||||
}
|
||||
|
||||
private List<String> teamIds;
|
||||
|
||||
private Long groupId;
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
package com.accompany.admin.params.flowteam;
|
||||
|
||||
import com.xuanyin.flowteam.model.FlowTeamMember;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TeamMemberEditParams extends FlowTeamMember {
|
||||
|
||||
private String inviteCodes;
|
||||
private Long groupId;
|
||||
}
|
@@ -1,19 +0,0 @@
|
||||
package com.accompany.admin.params.flowteam;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TeamMemberQueryParams {
|
||||
|
||||
private String memberName;
|
||||
|
||||
private String memberPhone;
|
||||
|
||||
private String inviteCode;
|
||||
|
||||
private Integer pageNumber;
|
||||
private Integer pageSize;
|
||||
private String teamId;
|
||||
private Long groupId;
|
||||
private String teamIds;
|
||||
}
|
@@ -1,20 +0,0 @@
|
||||
package com.accompany.admin.vo.flowteam;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class FlowTeamConfVO {
|
||||
|
||||
@Data
|
||||
public static class TeamItem {
|
||||
private String teamId;
|
||||
|
||||
private String teamName;
|
||||
}
|
||||
|
||||
List<TeamItem> teams;
|
||||
|
||||
Long canRefillInterval;
|
||||
}
|
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* 文 件 名: FlowTeamGroupAdminVO
|
||||
* 版 权:
|
||||
* 描 述: <描述>
|
||||
* 创建人: H1
|
||||
* 创建时间: 2022/1/13
|
||||
* 修改人:
|
||||
* 修改内容:
|
||||
* 修改时间:
|
||||
*/
|
||||
package com.accompany.admin.vo.flowteam;
|
||||
|
||||
import com.xuanyin.flowteam.model.FlowTeamGroup;
|
||||
import com.xuanyin.flowteam.model.FlowTeamMember;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <br>类描述:
|
||||
* <br>功能详细描述:
|
||||
*
|
||||
* @author H1
|
||||
* @date [2022/1/13]
|
||||
*/
|
||||
@Data
|
||||
public class FlowTeamGroupAdminVO extends FlowTeamGroup {
|
||||
private List<FlowTeamMember> groupLeaders;
|
||||
private Long teamNum;
|
||||
private Integer memberNum;
|
||||
}
|
@@ -1,13 +0,0 @@
|
||||
package com.accompany.admin.vo.flowteam;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class FlowTeamGroupStatisticSummaryVO extends TeamStatisticBaseVO {
|
||||
|
||||
private String groupId;
|
||||
|
||||
private Integer memberCount;
|
||||
|
||||
private String groupLeaders;
|
||||
}
|
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* 文 件 名: FlowTeamInfoAdminVO
|
||||
* 版 权:
|
||||
* 描 述: <描述>
|
||||
* 创建人: H1
|
||||
* 创建时间: 2022/1/14
|
||||
* 修改人:
|
||||
* 修改内容:
|
||||
* 修改时间:
|
||||
*/
|
||||
package com.accompany.admin.vo.flowteam;
|
||||
|
||||
import com.xuanyin.flowteam.model.FlowTeamInfo;
|
||||
import com.xuanyin.flowteam.model.FlowTeamMember;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <br>类描述:
|
||||
* <br>功能详细描述:
|
||||
*
|
||||
* @author H1
|
||||
* @date [2022/1/14]
|
||||
*/
|
||||
@Data
|
||||
public class FlowTeamInfoAdminVO extends FlowTeamInfo {
|
||||
private List<FlowTeamMember> teamLeaders;
|
||||
private Long memberNum;
|
||||
}
|
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* 文 件 名: FlowTeamInviteCodeRecordAdminVO
|
||||
* 版 权:
|
||||
* 描 述: <描述>
|
||||
* 创建人: H1
|
||||
* 创建时间: 2022/1/19
|
||||
* 修改人:
|
||||
* 修改内容:
|
||||
* 修改时间:
|
||||
*/
|
||||
package com.accompany.admin.vo.flowteam;
|
||||
|
||||
import com.xuanyin.flowteam.model.FlowTeamInviteCodeRecord;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* <br>类描述:
|
||||
* <br>功能详细描述:
|
||||
*
|
||||
* @author H1
|
||||
* @date [2022/1/19]
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class FlowTeamInviteCodeRecordAdminVO extends FlowTeamInviteCodeRecord {
|
||||
private String teamName;
|
||||
private Boolean hasBind;
|
||||
}
|
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* 文 件 名: FlowTeamInviteUserVO
|
||||
* 版 权:
|
||||
* 描 述: <描述>
|
||||
* 创建人: H1
|
||||
* 创建时间: 2022/4/24
|
||||
* 修改人:
|
||||
* 修改内容:
|
||||
* 修改时间:
|
||||
*/
|
||||
package com.accompany.admin.vo.flowteam;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <br>类描述:
|
||||
* <br>功能详细描述:
|
||||
*
|
||||
* @author H1
|
||||
* @date [2022/4/24]
|
||||
*/
|
||||
@Data
|
||||
public class FlowTeamInviteUserVO {
|
||||
private Long erbanNo;
|
||||
private String nick;
|
||||
private Long uid;
|
||||
private String groupName;
|
||||
private String teamName;
|
||||
private String memberName;
|
||||
private String inviteCode;
|
||||
private Date inviteTime;
|
||||
|
||||
private Integer source;
|
||||
}
|
@@ -1,18 +0,0 @@
|
||||
package com.accompany.admin.vo.flowteam;
|
||||
|
||||
import com.xuanyin.flowteam.model.FlowTeamMember;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class FlowTeamMemberVO extends FlowTeamMember {
|
||||
|
||||
/**
|
||||
* 邀请码
|
||||
*/
|
||||
private String inviteCodes;
|
||||
|
||||
/**
|
||||
* 团队id
|
||||
*/
|
||||
private Long groupId;
|
||||
}
|
@@ -1,19 +0,0 @@
|
||||
package com.accompany.admin.vo.flowteam;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class FlowTeamStatisticDetailVO extends TeamStatisticBaseVO {
|
||||
|
||||
private Long memberId;
|
||||
|
||||
private String memberName;
|
||||
|
||||
private String teamId;
|
||||
|
||||
private Integer teamRole;
|
||||
|
||||
private Integer memberStatus;
|
||||
|
||||
private String inviteCodes;
|
||||
}
|
@@ -1,19 +0,0 @@
|
||||
package com.accompany.admin.vo.flowteam;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class FlowTeamStatisticSummaryVO extends TeamStatisticBaseVO {
|
||||
|
||||
private String teamId;
|
||||
|
||||
private Integer memberCount;
|
||||
|
||||
private String teamLeaders;
|
||||
|
||||
private Integer twoRemainCount;
|
||||
|
||||
private Integer sevenRemainCount;
|
||||
|
||||
private Integer thirtyRemainCount;
|
||||
}
|
@@ -1,73 +0,0 @@
|
||||
package com.accompany.admin.vo.flowteam;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class FlowTeamStatisticUserDetailVO {
|
||||
|
||||
private String teamId;
|
||||
|
||||
private String teamMemberName;
|
||||
|
||||
private String inviteCode;
|
||||
|
||||
private String userErbanNo;
|
||||
|
||||
private String userNickName;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date signUpTime;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date firstChargeTime;
|
||||
|
||||
private Integer chargeCount;
|
||||
|
||||
/**
|
||||
* 充值金额 单位:元
|
||||
*/
|
||||
private Double chargeMoney;
|
||||
|
||||
/**
|
||||
* 累计送礼额 单位:元
|
||||
*/
|
||||
private Double totalSendGiftMoney;
|
||||
|
||||
/**
|
||||
* 累计非背包送礼额 单位:元
|
||||
*/
|
||||
private Double totalNoBackbagSendGiftMoney;
|
||||
|
||||
/**
|
||||
* 累计背包送礼额 单位:元
|
||||
*/
|
||||
private Double totalBackbagSendGiftMoney;
|
||||
|
||||
/**
|
||||
* 注册时的ip
|
||||
*/
|
||||
private String registerIp;
|
||||
|
||||
/**
|
||||
* 用户手机号
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 转赠次数
|
||||
*/
|
||||
private Integer giveCount = 0;
|
||||
|
||||
/**
|
||||
* 转赠金额
|
||||
*/
|
||||
private Double giveMoney = 0D;
|
||||
|
||||
/**
|
||||
* 邀请码填写类型
|
||||
*/
|
||||
private String sourceName;
|
||||
}
|
@@ -1,39 +0,0 @@
|
||||
package com.accompany.admin.vo.flowteam;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TeamStatisticBaseVO {
|
||||
|
||||
private Integer newUserCount;
|
||||
|
||||
private Integer newChargeUserCount;
|
||||
|
||||
/**
|
||||
* 付费转化率
|
||||
*/
|
||||
private String chargeRate;
|
||||
|
||||
private Integer chargeCount;
|
||||
|
||||
/**
|
||||
* 充值金额 单位:元
|
||||
*/
|
||||
private Double chargeMoney;
|
||||
/**
|
||||
* 送礼金额 单位:元
|
||||
*/
|
||||
private Double sendGiftMony;
|
||||
|
||||
private Double arpu;
|
||||
|
||||
/**
|
||||
* 转赠次数
|
||||
*/
|
||||
private Integer giveCount;
|
||||
|
||||
/**
|
||||
* 转赠金额
|
||||
*/
|
||||
private Double giveMoney;
|
||||
}
|
@@ -1,29 +0,0 @@
|
||||
package com.accompany.admin.vo.flowteam;
|
||||
|
||||
import com.accompany.core.model.Users;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UserWithFlowTeamInfoVO extends Users {
|
||||
|
||||
/**
|
||||
* 引入组
|
||||
*/
|
||||
private String teamId;
|
||||
|
||||
/**
|
||||
* 引入人Id
|
||||
*/
|
||||
private Long memberId;
|
||||
/**
|
||||
* 引入人
|
||||
*/
|
||||
private String teamMemberName;
|
||||
|
||||
/**
|
||||
* 是否在可补填邀请码范围内
|
||||
*/
|
||||
private Boolean isInCanRefillInviteCodeTime;
|
||||
|
||||
private String groupName;
|
||||
}
|
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
* 文 件 名: FlowTeamGroupMapper
|
||||
* 版 权:
|
||||
* 描 述: <描述>
|
||||
* 创建人: H1
|
||||
* 创建时间: 2022/1/13
|
||||
* 修改人:
|
||||
* 修改内容:
|
||||
* 修改时间:
|
||||
*/
|
||||
package com.accompany.admin.mapper.flowteam;
|
||||
|
||||
import com.accompany.admin.vo.flowteam.FlowTeamInviteUserVO;
|
||||
import com.xuanyin.flowteam.model.FlowTeamMember;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <br>接口描述:
|
||||
* <br>功能详细描述:
|
||||
*
|
||||
* @author H1
|
||||
* @date [2022/1/13]
|
||||
*/
|
||||
public interface FlowTeamGroupAdminMapper {
|
||||
|
||||
/**
|
||||
* 获取团队团长信息
|
||||
* @param groupId
|
||||
* @return
|
||||
*/
|
||||
List<FlowTeamMember> listGroupLeader(Long groupId);
|
||||
|
||||
/**
|
||||
* 获取团队有效成员人数
|
||||
* @param groupId
|
||||
* @return
|
||||
*/
|
||||
Integer countGroupValidMember(Long groupId);
|
||||
|
||||
/**
|
||||
* 获取手机号加入的有效团队数量
|
||||
* @param phone
|
||||
* @return
|
||||
*/
|
||||
Long getJoinGroupIdByPhone(String phone);
|
||||
|
||||
/**
|
||||
* 获取邀请用户的引流团队信息
|
||||
* @param erbanNo
|
||||
* @return
|
||||
*/
|
||||
List<FlowTeamInviteUserVO> listFlowTeamInfoWithUser(String erbanNo);
|
||||
}
|
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* 文 件 名: FlowTeamMemberInviteUserAdminMapper
|
||||
* 版 权:
|
||||
* 描 述: <描述>
|
||||
* 创建人: H1
|
||||
* 创建时间: 2021/12/16
|
||||
* 修改人:
|
||||
* 修改内容:
|
||||
* 修改时间:
|
||||
*/
|
||||
package com.accompany.admin.mapper.flowteam;
|
||||
|
||||
import com.xuanyin.flowteam.model.FlowTeamMemberInviteUser;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <br>接口描述:
|
||||
* <br>功能详细描述:
|
||||
*
|
||||
* @author H1
|
||||
* @date [2021/12/16]
|
||||
*/
|
||||
public interface FlowTeamMemberInviteUserAdminMapper {
|
||||
List<FlowTeamMemberInviteUser> listFlowTeamMemberInviteUserInfo();
|
||||
}
|
@@ -1,43 +0,0 @@
|
||||
package com.accompany.admin.mapper.flowteam;
|
||||
|
||||
import com.accompany.admin.params.flowteam.FlowTeamStatisticParams;
|
||||
import com.accompany.admin.vo.flowteam.FlowTeamStatisticDetailVO;
|
||||
import com.accompany.admin.vo.flowteam.FlowTeamStatisticSummaryVO;
|
||||
import com.accompany.admin.vo.flowteam.FlowTeamStatisticUserDetailVO;
|
||||
import com.accompany.admin.vo.flowteam.UserWithFlowTeamInfoVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface FlowTeamStatisticMapper {
|
||||
|
||||
FlowTeamStatisticSummaryVO staisticUseInviteCodes(@Param("inviteCodes") List<String> inviteCodes, @Param("params") FlowTeamStatisticParams params);
|
||||
|
||||
List<FlowTeamStatisticDetailVO> listTeamStatisticDetail(FlowTeamStatisticParams params);
|
||||
|
||||
List<FlowTeamStatisticUserDetailVO> listUserStatisticDetails(FlowTeamStatisticParams params);
|
||||
|
||||
List<UserWithFlowTeamInfoVO> listUsers(@Param("erbanNoList") List<String> erbanNoList);
|
||||
|
||||
/**
|
||||
* 按照引流团队-成员-邀请用户固化关系进行查询数据
|
||||
* @param inviteCodes
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
FlowTeamStatisticSummaryVO staisticUseInviteCodesV2(@Param("inviteCodes") List<String> inviteCodes, @Param("params") FlowTeamStatisticParams params);
|
||||
|
||||
/**
|
||||
* 按照引流团队-成员-邀请用户固化关系进行查询数据
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
List<FlowTeamStatisticDetailVO> listTeamStatisticDetailV2(FlowTeamStatisticParams params);
|
||||
|
||||
/**
|
||||
* 按照引流团队-成员-邀请用户固化关系进行查询数据
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
List<FlowTeamStatisticUserDetailVO> listUserStatisticDetailsV2(FlowTeamStatisticParams params);
|
||||
}
|
@@ -1,466 +0,0 @@
|
||||
/*
|
||||
* 文 件 名: FlowTeamGroupAdminService
|
||||
* 版 权:
|
||||
* 描 述: <描述>
|
||||
* 创建人: H1
|
||||
* 创建时间: 2022/1/13
|
||||
* 修改人:
|
||||
* 修改内容:
|
||||
* 修改时间:
|
||||
*/
|
||||
package com.accompany.admin.service.flowteam;
|
||||
|
||||
import com.accompany.admin.base.Pagination;
|
||||
import com.accompany.admin.mapper.flowteam.FlowTeamGroupAdminMapper;
|
||||
import com.accompany.admin.params.flowteam.FlowTeamEditInviteUserParams;
|
||||
import com.accompany.admin.vo.flowteam.FlowTeamGroupAdminVO;
|
||||
import com.accompany.admin.vo.flowteam.FlowTeamInfoAdminVO;
|
||||
import com.accompany.admin.vo.flowteam.FlowTeamInviteUserVO;
|
||||
import com.accompany.common.constant.Constant;
|
||||
import com.accompany.common.redis.RedisKey;
|
||||
import com.accompany.common.status.BusiStatus;
|
||||
import com.accompany.common.utils.StringUtils;
|
||||
import com.accompany.core.exception.AdminServiceException;
|
||||
import com.accompany.core.service.SysConfService;
|
||||
import com.accompany.core.service.common.JedisService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.xuanyin.flowteam.constant.FlowTeamConstant;
|
||||
import com.xuanyin.flowteam.model.*;
|
||||
import com.xuanyin.flowteam.service.*;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <br>类描述:
|
||||
* <br>功能详细描述:
|
||||
*
|
||||
* @author H1
|
||||
* @date [2022/1/13]
|
||||
*/
|
||||
@Service
|
||||
public class FlowTeamGroupAdminService {
|
||||
|
||||
@Autowired
|
||||
private FlowTeamGroupService flowTeamGroupService;
|
||||
@Autowired
|
||||
private FlowTeamGroupAdminMapper flowTeamGroupAdminMapper;
|
||||
@Autowired
|
||||
private FlowTeamInfoService flowTeamInfoService;
|
||||
@Autowired
|
||||
private FlowTeamMemberService flowTeamMemberService;
|
||||
@Autowired
|
||||
private JedisService jedisService;
|
||||
@Autowired
|
||||
private FlowTeamMemberInviteUserService flowTeamMemberInviteUserService;
|
||||
@Autowired
|
||||
private FlowTeamInviteUserChangeRecordService flowTeamInviteUserChangeRecordService;
|
||||
@Autowired
|
||||
private FlowTeamMemberInviteCodeService flowTeamMemberInviteCodeService;
|
||||
@Autowired
|
||||
private SysConfService sysConfService;
|
||||
|
||||
|
||||
private final static Integer MAX_TEAM_COUNT = 20;
|
||||
|
||||
|
||||
public Pagination listGroupByPage(Integer page, Integer pageSize, String groupName) {
|
||||
QueryWrapper<FlowTeamGroup> query = new QueryWrapper<>();
|
||||
if (StringUtils.isNotBlank(groupName)) {
|
||||
query.lambda().like(FlowTeamGroup::getGroupName, groupName);
|
||||
}
|
||||
PageHelper.startPage(page, pageSize);
|
||||
List<FlowTeamGroup> list = flowTeamGroupService.list(query);
|
||||
PageInfo<FlowTeamGroup> pageInfo = new PageInfo<>(list);
|
||||
List<FlowTeamGroupAdminVO> groupList = new ArrayList<>();
|
||||
list.forEach(
|
||||
group -> {
|
||||
FlowTeamGroupAdminVO vo = handleGroupVO(group);
|
||||
groupList.add(vo);
|
||||
}
|
||||
);
|
||||
PageInfo<FlowTeamGroupAdminVO> resPage = new PageInfo<>();
|
||||
BeanUtils.copyProperties(pageInfo, resPage);
|
||||
resPage.setList(groupList);
|
||||
return new Pagination(resPage);
|
||||
}
|
||||
|
||||
|
||||
@Transactional(rollbackFor = Exception.class, transactionManager = "mybatisplusTransactionManager")
|
||||
public void saveOrUpdateGroup(Long groupId, String groupName) {
|
||||
if (null == groupId) {
|
||||
FlowTeamGroup group = FlowTeamGroup.builder().groupName(groupName).status(FlowTeamConstant.MemberStatus.MEMBER_STATUS_VALID)
|
||||
.createTime(new Date()).updateTime(new Date())
|
||||
.build();
|
||||
flowTeamGroupService.save(group);
|
||||
} else {
|
||||
FlowTeamGroup group = flowTeamGroupService.getById(groupId);
|
||||
if (null == group) {
|
||||
throw new AdminServiceException(BusiStatus.SERVERBUSY, "团队不存在");
|
||||
}
|
||||
group.setGroupName(groupName);
|
||||
flowTeamGroupService.updateById(group);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class, transactionManager = "mybatisplusTransactionManager")
|
||||
public void changeGroupStatus(Long groupId, Integer status) {
|
||||
if (groupId == null || null == status) {
|
||||
throw new AdminServiceException(BusiStatus.PARAMERROR);
|
||||
}
|
||||
FlowTeamGroup group = flowTeamGroupService.getById(groupId);
|
||||
if (null == group) {
|
||||
throw new AdminServiceException(BusiStatus.SERVERBUSY, "团队不存在");
|
||||
}
|
||||
group.setStatus(status);
|
||||
flowTeamGroupService.updateById(group);
|
||||
}
|
||||
|
||||
|
||||
public Pagination listGroupTeamByPage(Integer page, Integer pageSize, Long groupId) {
|
||||
if (groupId == null) {
|
||||
throw new AdminServiceException(BusiStatus.PARAMERROR);
|
||||
}
|
||||
PageHelper.startPage(page, pageSize);
|
||||
QueryWrapper<FlowTeamInfo> query = new QueryWrapper<>();
|
||||
query.lambda().eq(FlowTeamInfo::getGroupId, groupId).ne(FlowTeamInfo::getStatus, FlowTeamConstant.MemberStatus.MEMBER_STATUS_DELETED);
|
||||
List<FlowTeamInfo> teams = flowTeamInfoService.list(query);
|
||||
List<FlowTeamInfoAdminVO> teamList = new ArrayList<>();
|
||||
teams.forEach(
|
||||
team -> {
|
||||
FlowTeamInfoAdminVO vo = handleTeamVO(team);
|
||||
teamList.add(vo);
|
||||
}
|
||||
);
|
||||
PageInfo<FlowTeamInfoAdminVO> pageInfo = new PageInfo<>(teamList);
|
||||
return new Pagination(pageInfo);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class, transactionManager = "mybatisplusTransactionManager")
|
||||
public void saveOrUpdateTeam(Long groupId, String teamId, String teamName) {
|
||||
if (StringUtils.isBlank(teamName)) {
|
||||
throw new AdminServiceException(BusiStatus.PARAMERROR);
|
||||
}
|
||||
if (StringUtils.isBlank(teamId)) {
|
||||
// 校验
|
||||
checkAddTeam(groupId, teamName);
|
||||
FlowTeamInfo flowTeamInfo = FlowTeamInfo.builder().teamId(generateTeamId())
|
||||
.teamName(teamName).groupId(groupId).status(FlowTeamConstant.MemberStatus.MEMBER_STATUS_VALID)
|
||||
.createTime(new Date()).updateTime(new Date()).build();
|
||||
flowTeamInfoService.save(flowTeamInfo);
|
||||
} else {
|
||||
// 编辑
|
||||
checkTeamName(teamName, teamId);
|
||||
FlowTeamInfo team = flowTeamInfoService.getById(teamId);
|
||||
if (null == team) {
|
||||
throw new AdminServiceException(BusiStatus.SERVERBUSY, "小组不存在");
|
||||
}
|
||||
team.setTeamName(teamName);
|
||||
flowTeamInfoService.updateById(team);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class, transactionManager = "mybatisplusTransactionManager")
|
||||
public void delTeam(String teamId) {
|
||||
if (StringUtils.isBlank(teamId)) {
|
||||
throw new AdminServiceException(BusiStatus.PARAMERROR);
|
||||
}
|
||||
FlowTeamInfo team = flowTeamInfoService.getById(teamId);
|
||||
if (null == team) {
|
||||
throw new AdminServiceException(BusiStatus.SERVERBUSY, "小组不存在");
|
||||
}
|
||||
// 判断当前组内是否含有团长,有团长的话不可以删除
|
||||
if (teamContainsGroupLeader(teamId)) {
|
||||
throw new AdminServiceException(BusiStatus.SERVERBUSY, "当前小组内有团长身份成员,无法删除小组。请将团长转移至其他小组后再删除该小组。");
|
||||
}
|
||||
// 删除小组信息
|
||||
team.setStatus(FlowTeamConstant.MemberStatus.MEMBER_STATUS_DELETED);
|
||||
flowTeamInfoService.updateById(team);
|
||||
// 小组成员置为已删除
|
||||
List<FlowTeamMember> memberList = listTeamNotDelMember(teamId);
|
||||
if (CollectionUtils.isNotEmpty(memberList)) {
|
||||
memberList.forEach(
|
||||
member -> {
|
||||
member.setMemberStatus(FlowTeamConstant.MemberStatus.MEMBER_STATUS_DELETED);
|
||||
}
|
||||
);
|
||||
flowTeamMemberService.updateBatchById(memberList);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public FlowTeamGroup getMemberGroup(String phone) {
|
||||
Long groupId = flowTeamGroupAdminMapper.getJoinGroupIdByPhone(phone);
|
||||
if (null != groupId) {
|
||||
FlowTeamGroup group = flowTeamGroupService.getById(groupId);
|
||||
return group;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public FlowTeamMember getUserMaxRoleMember(String phone) {
|
||||
QueryWrapper<FlowTeamMember> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(FlowTeamMember::getMemberPhone, phone)
|
||||
.in(FlowTeamMember::getTeamRole, Arrays.asList(FlowTeamConstant.TeamRole.LEADER, FlowTeamConstant.TeamRole.GROUP_LEADER))
|
||||
.eq(FlowTeamMember::getMemberStatus, FlowTeamConstant.MemberStatus.MEMBER_STATUS_VALID);
|
||||
List<FlowTeamMember> teamList = flowTeamMemberService.list(queryWrapper);
|
||||
if (org.springframework.util.CollectionUtils.isEmpty(teamList)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<String> teamIds = new ArrayList<>();
|
||||
FlowTeamMember maxRole = teamList.stream().max(Comparator.comparing(FlowTeamMember::getTeamRole)).get();
|
||||
return maxRole;
|
||||
}
|
||||
|
||||
private List<FlowTeamMember> listTeamNotDelMember(String teamId) {
|
||||
QueryWrapper<FlowTeamMember> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(FlowTeamMember::getTeamId, teamId)
|
||||
.ne(FlowTeamMember::getMemberStatus, FlowTeamConstant.MemberStatus.MEMBER_STATUS_DELETED);
|
||||
return flowTeamMemberService.list(queryWrapper);
|
||||
}
|
||||
|
||||
private Boolean teamContainsGroupLeader(String teamId) {
|
||||
QueryWrapper<FlowTeamMember> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(FlowTeamMember::getTeamId, teamId)
|
||||
.eq(FlowTeamMember::getMemberStatus, FlowTeamConstant.MemberStatus.MEMBER_STATUS_VALID)
|
||||
.eq(FlowTeamMember::getTeamRole, FlowTeamConstant.TeamRole.GROUP_LEADER);
|
||||
return flowTeamMemberService.count(queryWrapper) > 0;
|
||||
}
|
||||
|
||||
private String generateTeamId() {
|
||||
Date now = new Date();
|
||||
String dataStr = com.accompany.common.utils.DateTimeUtil.convertDate(now, com.accompany.common.utils.DateTimeUtil.DEFAULT_DATE_PATTERN_);
|
||||
Long seq = jedisService.incr(RedisKey.flow_team_id_seq.getKey(dataStr));
|
||||
long expireTime = com.accompany.common.utils.DateTimeUtil.getNextDay2(now, 1).getTime() - 1;
|
||||
jedisService.expireAt(RedisKey.flow_team_id_seq.getKey(dataStr), expireTime);
|
||||
|
||||
return dataStr + String.format("%04d", seq);
|
||||
}
|
||||
|
||||
|
||||
private void checkAddTeam(Long groupId, String teamName) {
|
||||
long teamNum = countGroupValidTeam(groupId);
|
||||
String maxCount = sysConfService.getDefaultSysConfValueById(Constant.SysConfId.FLOW_TEAM_MAX_TEAM_COUNT, MAX_TEAM_COUNT.toString());
|
||||
if (teamNum >= Long.parseLong(maxCount)) {
|
||||
throw new AdminServiceException(BusiStatus.SERVERBUSY, "超过团队小组上限");
|
||||
}
|
||||
checkTeamName(teamName, null);
|
||||
}
|
||||
|
||||
private void checkTeamName(String teamName, String teamId) {
|
||||
QueryWrapper<FlowTeamInfo> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(FlowTeamInfo::getTeamName, teamName).eq(FlowTeamInfo::getStatus, FlowTeamConstant.MemberStatus.MEMBER_STATUS_VALID);
|
||||
FlowTeamInfo flowTeamInfo = flowTeamInfoService.getOne(queryWrapper);
|
||||
if (null != teamId && flowTeamInfo != null && !flowTeamInfo.getTeamId().equals(teamId)) {
|
||||
throw new AdminServiceException(BusiStatus.SERVERBUSY, "小组名称已存在");
|
||||
}
|
||||
if (null == teamId && null != flowTeamInfo) {
|
||||
throw new AdminServiceException(BusiStatus.SERVERBUSY, "小组名称已存在");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private FlowTeamInfoAdminVO handleTeamVO(FlowTeamInfo info) {
|
||||
FlowTeamInfoAdminVO vo = new FlowTeamInfoAdminVO();
|
||||
BeanUtils.copyProperties(info, vo);
|
||||
// 组长信息
|
||||
List<FlowTeamMember> leaders = listTeamLeader(info.getTeamId());
|
||||
vo.setTeamLeaders(leaders);
|
||||
// 小组成员数量
|
||||
vo.setMemberNum(flowTeamMemberService.countValidMember(info.getTeamId()));
|
||||
return vo;
|
||||
}
|
||||
|
||||
private List<FlowTeamMember> listTeamLeader(String teamId) {
|
||||
QueryWrapper<FlowTeamMember> query = new QueryWrapper<>();
|
||||
query.lambda().eq(FlowTeamMember::getTeamId, teamId)
|
||||
.eq(FlowTeamMember::getTeamRole, FlowTeamConstant.TeamRole.LEADER)
|
||||
.ne(FlowTeamMember::getMemberStatus, FlowTeamConstant.MemberStatus.MEMBER_STATUS_DELETED);
|
||||
return flowTeamMemberService.list(query);
|
||||
}
|
||||
|
||||
private FlowTeamGroupAdminVO handleGroupVO(FlowTeamGroup group) {
|
||||
FlowTeamGroupAdminVO vo = new FlowTeamGroupAdminVO();
|
||||
BeanUtils.copyProperties(group, vo);
|
||||
// 团长信息
|
||||
List<FlowTeamMember> groupLeader = flowTeamGroupAdminMapper.listGroupLeader(group.getGroupId());
|
||||
vo.setGroupLeaders(groupLeader);
|
||||
// 小组数量
|
||||
vo.setTeamNum(countGroupValidTeam(group.getGroupId()));
|
||||
// 有效成员数量
|
||||
vo.setMemberNum(flowTeamGroupAdminMapper.countGroupValidMember(group.getGroupId()));
|
||||
return vo;
|
||||
}
|
||||
|
||||
private long countGroupValidTeam(Long groupId) {
|
||||
QueryWrapper<FlowTeamInfo> query = new QueryWrapper<>();
|
||||
query.lambda().eq(FlowTeamInfo::getGroupId, groupId)
|
||||
.eq(FlowTeamInfo::getStatus, FlowTeamConstant.MemberStatus.MEMBER_STATUS_VALID);
|
||||
return flowTeamInfoService.count(query);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class, transactionManager = "mybatisplusTransactionManager")
|
||||
public void initGroupAndTeam() throws IOException {
|
||||
|
||||
File logsFile = new File("C:\\Users\\H1\\Desktop\\group.txt");
|
||||
|
||||
BufferedReader reader = new BufferedReader(new FileReader(logsFile));
|
||||
|
||||
List<FlowTeamGroup> groups = new ArrayList<>();
|
||||
Map<String, List<FlowTeamInfo>> teamMap = new HashMap<>();
|
||||
String tempString = null;
|
||||
int line = 1;
|
||||
// 一次读入一行,直到读入null为文件结束
|
||||
while ((tempString = reader.readLine()) != null) {
|
||||
// 显示行号
|
||||
System.out.println("line " + line + ": " + tempString);
|
||||
List<String> list1 = Arrays.asList(tempString.split(","));
|
||||
String group = list1.get(0);
|
||||
String teamId = list1.get(1);
|
||||
String teamName = list1.get(2);
|
||||
group = group.trim();
|
||||
teamId = teamId.trim();
|
||||
teamName = teamName.trim();
|
||||
FlowTeamGroup flowTeamGroup = new FlowTeamGroup();
|
||||
flowTeamGroup.setGroupName(group);
|
||||
flowTeamGroup.setStatus(FlowTeamConstant.MemberStatus.MEMBER_STATUS_VALID);
|
||||
flowTeamGroup.setCreateTime(new Date());
|
||||
flowTeamGroup.setUpdateTime(new Date());
|
||||
groups.add(flowTeamGroup);
|
||||
FlowTeamInfo team = new FlowTeamInfo();
|
||||
team.setTeamId(teamId);
|
||||
team.setTeamName(teamName);
|
||||
List<FlowTeamInfo> tepTeams = teamMap.get(group);
|
||||
if (CollectionUtils.isEmpty(tepTeams)) {
|
||||
tepTeams = new ArrayList<>();
|
||||
teamMap.put(group, tepTeams);
|
||||
}
|
||||
tepTeams.add(team);
|
||||
line++;
|
||||
}
|
||||
groups = groups.stream().distinct().collect(Collectors.toList());
|
||||
reader.close();
|
||||
System.out.println(JSON.toJSONString(groups));
|
||||
System.out.println(JSON.toJSONString(teamMap));
|
||||
// 写入group
|
||||
flowTeamGroupService.saveBatch(groups);
|
||||
// 写入team
|
||||
for (String groupName : teamMap.keySet()) {
|
||||
FlowTeamGroup group = getByGroupName(groupName);
|
||||
if (null != group) {
|
||||
List<FlowTeamInfo> teamList = teamMap.get(groupName);
|
||||
teamList.forEach(
|
||||
team -> {
|
||||
team.setGroupId(group.getGroupId());
|
||||
team.setStatus(FlowTeamConstant.MemberStatus.MEMBER_STATUS_VALID);
|
||||
team.setCreateTime(new Date());
|
||||
team.setUpdateTime(new Date());
|
||||
}
|
||||
);
|
||||
flowTeamInfoService.saveBatch(teamList);
|
||||
}
|
||||
}
|
||||
System.out.println(groups.size());
|
||||
}
|
||||
|
||||
private FlowTeamGroup getByGroupName(String groupName) {
|
||||
QueryWrapper<FlowTeamGroup> query = new QueryWrapper<>();
|
||||
query.lambda().eq(FlowTeamGroup::getGroupName, groupName)
|
||||
.eq(FlowTeamGroup::getStatus, FlowTeamConstant.MemberStatus.MEMBER_STATUS_VALID);
|
||||
return flowTeamGroupService.getOne(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取邀请用户的引流团队信息
|
||||
*
|
||||
* @param page
|
||||
* @param pageSize
|
||||
* @param erbanNo
|
||||
* @return
|
||||
*/
|
||||
public Pagination<FlowTeamInviteUserVO> listFlowTeamInfoWithUser(Integer page, Integer pageSize, String erbanNo) {
|
||||
PageHelper.startPage(page, pageSize);
|
||||
List<FlowTeamInviteUserVO> flowTeamInviteUserVOS = flowTeamGroupAdminMapper.listFlowTeamInfoWithUser(erbanNo);
|
||||
PageInfo<FlowTeamInviteUserVO> pageInfo = new PageInfo<>(flowTeamInviteUserVOS);
|
||||
return new Pagination<>(pageInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param params
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class, transactionManager = "mybatisplusTransactionManager")
|
||||
public void updateFlowTeamInviteInfo(FlowTeamEditInviteUserParams params) {
|
||||
Long uid = params.getUid();
|
||||
Byte type = params.getOptType();
|
||||
FlowTeamMemberInviteUser inviteRecord = flowTeamMemberInviteUserService.getByUid(uid);
|
||||
if (null == inviteRecord) {
|
||||
throw new AdminServiceException(BusiStatus.SERVERBUSY, "该用户没有引流团队的邀请关系");
|
||||
}
|
||||
if (FlowTeamConstant.FlowTeamInviteUserOptType.DEL.equals(type)) {
|
||||
// 解绑
|
||||
flowTeamMemberInviteUserService.removeById(inviteRecord.getId());
|
||||
} else if (FlowTeamConstant.FlowTeamInviteUserOptType.UPDATE.equals(type)) {
|
||||
// 换绑
|
||||
checkChangeParams(params);
|
||||
FlowTeamMemberInviteUser recordForUpdate = new FlowTeamMemberInviteUser();
|
||||
recordForUpdate.setId(inviteRecord.getId());
|
||||
recordForUpdate.setGroupId(params.getGroupId());
|
||||
recordForUpdate.setTeamId(params.getTeamId());
|
||||
recordForUpdate.setMemberId(params.getMemberId());
|
||||
recordForUpdate.setInviteCode(params.getInviteCode());
|
||||
flowTeamMemberInviteUserService.updateById(recordForUpdate);
|
||||
}
|
||||
// 增加操作记录
|
||||
FlowTeamInviteUserChangeRecord record = FlowTeamInviteUserChangeRecord.builder()
|
||||
.inviteRecordId(inviteRecord.getId()).inviteCode(inviteRecord.getInviteCode())
|
||||
.groupId(inviteRecord.getGroupId()).teamId(inviteRecord.getTeamId()).memberId(inviteRecord.getMemberId())
|
||||
.uid(uid).type(type).operator(params.getOptUid()).createTime(new Date()).updateTime(new Date())
|
||||
.build();
|
||||
flowTeamInviteUserChangeRecordService.save(record);
|
||||
}
|
||||
|
||||
private void checkChangeParams(FlowTeamEditInviteUserParams params) {
|
||||
Long groupId = params.getGroupId();
|
||||
String teamId = params.getTeamId();
|
||||
Long memberId = params.getMemberId();
|
||||
String inviteCode = params.getInviteCode();
|
||||
if (null == groupId || null == memberId
|
||||
|| StringUtils.isBlank(teamId) || StringUtils.isBlank(inviteCode)) {
|
||||
throw new AdminServiceException(BusiStatus.PARAMERROR);
|
||||
}
|
||||
FlowTeamInfo team = flowTeamInfoService.getByTeamId(teamId);
|
||||
if (team == null) {
|
||||
throw new AdminServiceException(BusiStatus.SERVERBUSY, "小组不存在");
|
||||
}
|
||||
if (!team.getGroupId().equals(groupId)) {
|
||||
throw new AdminServiceException(BusiStatus.SERVERBUSY, "小组与团队不对应");
|
||||
}
|
||||
FlowTeamMember member = flowTeamMemberService.getById(memberId);
|
||||
if (member == null || FlowTeamConstant.MemberStatus.MEMBER_STATUS_DELETED.equals(member.getMemberStatus())) {
|
||||
throw new AdminServiceException(BusiStatus.SERVERBUSY, "成员不存在");
|
||||
}
|
||||
if (!member.getTeamId().equals(teamId)) {
|
||||
throw new AdminServiceException(BusiStatus.SERVERBUSY, "小组与成员不对应");
|
||||
}
|
||||
FlowTeamMemberInviteCode memberInviteCode = flowTeamMemberInviteCodeService.getByInviteCode(inviteCode);
|
||||
if (memberInviteCode == null) {
|
||||
throw new AdminServiceException(BusiStatus.SERVERBUSY, "邀请码不存在");
|
||||
}
|
||||
if (!memberInviteCode.getMemberId().equals(memberId)) {
|
||||
throw new AdminServiceException(BusiStatus.SERVERBUSY, "邀请码与成员不对应");
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* 文 件 名: FlowTeamMemberInviteUserAdminService
|
||||
* 版 权:
|
||||
* 描 述: <描述>
|
||||
* 创建人: H1
|
||||
* 创建时间: 2021/12/16
|
||||
* 修改人:
|
||||
* 修改内容:
|
||||
* 修改时间:
|
||||
*/
|
||||
package com.accompany.admin.service.flowteam;
|
||||
|
||||
import com.accompany.admin.mapper.flowteam.FlowTeamMemberInviteUserAdminMapper;
|
||||
import com.xuanyin.flowteam.model.FlowTeamMemberInviteUser;
|
||||
import com.xuanyin.flowteam.service.FlowTeamMemberInviteUserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <br>类描述:
|
||||
* <br>功能详细描述:
|
||||
*
|
||||
* @author H1
|
||||
* @date [2021/12/16]
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class FlowTeamMemberInviteUserAdminService {
|
||||
@Autowired
|
||||
private FlowTeamMemberInviteUserService flowTeamMemberInviteUserService;
|
||||
@Autowired
|
||||
private FlowTeamMemberInviteUserAdminMapper flowTeamMemberInviteUserAdminMapper;
|
||||
|
||||
@Transactional(rollbackFor = Exception.class, transactionManager = "mybatisplusTransactionManager")
|
||||
public void initFlowTeamMemberInviteUserData() {
|
||||
List<FlowTeamMemberInviteUser> info = flowTeamMemberInviteUserAdminMapper.listFlowTeamMemberInviteUserInfo();
|
||||
if (CollectionUtils.isEmpty(info)) {
|
||||
return;
|
||||
}
|
||||
flowTeamMemberInviteUserService.saveBatch(info);
|
||||
}
|
||||
}
|
@@ -1,952 +0,0 @@
|
||||
package com.accompany.admin.service.flowteam;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.accompany.admin.base.Pagination;
|
||||
import com.accompany.admin.mapper.RoomInviteCodeAdminMapper;
|
||||
import com.accompany.admin.mapper.UserMapperExpand;
|
||||
import com.accompany.admin.mapper.flowteam.FlowTeamGroupAdminMapper;
|
||||
import com.accompany.admin.mapper.flowteam.FlowTeamStatisticMapper;
|
||||
import com.accompany.admin.params.flowteam.FlowTeamStatisticParams;
|
||||
import com.accompany.admin.params.flowteam.TeamMemberEditParams;
|
||||
import com.accompany.admin.params.flowteam.TeamMemberQueryParams;
|
||||
import com.accompany.admin.util.InviteCodeUtil;
|
||||
import com.accompany.admin.vo.flowteam.*;
|
||||
import com.accompany.business.event.RefillUserInviteCodeEvent;
|
||||
import com.accompany.business.model.RoomInviteCode;
|
||||
import com.accompany.business.model.UserInviteCode;
|
||||
import com.accompany.business.service.room.RoomInviteCodeService;
|
||||
import com.accompany.business.service.room.RoomService;
|
||||
import com.accompany.business.service.user.InviteCodeService;
|
||||
import com.accompany.business.service.invite.UserInviteCodeService;
|
||||
import com.accompany.business.service.user.UsersService;
|
||||
import com.accompany.business.vo.room.RoomInviteCodeVo;
|
||||
import com.accompany.common.config.SystemConfig;
|
||||
import com.accompany.common.constant.Constant;
|
||||
import com.accompany.common.status.BusiStatus;
|
||||
import com.accompany.common.utils.AppUtils;
|
||||
import com.accompany.common.utils.StringUtils;
|
||||
import com.accompany.core.exception.AdminServiceException;
|
||||
import com.accompany.core.exception.ServiceException;
|
||||
import com.accompany.core.model.Room;
|
||||
import com.accompany.core.model.Users;
|
||||
import com.accompany.core.service.SysConfService;
|
||||
import com.accompany.core.service.user.UsersBaseService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.xuanyin.flowteam.constant.FlowTeamConstant;
|
||||
import com.xuanyin.flowteam.mapper.FlowTeamMemberInviteCodeMapper;
|
||||
import com.xuanyin.flowteam.mapper.FlowTeamMemberMapper;
|
||||
import com.xuanyin.flowteam.model.*;
|
||||
import com.xuanyin.flowteam.service.*;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class FlowTeamService {
|
||||
|
||||
@Autowired
|
||||
private UserMapperExpand userMapperExpand;
|
||||
@Autowired
|
||||
private FlowTeamMemberMapper flowTeamMemberMapper;
|
||||
@Autowired
|
||||
private FlowTeamMemberInviteCodeMapper flowTeamMemberInviteCodeMapper;
|
||||
@Autowired
|
||||
private UsersBaseService usersBaseService;
|
||||
@Autowired
|
||||
private FlowTeamStatisticMapper flowTeamStatisticMapper;
|
||||
@Autowired
|
||||
private SysConfService sysConfService;
|
||||
@Autowired
|
||||
private UsersService usersService;
|
||||
@Autowired
|
||||
private InviteCodeService inviteCodeService;
|
||||
@Autowired
|
||||
private ApplicationContext applicationContext;
|
||||
@Autowired
|
||||
private FlowTeamInviteCodeRecordService flowTeamInviteCodeRecordService;
|
||||
@Autowired
|
||||
private RoomInviteCodeService roomInviteCodeService;
|
||||
@Autowired
|
||||
private RoomInviteCodeAdminMapper roomInviteCodeAdminMapper;
|
||||
@Autowired
|
||||
private RoomService roomService;
|
||||
@Autowired
|
||||
private UserInviteCodeService userInviteCodeService;
|
||||
@Autowired
|
||||
private FlowTeamMemberInviteUserBizService flowTeamMemberInviteUserBizService;
|
||||
@Autowired
|
||||
private FlowTeamInfoService flowTeamInfoService;
|
||||
@Autowired
|
||||
private FlowTeamGroupAdminMapper flowTeamGroupAdminMapper;
|
||||
@Autowired
|
||||
private FlowTeamMemberService flowTeamMemberService;
|
||||
@Autowired
|
||||
private FlowTeamGroupService flowTeamGroupService;
|
||||
|
||||
private final static Integer MEMBER_STATUS_VALID = 1;
|
||||
private final static Integer MEMBER_STATUS_INVALID = 0;
|
||||
private final static Integer MEMBER_STATUS_DELETED = -1;
|
||||
|
||||
private final static Integer TEAM_ROLE_MEMBER = 1;
|
||||
private final static Integer TEAM_ROLE_LEADER = 2;
|
||||
|
||||
// 可以补填邀请码的时间
|
||||
private final static Long DEFAULT_CAN_REFILL_INTERVAL = 120L;
|
||||
|
||||
// 生成邀请码的最大个数
|
||||
private final static Integer GEN_INVITECODE_MAX_COUNT = 5;
|
||||
|
||||
// 小组成员上限
|
||||
private final static Integer TEAM_MAX_MEMBER_COUNT = 100;
|
||||
|
||||
// 单人最多持有有效验证码个数
|
||||
private final static Integer TEAM_MAX_INVITECODE_COUNT_ONE_PERSON = 5;
|
||||
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long addTeamMember(TeamMemberEditParams params) {
|
||||
checkAddMember(params);
|
||||
List<String> inviteCodes = new ArrayList<>();
|
||||
if (StringUtils.isNotBlank(params.getInviteCodes())) {
|
||||
inviteCodes = getInviteCodeList(params.getInviteCodes().toUpperCase());
|
||||
}
|
||||
return addTeamMemberBase(params, inviteCodes);
|
||||
}
|
||||
|
||||
private Long addTeamMemberBase(TeamMemberEditParams params, List<String> inviteCodes) {
|
||||
if (!CollectionUtils.isEmpty(inviteCodes)) {
|
||||
validInviteCods(inviteCodes, params.getTeamId());
|
||||
}
|
||||
FlowTeamMember memberForInsert = new FlowTeamMember();
|
||||
BeanUtil.copyProperties(params, memberForInsert);
|
||||
memberForInsert.setCreateTime(new Date());
|
||||
flowTeamMemberMapper.insert(memberForInsert);
|
||||
Long memberId = memberForInsert.getMemberId();
|
||||
if (!CollectionUtils.isEmpty(inviteCodes)) {
|
||||
addMemberInviteCode(memberId, inviteCodes);
|
||||
}
|
||||
|
||||
return memberId;
|
||||
}
|
||||
|
||||
private void checkAddMember(TeamMemberEditParams params) {
|
||||
if (params == null) {
|
||||
throw new AdminServiceException(BusiStatus.PARAMERROR, "请求参数为空");
|
||||
}
|
||||
if (StringUtils.isBlank(params.getTeamId())) {
|
||||
throw new AdminServiceException(BusiStatus.PARAMERROR, "请选择加入小组");
|
||||
}
|
||||
if (StringUtils.isBlank(params.getMemberName())) {
|
||||
throw new AdminServiceException(BusiStatus.PARAMERROR, "请输入成员姓名");
|
||||
}
|
||||
if (StringUtils.isBlank(params.getMemberPhone())) {
|
||||
throw new AdminServiceException(BusiStatus.PARAMERROR, "请输入成员电话");
|
||||
}
|
||||
if (params.getTeamRole() == null) {
|
||||
throw new AdminServiceException(BusiStatus.PARAMERROR, "请选择职务");
|
||||
}
|
||||
// 团长可以不填邀请码
|
||||
if (!params.getTeamRole().equals(FlowTeamConstant.TeamRole.GROUP_LEADER) && StringUtils.isBlank(params.getInviteCodes())) {
|
||||
throw new AdminServiceException(BusiStatus.PARAMERROR, "请输入邀请码");
|
||||
}
|
||||
// 校验当前手机号是否加入其它团队
|
||||
Long joinGroupId = flowTeamGroupAdminMapper.getJoinGroupIdByPhone(params.getMemberPhone());
|
||||
if (joinGroupId != null && joinGroupId != params.getGroupId()) {
|
||||
throw new AdminServiceException(BusiStatus.BUSIERROR, "该手机号已被其他团队使用,无法添加成员");
|
||||
}
|
||||
// 小组最大成员上限
|
||||
checkTeamMemberCount(params.getTeamId());
|
||||
}
|
||||
|
||||
private void checkTeamMemberCount(String teamId) {
|
||||
long memberCount = flowTeamMemberService.countValidMember(teamId);
|
||||
if (memberCount > TEAM_MAX_MEMBER_COUNT) {
|
||||
throw new AdminServiceException(BusiStatus.BUSIERROR, "超过小组成员人数上限");
|
||||
}
|
||||
}
|
||||
|
||||
private void addMemberInviteCode(Long memberId, List<String> inviteCodes) {
|
||||
inviteCodes.forEach(code -> {
|
||||
FlowTeamMemberInviteCode item = new FlowTeamMemberInviteCode();
|
||||
item.setMemberId(memberId);
|
||||
item.setInviteCode(code);
|
||||
flowTeamMemberInviteCodeMapper.insert(item);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class, transactionManager = "mybatisplusTransactionManager")
|
||||
public void editTeamMember(TeamMemberEditParams params) {
|
||||
editTeamMemberBase(params, false);
|
||||
}
|
||||
|
||||
private void editTeamMemberBase(TeamMemberEditParams params, Boolean editByLeader) {
|
||||
if (params == null) {
|
||||
throw new AdminServiceException(BusiStatus.PARAMERROR, "请求参数为空");
|
||||
}
|
||||
if (params.getMemberId() == null) {
|
||||
throw new AdminServiceException(BusiStatus.PARAMERROR, "传入的memberId不能为空");
|
||||
}
|
||||
// 校验当前手机号是否加入其它团队
|
||||
Long joinGroupIdByPhone = flowTeamGroupAdminMapper.getJoinGroupIdByPhone(params.getMemberPhone());
|
||||
if (joinGroupIdByPhone != null && !joinGroupIdByPhone.equals(params.getGroupId())) {
|
||||
throw new AdminServiceException(BusiStatus.BUSIERROR, "该手机号已被其他团队使用,无法添加成员");
|
||||
}
|
||||
// 小组最大成员上限
|
||||
checkTeamMemberCount(params.getTeamId());
|
||||
List<String> inviteCodes = getInviteCodeList(params.getInviteCodes());
|
||||
if (!CollectionUtils.isEmpty(inviteCodes)) {
|
||||
validInviteCods(inviteCodes, params.getMemberId(), params.getTeamId());
|
||||
}
|
||||
|
||||
FlowTeamMember memberForInsert = new FlowTeamMember();
|
||||
BeanUtil.copyProperties(params, memberForInsert);
|
||||
memberForInsert.setUpdateTime(new Date());
|
||||
flowTeamMemberMapper.updateById(memberForInsert);
|
||||
Long memberId = memberForInsert.getMemberId();
|
||||
updateMemberInviteCodes(memberId, inviteCodes, editByLeader);
|
||||
}
|
||||
|
||||
private void updateMemberInviteCodes(Long memberId, List<String> inviteCodes, Boolean editByLeader) {
|
||||
QueryWrapper<FlowTeamMemberInviteCode> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(FlowTeamMemberInviteCode::getMemberId, memberId);
|
||||
List<FlowTeamMemberInviteCode> memberInviteCodes = flowTeamMemberInviteCodeMapper.selectList(queryWrapper);
|
||||
if (memberInviteCodes == null || memberInviteCodes.isEmpty()) {
|
||||
addMemberInviteCode(memberId, inviteCodes);
|
||||
return;
|
||||
}
|
||||
|
||||
Map<String, FlowTeamMemberInviteCode> memberCodeMap = memberInviteCodes.stream().collect(Collectors.toMap(FlowTeamMemberInviteCode::getInviteCode, memberInviteCode -> memberInviteCode, (k1, k2) -> k1));
|
||||
List<Long> needDeleteItemIds = new ArrayList<>();
|
||||
List<String> needAddCodes = new ArrayList<>();
|
||||
List<String> needDeleteCodes = new ArrayList<>();
|
||||
inviteCodes.forEach(code -> {
|
||||
if (memberCodeMap.containsKey(code)) {
|
||||
// 已经存在的就维持不变
|
||||
memberCodeMap.remove(code);
|
||||
} else {
|
||||
// 不存在的就新增
|
||||
needAddCodes.add(code);
|
||||
}
|
||||
});
|
||||
if (!memberCodeMap.isEmpty()) {
|
||||
// 剩下的就是要删除的
|
||||
memberCodeMap.values().stream().forEach(memberInviteCode -> {
|
||||
needDeleteItemIds.add(memberInviteCode.getId());
|
||||
needDeleteCodes.add(memberInviteCode.getInviteCode());
|
||||
});
|
||||
}
|
||||
|
||||
if (!needAddCodes.isEmpty()) {
|
||||
if (editByLeader) {
|
||||
checkOperateInviteCodeByLeader(needAddCodes);
|
||||
}
|
||||
addMemberInviteCode(memberId, needAddCodes);
|
||||
}
|
||||
|
||||
if (!needDeleteItemIds.isEmpty()) {
|
||||
System.out.println("needDeleteCodes:" + JSON.toJSONString(needDeleteCodes));
|
||||
if (editByLeader) {
|
||||
checkOperateInviteCodeByLeader(needDeleteCodes);
|
||||
}
|
||||
deleteMemberInviteCodes(needDeleteItemIds);
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteMemberInviteCodes(List<Long> memberCodeIds) {
|
||||
flowTeamMemberInviteCodeMapper.deleteBatchIds(memberCodeIds);
|
||||
}
|
||||
|
||||
private void validInviteCods(List<String> inviteCodes, String teamId) {
|
||||
validInviteCods(inviteCodes, null, teamId);
|
||||
}
|
||||
|
||||
private void validInviteCods(List<String> inviteCodes, Long memberId, String teamId) {
|
||||
// 成员邀请码最大上限
|
||||
if (inviteCodes.size() > TEAM_MAX_INVITECODE_COUNT_ONE_PERSON) {
|
||||
throw new AdminServiceException(BusiStatus.SERVERBUSY, "成员邀请码超过上限");
|
||||
}
|
||||
List<String> invalidCods = new ArrayList<>(inviteCodes.stream().map(String::toUpperCase).collect(Collectors.toList()));
|
||||
// 从表中获取邀请码信息
|
||||
List<UserInviteCode> userInviteCodes = inviteCodeService.listByInviteCode(inviteCodes);
|
||||
// 小组后台生成的邀请码
|
||||
List<UserInviteCode> flowTeamGenInviteCodes = userInviteCodes.stream().filter(i -> Constant.InviteCodeGenScene.flow_team.equals(i.getGenScene())).collect(Collectors.toList());
|
||||
List<String> otherTeamCodes = new ArrayList<>();
|
||||
flowTeamGenInviteCodes.forEach(
|
||||
code -> {
|
||||
FlowTeamInviteCodeRecord record = flowTeamInviteCodeRecordService.getByTeamIdAndCode(teamId, code.getInviteCode());
|
||||
if (record == null) {
|
||||
otherTeamCodes.add(code.getInviteCode());
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
// 将表中有的,从list中排除,剩下的就是无效的
|
||||
userInviteCodes.forEach(info -> {
|
||||
invalidCods.remove(info.getInviteCode().toUpperCase());
|
||||
});
|
||||
|
||||
List<String> duplicateCods = new ArrayList<>();
|
||||
userInviteCodes.forEach(userInviteCode -> {
|
||||
// 校验是否已经被其他人填写
|
||||
QueryWrapper<FlowTeamMember> queryWrapper = new QueryWrapper<>();
|
||||
if (memberId != null) {
|
||||
queryWrapper.lambda().ne(FlowTeamMember::getMemberId, memberId);
|
||||
}
|
||||
queryWrapper.lambda().exists("select 1 from flow_team_member_invite_code ic where flow_team_member.member_id = ic.member_id and ic.invite_code = '" + userInviteCode.getInviteCode() + "'");
|
||||
queryWrapper.lambda().in(FlowTeamMember::getMemberStatus, Arrays.asList(MEMBER_STATUS_VALID, MEMBER_STATUS_INVALID));
|
||||
long count = flowTeamMemberMapper.selectCount(queryWrapper);
|
||||
if (count > 0L) {
|
||||
duplicateCods.add(userInviteCode.getInviteCode());
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
if (!invalidCods.isEmpty() || !duplicateCods.isEmpty() || !otherTeamCodes.isEmpty()) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (!invalidCods.isEmpty()) {
|
||||
sb.append("以下邀请码不存在:").append(StringUtils.join(invalidCods, ",")).append("。");
|
||||
}
|
||||
if (!duplicateCods.isEmpty()) {
|
||||
sb.append("以下邀请码已跟其他成员绑定:").append(StringUtils.join(duplicateCods, ",")).append("。");
|
||||
}
|
||||
if (!otherTeamCodes.isEmpty()) {
|
||||
sb.append("以下邀请码非本组邀请码:").append(StringUtils.join(otherTeamCodes, ",")).append("。");
|
||||
}
|
||||
sb.append("请调整后再提交");
|
||||
throw new AdminServiceException(BusiStatus.PARAMERROR, sb.toString());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> getInviteCodeList(String inviteCodes) {
|
||||
inviteCodes = inviteCodes.trim();
|
||||
if (StringUtils.isNotBlank(inviteCodes)) {
|
||||
String[] codeArr = inviteCodes.trim().replaceAll(",", ",").split(",");
|
||||
return Arrays.asList(codeArr);
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class, transactionManager = "mybatisplusTransactionManager")
|
||||
public void changeMemberStatus(@Nonnull Long memberId, @Nonnull Integer status) {
|
||||
FlowTeamMember memberForUpdate = new FlowTeamMember();
|
||||
memberForUpdate.setMemberId(memberId);
|
||||
memberForUpdate.setMemberStatus(status);
|
||||
memberForUpdate.setCreateTime(new Date());
|
||||
flowTeamMemberMapper.updateById(memberForUpdate);
|
||||
}
|
||||
|
||||
public IPage<FlowTeamMemberVO> listFlowMembersByPage(TeamMemberQueryParams params) {
|
||||
if (params.getPageNumber() == null) {
|
||||
params.setPageNumber(1);
|
||||
}
|
||||
if (params.getPageSize() == null) {
|
||||
params.setPageSize(20);
|
||||
}
|
||||
QueryWrapper<FlowTeamMember> queryWrapper = new QueryWrapper<>();
|
||||
if (StringUtils.isNotBlank(params.getMemberName())) {
|
||||
queryWrapper.lambda().like(FlowTeamMember::getMemberName, "%" + params.getMemberName() + "%");
|
||||
}
|
||||
if (StringUtils.isNotBlank(params.getMemberPhone())) {
|
||||
queryWrapper.lambda().eq(FlowTeamMember::getMemberPhone, params.getMemberPhone());
|
||||
}
|
||||
if (StringUtils.isNotBlank(params.getTeamId())) {
|
||||
queryWrapper.lambda().eq(FlowTeamMember::getTeamId, params.getTeamId());
|
||||
}
|
||||
if (StringUtils.isNotBlank(params.getTeamIds())) {
|
||||
List<String> teamIdList = Arrays.asList(params.getTeamIds().split(","));
|
||||
queryWrapper.lambda().in(FlowTeamMember::getTeamId, teamIdList);
|
||||
}
|
||||
if (StringUtils.isNotBlank(params.getInviteCode())) {
|
||||
queryWrapper.lambda().exists("select 1 from flow_team_member_invite_code ic where flow_team_member.member_id = ic.member_id and ic.invite_code = '" + params.getInviteCode() + "'");
|
||||
}
|
||||
queryWrapper.lambda().in(FlowTeamMember::getMemberStatus, Arrays.asList(MEMBER_STATUS_VALID, MEMBER_STATUS_INVALID))
|
||||
.orderByDesc(FlowTeamMember::getTeamRole).orderByDesc(FlowTeamMember::getMemberId);
|
||||
|
||||
IPage<FlowTeamMember> iPage = new Page<>(params.getPageNumber(), params.getPageSize());
|
||||
IPage<FlowTeamMember> flowTeamMemberIPage = flowTeamMemberMapper.selectPage(iPage, queryWrapper);
|
||||
|
||||
return buildVoPage(flowTeamMemberIPage);
|
||||
}
|
||||
|
||||
private IPage<FlowTeamMemberVO> buildVoPage(IPage<FlowTeamMember> flowTeamMemberIPage) {
|
||||
IPage<FlowTeamMemberVO> resultPage = null;
|
||||
List<FlowTeamMember> records = flowTeamMemberIPage.getRecords();
|
||||
if (records == null || records.isEmpty()) {
|
||||
return new Page<>();
|
||||
}
|
||||
|
||||
// 获取成员的邀请码列表
|
||||
Map<Long, List<String>> memberInviteCodesMap = records.stream().collect(Collectors.toMap(FlowTeamMember::getMemberId, member -> new ArrayList<String>()));
|
||||
List<FlowTeamMemberInviteCode> memberInviteCodes = listFlowTeamMemberInviteCodes(memberInviteCodesMap.keySet());
|
||||
memberInviteCodes.forEach(memberInviteCode -> {
|
||||
List<String> codes = memberInviteCodesMap.get(memberInviteCode.getMemberId());
|
||||
codes.add(memberInviteCode.getInviteCode());
|
||||
});
|
||||
|
||||
// 获取成员的团队信息
|
||||
List<String> teamIds = records.stream().map(FlowTeamMember::getTeamId).collect(Collectors.toList());
|
||||
Map<String, Long> teamGroupMap = new HashMap<>(teamIds.size());
|
||||
List<FlowTeamInfo> flowTeamInfos = listFlowTeamInfoByTeamIds(teamIds);
|
||||
flowTeamInfos.forEach(
|
||||
team -> {
|
||||
teamGroupMap.put(team.getTeamId(), team.getGroupId());
|
||||
}
|
||||
);
|
||||
|
||||
List<FlowTeamMemberVO> voList = new ArrayList<>(records.size());
|
||||
records.forEach(record -> {
|
||||
FlowTeamMemberVO flowTeamMemberVO = new FlowTeamMemberVO();
|
||||
BeanUtil.copyProperties(record, flowTeamMemberVO);
|
||||
List<String> inviteCodes = memberInviteCodesMap.get(record.getMemberId());
|
||||
flowTeamMemberVO.setInviteCodes(StringUtils.join(inviteCodes, ","));
|
||||
flowTeamMemberVO.setGroupId(teamGroupMap.get(record.getTeamId()));
|
||||
voList.add(flowTeamMemberVO);
|
||||
});
|
||||
|
||||
resultPage = new Page<>(flowTeamMemberIPage.getCurrent(), flowTeamMemberIPage.getSize(), flowTeamMemberIPage.getTotal());
|
||||
resultPage.setRecords(voList);
|
||||
|
||||
return resultPage;
|
||||
}
|
||||
|
||||
private List<FlowTeamInfo> listFlowTeamInfoByTeamIds(List<String> teamIds) {
|
||||
QueryWrapper<FlowTeamInfo> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(FlowTeamInfo::getStatus, FlowTeamConstant.MemberStatus.MEMBER_STATUS_VALID)
|
||||
.in(FlowTeamInfo::getTeamId, teamIds);
|
||||
return flowTeamInfoService.list(queryWrapper);
|
||||
}
|
||||
|
||||
private List<FlowTeamMemberInviteCode> listFlowTeamMemberInviteCodes(Collection<Long> memberIds) {
|
||||
QueryWrapper<FlowTeamMemberInviteCode> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().in(FlowTeamMemberInviteCode::getMemberId, memberIds);
|
||||
return flowTeamMemberInviteCodeMapper.selectList(queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分组统计列表
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
public List<FlowTeamStatisticSummaryVO> listStatisticSummary(FlowTeamStatisticParams params) {
|
||||
QueryWrapper<FlowTeamMember> memberQueryWrapper = new QueryWrapper<>();
|
||||
if (StringUtils.isNotBlank(params.getTeamId())) {
|
||||
memberQueryWrapper.lambda().eq(FlowTeamMember::getTeamId, params.getTeamId());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(params.getTeamIds())) {
|
||||
memberQueryWrapper.lambda().in(FlowTeamMember::getTeamId, params.getTeamIds());
|
||||
}
|
||||
List<FlowTeamMember> flowTeamMembers = flowTeamMemberMapper.selectList(memberQueryWrapper);
|
||||
if (flowTeamMembers == null || flowTeamMembers.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
// 按组组合数据
|
||||
Map<String, List<FlowTeamMember>> teamMap = new ConcurrentHashMap<>();
|
||||
flowTeamMembers.forEach(member -> {
|
||||
List<FlowTeamMember> flowTeamMembersInMap = teamMap.get(member.getTeamId());
|
||||
if (flowTeamMembersInMap == null) {
|
||||
synchronized (teamMap) {
|
||||
flowTeamMembersInMap = teamMap.get(member.getTeamId());
|
||||
if (flowTeamMembersInMap == null) {
|
||||
flowTeamMembersInMap = new ArrayList<>();
|
||||
teamMap.put(member.getTeamId(), flowTeamMembersInMap);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
flowTeamMembersInMap.add(member);
|
||||
});
|
||||
|
||||
List<FlowTeamStatisticSummaryVO> summaryVOS = new ArrayList<>();
|
||||
|
||||
List<String> groupApps = AppUtils.getGroupApps(params.getApp());
|
||||
params.setGroupApps(groupApps);
|
||||
|
||||
// 分组进行统计
|
||||
teamMap.values().forEach(teamMembers -> {
|
||||
List<Long> memberIds = new ArrayList<>(teamMembers.size());
|
||||
List<String> teamLeaders = new ArrayList<>();
|
||||
teamMembers.stream().forEach(member -> {
|
||||
memberIds.add(member.getMemberId());
|
||||
if (member.getTeamRole().equals(TEAM_ROLE_LEADER)) {
|
||||
teamLeaders.add(member.getMemberName());
|
||||
}
|
||||
});
|
||||
List<FlowTeamMemberInviteCode> memberInviteCodes = listFlowTeamMemberInviteCodes(memberIds);
|
||||
List<String> inviteCodes = memberInviteCodes.stream().map(FlowTeamMemberInviteCode::getInviteCode).collect(Collectors.toList());
|
||||
params.setTeamId(teamMembers.get(0).getTeamId());
|
||||
FlowTeamStatisticSummaryVO flowTeamStatisticSummaryVO = flowTeamStatisticMapper.staisticUseInviteCodesV2(inviteCodes, params);
|
||||
if (flowTeamStatisticSummaryVO == null) {
|
||||
flowTeamStatisticSummaryVO = new FlowTeamStatisticSummaryVO();
|
||||
}
|
||||
|
||||
flowTeamStatisticSummaryVO.setTeamId(teamMembers.get(0).getTeamId());
|
||||
flowTeamStatisticSummaryVO.setMemberCount(Long.valueOf(teamMembers.stream().filter(member -> member.getMemberStatus().equals(MEMBER_STATUS_VALID)).count()).intValue());
|
||||
flowTeamStatisticSummaryVO.setTeamLeaders(StringUtils.join(teamLeaders, ","));
|
||||
calChargeRateAndArpu(flowTeamStatisticSummaryVO);
|
||||
|
||||
//次留
|
||||
flowTeamStatisticSummaryVO.setTwoRemainCount(userMapperExpand.getTwoRemainCount(inviteCodes, params.getStartDate(), params.getEndDate()));
|
||||
//七留
|
||||
flowTeamStatisticSummaryVO.setSevenRemainCount(userMapperExpand.getSevenRemainCount(inviteCodes, params.getStartDate(), params.getEndDate()));
|
||||
//月留
|
||||
flowTeamStatisticSummaryVO.setThirtyRemainCount(userMapperExpand.getThirtyRemainCount(inviteCodes, params.getStartDate(), params.getEndDate()));
|
||||
summaryVOS.add(flowTeamStatisticSummaryVO);
|
||||
});
|
||||
|
||||
return summaryVOS;
|
||||
}
|
||||
|
||||
public static void calChargeRateAndArpu(TeamStatisticBaseVO flowTeamStatisticSummaryVO) {
|
||||
if (flowTeamStatisticSummaryVO.getNewUserCount() != null && flowTeamStatisticSummaryVO.getNewUserCount() > 0) {
|
||||
// 计算付费转化
|
||||
Double chargeRate = (double) Optional.of(flowTeamStatisticSummaryVO.getNewChargeUserCount()).orElse(0) * 1.0 / flowTeamStatisticSummaryVO.getNewUserCount();
|
||||
flowTeamStatisticSummaryVO.setChargeRate(new BigDecimal(chargeRate).multiply(Constant.HUNDRED).setScale(2, BigDecimal.ROUND_HALF_UP).toString() + "%");
|
||||
|
||||
// 计算arpu
|
||||
Double arpu = new BigDecimal(Optional.of(flowTeamStatisticSummaryVO.getChargeMoney()).orElse(0.0) / flowTeamStatisticSummaryVO.getNewUserCount()).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
flowTeamStatisticSummaryVO.setArpu(arpu);
|
||||
} else {
|
||||
flowTeamStatisticSummaryVO.setChargeRate("0");
|
||||
flowTeamStatisticSummaryVO.setArpu(0.0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分组统计明细
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
public List<FlowTeamStatisticDetailVO> listFlowTeamStatisticDetails(FlowTeamStatisticParams params) {
|
||||
if (StringUtils.isBlank(params.getTeamId())) {
|
||||
throw new AdminServiceException(BusiStatus.PARAMERROR, "传入的teamId不能为空");
|
||||
}
|
||||
List<FlowTeamStatisticDetailVO> detailVOS = flowTeamStatisticMapper.listTeamStatisticDetailV2(params);
|
||||
if (detailVOS != null && !detailVOS.isEmpty()) {
|
||||
detailVOS.stream().forEach(item -> {
|
||||
calChargeRateAndArpu(item);
|
||||
handleTeamRole(item, params.getTeamId());
|
||||
});
|
||||
}
|
||||
return detailVOS;
|
||||
}
|
||||
|
||||
private void handleTeamRole(FlowTeamStatisticDetailVO flowTeamStatisticSummaryVO, String queryTeamId) {
|
||||
if (!flowTeamStatisticSummaryVO.getTeamId().equals(queryTeamId)) {
|
||||
flowTeamStatisticSummaryVO.setTeamRole(null);
|
||||
flowTeamStatisticSummaryVO.setMemberStatus(null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 个人统计明细
|
||||
*/
|
||||
public List<FlowTeamStatisticUserDetailVO> listUserStatisticDetails(FlowTeamStatisticParams params) {
|
||||
return flowTeamStatisticMapper.listUserStatisticDetailsV2(params);
|
||||
}
|
||||
|
||||
public FlowTeamConfVO getConfig() {
|
||||
String configStr = sysConfService.getDefaultSysConfValueById(Constant.SysConfId.FLOW_TEAM_MANAGE, "{}");
|
||||
FlowTeamConfVO flowTeamConfVO = JSONObject.parseObject(configStr, FlowTeamConfVO.class);
|
||||
if (flowTeamConfVO.getCanRefillInterval() == null) {
|
||||
flowTeamConfVO.setCanRefillInterval(DEFAULT_CAN_REFILL_INTERVAL);
|
||||
}
|
||||
return flowTeamConfVO;
|
||||
|
||||
}
|
||||
|
||||
public Map<String, FlowTeamConfVO.TeamItem> getTeamMap() {
|
||||
List<FlowTeamInfo> flowTeamInfos = listTeam();
|
||||
List<FlowTeamConfVO.TeamItem> teams = new ArrayList<>();
|
||||
flowTeamInfos.forEach(
|
||||
team -> {
|
||||
FlowTeamConfVO.TeamItem item = new FlowTeamConfVO.TeamItem();
|
||||
item.setTeamId(team.getTeamId());
|
||||
item.setTeamName(team.getTeamName());
|
||||
teams.add(item);
|
||||
}
|
||||
);
|
||||
|
||||
return teams.stream().collect(Collectors.toMap(FlowTeamConfVO.TeamItem::getTeamId, team -> team));
|
||||
}
|
||||
|
||||
public List<UserWithFlowTeamInfoVO> listUsersByErbanNo(String erbanNosStr) {
|
||||
List<String> erbanNoList = Arrays.asList(erbanNosStr.split(","));
|
||||
|
||||
List<UserWithFlowTeamInfoVO> userWithFlowTeamInfoVOS = flowTeamStatisticMapper.listUsers(erbanNoList);
|
||||
Map<Long, FlowTeamMember> membermap = new HashMap<>();
|
||||
Map<Long, FlowTeamGroup> groupMap = new HashMap<>();
|
||||
|
||||
for (UserWithFlowTeamInfoVO user : userWithFlowTeamInfoVOS) {
|
||||
Long memberId = user.getMemberId();
|
||||
user.setIsInCanRefillInviteCodeTime(isInCanRefillInviteCodeTime(user));
|
||||
if (memberId != null) {
|
||||
FlowTeamMember flowTeamMember = membermap.get(memberId);
|
||||
if (flowTeamMember == null) {
|
||||
flowTeamMember = flowTeamMemberMapper.selectById(memberId);
|
||||
if (flowTeamMember != null) {
|
||||
membermap.put(memberId, flowTeamMember);
|
||||
}
|
||||
}
|
||||
|
||||
if (flowTeamMember != null) {
|
||||
user.setTeamMemberName(flowTeamMember.getMemberName());
|
||||
user.setTeamId(flowTeamMember.getTeamId());
|
||||
}
|
||||
FlowTeamGroup group = groupMap.get(memberId);
|
||||
if (null == group) {
|
||||
group = flowTeamGroupService.getByTeamId(flowTeamMember.getTeamId());
|
||||
if (group != null) {
|
||||
groupMap.put(memberId, group);
|
||||
}
|
||||
}
|
||||
user.setGroupName(group.getGroupName());
|
||||
}
|
||||
}
|
||||
return userWithFlowTeamInfoVOS;
|
||||
}
|
||||
|
||||
private boolean isInCanRefillInviteCodeTime(Users user) {
|
||||
FlowTeamConfVO flowTeamConfVO = getConfig();
|
||||
if (user.getCreateTime().getTime() < System.currentTimeMillis() - flowTeamConfVO.getCanRefillInterval() * 60 * 1000L) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private long checkInviteCodeForRefill(String inviteCode) {
|
||||
Long uid = inviteCodeService.getUidByInviteCode(inviteCode);
|
||||
if (uid == null) {
|
||||
throw new ServiceException(BusiStatus.PARAMERROR, "邀请码无效,请重新填写");
|
||||
}
|
||||
Users usersByUid = usersService.getUsersByUid(uid);
|
||||
if (usersByUid == null) {
|
||||
throw new ServiceException(BusiStatus.PARAMERROR, "邀请码无效,请重新填写");
|
||||
}
|
||||
|
||||
return uid;
|
||||
}
|
||||
|
||||
public void refillUserInviteCode(Users user) {
|
||||
if (user.getUid() == null) {
|
||||
throw new ServiceException(BusiStatus.PARAMERROR, "传入的Uid不能为空");
|
||||
}
|
||||
if (StringUtils.isBlank(user.getInviteCode())) {
|
||||
throw new ServiceException(BusiStatus.PARAMERROR, "请填写邀请码");
|
||||
}
|
||||
long inviteUid = checkInviteCodeForRefill(user.getInviteCode());
|
||||
Users usersByUid = usersService.getUsersByUid(user.getUid());
|
||||
if (usersByUid == null) {
|
||||
throw new ServiceException(BusiStatus.USERNOTEXISTS);
|
||||
}
|
||||
if (!isInCanRefillInviteCodeTime(usersByUid)) {
|
||||
throw new ServiceException(BusiStatus.TIME_OUT_TO_REFILL_INVITE_CODE);
|
||||
}
|
||||
Users userForUpdate = new Users();
|
||||
userForUpdate.setUid(user.getUid());
|
||||
userForUpdate.setInviteCode(user.getInviteCode());
|
||||
userForUpdate.setInviteUid(inviteUid);
|
||||
usersBaseService.updateUser(userForUpdate);
|
||||
// 绑定用户与引流团队成员的邀请关系
|
||||
flowTeamMemberInviteUserBizService.saveFlowTeamMemberInviteUser(user.getInviteCode(), user.getUid(), FlowTeamConstant.UserSourceType.REPAIR);
|
||||
|
||||
applicationContext.publishEvent(new RefillUserInviteCodeEvent(userForUpdate));
|
||||
}
|
||||
|
||||
/**
|
||||
* 组长添加组内成员
|
||||
*
|
||||
* @param params
|
||||
*/
|
||||
public void addTeamMemberByLeader(TeamMemberEditParams params) {
|
||||
if (FlowTeamConstant.TeamRole.GROUP_LEADER.equals(params.getTeamRole())) {
|
||||
throw new AdminServiceException(BusiStatus.PARAMERROR, "当前无权限进行此操作");
|
||||
}
|
||||
checkAddMember(params);
|
||||
List<String> inviteCodeList = new ArrayList<>();
|
||||
if (StringUtils.isNotBlank(params.getInviteCodes())) {
|
||||
inviteCodeList = getInviteCodeList(params.getInviteCodes());
|
||||
checkOperateInviteCodeByLeader(inviteCodeList);
|
||||
}
|
||||
addTeamMemberBase(params, inviteCodeList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验组长操作的邀请码
|
||||
* <p>组长只能操作自己在小组后台生成的邀请码</p>
|
||||
*
|
||||
* @param inviteCodeList
|
||||
*/
|
||||
private void checkOperateInviteCodeByLeader(List<String> inviteCodeList) {
|
||||
List<UserInviteCode> userInviteCodes = inviteCodeService.listByInviteCode(inviteCodeList);
|
||||
|
||||
List<UserInviteCode> notFlowTeamGenInviteCodes = userInviteCodes.stream()
|
||||
.filter(i -> !Constant.InviteCodeGenScene.flow_team.equals(i.getGenScene())).collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(notFlowTeamGenInviteCodes)) {
|
||||
List<String> codes = new ArrayList<>();
|
||||
notFlowTeamGenInviteCodes.forEach(code -> {
|
||||
codes.add(code.getInviteCode());
|
||||
});
|
||||
String msg = "以下邀请码无权操作:" + StringUtils.join(codes, ",") + "。";
|
||||
throw new AdminServiceException(BusiStatus.PARAMERROR, msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 组长编辑组内成员
|
||||
*
|
||||
* @param params
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class, transactionManager = "mybatisplusTransactionManager")
|
||||
public void editTeamMemberByLeader(TeamMemberEditParams params) {
|
||||
if (FlowTeamConstant.TeamRole.GROUP_LEADER.equals(params.getTeamRole())) {
|
||||
throw new AdminServiceException(BusiStatus.PARAMERROR, "当前无权限进行此操作");
|
||||
}
|
||||
editTeamMemberBase(params, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取小组下的邀请码自动进房列表
|
||||
*
|
||||
* @param teamId 小组id
|
||||
* @return
|
||||
*/
|
||||
public Pagination listTeamRoomInviteCode(String teamId, String erbanNo, String roomInviteCode, Integer page, Integer pageSize) {
|
||||
if (StringUtils.isBlank(teamId)) {
|
||||
throw new AdminServiceException(BusiStatus.PARAMERROR);
|
||||
}
|
||||
List<String> teamIds = Arrays.asList(teamId.split(","));
|
||||
// 小组生成的邀请码
|
||||
List<FlowTeamInviteCodeRecord> inviteCodes = flowTeamInviteCodeRecordService.listTeamGenInviteCode(teamIds);
|
||||
List<String> queryErbanNos = StringUtils.isNotBlank(erbanNo) ? convertStringToList(erbanNo) : null;
|
||||
List<Long> queryUidList = new ArrayList<>();
|
||||
if (!CollectionUtils.isEmpty(queryErbanNos)) {
|
||||
for (String erbanNoStr : queryErbanNos) {
|
||||
Users users = usersService.getUserByErbanNo(Long.valueOf(erbanNoStr));
|
||||
if (users != null) {
|
||||
queryUidList.add(users.getUid());
|
||||
}
|
||||
}
|
||||
}
|
||||
List<String> inviteCodeList = inviteCodes.stream().map(FlowTeamInviteCodeRecord::getInviteCode).collect(Collectors.toList());
|
||||
List<String> queryInviteCodes = StringUtils.isNotBlank(roomInviteCode) ? convertStringToList(roomInviteCode) : inviteCodeList;
|
||||
PageHelper.startPage(page, pageSize);
|
||||
List<RoomInviteCodeVo> roomInviteCodeList = roomInviteCodeAdminMapper.getRoomInviteCodeList(queryUidList, queryInviteCodes);
|
||||
// 过滤掉不属于本组邀请码的数据
|
||||
roomInviteCodeList = roomInviteCodeList.stream().filter(i -> inviteCodeList.contains(i.getRoomInviteCode())).collect(Collectors.toList());
|
||||
PageInfo pageInfo = new PageInfo<>(roomInviteCodeList);
|
||||
return new Pagination(pageInfo);
|
||||
}
|
||||
|
||||
private List<String> convertStringToList(String str) {
|
||||
String[] codeArr = str.trim().replaceAll(",", ",").split(",");
|
||||
return Arrays.asList(codeArr);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class, transactionManager = "mybatisplusTransactionManager")
|
||||
public void saveOrUpdateTeamRoomInviteCode(String teamId, Long id, Long erbanNo, String roomInviteCode) {
|
||||
if (StringUtils.isBlank(teamId)) {
|
||||
throw new AdminServiceException(BusiStatus.PARAMERROR, "请选择小组后再进行操作");
|
||||
}
|
||||
checkTeamRoomInviteCode(teamId, roomInviteCode);
|
||||
RoomInviteCode roomInviteCodeForUpdate = new RoomInviteCode();
|
||||
if (id != null) {
|
||||
roomInviteCodeForUpdate.setId(id);
|
||||
}
|
||||
if (erbanNo != null) {
|
||||
Users user = usersService.getUserByErbanNo(erbanNo);
|
||||
if (user == null) {
|
||||
throw new AdminServiceException(BusiStatus.USERNOTEXISTS);
|
||||
}
|
||||
Room room = roomService.getRoomByUid(user.getUid());
|
||||
if (room == null) {
|
||||
throw new AdminServiceException(BusiStatus.ROOMNOTEXIST);
|
||||
}
|
||||
roomInviteCodeForUpdate.setRoomUid(user.getUid());
|
||||
}
|
||||
roomInviteCodeForUpdate.setRoomInviteCode(roomInviteCode);
|
||||
roomInviteCodeForUpdate.setUpdateTime(new Date());
|
||||
roomInviteCodeService.saveOrUpdate(roomInviteCodeForUpdate);
|
||||
}
|
||||
|
||||
private void checkTeamRoomInviteCode(String teamId, String roomInviteCode) {
|
||||
// 校验邀请码是否已经被绑定
|
||||
List<String> invitecodes = Arrays.asList(roomInviteCode);
|
||||
List<RoomInviteCode> records = roomInviteCodeService.listByInviteCodes(invitecodes);
|
||||
if (!CollectionUtils.isEmpty(records)) {
|
||||
throw new AdminServiceException(BusiStatus.BUSIERROR, "邀请码已绑定其他房间");
|
||||
}
|
||||
UserInviteCode specialCode = userInviteCodeService.getByCode(roomInviteCode);
|
||||
if (specialCode != null) {
|
||||
return;
|
||||
}
|
||||
// 校验邀请码是不是自己小组的
|
||||
FlowTeamInviteCodeRecord record = flowTeamInviteCodeRecordService.getByTeamIdAndCode(teamId, roomInviteCode);
|
||||
if (record == null) {
|
||||
throw new AdminServiceException(BusiStatus.BUSIERROR, "邀请码无权操作");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public RoomInviteCodeVo getRoomInviteCode(Integer id) {
|
||||
if (id == null) {
|
||||
throw new AdminServiceException(BusiStatus.PARAMERROR);
|
||||
}
|
||||
RoomInviteCode roomInviteCode = roomInviteCodeService.getById(id);
|
||||
Users users = usersService.getUsersByUid(roomInviteCode.getRoomUid());
|
||||
RoomInviteCodeVo vo = new RoomInviteCodeVo();
|
||||
vo.setId(roomInviteCode.getId());
|
||||
vo.setRoomInviteCode(roomInviteCode.getRoomInviteCode());
|
||||
vo.setErbanNo(users.getErbanNo());
|
||||
return vo;
|
||||
}
|
||||
|
||||
public void delteRoomInviteCodeRecord(Long id) {
|
||||
if (id == null) {
|
||||
throw new AdminServiceException(BusiStatus.PARAMERROR);
|
||||
}
|
||||
roomInviteCodeService.removeById(id);
|
||||
}
|
||||
|
||||
public Pagination listFlowTeamGenInviteCodeByPage(Integer page, Integer pageSize, String inviteCode, String teamId) {
|
||||
if (StringUtils.isBlank(teamId)) {
|
||||
throw new AdminServiceException(BusiStatus.PARAMERROR);
|
||||
}
|
||||
List<String> teamIdList = Arrays.asList(teamId.split(","));
|
||||
QueryWrapper<FlowTeamInviteCodeRecord> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().in(FlowTeamInviteCodeRecord::getTeamId, teamIdList)
|
||||
.eq(FlowTeamInviteCodeRecord::getStatus, Constant.status.valid)
|
||||
.orderByDesc(FlowTeamInviteCodeRecord::getCreateTime);
|
||||
if (StringUtils.isNotBlank(inviteCode)) {
|
||||
queryWrapper.lambda().eq(FlowTeamInviteCodeRecord::getInviteCode, inviteCode);
|
||||
}
|
||||
PageHelper.startPage(page, pageSize);
|
||||
List<FlowTeamInviteCodeRecord> records = flowTeamInviteCodeRecordService.list(queryWrapper);
|
||||
List<FlowTeamInviteCodeRecordAdminVO> adminRecords = new ArrayList<>();
|
||||
records.forEach(
|
||||
record -> {
|
||||
FlowTeamInviteCodeRecordAdminVO vo = new FlowTeamInviteCodeRecordAdminVO();
|
||||
BeanUtils.copyProperties(record, vo);
|
||||
FlowTeamInfo team = flowTeamInfoService.getById(vo.getTeamId());
|
||||
vo.setTeamName(team != null ? team.getTeamName() : null);
|
||||
FlowTeamMemberInviteCode code = flowTeamMemberInviteCodeMapper.getByInviteCode(vo.getInviteCode());
|
||||
vo.setHasBind(code != null);
|
||||
adminRecords.add(vo);
|
||||
}
|
||||
);
|
||||
PageInfo<FlowTeamInviteCodeRecordAdminVO> pageInfo = new PageInfo<>(adminRecords);
|
||||
Pagination pagination = new Pagination(pageInfo);
|
||||
return pagination;
|
||||
}
|
||||
|
||||
/**
|
||||
* 组长生成邀请码
|
||||
*
|
||||
* @param teamId
|
||||
* @param genCount
|
||||
* @param creator
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class, transactionManager = "mybatisplusTransactionManager")
|
||||
public Integer genInviteCount(String teamId, String creator, Integer genCount) {
|
||||
if (StringUtils.isBlank(teamId) || null == genCount) {
|
||||
throw new AdminServiceException(BusiStatus.PARAMERROR);
|
||||
}
|
||||
if (genCount > GEN_INVITECODE_MAX_COUNT) {
|
||||
throw new AdminServiceException(BusiStatus.PARAMERROR, "一次性生成的邀请码不可超过" + GEN_INVITECODE_MAX_COUNT + "个");
|
||||
}
|
||||
// 生成邀请码
|
||||
List<String> codeList = InviteCodeUtil.genInviteCode(genCount);
|
||||
codeList = checkGenInviteCode(codeList);
|
||||
// 插入用户邀请码表
|
||||
List<UserInviteCode> userInviteCodeList = new ArrayList<>();
|
||||
codeList.forEach(code -> {
|
||||
UserInviteCode record = new UserInviteCode();
|
||||
record.setUid(Long.parseLong(SystemConfig.flowTeamGenInviteCodeUid));
|
||||
record.setInviteCode(code);
|
||||
record.setStatus(Constant.status.valid);
|
||||
record.setCreator(creator);
|
||||
record.setIsPrimary(false);
|
||||
record.setInviteCodeType(Constant.InviteCodeType.SPECIAL.getType());
|
||||
record.setGenScene(Constant.InviteCodeGenScene.flow_team);
|
||||
record.setCreator(creator);
|
||||
record.setCreateTime(new Date());
|
||||
record.setUpdateTime(new Date());
|
||||
userInviteCodeList.add(record);
|
||||
});
|
||||
userInviteCodeService.saveBatch(userInviteCodeList);
|
||||
// 邀请码生成记录
|
||||
List<FlowTeamInviteCodeRecord> records = new ArrayList<>();
|
||||
codeList.forEach(code -> {
|
||||
FlowTeamInviteCodeRecord record = FlowTeamInviteCodeRecord.builder()
|
||||
.teamId(teamId)
|
||||
.inviteCode(code).status(Constant.status.valid).creator(creator)
|
||||
.createTime(new Date()).updateTime(new Date())
|
||||
.build();
|
||||
records.add(record);
|
||||
});
|
||||
flowTeamInviteCodeRecordService.saveBatch(records);
|
||||
return codeList.size();
|
||||
}
|
||||
|
||||
private List<String> checkGenInviteCode(List<String> codeList) {
|
||||
List<String> validCodeList = new ArrayList<>();
|
||||
codeList.forEach(code -> {
|
||||
// 检查邀请码是否已经被使用
|
||||
QueryWrapper<UserInviteCode> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(UserInviteCode::getInviteCode, code);
|
||||
UserInviteCode result = userInviteCodeService.getOne(queryWrapper);
|
||||
if (result == null) {
|
||||
validCodeList.add(code);
|
||||
}
|
||||
});
|
||||
return validCodeList;
|
||||
}
|
||||
|
||||
public List<FlowTeamInfo> listTeamByGroupId(Long groupId) {
|
||||
QueryWrapper<FlowTeamInfo> query = new QueryWrapper<>();
|
||||
query.lambda().eq(FlowTeamInfo::getGroupId, groupId).eq(FlowTeamInfo::getStatus, FlowTeamConstant.MemberStatus.MEMBER_STATUS_VALID);
|
||||
return flowTeamInfoService.list(query);
|
||||
}
|
||||
|
||||
public List<FlowTeamInfo> listTeam() {
|
||||
QueryWrapper<FlowTeamInfo> query = new QueryWrapper<>();
|
||||
query.lambda().eq(FlowTeamInfo::getStatus, FlowTeamConstant.MemberStatus.MEMBER_STATUS_VALID);
|
||||
return flowTeamInfoService.list(query);
|
||||
}
|
||||
|
||||
public List<FlowTeamMember> listTeamMember(String teamId) {
|
||||
QueryWrapper<FlowTeamMember> query = new QueryWrapper<>();
|
||||
query.lambda().in(FlowTeamMember::getMemberStatus, FlowTeamConstant.MemberStatus.MEMBER_STATUS_VALID,
|
||||
FlowTeamConstant.MemberStatus.MEMBER_STATUS_INVALID)
|
||||
.eq(FlowTeamMember::getTeamId, teamId);
|
||||
return flowTeamMemberService.list(query);
|
||||
}
|
||||
|
||||
public List<FlowTeamMemberInviteCode> listMemberInviteCode(Long memberId) {
|
||||
QueryWrapper<FlowTeamMemberInviteCode> query = new QueryWrapper<>();
|
||||
query.lambda().eq(FlowTeamMemberInviteCode::getMemberId, memberId);
|
||||
return flowTeamMemberInviteCodeMapper.selectList(query);
|
||||
}
|
||||
}
|
@@ -7,13 +7,11 @@ import com.accompany.admin.dto.UserDetailQueryDto;
|
||||
import com.accompany.admin.mapper.ChargeRecordAdminMapper;
|
||||
import com.accompany.admin.mapper.UserMapperExpand;
|
||||
import com.accompany.admin.service.base.BaseService;
|
||||
import com.accompany.admin.service.room.RoomVisitorService;
|
||||
import com.accompany.admin.vo.stats.UserDetailVo;
|
||||
import com.accompany.business.model.UserInRoomRecord;
|
||||
import com.accompany.business.model.room.RoomVisitor;
|
||||
import com.accompany.business.model.room.RoomVisitorUserDict;
|
||||
import com.accompany.business.mybatismapper.UserInRoomRecordMapper;
|
||||
import com.accompany.business.mybatismapper.flow.FlowTeamMemberBaseMapper;
|
||||
import com.accompany.business.mybatismapper.room.RoomVisitorMapper;
|
||||
import com.accompany.business.mybatismapper.room.RoomVisitorUserDictMapper;
|
||||
import com.accompany.business.service.user.UserLoginService;
|
||||
@@ -26,18 +24,10 @@ import com.accompany.core.exception.AdminServiceException;
|
||||
import com.accompany.core.model.AccountLoginRecord;
|
||||
import com.accompany.core.mybatismapper.AccountLoginRecordMapperExpand;
|
||||
import com.accompany.core.mybatismapper.UsersMapper;
|
||||
import com.accompany.core.service.SysConfService;
|
||||
import com.accompany.payment.model.ChargeRecord;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.xuanyin.flowteam.constant.FlowTeamConstant;
|
||||
import com.xuanyin.flowteam.mapper.FlowTeamGroupMapper;
|
||||
import com.xuanyin.flowteam.mapper.FlowTeamInfoMapper;
|
||||
import com.xuanyin.flowteam.mapper.FlowTeamMemberInviteUserMapper;
|
||||
import com.xuanyin.flowteam.model.FlowTeamGroup;
|
||||
import com.xuanyin.flowteam.model.FlowTeamInfo;
|
||||
import com.xuanyin.flowteam.model.FlowTeamMemberInviteUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@@ -60,15 +50,6 @@ public class StatsUserDetailAdminService extends BaseService {
|
||||
@Autowired
|
||||
private UserInRoomRecordMapper userInRoomRecordMapper;
|
||||
|
||||
@Autowired
|
||||
private FlowTeamInfoMapper flowTeamInfoMapper;
|
||||
|
||||
@Autowired
|
||||
private FlowTeamMemberInviteUserMapper flowTeamMemberInviteUserMapper;
|
||||
|
||||
@Autowired
|
||||
private FlowTeamGroupMapper flowTeamGroupMapper;
|
||||
|
||||
@Autowired
|
||||
private RoomVisitorUserDictMapper roomVisitorUserDictMapper;
|
||||
|
||||
@@ -192,7 +173,6 @@ public class StatsUserDetailAdminService extends BaseService {
|
||||
}
|
||||
record.setLoginTypeStr(loginTypeStr);
|
||||
record.setNewDevice(isNewDevice(uid, record.getDeviceId()));
|
||||
setInviteCodeInfo(record);
|
||||
}
|
||||
}
|
||||
return pageInfo;
|
||||
@@ -280,28 +260,4 @@ public class StatsUserDetailAdminService extends BaseService {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setInviteCodeInfo(UserDetailVo userDetailVo) {
|
||||
if (BlankUtil.isBlank(userDetailVo.getInviteCode())) return;
|
||||
QueryWrapper<FlowTeamMemberInviteUser> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(FlowTeamMemberInviteUser::getUid, userDetailVo.getUid());
|
||||
FlowTeamMemberInviteUser inviteUser = flowTeamMemberInviteUserMapper.selectOne(queryWrapper);
|
||||
if (ObjectUtil.isNull(inviteUser)) return;
|
||||
QueryWrapper<FlowTeamInfo> teamInfoQueryWrapper = new QueryWrapper<>();
|
||||
teamInfoQueryWrapper.lambda().eq(FlowTeamInfo::getTeamId, inviteUser.getTeamId());
|
||||
FlowTeamInfo flowTeamInfo = flowTeamInfoMapper.selectOne(teamInfoQueryWrapper);
|
||||
if (ObjectUtil.isNull(flowTeamInfo)) return;
|
||||
FlowTeamGroup group = flowTeamGroupMapper.selectById(flowTeamInfo.getGroupId());
|
||||
if (FlowTeamConstant.MemberStatus.MEMBER_STATUS_VALID.equals(flowTeamInfo.getStatus())) {
|
||||
userDetailVo.setInviteCodeinfo(userDetailVo.getInviteCode()
|
||||
+ (ObjectUtil.isNull(flowTeamInfo.getTeamName()) ? "" : StrUtil.DASHED + flowTeamInfo.getTeamName())
|
||||
+ (ObjectUtil.isNull(group.getGroupName()) ? "" : StrUtil.DASHED + group.getGroupName())
|
||||
);
|
||||
userDetailVo.setFlowChannel("流量团队新增");
|
||||
} else {
|
||||
userDetailVo.setInviteCodeinfo(userDetailVo.getInviteCode() + (ObjectUtil.isNull(flowTeamInfo.getTeamName()) ? "" : StrUtil.DASHED + flowTeamInfo.getTeamName()));
|
||||
userDetailVo.setInviteCodeinfo(userDetailVo.getInviteCodeinfo() + "(小组已删除)");
|
||||
userDetailVo.setFlowChannel("流量团队新增");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,51 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.accompany.admin.mapper.flowteam.FlowTeamGroupAdminMapper">
|
||||
<select id="listGroupLeader" resultType="com.xuanyin.flowteam.model.FlowTeamMember">
|
||||
select fm.* from flow_team_info ft, flow_team_member fm
|
||||
where ft.group_id = #{groupId} and ft.status = 1
|
||||
and ft.team_id = fm.team_id and fm.member_status != -1
|
||||
and fm.team_role = 3;
|
||||
</select>
|
||||
|
||||
<select id="countGroupValidMember" resultType="java.lang.Integer">
|
||||
select count(fm.member_id) from flow_team_info ft, flow_team_member fm
|
||||
where ft.group_id = #{groupId} and ft.status = 1
|
||||
and ft.team_id = fm.team_id and fm.member_status = 1;
|
||||
</select>
|
||||
|
||||
<select id="getJoinGroupIdByPhone" resultType="java.lang.Long">
|
||||
select i.group_id from flow_team_member m, flow_team_info i
|
||||
where m.team_id = i.team_id and m.member_status != -1
|
||||
and i.status != -1
|
||||
and m.member_phone = #{phone}
|
||||
group by i.group_id
|
||||
</select>
|
||||
|
||||
<select id="listFlowTeamInfoWithUser" resultType="com.accompany.admin.vo.flowteam.FlowTeamInviteUserVO">
|
||||
select
|
||||
u.uid,
|
||||
u.erban_no,
|
||||
u.nick,
|
||||
g.group_name,
|
||||
t.team_name,
|
||||
m.member_name,
|
||||
f.invite_code,
|
||||
f.create_time inviteTime,
|
||||
f.source
|
||||
from
|
||||
flow_team_member_invite_user f,
|
||||
users u,
|
||||
flow_team_group g,
|
||||
flow_team_info t,
|
||||
flow_team_member m
|
||||
where f.uid = u.uid
|
||||
and f.group_id = g.group_id
|
||||
and f.team_id = t.team_id
|
||||
and f.member_id = m.member_id
|
||||
and g.status = 1
|
||||
and t.status = 1
|
||||
and m.member_status in (1, 0)
|
||||
and u.erban_no = #{erbanNo}
|
||||
</select>
|
||||
</mapper>
|
@@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.accompany.admin.mapper.flowteam.FlowTeamMemberInviteUserAdminMapper">
|
||||
<select id="listFlowTeamMemberInviteUserInfo" resultType="com.xuanyin.flowteam.model.FlowTeamMemberInviteUser">
|
||||
select u.invite_code inviteCode, uid, fi.member_id memberId, fm.team_id teamId, u.create_time createTime, current_timestamp updateTime
|
||||
from users u, flow_team_member_invite_code fi, flow_team_member fm
|
||||
where u.invite_code is not null and def_user = 1
|
||||
and u.invite_code = fi.invite_code and fi.member_id = fm.member_id
|
||||
and fm.member_status = 1;
|
||||
</select>
|
||||
</mapper>
|
@@ -1,720 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.accompany.admin.mapper.flowteam.FlowTeamStatisticMapper">
|
||||
|
||||
|
||||
<select id="staisticUseInviteCodes"
|
||||
resultType="com.accompany.admin.vo.flowteam.FlowTeamStatisticSummaryVO">
|
||||
select sum(total_user) newUserCount, sum(charge_user) newChargeUserCount,
|
||||
sum(charge_count) chargeCount, sum(total_charge) chargeMoney,
|
||||
sum(total_send_gift) sendGiftMony from (
|
||||
select count(distinct u.uid) total_user,
|
||||
count(distinct cr.uid) charge_user,
|
||||
sum(case when cr.uid is not null then 1 else 0 end) charge_count,
|
||||
sum(case when cr.amount is not null then cr.amount else 0 end) / 100 total_charge,
|
||||
0 total_send_gift
|
||||
from account a, users u
|
||||
left join charge_record cr
|
||||
on cr.uid = u.uid and cr.charge_status in (2,6) and cr.charge_prod_id <> 'exchange'
|
||||
<if test="params.groupApps != null and params.groupApps.size > 0">
|
||||
and cr.charge_app in
|
||||
<foreach collection="params.groupApps" item="signUpApp" open="(" separator="," close=")">
|
||||
#{signUpApp}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="params.chargeStartTime != null and params.chargeStartTime != ''">
|
||||
and cr.create_time >= #{params.chargeStartTime}
|
||||
</if>
|
||||
<if test="params.chargeEndTime != null and params.chargeEndTime != ''">
|
||||
and cr.create_time < #{params.chargeEndTime}
|
||||
</if>
|
||||
where u.invite_code in
|
||||
<foreach item="inviteCode" collection="inviteCodes" open="(" separator="," close=")">
|
||||
#{inviteCode}
|
||||
</foreach>
|
||||
and a.uid = u.uid
|
||||
<if test="params.groupApps != null and params.groupApps.size > 0">
|
||||
and a.signup_app in
|
||||
<foreach collection="params.groupApps" item="signUpApp" open="(" separator="," close=")">
|
||||
#{signUpApp}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="params.startDate != null and params.startDate != ''">
|
||||
and u.create_time >= #{params.startDate}
|
||||
</if>
|
||||
<if test="params.endDate != null and params.endDate != ''">
|
||||
and u.create_time < #{params.endDate}
|
||||
</if>
|
||||
union
|
||||
select 0 total_user,
|
||||
0 charge_user,
|
||||
0 charge_count,
|
||||
0 total_charge,
|
||||
sum(case when gsr.total_gold_num is not null then gsr.total_gold_num else 0 end) total_send_gift
|
||||
from account a, users u
|
||||
left join gift_send_record gsr on u.uid = gsr.uid
|
||||
where u.invite_code in
|
||||
<foreach item="inviteCode" collection="inviteCodes" open="(" separator="," close=")">
|
||||
#{inviteCode}
|
||||
</foreach>
|
||||
and a.uid = u.uid
|
||||
<if test="params.groupApps != null and params.groupApps.size > 0">
|
||||
and a.signup_app in
|
||||
<foreach collection="params.groupApps" item="signUpApp" open="(" separator="," close=")">
|
||||
#{signUpApp}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="params.startDate != null and params.startDate != ''">
|
||||
and u.create_time >= #{params.startDate}
|
||||
</if>
|
||||
<if test="params.endDate != null and params.endDate != ''">
|
||||
and u.create_time < #{params.endDate}
|
||||
</if>
|
||||
) t;
|
||||
</select>
|
||||
|
||||
<select id="listTeamStatisticDetail"
|
||||
resultType="com.accompany.admin.vo.flowteam.FlowTeamStatisticDetailVO">
|
||||
select t.team_id,
|
||||
t.member_id,
|
||||
t.member_name,
|
||||
t.member_status,
|
||||
t.team_role,
|
||||
sum(total_user) newUserCount, sum(charge_user) newChargeUserCount,
|
||||
sum(charge_count) chargeCount, sum(total_charge) chargeMoney,
|
||||
sum(total_send_gift) sendGiftMony from (
|
||||
select tm.team_id,
|
||||
tm.member_id,
|
||||
tm.member_name,
|
||||
tm.member_status,
|
||||
tm.team_role,
|
||||
count(distinct a.uid) total_user,
|
||||
0 charge_user,
|
||||
0 charge_count,
|
||||
0 total_charge,
|
||||
0 total_send_gift
|
||||
from flow_team_member tm,
|
||||
flow_team_member_invite_code ic,
|
||||
user_invite_code uic
|
||||
left join users u on uic.uid = u.invite_uid and u.invite_code = uic.invite_code
|
||||
left join account a on a.uid = u.uid
|
||||
<if test="groupApps != null and groupApps.size > 0">
|
||||
and a.signup_app in
|
||||
<foreach collection="groupApps" item="signUpApp" open="(" separator="," close=")">
|
||||
#{signUpApp}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="startDate != null and startDate != ''">
|
||||
and u.create_time >= #{startDate}
|
||||
</if>
|
||||
<if test="endDate != null and endDate != ''">
|
||||
and u.create_time < #{endDate}
|
||||
</if>
|
||||
where tm.member_id = ic.member_id
|
||||
and tm.member_status in (0, 1)
|
||||
and tm.team_id = #{teamId}
|
||||
and uic.invite_code = ic.invite_code
|
||||
and uic.status = 1
|
||||
group by tm.team_id, tm.member_id, tm.member_name, tm.member_status, tm.team_role
|
||||
union
|
||||
select tm.team_id,
|
||||
tm.member_id,
|
||||
tm.member_name,
|
||||
tm.member_status,
|
||||
tm.team_role,
|
||||
0 total_user,
|
||||
count(distinct cr.uid) charge_user,
|
||||
sum(case when cr.uid is not null then 1 else 0 end) charge_count,
|
||||
sum(case when cr.amount is not null then cr.amount else 0 end) / 100 total_charge,
|
||||
0 total_send_gift
|
||||
from flow_team_member tm,
|
||||
flow_team_member_invite_code ic,
|
||||
user_invite_code uic,
|
||||
account a, users u
|
||||
left join charge_record cr
|
||||
on cr.uid = u.uid and cr.charge_status in (2,6) and cr.charge_prod_id <> 'exchange'
|
||||
<if test="groupApps != null and groupApps.size > 0">
|
||||
and cr.charge_app in
|
||||
<foreach collection="groupApps" item="signUpApp" open="(" separator="," close=")">
|
||||
#{signUpApp}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="chargeStartTime != null and chargeStartTime != ''">
|
||||
and cr.create_time >= #{chargeStartTime}
|
||||
</if>
|
||||
<if test="chargeEndTime != null and chargeEndTime != ''">
|
||||
and cr.create_time < #{chargeEndTime}
|
||||
</if>
|
||||
where tm.member_id = ic.member_id
|
||||
and tm.member_status in (0, 1)
|
||||
and uic.invite_code = ic.invite_code
|
||||
and uic.status = 1
|
||||
and u.invite_uid = uic.uid
|
||||
and u.invite_code = uic.invite_code
|
||||
and a.uid = u.uid
|
||||
<if test="groupApps != null and groupApps.size > 0">
|
||||
and a.signup_app in
|
||||
<foreach collection="groupApps" item="signUpApp" open="(" separator="," close=")">
|
||||
#{signUpApp}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="startDate != null and startDate != ''">
|
||||
and u.create_time >= #{startDate}
|
||||
</if>
|
||||
<if test="endDate != null and endDate != ''">
|
||||
and u.create_time < #{endDate}
|
||||
</if>
|
||||
and tm.team_id = #{teamId}
|
||||
group by tm.team_id, tm.member_id,tm.member_name, tm.member_status, tm.team_role
|
||||
union
|
||||
select tm.team_id,
|
||||
tm.member_id,
|
||||
tm.member_name,
|
||||
tm.member_status,
|
||||
tm.team_role,
|
||||
0 total_user,
|
||||
0 charge_user,
|
||||
0 charge_count,
|
||||
0 total_charge,
|
||||
sum(case when gsr.total_gold_num is not null then gsr.total_gold_num else 0 end) total_send_gift
|
||||
from flow_team_member tm,
|
||||
flow_team_member_invite_code ic,
|
||||
user_invite_code uic,
|
||||
account a, users u
|
||||
left join gift_send_record gsr on u.uid = gsr.uid
|
||||
where tm.member_id = ic.member_id
|
||||
and tm.member_status in (0, 1)
|
||||
and uic.invite_code = ic.invite_code
|
||||
and uic.status = 1
|
||||
and u.invite_uid = uic.uid
|
||||
and u.invite_code = uic.invite_code
|
||||
and a.uid = u.uid
|
||||
<if test="groupApps != null and groupApps.size > 0">
|
||||
and a.signup_app in
|
||||
<foreach collection="groupApps" item="signUpApp" open="(" separator="," close=")">
|
||||
#{signUpApp}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="startDate != null and startDate != ''">
|
||||
and u.create_time >= #{startDate}
|
||||
</if>
|
||||
<if test="endDate != null and endDate != ''">
|
||||
and u.create_time < #{endDate}
|
||||
</if>
|
||||
and tm.team_id = #{teamId}
|
||||
group by tm.team_id, tm.member_id,tm.member_name, tm.member_status, tm.team_role
|
||||
) t
|
||||
group by t.team_id, t.member_id,t.member_name, t.member_status, t.team_role;
|
||||
</select>
|
||||
<select id="listUserStatisticDetails"
|
||||
resultType="com.accompany.admin.vo.flowteam.FlowTeamStatisticUserDetailVO">
|
||||
select t.member_name teamMemberName, t.team_id teamId, t.invite_code inviteCode, t.erban_no userErbanNo , t.nick
|
||||
userNickName,t.create_time signUpTime,
|
||||
sum(t.charge_count) chargeCount,
|
||||
sum(t.total_charge) chargeMoney,
|
||||
sum(t.total_send_gift) totalSendGiftMoney,
|
||||
sum(t.total_no_backbag_send_gift) totalNoBackbagSendGiftMoney,
|
||||
sum(t.total_backbag_send_gift) totalBackbagSendGiftMoney,
|
||||
a.register_ip registerIp
|
||||
from (
|
||||
select tm.member_name , tm.team_id, u.invite_code,
|
||||
u.erban_no,
|
||||
u.nick,
|
||||
u.create_time,
|
||||
sum(case when cr.amount is not null then 1 else 0 end) charge_count,
|
||||
sum(case when cr.amount is not null then cr.amount else 0 end) / 100 total_charge,
|
||||
0 total_send_gift,
|
||||
0 total_no_backbag_send_gift,
|
||||
0 total_backbag_send_gift
|
||||
from flow_team_member tm,
|
||||
flow_team_member_invite_code ic,
|
||||
user_invite_code uic,
|
||||
account a, users u
|
||||
left join charge_record cr
|
||||
on cr.uid = u.uid and cr.charge_status in (2,6) and cr.charge_prod_id <> 'exchange'
|
||||
<if test="groupApps != null and groupApps.size > 0">
|
||||
and cr.charge_app in
|
||||
<foreach collection="groupApps" item="signUpApp" open="(" separator="," close=")">
|
||||
#{signUpApp}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="chargeStartTime != null and chargeStartTime != ''">
|
||||
and cr.create_time >= #{chargeStartTime}
|
||||
</if>
|
||||
<if test="chargeEndTime != null and chargeEndTime != ''">
|
||||
and cr.create_time < #{chargeEndTime}
|
||||
</if>
|
||||
where tm.member_id = ic.member_id
|
||||
and tm.member_status in (0, 1)
|
||||
and uic.invite_code = ic.invite_code
|
||||
and uic.status = 1
|
||||
and u.invite_uid = uic.uid
|
||||
and u.invite_code = uic.invite_code
|
||||
and a.uid = u.uid
|
||||
<if test="groupApps != null and groupApps.size > 0">
|
||||
and a.signup_app in
|
||||
<foreach collection="groupApps" item="signUpApp" open="(" separator="," close=")">
|
||||
#{signUpApp}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="teamId != null">
|
||||
and tm.team_id = #{teamId}
|
||||
</if>
|
||||
<if test="memberId != null">
|
||||
and tm.member_id = #{memberId}
|
||||
</if>
|
||||
<if test="startDate != null and startDate != ''">
|
||||
and u.create_time >= #{startDate}
|
||||
</if>
|
||||
<if test="endDate != null and endDate != ''">
|
||||
and u.create_time < #{endDate}
|
||||
</if>
|
||||
group by tm.member_name,tm.team_id,u.invite_code, u.uid, u.erban_no, u.nick, u.create_time
|
||||
union all
|
||||
select tm.member_name,tm.team_id,
|
||||
u.invite_code,
|
||||
u.erban_no,
|
||||
u.nick,
|
||||
u.create_time,
|
||||
0 charge_count,
|
||||
0 total_charge,
|
||||
sum(case when gsr.total_gold_num is not null then gsr.total_gold_num else 0 end) total_send_gift,
|
||||
sum(case when gsr.gift_source = 1 and gsr.total_gold_num is not null then gsr.total_gold_num else 0 end)
|
||||
total_no_backbag_send_gift,
|
||||
sum(case when gsr.gift_source = 2 and gsr.total_gold_num is not null then gsr.total_gold_num else 0 end)
|
||||
total_backbag_send_gift
|
||||
from flow_team_member tm,
|
||||
flow_team_member_invite_code ic,
|
||||
user_invite_code uic,
|
||||
account a, users u
|
||||
left join gift_send_record gsr on u.uid = gsr.uid
|
||||
where tm.member_id = ic.member_id
|
||||
and tm.member_status in (0, 1)
|
||||
and uic.invite_code = ic.invite_code
|
||||
and uic.status = 1
|
||||
and u.invite_uid = uic.uid
|
||||
and u.invite_code = uic.invite_code
|
||||
and a.uid = u.uid
|
||||
<if test="groupApps != null and groupApps.size > 0">
|
||||
and a.signup_app in
|
||||
<foreach collection="groupApps" item="signUpApp" open="(" separator="," close=")">
|
||||
#{signUpApp}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="teamId != null">
|
||||
and tm.team_id = #{teamId}
|
||||
</if>
|
||||
<if test="memberId != null">
|
||||
and tm.member_id = #{memberId}
|
||||
</if>
|
||||
<if test="startDate != null and startDate != ''">
|
||||
and u.create_time >= #{startDate}
|
||||
</if>
|
||||
<if test="endDate != null and endDate != ''">
|
||||
and u.create_time < #{endDate}
|
||||
</if>
|
||||
group by tm.member_name,tm.team_id,u.invite_code, u.uid, u.erban_no, u.nick, u.create_time
|
||||
) t LEFT JOIN account a ON t.erban_no = a.erban_no
|
||||
group by t.member_name, t.team_id,t.invite_code, t.erban_no , t.nick,t.create_time, a.register_ip
|
||||
order by t.create_time desc, t.invite_code
|
||||
;
|
||||
</select>
|
||||
<select id="listUsers" resultType="com.accompany.admin.vo.flowteam.UserWithFlowTeamInfoVO">
|
||||
select u.uid, u.erban_no erbanNo, u.nick, u.create_time createTime, u.invite_code, ic.member_id memberId from
|
||||
users u
|
||||
left join flow_team_member_invite_code ic on ic.invite_code = u.invite_code
|
||||
where u.erban_no in
|
||||
<foreach item="erbanNo" collection="erbanNoList" open="(" separator="," close=")">
|
||||
#{erbanNo}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="staisticUseInviteCodesV2" resultType="com.accompany.admin.vo.flowteam.FlowTeamStatisticSummaryVO">
|
||||
select
|
||||
sum(total_user) as newUserCount,
|
||||
sum(charge_user) as newChargeUserCount,
|
||||
sum(charge_count) as chargeCount,
|
||||
sum(total_charge) as chargeMoney,
|
||||
sum(total_send_gift) as sendGiftMony,
|
||||
sum(give_count) as giveCount,
|
||||
sum(total_give) as giveMoney
|
||||
from (
|
||||
select
|
||||
count(distinct u.uid) as total_user,
|
||||
count(distinct cr.uid) as charge_user,
|
||||
sum(case when cr.uid is not null then 1 else 0 end) as charge_count,
|
||||
(sum(case when cr.amount is not null then cr.amount else 0 end) / 100) as total_charge,
|
||||
0 as total_send_gift,
|
||||
0 as give_count,
|
||||
0 as total_give
|
||||
from flow_team_member_invite_user as ftmiu
|
||||
inner join users as u on ftmiu.uid = u.uid
|
||||
left join charge_record as cr
|
||||
on cr.uid = u.uid and cr.charge_status in (2,6)
|
||||
and cr.charge_prod_id <> 'exchange' and cr.buss_type in (0,4)
|
||||
and cr.create_time >= u.create_time
|
||||
<if test="params.groupApps != null and params.groupApps.size > 0">
|
||||
and cr.charge_app in
|
||||
<foreach collection="params.groupApps" item="signUpApp" open="(" separator="," close=")">
|
||||
#{signUpApp}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="params.chargeStartTime != null and params.chargeStartTime != ''">
|
||||
and cr.create_time >= #{params.chargeStartTime}
|
||||
</if>
|
||||
<if test="params.chargeEndTime != null and params.chargeEndTime != ''">
|
||||
and cr.create_time < #{params.chargeEndTime}
|
||||
</if>
|
||||
where 1 = 1
|
||||
<if test="params.teamId != null ">
|
||||
and ftmiu.team_id = #{params.teamId}
|
||||
</if>
|
||||
<if test="params.teamIds != null and params.teamIds.size > 0">
|
||||
and ftmiu.team_id in
|
||||
<foreach collection="params.teamIds" item="teamId" open="(" separator="," close=")">
|
||||
#{teamId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="params.startDate != null and params.startDate != ''">
|
||||
and u.create_time >= #{params.startDate}
|
||||
</if>
|
||||
<if test="params.endDate != null and params.endDate != ''">
|
||||
and u.create_time < #{params.endDate}
|
||||
</if>
|
||||
union
|
||||
select
|
||||
0 as total_user,
|
||||
0 as charge_user,
|
||||
0 as charge_count,
|
||||
0 as total_charge,
|
||||
sum(case when gsr.total_gold_num is not null then gsr.total_gold_num else 0 end) as total_send_gift,
|
||||
0 as give_count,
|
||||
0 as total_give
|
||||
from flow_team_member_invite_user as ftmiu
|
||||
inner join users as u on ftmiu.uid = u.uid
|
||||
left join gift_send_record as gsr on u.uid = gsr.uid and gsr.create_time >= u.create_time
|
||||
where 1 = 1
|
||||
<if test="params.teamId != null ">
|
||||
and ftmiu.team_id = #{params.teamId}
|
||||
</if>
|
||||
<if test="params.teamIds != null and params.teamIds.size > 0">
|
||||
and ftmiu.team_id in
|
||||
<foreach collection="params.teamIds" item="teamId" open="(" separator="," close=")">
|
||||
#{teamId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="params.startDate != null and params.startDate != ''">
|
||||
and u.create_time >= #{params.startDate}
|
||||
</if>
|
||||
<if test="params.endDate != null and params.endDate != ''">
|
||||
and u.create_time < #{params.endDate}
|
||||
</if>
|
||||
union
|
||||
select
|
||||
0 as total_user,
|
||||
0 as charge_user,
|
||||
0 as charge_count,
|
||||
0 as total_charge,
|
||||
0 as total_send_gift,
|
||||
count(1) as give_count,
|
||||
(sum(case when dgh.diamond_num is not null then dgh.diamond_num else 0 end) / 1000) as total_give
|
||||
from flow_team_member_invite_user as ftmiu
|
||||
inner join users as u on ftmiu.uid = u.uid
|
||||
left join diamond_give_history as dgh on u.uid = dgh.to_uid and dgh.create_time >= u.create_time
|
||||
where dgh.diamond_num > 0
|
||||
<if test="params.teamId != null ">
|
||||
and ftmiu.team_id = #{params.teamId}
|
||||
</if>
|
||||
<if test="params.teamIds != null and params.teamIds.size > 0">
|
||||
and ftmiu.team_id in
|
||||
<foreach collection="params.teamIds" item="teamId" open="(" separator="," close=")">
|
||||
#{teamId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="params.startDate != null and params.startDate != ''">
|
||||
and u.create_time >= #{params.startDate}
|
||||
</if>
|
||||
<if test="params.endDate != null and params.endDate != ''">
|
||||
and u.create_time < #{params.endDate}
|
||||
</if>
|
||||
) t;
|
||||
</select>
|
||||
<select id="listTeamStatisticDetailV2" resultType="com.accompany.admin.vo.flowteam.FlowTeamStatisticDetailVO">
|
||||
select t.team_id,
|
||||
t.member_id,
|
||||
t.member_name,
|
||||
t.member_status,
|
||||
t.team_role,
|
||||
sum(total_user) newUserCount, sum(charge_user) newChargeUserCount,
|
||||
sum(charge_count) chargeCount, sum(total_charge) chargeMoney,
|
||||
sum(total_send_gift) sendGiftMony from (
|
||||
select tm.team_id,
|
||||
tm.member_id,
|
||||
tm.member_name,
|
||||
tm.member_status,
|
||||
tm.team_role,
|
||||
count(distinct u.uid) total_user,
|
||||
0 charge_user,
|
||||
0 charge_count,
|
||||
0 total_charge,
|
||||
0 total_send_gift
|
||||
from flow_team_member_invite_user fu
|
||||
left join flow_team_member tm on fu.member_id = tm.member_id
|
||||
inner join users u on fu.uid = u.uid
|
||||
where fu.team_id = #{teamId}
|
||||
<if test="startDate != null and startDate != ''">
|
||||
and u.create_time >= #{startDate}
|
||||
</if>
|
||||
<if test="endDate != null and endDate != ''">
|
||||
and u.create_time < #{endDate}
|
||||
</if>
|
||||
group by tm.team_id, tm.member_id, tm.member_name, tm.member_status, tm.team_role
|
||||
union
|
||||
select tm.team_id,
|
||||
tm.member_id,
|
||||
tm.member_name,
|
||||
tm.member_status,
|
||||
tm.team_role,
|
||||
0 total_user,
|
||||
count(distinct cr.uid) charge_user,
|
||||
sum(case when cr.uid is not null then 1 else 0 end) charge_count,
|
||||
sum(case when cr.amount is not null then cr.amount else 0 end) / 100 total_charge,
|
||||
0 total_send_gift
|
||||
from flow_team_member_invite_user fu
|
||||
inner join users u on fu.uid = u.uid
|
||||
left join flow_team_member tm on tm.member_id = fu.member_id
|
||||
left join charge_record cr
|
||||
on cr.uid = u.uid and cr.charge_status in (2,6) and cr.charge_prod_id <> 'exchange' and cr.buss_type in
|
||||
(0,4)
|
||||
and cr.create_time >= u.create_time
|
||||
<if test="groupApps != null and groupApps.size > 0">
|
||||
and cr.charge_app in
|
||||
<foreach collection="groupApps" item="signUpApp" open="(" separator="," close=")">
|
||||
#{signUpApp}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="chargeStartTime != null and chargeStartTime != ''">
|
||||
and cr.create_time >= #{chargeStartTime}
|
||||
</if>
|
||||
<if test="chargeEndTime != null and chargeEndTime != ''">
|
||||
and cr.create_time < #{chargeEndTime}
|
||||
</if>
|
||||
where 1 = 1
|
||||
<if test="startDate != null and startDate != ''">
|
||||
and u.create_time >= #{startDate}
|
||||
</if>
|
||||
<if test="endDate != null and endDate != ''">
|
||||
and u.create_time < #{endDate}
|
||||
</if>
|
||||
and fu.team_id = #{teamId}
|
||||
group by tm.team_id, tm.member_id,tm.member_name, tm.member_status, tm.team_role
|
||||
union
|
||||
select tm.team_id,
|
||||
tm.member_id,
|
||||
tm.member_name,
|
||||
tm.member_status,
|
||||
tm.team_role,
|
||||
0 total_user,
|
||||
0 charge_user,
|
||||
0 charge_count,
|
||||
0 total_charge,
|
||||
sum(case when gsr.total_gold_num is not null then gsr.total_gold_num else 0 end) total_send_gift
|
||||
from flow_team_member tm
|
||||
left join flow_team_member_invite_user fu on tm.member_id = fu.member_id
|
||||
inner join users u on fu.uid = u.uid
|
||||
left join gift_send_record gsr on u.uid = gsr.uid
|
||||
and gsr.create_time >= u.create_time
|
||||
where 1=1
|
||||
<if test="startDate != null and startDate != ''">
|
||||
and u.create_time >= #{startDate}
|
||||
</if>
|
||||
<if test="endDate != null and endDate != ''">
|
||||
and u.create_time < #{endDate}
|
||||
</if>
|
||||
and fu.team_id = #{teamId}
|
||||
group by tm.team_id, tm.member_id,tm.member_name, tm.member_status, tm.team_role
|
||||
) t
|
||||
group by t.team_id, t.member_id,t.member_name, t.member_status, t.team_role;
|
||||
</select>
|
||||
|
||||
<select id="listUserStatisticDetailsV2"
|
||||
resultType="com.accompany.admin.vo.flowteam.FlowTeamStatisticUserDetailVO">
|
||||
select
|
||||
t.member_name as teamMemberName,
|
||||
t.team_id as teamId,
|
||||
t.invite_code as inviteCode,
|
||||
t.erban_no as userErbanNo ,
|
||||
t.nick as userNickName,
|
||||
t.create_time as signUpTime,
|
||||
t.phone,
|
||||
t.sourceName,
|
||||
sum(t.charge_count) as chargeCount,
|
||||
sum(t.total_charge) as chargeMoney,
|
||||
sum(t.total_send_gift) as totalSendGiftMoney,
|
||||
sum(t.total_no_backbag_send_gift) as totalNoBackbagSendGiftMoney,
|
||||
sum(t.total_backbag_send_gift) as totalBackbagSendGiftMoney,
|
||||
a.register_ip as registerIp,
|
||||
sum(t.give_count) as giveCount,
|
||||
sum(t.total_give) as giveMoney
|
||||
from (
|
||||
select
|
||||
tm.member_name,
|
||||
tm.team_id,
|
||||
u.invite_code,
|
||||
u.uid,
|
||||
if(u.source = 0, '自填', '补填') as sourceName,
|
||||
u1.erban_no,
|
||||
u1.nick,
|
||||
u1.create_time,
|
||||
u1.phone,
|
||||
sum(case when cr.amount is not null then 1 else 0 end) as charge_count,
|
||||
(sum(case when cr.amount is not null then cr.amount else 0 end) / 100) as total_charge,
|
||||
0 as total_send_gift,
|
||||
0 as total_no_backbag_send_gift,
|
||||
0 as total_backbag_send_gift,
|
||||
0 as give_count,
|
||||
0 as total_give
|
||||
from flow_team_member_invite_user as u
|
||||
left join account as a on u.uid = a.uid
|
||||
<if test="groupApps != null and groupApps.size > 0">
|
||||
and a.signup_app in
|
||||
<foreach collection="groupApps" item="signUpApp" open="(" separator="," close=")">
|
||||
#{signUpApp}
|
||||
</foreach>
|
||||
</if>
|
||||
left join flow_team_member as tm on u.member_id = tm.member_id
|
||||
left join charge_record as cr
|
||||
on cr.uid = u.uid and cr.charge_status in (2,6) and cr.charge_prod_id <> 'exchange'
|
||||
and cr.buss_type in (0,4)
|
||||
<if test="groupApps != null and groupApps.size > 0">
|
||||
and cr.charge_app in
|
||||
<foreach collection="groupApps" item="signUpApp" open="(" separator="," close=")">
|
||||
#{signUpApp}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="chargeStartTime != null and chargeStartTime != ''">
|
||||
and cr.create_time >= #{chargeStartTime}
|
||||
</if>
|
||||
<if test="chargeEndTime != null and chargeEndTime != ''">
|
||||
and cr.create_time < #{chargeEndTime}
|
||||
</if>
|
||||
left join users as u1 on u.uid = u1.uid
|
||||
where 1=1
|
||||
<if test="teamId != null">
|
||||
and u.team_id = #{teamId}
|
||||
</if>
|
||||
<if test="memberId != null">
|
||||
and u.member_id = #{memberId}
|
||||
</if>
|
||||
<if test="startDate != null and startDate != ''">
|
||||
and u1.create_time >= #{startDate}
|
||||
</if>
|
||||
<if test="endDate != null and endDate != ''">
|
||||
and u1.create_time < #{endDate}
|
||||
</if>
|
||||
<if test="groupId != null and endDate != ''">
|
||||
and u.group_id = #{groupId}
|
||||
</if>
|
||||
group by tm.member_name, tm.team_id, u.invite_code, u.uid, u1.erban_no, u1.nick, u1.create_time, u1.phone
|
||||
union all
|
||||
select
|
||||
tm.member_name,
|
||||
tm.team_id,
|
||||
u.invite_code,
|
||||
u.uid,
|
||||
if(u.source = 0, '自填', '补填') as sourceName,
|
||||
u1.erban_no,
|
||||
u1.nick,
|
||||
u1.create_time,
|
||||
u1.phone,
|
||||
0 as charge_count,
|
||||
0 as total_charge,
|
||||
sum(case when gsr.total_gold_num is not null then gsr.total_gold_num else 0 end) as total_send_gift,
|
||||
sum(case when gsr.gift_source = 1 and gsr.total_gold_num is not null then gsr.total_gold_num else 0 end) as
|
||||
total_no_backbag_send_gift,
|
||||
sum(case when gsr.gift_source = 2 and gsr.total_gold_num is not null then gsr.total_gold_num else 0 end) as
|
||||
total_backbag_send_gift,
|
||||
0 as give_count,
|
||||
0 as total_give
|
||||
from flow_team_member_invite_user as u
|
||||
left join account as a on a.uid = u.uid
|
||||
<if test="groupApps != null and groupApps.size > 0">
|
||||
and a.signup_app in
|
||||
<foreach collection="groupApps" item="signUpApp" open="(" separator="," close=")">
|
||||
#{signUpApp}
|
||||
</foreach>
|
||||
</if>
|
||||
left join flow_team_member as tm on u.member_id = tm.member_id
|
||||
left join users as u1 on u.uid = u1.uid
|
||||
left join gift_send_record as gsr on u1.uid = gsr.uid and gsr.create_time >= u1.create_time
|
||||
where 1= 1
|
||||
<if test="teamId != null">
|
||||
and u.team_id = #{teamId}
|
||||
</if>
|
||||
<if test="memberId != null">
|
||||
and u.member_id = #{memberId}
|
||||
</if>
|
||||
<if test="startDate != null and startDate != ''">
|
||||
and u1.create_time >= #{startDate}
|
||||
</if>
|
||||
<if test="endDate != null and endDate != ''">
|
||||
and u1.create_time < #{endDate}
|
||||
</if>
|
||||
<if test="groupId != null and endDate != ''">
|
||||
and u.group_id = #{groupId}
|
||||
</if>
|
||||
group by tm.member_name, tm.team_id, u.invite_code, u.uid, u1.erban_no, u1.nick, u1.create_time, u1.phone
|
||||
union all
|
||||
select
|
||||
tm.member_name,
|
||||
tm.team_id,
|
||||
u.invite_code,
|
||||
u.uid,
|
||||
if(u.source = 0, '自填', '补填') as sourceName,
|
||||
u1.erban_no,
|
||||
u1.nick,
|
||||
u1.create_time,
|
||||
u1.phone,
|
||||
0 as charge_count,
|
||||
0 as total_charge,
|
||||
0 as total_send_gift,
|
||||
0 as total_no_backbag_send_gift,
|
||||
0 as total_backbag_send_gift,
|
||||
count(1) as give_count,
|
||||
(sum(case when dgh.diamond_num is not null then dgh.diamond_num else 0 end) / 1000) as total_give
|
||||
from flow_team_member_invite_user as u
|
||||
left join account as a on a.uid = u.uid
|
||||
<if test="groupApps != null and groupApps.size > 0">
|
||||
and a.signup_app in
|
||||
<foreach collection="groupApps" item="signUpApp" open="(" separator="," close=")">
|
||||
#{signUpApp}
|
||||
</foreach>
|
||||
</if>
|
||||
left join flow_team_member as tm on u.member_id = tm.member_id
|
||||
left join users as u1 on u.uid = u1.uid
|
||||
left join diamond_give_history as dgh on u1.uid = dgh.to_uid and dgh.create_time >= u1.create_time
|
||||
where dgh.diamond_num > 0
|
||||
<if test="teamId != null">
|
||||
and u.team_id = #{teamId}
|
||||
</if>
|
||||
<if test="memberId != null">
|
||||
and u.member_id = #{memberId}
|
||||
</if>
|
||||
<if test="startDate != null and startDate != ''">
|
||||
and u1.create_time >= #{startDate}
|
||||
</if>
|
||||
<if test="endDate != null and endDate != ''">
|
||||
and u1.create_time < #{endDate}
|
||||
</if>
|
||||
<if test="groupId != null and endDate != ''">
|
||||
and u.group_id = #{groupId}
|
||||
</if>
|
||||
group by tm.member_name, tm.team_id, u.invite_code, u.uid, u1.erban_no, u1.nick, u1.create_time, u1.phone
|
||||
) as t
|
||||
LEFT JOIN account as a ON t.erban_no = a.erban_no
|
||||
group by t.member_name, t.team_id, t.invite_code, t.erban_no , t.uid, t.nick, t.create_time, a.register_ip,
|
||||
t.phone
|
||||
order by t.create_time desc, t.invite_code
|
||||
;
|
||||
</select>
|
||||
</mapper>
|
@@ -18,11 +18,11 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
*/
|
||||
@EnableDynamicTp
|
||||
@SpringBootApplication
|
||||
@ComponentScan({"com.accompany","com.xuanyin"})
|
||||
@ComponentScan({"com.accompany"})
|
||||
@EnableScheduling
|
||||
@EnableAsync(proxyTargetClass = true)
|
||||
@MapperScan({"com.accompany.*.mapper","com.accompany.*.mybatismapper","com.xuanyin.*.mapper"})
|
||||
@ServletComponentScan(value = {"com.accompany", "com.xuanyin"})
|
||||
@MapperScan({"com.accompany.*.mapper","com.accompany.*.mybatismapper"})
|
||||
@ServletComponentScan(value = {"com.accompany"})
|
||||
@SpringBootConfiguration
|
||||
public class AdminApplication {
|
||||
|
||||
|
@@ -1,331 +0,0 @@
|
||||
package com.accompany.admin.controller.flowteam;
|
||||
|
||||
import cn.hutool.core.text.StrBuilder;
|
||||
import com.accompany.admin.base.Pagination;
|
||||
import com.accompany.admin.controller.BaseController;
|
||||
import com.accompany.admin.params.flowteam.FlowTeamStatisticParams;
|
||||
import com.accompany.admin.params.flowteam.TeamMemberEditParams;
|
||||
import com.accompany.admin.params.flowteam.TeamMemberQueryParams;
|
||||
import com.accompany.admin.service.flowteam.FlowTeamMemberInviteUserAdminService;
|
||||
import com.accompany.admin.service.flowteam.FlowTeamService;
|
||||
import com.accompany.admin.service.system.AdminLogService;
|
||||
import com.accompany.admin.vo.flowteam.*;
|
||||
import com.accompany.common.status.BusiStatus;
|
||||
import com.accompany.common.utils.DateTimeUtil;
|
||||
import com.accompany.core.model.Users;
|
||||
import com.accompany.core.vo.BaseResponseVO;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.xuanyin.flowteam.model.FlowTeamInfo;
|
||||
import com.xuanyin.flowteam.model.FlowTeamMember;
|
||||
import com.xuanyin.flowteam.model.FlowTeamMemberInviteCode;
|
||||
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/admin/flowTeam")
|
||||
public class FlowTeamAdminController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private FlowTeamService flowTeamService;
|
||||
@Autowired
|
||||
private FlowTeamMemberInviteUserAdminService flowTeamMemberInviteUserAdminService;
|
||||
@Autowired
|
||||
private AdminLogService adminLogService;
|
||||
|
||||
|
||||
@GetMapping("/listFlowMembersByPage")
|
||||
public Pagination listFlowMembersByPage(TeamMemberQueryParams params) {
|
||||
IPage<FlowTeamMemberVO> flowTeamMemberVOIPage = flowTeamService.listFlowMembersByPage(params);
|
||||
|
||||
return new Pagination(flowTeamMemberVOIPage);
|
||||
}
|
||||
|
||||
@GetMapping("/getConfig")
|
||||
public BaseResponseVO<FlowTeamConfVO> getConfig() {
|
||||
FlowTeamConfVO config = flowTeamService.getConfig();
|
||||
return new BaseResponseVO(config);
|
||||
}
|
||||
|
||||
@PostMapping("/saveMember")
|
||||
public BaseResponseVO saveOrUpdateMember(@RequestBody TeamMemberEditParams params) {
|
||||
adminLogService.insertLog(getAdminId(), getClass().getCanonicalName(), "saveOrUpdateMember", "params===>>params:" + JSON.toJSONString(params));
|
||||
if (params.getMemberId() != null) {
|
||||
flowTeamService.editTeamMember(params);
|
||||
} else {
|
||||
flowTeamService.addTeamMember(params);
|
||||
}
|
||||
|
||||
return new BaseResponseVO(BusiStatus.SUCCESS);
|
||||
}
|
||||
|
||||
@PostMapping("/changeMemberStatus")
|
||||
public BaseResponseVO changeMemberStatus(@RequestBody TeamMemberEditParams params) {
|
||||
flowTeamService.changeMemberStatus(params.getMemberId(), params.getMemberStatus());
|
||||
|
||||
return new BaseResponseVO(BusiStatus.SUCCESS);
|
||||
}
|
||||
|
||||
@PostMapping("/listStatisticSummary")
|
||||
public List<FlowTeamStatisticSummaryVO> listStatisticSummary(@RequestBody FlowTeamStatisticParams params) {
|
||||
return flowTeamService.listStatisticSummary(params);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/exportuserStatisticDetailOfTeam", method = RequestMethod.GET)
|
||||
public void export(HttpServletResponse response, FlowTeamStatisticParams params) throws IOException {
|
||||
List<FlowTeamStatisticUserDetailVO> summaryVOS = flowTeamService.listUserStatisticDetails(params);
|
||||
Map<String, FlowTeamConfVO.TeamItem> teamMap = flowTeamService.getTeamMap();
|
||||
FlowTeamConfVO.TeamItem teamItem = teamMap.get(params.getTeamId());
|
||||
|
||||
HSSFWorkbook workbook = this.buildUserStatisticDetailOfTeamExcel(summaryVOS, teamItem);
|
||||
// 设置下载时客户端Excel的名称
|
||||
String filename = new StrBuilder(teamItem.getTeamName()).append(params.getStartDate()).append("_").append(params.getEndDate()).append("邀请明细.xls").toString();
|
||||
response.setContentType("application/vnd.ms-excel");
|
||||
response.setHeader("Content-disposition", "attachment;filename=" + new String(filename.getBytes("utf-8"), "ISO8859-1"));
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
OutputStream ouputStream = response.getOutputStream();
|
||||
workbook.write(ouputStream);
|
||||
ouputStream.flush();
|
||||
ouputStream.close();
|
||||
}
|
||||
|
||||
private HSSFWorkbook buildUserStatisticDetailOfTeamExcel(List<FlowTeamStatisticUserDetailVO> voList, FlowTeamConfVO.TeamItem teamItem) {
|
||||
HSSFWorkbook workbook = new HSSFWorkbook();
|
||||
HSSFSheet sheet = workbook.createSheet("邀请明细");
|
||||
|
||||
String[] headers = {"邀请码", "邀请码填写类型", "被邀请用户id", "被邀请用户昵称",
|
||||
"被邀请用户注册ip", "被邀请用户手机号",
|
||||
"引入组", "引入人", "新增日期", "充值次数", "充值金额(美元)",
|
||||
"送礼钻石数",
|
||||
"送礼背包钻石数", "送礼非背包钻石数",
|
||||
"累计收到转赠次数", "累计收到转赠金额"
|
||||
};
|
||||
HSSFRow header = sheet.createRow(0);
|
||||
for (int i = 0; i < headers.length; i++) {
|
||||
header.createCell(i).setCellValue(headers[i]);
|
||||
}
|
||||
int rowNum = 1;
|
||||
for (FlowTeamStatisticUserDetailVO item : voList) {
|
||||
HSSFRow row = sheet.createRow(rowNum++);
|
||||
int cellIdx = 0;
|
||||
row.createCell(cellIdx).setCellValue(item.getInviteCode());
|
||||
cellIdx++;
|
||||
row.createCell(cellIdx).setCellValue(item.getSourceName());
|
||||
cellIdx++;
|
||||
row.createCell(cellIdx).setCellValue(item.getUserErbanNo());
|
||||
cellIdx++;
|
||||
row.createCell(cellIdx).setCellValue(item.getUserNickName());
|
||||
cellIdx++;
|
||||
row.createCell(cellIdx).setCellValue(item.getRegisterIp());
|
||||
cellIdx++;
|
||||
row.createCell(cellIdx).setCellValue(item.getPhone());
|
||||
cellIdx++;
|
||||
row.createCell(cellIdx).setCellValue(teamItem.getTeamName());
|
||||
cellIdx++;
|
||||
row.createCell(cellIdx).setCellValue(item.getTeamMemberName());
|
||||
cellIdx++;
|
||||
row.createCell(cellIdx).setCellValue(DateTimeUtil.convertDate(item.getSignUpTime()));
|
||||
cellIdx++;
|
||||
row.createCell(cellIdx).setCellValue(item.getChargeCount());
|
||||
cellIdx++;
|
||||
row.createCell(cellIdx).setCellValue(item.getChargeMoney());
|
||||
cellIdx++;
|
||||
row.createCell(cellIdx).setCellValue(item.getTotalSendGiftMoney());
|
||||
cellIdx++;
|
||||
row.createCell(cellIdx).setCellValue(item.getTotalBackbagSendGiftMoney());
|
||||
cellIdx++;
|
||||
row.createCell(cellIdx).setCellValue(item.getTotalNoBackbagSendGiftMoney());
|
||||
cellIdx++;
|
||||
row.createCell(cellIdx).setCellValue(item.getGiveCount());
|
||||
cellIdx++;
|
||||
row.createCell(cellIdx).setCellValue(item.getGiveMoney());
|
||||
cellIdx++;
|
||||
}
|
||||
return workbook;
|
||||
}
|
||||
|
||||
@GetMapping("/listFlowTeamStatisticDetails")
|
||||
public List<FlowTeamStatisticDetailVO> listFlowTeamStatisticDetails(FlowTeamStatisticParams params) {
|
||||
return flowTeamService.listFlowTeamStatisticDetails(params);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/exportTeamStatisticDetails", method = RequestMethod.GET)
|
||||
public void exportTeamStatisticDetails(HttpServletResponse response, FlowTeamStatisticParams params) throws IOException {
|
||||
List<FlowTeamStatisticDetailVO> summaryVOS = flowTeamService.listFlowTeamStatisticDetails(params);
|
||||
Map<String, FlowTeamConfVO.TeamItem> teamMap = flowTeamService.getTeamMap();
|
||||
FlowTeamConfVO.TeamItem teamItem = teamMap.get(params.getTeamId());
|
||||
|
||||
HSSFWorkbook workbook = this.buildTeamStatisticDetailsExcel(summaryVOS, teamItem);
|
||||
// 设置下载时客户端Excel的名称
|
||||
String filename = new StrBuilder(teamItem.getTeamName()).append(params.getStartDate()).append("_").append(params.getEndDate()).append("明细.xls").toString();
|
||||
response.setContentType("application/vnd.ms-excel");
|
||||
response.setHeader("Content-disposition", "attachment;filename=" + new String(filename.getBytes("utf-8"), "ISO8859-1"));
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
OutputStream ouputStream = response.getOutputStream();
|
||||
workbook.write(ouputStream);
|
||||
ouputStream.flush();
|
||||
ouputStream.close();
|
||||
}
|
||||
|
||||
private HSSFWorkbook buildTeamStatisticDetailsExcel(List<FlowTeamStatisticDetailVO> voList, FlowTeamConfVO.TeamItem teamItem) {
|
||||
HSSFWorkbook workbook = new HSSFWorkbook();
|
||||
HSSFSheet sheet = workbook.createSheet("邀请明细");
|
||||
|
||||
String[] headers = {"成员名", "职务", "成员状态", "新增用户", "新增充值", "付费转化", "充值次数", "充值金额(美元)",
|
||||
"送礼钻石数", "Arpu"};
|
||||
HSSFRow header = sheet.createRow(0);
|
||||
for (int i = 0; i < headers.length; i++) {
|
||||
header.createCell(i).setCellValue(headers[i]);
|
||||
}
|
||||
int rowNum = 1;
|
||||
for (FlowTeamStatisticDetailVO item : voList) {
|
||||
HSSFRow row = sheet.createRow(rowNum++);
|
||||
row.createCell(0).setCellValue(item.getMemberName());
|
||||
row.createCell(1).setCellValue(item.getTeamRole() == null ? null : item.getTeamRole() == 2 ? "组长" : "组员");
|
||||
row.createCell(2).setCellValue(item.getMemberStatus() == null ? null : item.getMemberStatus() == 1 ? "生效" : "无效");
|
||||
row.createCell(3).setCellValue(item.getNewUserCount());
|
||||
row.createCell(4).setCellValue(item.getNewChargeUserCount());
|
||||
row.createCell(5).setCellValue(item.getChargeRate());
|
||||
row.createCell(6).setCellValue(item.getChargeCount());
|
||||
row.createCell(7).setCellValue(item.getChargeMoney());
|
||||
row.createCell(8).setCellValue(item.getSendGiftMony());
|
||||
row.createCell(9).setCellValue(item.getArpu());
|
||||
}
|
||||
return workbook;
|
||||
}
|
||||
|
||||
@GetMapping("/listUserStatisticDetails")
|
||||
public List<FlowTeamStatisticUserDetailVO> listUserStatisticDetails(FlowTeamStatisticParams params) {
|
||||
List<FlowTeamStatisticUserDetailVO> summaryVOS = flowTeamService.listUserStatisticDetails(params);
|
||||
|
||||
return summaryVOS;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/exportUserStatisticDetails", method = RequestMethod.GET)
|
||||
public void exportUserStatisticDetails(HttpServletResponse response, FlowTeamStatisticParams params) throws IOException {
|
||||
List<FlowTeamStatisticUserDetailVO> summaryVOS = flowTeamService.listUserStatisticDetails(params);
|
||||
if (summaryVOS == null || summaryVOS.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
FlowTeamStatisticUserDetailVO flowTeamStatisticUserDetailVO = summaryVOS.get(0);
|
||||
Map<String, FlowTeamConfVO.TeamItem> teamMap = flowTeamService.getTeamMap();
|
||||
FlowTeamConfVO.TeamItem teamItem = teamMap.get(flowTeamStatisticUserDetailVO.getTeamId());
|
||||
|
||||
HSSFWorkbook workbook = this.buildUserStatisticDetailsExcel(summaryVOS);
|
||||
// 设置下载时客户端Excel的名称
|
||||
String filename = new StrBuilder(teamItem.getTeamName()).append(" ")
|
||||
.append(flowTeamStatisticUserDetailVO.getTeamMemberName()).append(" ")
|
||||
.append(params.getStartDate()).append("_").append(params.getEndDate()).append("明细.xls").toString();
|
||||
response.setContentType("application/vnd.ms-excel");
|
||||
response.setHeader("Content-disposition", "attachment;filename=" + new String(filename.getBytes("utf-8"), "ISO8859-1"));
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
OutputStream ouputStream = response.getOutputStream();
|
||||
workbook.write(ouputStream);
|
||||
ouputStream.flush();
|
||||
ouputStream.close();
|
||||
}
|
||||
|
||||
private HSSFWorkbook buildUserStatisticDetailsExcel(List<FlowTeamStatisticUserDetailVO> voList) {
|
||||
HSSFWorkbook workbook = new HSSFWorkbook();
|
||||
HSSFSheet sheet = workbook.createSheet("邀请明细");
|
||||
|
||||
String[] headers = {"邀请码", "邀请码填写类型", "被邀请用户id", "被邀请用户昵称", "被邀请用户注册ip", "被邀请用户手机号", "引入人", "新增日期", "充值次数", "充值金额", "送礼金额",
|
||||
"送礼背包金额", "送礼非背包金额", "累计收到转赠次数", "累计收到转赠金额"};
|
||||
HSSFRow header = sheet.createRow(0);
|
||||
for (int i = 0; i < headers.length; i++) {
|
||||
header.createCell(i).setCellValue(headers[i]);
|
||||
}
|
||||
int rowNum = 1;
|
||||
for (FlowTeamStatisticUserDetailVO item : voList) {
|
||||
int cellIdx = 0;
|
||||
HSSFRow row = sheet.createRow(rowNum++);
|
||||
row.createCell(cellIdx).setCellValue(item.getInviteCode());
|
||||
cellIdx++;
|
||||
row.createCell(cellIdx).setCellValue(item.getSourceName());
|
||||
cellIdx++;
|
||||
row.createCell(cellIdx).setCellValue(item.getUserErbanNo());
|
||||
cellIdx++;
|
||||
row.createCell(cellIdx).setCellValue(item.getUserNickName());
|
||||
cellIdx++;
|
||||
row.createCell(cellIdx).setCellValue(item.getRegisterIp());
|
||||
cellIdx++;
|
||||
row.createCell(cellIdx).setCellValue(item.getPhone());
|
||||
cellIdx++;
|
||||
row.createCell(cellIdx).setCellValue(item.getTeamMemberName());
|
||||
cellIdx++;
|
||||
row.createCell(cellIdx).setCellValue(DateTimeUtil.convertDate(item.getSignUpTime()));
|
||||
cellIdx++;
|
||||
row.createCell(cellIdx).setCellValue(item.getChargeCount());
|
||||
cellIdx++;
|
||||
row.createCell(cellIdx).setCellValue(item.getChargeMoney());
|
||||
cellIdx++;
|
||||
row.createCell(cellIdx).setCellValue(item.getTotalSendGiftMoney());
|
||||
cellIdx++;
|
||||
row.createCell(cellIdx).setCellValue(item.getTotalBackbagSendGiftMoney());
|
||||
cellIdx++;
|
||||
row.createCell(cellIdx).setCellValue(item.getTotalNoBackbagSendGiftMoney());
|
||||
cellIdx++;
|
||||
row.createCell(cellIdx).setCellValue(item.getGiveCount());
|
||||
cellIdx++;
|
||||
row.createCell(cellIdx).setCellValue(item.getGiveMoney());
|
||||
cellIdx++;
|
||||
}
|
||||
return workbook;
|
||||
}
|
||||
|
||||
@GetMapping("/listUsers")
|
||||
public List<UserWithFlowTeamInfoVO> listUsers(String erbanNoList) {
|
||||
List<UserWithFlowTeamInfoVO> users = flowTeamService.listUsersByErbanNo(erbanNoList);
|
||||
|
||||
return users;
|
||||
}
|
||||
|
||||
@PostMapping("/refillUserInviteCode")
|
||||
public BaseResponseVO refillInviteCode(@RequestBody Users user) {
|
||||
adminLogService.insertLog(getAdminId(), getClass().getCanonicalName(), "refillInviteCode", "params===>>user:" + JSON.toJSONString(user));
|
||||
flowTeamService.refillUserInviteCode(user);
|
||||
|
||||
return new BaseResponseVO(BusiStatus.SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化用户与引流小组成员的邀请绑定关系
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/init/member/inviteUserData")
|
||||
public BaseResponseVO initFlowTeamMemberInviteUserData() {
|
||||
flowTeamMemberInviteUserAdminService.initFlowTeamMemberInviteUserData();
|
||||
return new BaseResponseVO(BusiStatus.SUCCESS);
|
||||
}
|
||||
|
||||
@GetMapping("/listTeamByGroupId")
|
||||
public BaseResponseVO<List<FlowTeamInfo>> listTeamByGroupId(Long groupId) {
|
||||
return new BaseResponseVO<>(flowTeamService.listTeamByGroupId(groupId));
|
||||
}
|
||||
|
||||
@GetMapping("/listTeam")
|
||||
public BaseResponseVO<List<FlowTeamInfo>> listTeam() {
|
||||
return new BaseResponseVO<>(flowTeamService.listTeam());
|
||||
}
|
||||
|
||||
@GetMapping("/listMember")
|
||||
public BaseResponseVO<List<FlowTeamMember>> listMember(String teamId) {
|
||||
return new BaseResponseVO<>(flowTeamService.listTeamMember(teamId));
|
||||
}
|
||||
|
||||
@GetMapping("/listMemberInviteCode")
|
||||
public BaseResponseVO<List<FlowTeamMemberInviteCode>> listMemberInviteCode(Long memberId) {
|
||||
return new BaseResponseVO<>(flowTeamService.listMemberInviteCode(memberId));
|
||||
}
|
||||
|
||||
}
|
@@ -1,114 +0,0 @@
|
||||
/*
|
||||
* 文 件 名: FlowTeamGroupAdminController
|
||||
* 版 权:
|
||||
* 描 述: <描述>
|
||||
* 创建人: H1
|
||||
* 创建时间: 2022/1/13
|
||||
* 修改人:
|
||||
* 修改内容:
|
||||
* 修改时间:
|
||||
*/
|
||||
package com.accompany.admin.controller.flowteam;
|
||||
|
||||
import com.accompany.admin.base.Pagination;
|
||||
import com.accompany.admin.controller.BaseController;
|
||||
import com.accompany.admin.params.flowteam.FlowTeamEditInviteUserParams;
|
||||
import com.accompany.admin.service.flowteam.FlowTeamGroupAdminService;
|
||||
import com.accompany.admin.service.system.AdminLogService;
|
||||
import com.accompany.admin.vo.flowteam.FlowTeamInviteUserVO;
|
||||
import com.accompany.common.status.BusiStatus;
|
||||
import com.accompany.core.vo.BaseResponseVO;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* <br>类描述:
|
||||
* <br>功能详细描述:
|
||||
*
|
||||
* @author H1
|
||||
* @date [2022/1/13]
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/admin/flowteam/group")
|
||||
public class FlowTeamGroupAdminController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private FlowTeamGroupAdminService flowTeamGroupAdminService;
|
||||
@Autowired
|
||||
private AdminLogService adminLogService;
|
||||
|
||||
|
||||
/**
|
||||
* 分页获取团队列表
|
||||
*
|
||||
* @param page
|
||||
* @param pageSize
|
||||
* @param groupName
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/listGroupByPage")
|
||||
public Pagination listGroupByPage(Integer page, Integer pageSize, String groupName) {
|
||||
return flowTeamGroupAdminService.listGroupByPage(page, pageSize, groupName);
|
||||
}
|
||||
|
||||
@GetMapping("/saveOrUpdateGroup")
|
||||
public BaseResponseVO saveOrUpdateGroup(Long groupId, String groupName) {
|
||||
flowTeamGroupAdminService.saveOrUpdateGroup(groupId, groupName);
|
||||
return new BaseResponseVO();
|
||||
}
|
||||
|
||||
@GetMapping("/changeGroupStatus")
|
||||
public BaseResponseVO changeGroupStatus(Long groupId, Integer status) {
|
||||
flowTeamGroupAdminService.changeGroupStatus(groupId, status);
|
||||
return new BaseResponseVO();
|
||||
}
|
||||
|
||||
@GetMapping("/listGroupTeamByPage")
|
||||
public Pagination listGroupTeamByPage(Integer page, Integer pageSize, Long groupId) {
|
||||
return flowTeamGroupAdminService.listGroupTeamByPage(page, pageSize, groupId);
|
||||
}
|
||||
|
||||
@GetMapping("/saveOrUpdateTeam")
|
||||
public BaseResponseVO saveOrUpdateTeam(Long groupId, String teamId, String teamName) {
|
||||
flowTeamGroupAdminService.saveOrUpdateTeam(groupId, teamId, teamName);
|
||||
return new BaseResponseVO();
|
||||
}
|
||||
|
||||
@GetMapping("/delTeam")
|
||||
public BaseResponseVO delTeam(String teamId) {
|
||||
flowTeamGroupAdminService.delTeam(teamId);
|
||||
int adminId = getAdminId();
|
||||
adminLogService.insertLog(adminId, getClass().getCanonicalName(), "delTeam", teamId);
|
||||
return new BaseResponseVO();
|
||||
}
|
||||
|
||||
/**
|
||||
* 团队功能上线时初始化已有的团队与组信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
// @RequestMapping(value = "/initGroupAndTeam", method = RequestMethod.GET)
|
||||
public BaseResponseVO initGroupAndTeam() throws IOException {
|
||||
flowTeamGroupAdminService.initGroupAndTeam();
|
||||
return new BaseResponseVO();
|
||||
}
|
||||
|
||||
@ApiOperation("获取邀请用户的引流团队信息")
|
||||
@GetMapping("/listFlowTeamInfoWithUser")
|
||||
public Pagination<FlowTeamInviteUserVO> listFlowTeamInfoWithUser(Integer page, Integer pageSize, String erbanNo) {
|
||||
return flowTeamGroupAdminService.listFlowTeamInfoWithUser(page, pageSize, erbanNo);
|
||||
}
|
||||
|
||||
@ApiOperation("编辑邀请用户的引流团队固化信息")
|
||||
@PostMapping("/updateFlowTeamInviteInfo")
|
||||
public BaseResponseVO updateFlowTeamInviteInfo(@RequestBody FlowTeamEditInviteUserParams params) {
|
||||
int adminId = getAdminId();
|
||||
params.setOptUid((long) adminId);
|
||||
flowTeamGroupAdminService.updateFlowTeamInviteInfo(params);
|
||||
return new BaseResponseVO(BusiStatus.SUCCESS);
|
||||
}
|
||||
|
||||
}
|
@@ -1,140 +0,0 @@
|
||||
/*
|
||||
* 文 件 名: FlowTeamSettlementInfoController
|
||||
* 版 权:
|
||||
* 描 述: <描述>
|
||||
* 创建人: H1
|
||||
* 创建时间: 2021/11/11
|
||||
* 修改人:
|
||||
* 修改内容:
|
||||
* 修改时间:
|
||||
*/
|
||||
package com.accompany.admin.controller.flowteam;
|
||||
|
||||
import cn.hutool.core.text.StrBuilder;
|
||||
import com.accompany.admin.base.Pagination;
|
||||
import com.accompany.admin.controller.BaseController;
|
||||
import com.accompany.admin.service.flowteam.FlowTeamService;
|
||||
import com.accompany.admin.vo.flowteam.FlowTeamConfVO;
|
||||
import com.accompany.business.service.flow.FlowTeamSettlementBizService;
|
||||
import com.accompany.common.utils.DateTimeUtil;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.xuanyin.flowteam.dto.FlowTeamSettlementDetail;
|
||||
import com.xuanyin.flowteam.model.FlowTeamSettlementInfo;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.context.request.ServletWebRequest;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <br>类描述: 引流小组结算controller
|
||||
* <br>功能详细描述:
|
||||
*
|
||||
* @author H1
|
||||
* @date [2021/11/11]
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = "/admin/flowteamSettlement")
|
||||
public class FlowTeamSettlementInfoController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private FlowTeamSettlementBizService flowTeamSettlementBizService;
|
||||
@Autowired
|
||||
private FlowTeamService flowTeamService;
|
||||
|
||||
|
||||
/**
|
||||
* 获取引流团队结算数据
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/listTeamSettlementData")
|
||||
public Pagination<FlowTeamSettlementInfo> listTeamSettlementData(Long groupId, String teamId) {
|
||||
try {
|
||||
List<FlowTeamSettlementInfo> infos = flowTeamSettlementBizService.listTeamSettlementData(groupId, teamId);
|
||||
return new Pagination<>(infos.size(), infos);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
return new Pagination<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取引流团队结算数据
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/listTeamSettlementDataDetail")
|
||||
public Pagination listTeamSettlementDataDetail(String teamId, String month, String erbanNo, Integer page, Integer pageSize) {
|
||||
PageInfo<FlowTeamSettlementDetail> pageInfo = flowTeamSettlementBizService.listFlowTeamSettleDetail(teamId, month, erbanNo, page, pageSize);
|
||||
return new Pagination(pageInfo);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/exportTeamSettlementDetails", method = RequestMethod.GET)
|
||||
public void exportTeamStatisticDetails(HttpServletResponse response, String teamId, String month, String erbanNo) throws IOException {
|
||||
PageInfo<FlowTeamSettlementDetail> pageInfo = flowTeamSettlementBizService.listFlowTeamSettleDetail(teamId, month, erbanNo, 1, Integer.MAX_VALUE);
|
||||
List<FlowTeamSettlementDetail> details = pageInfo.getList();
|
||||
HSSFWorkbook workbook = buildTeamStatisticDetailsExcel(details);
|
||||
Map<String, FlowTeamConfVO.TeamItem> teamMap = flowTeamService.getTeamMap();
|
||||
FlowTeamConfVO.TeamItem teamItem = teamMap.get(teamId);
|
||||
// 设置下载时客户端Excel的名称
|
||||
String filename = new StrBuilder("_").append(month).append("累计充值明细.xls").toString();
|
||||
response.setContentType("application/vnd.ms-excel");
|
||||
response.setHeader("Content-disposition", "attachment;filename=" + new String(filename.getBytes("utf-8"), "ISO8859-1"));
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
OutputStream ouputStream = response.getOutputStream();
|
||||
workbook.write(ouputStream);
|
||||
ouputStream.flush();
|
||||
ouputStream.close();
|
||||
}
|
||||
|
||||
private HSSFWorkbook buildTeamStatisticDetailsExcel(List<FlowTeamSettlementDetail> details) {
|
||||
HSSFWorkbook workbook = new HSSFWorkbook();
|
||||
HSSFSheet sheet = workbook.createSheet("邀请明细");
|
||||
|
||||
String[] headers = {"用户ID", "用户名称", "新增日期", "邀请码", "引入人", "充值时间", "充值金额"};
|
||||
HSSFRow header = sheet.createRow(0);
|
||||
for (int i = 0; i < headers.length; i++) {
|
||||
header.createCell(i).setCellValue(headers[i]);
|
||||
}
|
||||
int rowNum = 1;
|
||||
for (FlowTeamSettlementDetail item : details) {
|
||||
HSSFRow row = sheet.createRow(rowNum++);
|
||||
row.createCell(0).setCellValue(item.getErbanNo());
|
||||
row.createCell(1).setCellValue(item.getNick());
|
||||
row.createCell(2).setCellValue(DateTimeUtil.convertDate(item.getCreateTime()));
|
||||
row.createCell(3).setCellValue(item.getInviteCode());
|
||||
row.createCell(4).setCellValue(item.getInviteUserNick());
|
||||
row.createCell(5).setCellValue(DateTimeUtil.convertDate(item.getChargeTime()));
|
||||
row.createCell(6).setCellValue(item.getAmount());
|
||||
}
|
||||
return workbook;
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出
|
||||
*
|
||||
* @param groupId
|
||||
* @param teamId
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
@ApiOperation("导出")
|
||||
@GetMapping("export")
|
||||
public void export(@RequestParam(value = "query-teamSelector", required = false) Long groupId,
|
||||
@RequestParam(value = "teamSelector", required = false) String teamId,
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
flowTeamSettlementBizService.export(groupId, teamId, new ServletWebRequest(request, response));
|
||||
}
|
||||
|
||||
}
|
@@ -113,7 +113,6 @@
|
||||
<!--开发环境:打印控制台-->
|
||||
<springProfile name="dev">
|
||||
<logger name="com.accompany" level="DEBUG"/>
|
||||
<logger name="com.xuanyin" level="DEBUG"/>
|
||||
<root level="info">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
<appender-ref ref="info_async_file"/>
|
||||
@@ -125,7 +124,6 @@
|
||||
<!--开发环境:打印控制台-->
|
||||
<springProfile name="native">
|
||||
<logger name="com.accompany" level="DEBUG"/>
|
||||
<logger name="com.xuanyin" level="DEBUG"/>
|
||||
<root level="info">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
<appender-ref ref="info_async_file"/>
|
||||
|
@@ -32,8 +32,7 @@ import java.util.Properties;
|
||||
@Import({DataSourceAutoConfiguration.class})
|
||||
@MapperScan(value = {"com.accompany.business.mybatismapper",
|
||||
"com.accompany.community.mapper", "com.accompany.core.mybatismapper", "com.accompany.sms.mapper", "com.accompany.payment.mapper",
|
||||
"com.accompany.admin.mapper", // "com.accompany.flowteam.admin.mapper",
|
||||
"com.xuanyin.gamematch.mapper", "com.xuanyin.flowteam.mapper",
|
||||
"com.accompany.admin.mapper",
|
||||
"com.accompany.sharding.mapper"},
|
||||
sqlSessionFactoryRef="sqlSessionFactory")
|
||||
public class MybatisPlusConfig {
|
||||
|
@@ -5,8 +5,6 @@ import com.accompany.business.event.NewUserEvent;
|
||||
import com.accompany.business.service.invite.UserInviteCodeService;
|
||||
import com.accompany.core.model.Users;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xuanyin.flowteam.constant.FlowTeamConstant;
|
||||
import com.xuanyin.flowteam.service.FlowTeamMemberInviteUserBizService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
@@ -19,8 +17,6 @@ public class InviteCodeListener implements ApplicationListener<NewUserEvent> {
|
||||
|
||||
@Autowired
|
||||
private UserInviteCodeService userInviteCodeService;
|
||||
@Autowired
|
||||
private FlowTeamMemberInviteUserBizService flowTeamMemberInviteUserBizService;
|
||||
|
||||
@Async
|
||||
@Override
|
||||
@@ -31,10 +27,6 @@ public class InviteCodeListener implements ApplicationListener<NewUserEvent> {
|
||||
Long uid = user.getUid();
|
||||
// 初始化用户邀请码
|
||||
userInviteCodeService.initUserInviteCode(uid);
|
||||
|
||||
// 绑定与引流小组成员的邀请关系
|
||||
String inviteCode = user.getInviteCode();
|
||||
flowTeamMemberInviteUserBizService.saveFlowTeamMemberInviteUser(inviteCode, uid, FlowTeamConstant.UserSourceType.SELF);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* 文 件 名: FlowTeamBaseService
|
||||
* 版 权:
|
||||
* 描 述: <描述>
|
||||
* 创建人: H1
|
||||
* 创建时间: 2022/8/29
|
||||
* 修改人:
|
||||
* 修改内容:
|
||||
* 修改时间:
|
||||
*/
|
||||
package com.accompany.business.service.flow;
|
||||
|
||||
import com.accompany.common.utils.DateTimeUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <br>类描述:
|
||||
* <br>功能详细描述:
|
||||
*
|
||||
* @author H1
|
||||
* @date [2022/8/29]
|
||||
*/
|
||||
@Service
|
||||
public class FlowTeamBaseService {
|
||||
|
||||
/**
|
||||
* 获取引流后台查询用户数据的限制时间
|
||||
* @return
|
||||
*/
|
||||
public Date getFlowTeamUserLimitQueryDate() {
|
||||
// 限制查询时间为当前时间去年下个月的月初
|
||||
Date lastYear = DateTimeUtil.addYears(new Date(), -1);
|
||||
return DateTimeUtil.getBeginTimeOfMonth(DateTimeUtil.addMonth(lastYear, 1));
|
||||
}
|
||||
}
|
@@ -1,271 +0,0 @@
|
||||
/*
|
||||
* 文 件 名: FlowTeamSettlementService
|
||||
* 版 权:
|
||||
* 描 述: <描述>
|
||||
* 创建人: H1
|
||||
* 创建时间: 2021/11/11
|
||||
* 修改人:
|
||||
* 修改内容:
|
||||
* 修改时间:
|
||||
*/
|
||||
package com.accompany.business.service.flow;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.accompany.common.constant.Constant;
|
||||
import com.accompany.common.redis.RedisKey;
|
||||
import com.accompany.common.status.BusiStatus;
|
||||
import com.accompany.common.utils.DateTimeUtil;
|
||||
import com.accompany.common.utils.StringUtils;
|
||||
import com.accompany.core.exception.ServiceException;
|
||||
import com.accompany.core.service.common.JedisService;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.xuanyin.flowteam.dto.FlowTeamSettlementDetail;
|
||||
import com.xuanyin.flowteam.dto.FlowTeamSettlementInfoExportDto;
|
||||
import com.xuanyin.flowteam.dto.FlowTeamSettlementInfoVo;
|
||||
import com.xuanyin.flowteam.mapper.FlowTeamSettlementInfoMapper;
|
||||
import com.xuanyin.flowteam.mapper.FlowTeamSettlementInfoMapperExpand;
|
||||
import com.xuanyin.flowteam.model.FlowTeamInfo;
|
||||
import com.xuanyin.flowteam.model.FlowTeamSettlementInfo;
|
||||
import com.xuanyin.flowteam.service.FlowTeamInfoService;
|
||||
import com.xuanyin.flowteam.service.FlowTeamSettlementInfoService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.context.request.ServletWebRequest;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <br>类描述:
|
||||
* <br>功能详细描述:
|
||||
*
|
||||
* @author H1
|
||||
* @date [2021/11/11]
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class FlowTeamSettlementBizService {
|
||||
|
||||
@Autowired
|
||||
private FlowTeamSettlementInfoMapper flowTeamSettlementInfoMapper;
|
||||
@Autowired
|
||||
private FlowTeamSettlementInfoMapperExpand flowTeamSettlementInfoMapperExpand;
|
||||
@Autowired
|
||||
private FlowTeamSettlementInfoService flowTeamSettlementInfoService;
|
||||
@Autowired
|
||||
private JedisService jedisService;
|
||||
@Autowired
|
||||
private FlowTeamInfoService flowTeamInfoService;
|
||||
@Autowired
|
||||
private FlowTeamBaseService flowTeamBaseService;
|
||||
|
||||
public List<FlowTeamSettlementInfo> listTeamSettlementData(String teamIds) {
|
||||
if (StringUtils.isBlank(teamIds)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<String> teamIdList = Arrays.asList(teamIds.split(","));
|
||||
List<FlowTeamSettlementInfo> flowTeamSettlementInfos = flowTeamSettlementInfoMapper.listFlowTeamSettlementInfoV2(teamIdList, null, null);
|
||||
// 数据组合返回
|
||||
return buildResList(flowTeamSettlementInfos);
|
||||
}
|
||||
|
||||
public List<FlowTeamSettlementInfo> listTeamSettlementData(Long groupId, String teamIds) {
|
||||
List<String> teamIdList;
|
||||
if (groupId != null && StringUtils.isBlank(teamIds)) {
|
||||
List<FlowTeamInfo> groupTeams = flowTeamInfoService.listByGroupId(groupId);
|
||||
if (CollectionUtils.isEmpty(groupTeams)) {
|
||||
teamIdList = Collections.emptyList();
|
||||
} else {
|
||||
teamIdList = groupTeams.stream().map(FlowTeamInfo::getTeamId).collect(Collectors.toList());
|
||||
}
|
||||
} else {
|
||||
teamIdList = Arrays.asList(teamIds.split(","));
|
||||
}
|
||||
|
||||
List<FlowTeamSettlementInfo> flowTeamSettlementInfos =
|
||||
flowTeamSettlementInfoMapper.listFlowTeamSettlementInfoV2(teamIdList, null, null);
|
||||
// 数据组合返回
|
||||
return buildResList(flowTeamSettlementInfos);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取小组某月结算详情
|
||||
*
|
||||
* @param teamId
|
||||
* @param month
|
||||
* @param erbanNo
|
||||
* @return
|
||||
*/
|
||||
public PageInfo<FlowTeamSettlementDetail> listFlowTeamSettleDetail(String teamId, String month, String erbanNo, Integer page, Integer pageSize) {
|
||||
if (StringUtils.isBlank(teamId) || StringUtils.isBlank(month)) {
|
||||
return new PageInfo<>();
|
||||
}
|
||||
List<String> teamIdList = Arrays.asList(teamId.split(","));
|
||||
page = page == null ? Constant.DEFAULT_PAGE : page;
|
||||
pageSize = pageSize == null ? Constant.DEFAULT_PAGE_SIZE : pageSize;
|
||||
PageHelper.startPage(page, pageSize);
|
||||
List<FlowTeamSettlementDetail> details = flowTeamSettlementInfoMapper.listFlowTeamSettleDetailV2(teamIdList, month, erbanNo);
|
||||
PageInfo<FlowTeamSettlementDetail> pages = new PageInfo<>(details);
|
||||
return pages;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取小组某月结算详情V2 (按照用户进行分组统总)
|
||||
*
|
||||
* @param teamId
|
||||
* @param month
|
||||
* @param erbanNo
|
||||
* @return
|
||||
*/
|
||||
public PageInfo<FlowTeamSettlementDetail> listFlowTeamSettleDetailGroupByUser(String teamId, String month, String erbanNo,
|
||||
Integer page, Integer pageSize) {
|
||||
if (StringUtils.isBlank(teamId) || StringUtils.isBlank(month)) {
|
||||
return new PageInfo<>();
|
||||
}
|
||||
List<String> teamIdList = Arrays.asList(teamId.split(","));
|
||||
page = page == null ? Constant.DEFAULT_PAGE : page;
|
||||
pageSize = pageSize == null ? Constant.DEFAULT_PAGE_SIZE : pageSize;
|
||||
PageHelper.startPage(page, pageSize);
|
||||
Date limitQueryDate = flowTeamBaseService.getFlowTeamUserLimitQueryDate();
|
||||
List<FlowTeamSettlementDetail> details = flowTeamSettlementInfoMapper.listFlowTeamSettleDetailV3(teamIdList, month, erbanNo, null);
|
||||
return new PageInfo<>(details);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 固化引流小组往月的结算数据
|
||||
*/
|
||||
private List<FlowTeamSettlementInfo> initFlowTeamMonthSettlementData(String teamId) {
|
||||
String cacheKey = RedisKey.flow_team_settlement_init_lock.getKey(teamId);
|
||||
String lockKey = jedisService.lock(cacheKey, 3000, 10 * 1000);
|
||||
if (StringUtils.isBlank(lockKey)) {
|
||||
throw new ServiceException(BusiStatus.SERVERBUSY);
|
||||
}
|
||||
try {
|
||||
List<FlowTeamSettlementInfo> flowTeamSettlementInfos = flowTeamSettlementInfoMapper.listFlowTeamSettlementInfo(teamId, true, null);
|
||||
if (CollectionUtils.isEmpty(flowTeamSettlementInfos)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
flowTeamSettlementInfoService.saveBatch(flowTeamSettlementInfos);
|
||||
return flowTeamSettlementInfos;
|
||||
} finally {
|
||||
jedisService.unlock(cacheKey, lockKey);
|
||||
}
|
||||
}
|
||||
|
||||
private List<FlowTeamSettlementInfo> buildResList(List<FlowTeamSettlementInfo> settlementInfos) {
|
||||
List<FlowTeamSettlementInfo> resInfos = new ArrayList<>();
|
||||
// 获取当前时间前12个月
|
||||
ArrayList<String> last12Months = new ArrayList<>(Arrays.asList(getLast12Months()));
|
||||
List<String> month = settlementInfos.stream().map(FlowTeamSettlementInfo::getMonth).collect(Collectors.toList());
|
||||
last12Months.removeAll(month);
|
||||
List<FlowTeamSettlementInfo> withoutDataMonth = handleWithoutDataMonth(last12Months);
|
||||
resInfos.addAll(settlementInfos);
|
||||
resInfos.addAll(withoutDataMonth);
|
||||
resInfos = resInfos.stream().filter(v -> StrUtil.isNotEmpty(v.getMonth())).sorted(Comparator.comparing(FlowTeamSettlementInfo::getMonth).reversed()).collect(Collectors.toList());
|
||||
return resInfos;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理没有数据的月份
|
||||
*
|
||||
* @param withoutDataMonth
|
||||
* @return
|
||||
*/
|
||||
private List<FlowTeamSettlementInfo> handleWithoutDataMonth(List<String> withoutDataMonth) {
|
||||
List<FlowTeamSettlementInfo> infos = new ArrayList<>(withoutDataMonth.size());
|
||||
for (String month : withoutDataMonth) {
|
||||
FlowTeamSettlementInfo info = new FlowTeamSettlementInfo();
|
||||
info.setMonth(month);
|
||||
info.setNewUserNum(0);
|
||||
info.setNewUserChargeAmount(0.00);
|
||||
info.setTotalChargeAmount(0.00);
|
||||
info.setTotalChargeUserNum(0);
|
||||
info.setTotalChargeNum(0);
|
||||
infos.add(info);
|
||||
}
|
||||
return infos;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取最近12个月
|
||||
*/
|
||||
private static String[] getLast12Months() {
|
||||
String[] last12Months = new String[12];
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
|
||||
cal.set(Calendar.MONTH, cal.get(Calendar.MONTH) + 1); //要先+1,才能把本月的算进去
|
||||
|
||||
for (int i = 0; i < 12; i++) {
|
||||
cal.set(Calendar.MONTH, cal.get(Calendar.MONTH) - 1); //逐次往前推1个月
|
||||
|
||||
last12Months[11 - i] = cal.get(Calendar.YEAR) + "-" + fillZero((cal.get(Calendar.MONTH) + 1));
|
||||
}
|
||||
return last12Months;
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化月份
|
||||
*/
|
||||
private static String fillZero(int i) {
|
||||
String month = "";
|
||||
if (i < 10) {
|
||||
month = "0" + i;
|
||||
} else {
|
||||
month = String.valueOf(i);
|
||||
}
|
||||
return month;
|
||||
}
|
||||
|
||||
public void export(Long groupId, String teamId, ServletWebRequest servletWebRequest) {
|
||||
List<FlowTeamSettlementInfoVo> admins = flowTeamSettlementInfoMapperExpand.settlementExport(groupId, teamId);
|
||||
List<FlowTeamSettlementInfoExportDto> datas = new ArrayList<>();
|
||||
if (CollectionUtil.isNotEmpty(admins)) {
|
||||
for (FlowTeamSettlementInfoVo admin : admins) {
|
||||
FlowTeamSettlementInfoExportDto dto = new FlowTeamSettlementInfoExportDto();
|
||||
BeanUtils.copyProperties(admin, dto);
|
||||
Date signUpTime = admin.getSignUpTime();
|
||||
Date inviteTime = admin.getInviteTime();
|
||||
Date firstChargeTime = admin.getFirstChargeTime();
|
||||
Date firstGiveTime = admin.getFirstGiveTime();
|
||||
if (signUpTime != null) {
|
||||
dto.setSignUpTimeStr(DateTimeUtil.convertDate(signUpTime));
|
||||
}
|
||||
if (inviteTime != null) {
|
||||
dto.setInviteTimeStr(DateTimeUtil.convertDate(inviteTime));
|
||||
}
|
||||
if (firstChargeTime != null) {
|
||||
dto.setFirstChargeTimeStr(DateTimeUtil.convertDate(firstChargeTime));
|
||||
}
|
||||
if (firstGiveTime != null) {
|
||||
dto.setFirstGiveTimeStr(DateTimeUtil.convertDate(firstGiveTime));
|
||||
}
|
||||
datas.add(dto);
|
||||
}
|
||||
}
|
||||
if (servletWebRequest.getResponse() != null) {
|
||||
try {
|
||||
//这里注意 有同学反应使用swagger 会导致各种问题,请直接用浏览器或者用postman
|
||||
servletWebRequest.getResponse().setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
servletWebRequest.getResponse().setCharacterEncoding("utf-8");
|
||||
//这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
|
||||
String fileName = URLEncoder.encode("邀请用户", "UTF-8").replaceAll("\\+", "%20");
|
||||
servletWebRequest.getResponse().setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
|
||||
EasyExcel.write(servletWebRequest.getResponse().getOutputStream(), FlowTeamSettlementInfoExportDto.class)
|
||||
.sheet("邀请用户")
|
||||
.doWrite(datas);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -21,11 +21,11 @@ import org.springframework.boot.actuate.autoconfigure.metrics.MeterRegistryCusto
|
||||
@SpringBootApplication
|
||||
@EnableTransactionManagement
|
||||
@EnableAspectJAutoProxy(proxyTargetClass = true)
|
||||
@ComponentScan({"com.accompany","com.xuanyin"})
|
||||
@ServletComponentScan(value = {"com.accompany", "com.xuanyin"})
|
||||
@ComponentScan({"com.accompany"})
|
||||
@ServletComponentScan(value = {"com.accompany"})
|
||||
@EnableAsync(proxyTargetClass = true)
|
||||
@EnableScheduling
|
||||
@MapperScan({"com.accompany.*.mybatismapper","com.accompany.*.mapper", "com.xuanyin.*.mapper"})
|
||||
@MapperScan({"com.accompany.*.mybatismapper","com.accompany.*.mapper"})
|
||||
@SpringBootConfiguration
|
||||
public class BusinessApplication extends SpringBootServletInitializer {
|
||||
|
||||
|
@@ -83,7 +83,6 @@
|
||||
<!--开发环境:打印控制台-->
|
||||
<springProfile name="dev">
|
||||
<logger name="com.accompany" level="DEBUG"/>
|
||||
<logger name="com.xuanyin" level="DEBUG"/>
|
||||
<root level="info">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
<appender-ref ref="info_async_file"/>
|
||||
@@ -93,7 +92,6 @@
|
||||
|
||||
<springProfile name="native">
|
||||
<logger name="com.accompany" level="DEBUG"/>
|
||||
<logger name="com.xuanyin" level="DEBUG"/>
|
||||
<root level="info">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
<appender-ref ref="info_async_file"/>
|
||||
|
@@ -13,7 +13,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
@EnableDynamicTp
|
||||
@SpringBootApplication
|
||||
@ComponentScan("com.accompany")
|
||||
@ServletComponentScan(value = {"com.accompany", "com.xuanyin"})
|
||||
@ServletComponentScan(value = {"com.accompany"})
|
||||
@EnableScheduling
|
||||
@EnableAsync(proxyTargetClass = true)
|
||||
@MapperScan({"com.accompany.*.mapper","com.accompany.*.mybatismapper"})
|
||||
|
@@ -122,7 +122,6 @@
|
||||
|
||||
<springProfile name="native">
|
||||
<logger name="com.accompany" level="DEBUG"/>
|
||||
<logger name="com.xuanyin" level="DEBUG"/>
|
||||
<root level="info">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
<appender-ref ref="info_async_file"/>
|
||||
|
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* 文 件 名: SaveLastMonthDataTask
|
||||
* 版 权:
|
||||
* 描 述: <描述>
|
||||
* 创建人: H1
|
||||
* 创建时间: 2021/11/17
|
||||
* 修改人:
|
||||
* 修改内容:
|
||||
* 修改时间:
|
||||
*/
|
||||
package com.accompany.scheduler.task.flowteam;
|
||||
|
||||
import com.accompany.scheduler.base.BaseTask;
|
||||
import com.xuanyin.flowteam.service.FlowTeamSettlementInfoService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <br>类描述: 固化上个月结算数据
|
||||
* <br>功能详细描述:
|
||||
*
|
||||
* @author H1
|
||||
* @date [2021/11/17]
|
||||
*/
|
||||
//@Component
|
||||
@Slf4j
|
||||
public class SaveLastMonthSettlementDataTask extends BaseTask {
|
||||
|
||||
@Autowired
|
||||
private FlowTeamSettlementInfoService flowTeamSettlementInfoService;
|
||||
|
||||
/**
|
||||
* 每月1号00:00:00执行
|
||||
*/
|
||||
@Scheduled(cron = "0 0 0 1 * ?")
|
||||
public void saveLastMonthSettlementData() {
|
||||
log.info("start saveLastMonthSettlementData");
|
||||
// 获取存在往月固化数据的小组
|
||||
List<String> teamIds = flowTeamSettlementInfoService.listExsitDataTeamId();
|
||||
if (CollectionUtils.isEmpty(teamIds)) {
|
||||
return;
|
||||
}
|
||||
for (String teamId : teamIds) {
|
||||
flowTeamSettlementInfoService.saveLastMonthSettlementDataAsync(teamId);
|
||||
}
|
||||
}
|
||||
}
|
@@ -17,10 +17,10 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
*/
|
||||
@EnableDynamicTp
|
||||
@SpringBootApplication
|
||||
@ComponentScan({"com.accompany","com.xuanyin"})
|
||||
@ComponentScan({"com.accompany"})
|
||||
@EnableScheduling
|
||||
@EnableAsync(proxyTargetClass = true)
|
||||
@MapperScan({"com.accompany.*.mapper","com.accompany.*.mybatismapper", "com.xuanyin.*.mapper"})
|
||||
@MapperScan({"com.accompany.*.mapper","com.accompany.*.mybatismapper"})
|
||||
@SpringBootConfiguration
|
||||
public class JobApplication {
|
||||
|
||||
|
Reference in New Issue
Block a user