新增累计收到转赠统计
This commit is contained in:
@@ -58,9 +58,9 @@ public class FlowTeamSettlementInfoController extends BaseController {
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/listTeamSettlementData")
|
||||
public Pagination listTeamSettlementData(String teamId) {
|
||||
public Pagination<FlowTeamSettlementInfo> listTeamSettlementData(String teamId) {
|
||||
List<FlowTeamSettlementInfo> infos = flowTeamSettlementBizService.listTeamSettlementData(teamId);
|
||||
return new Pagination(infos.size(), infos);
|
||||
return new Pagination<FlowTeamSettlementInfo>(infos.size(), infos);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -67,27 +67,12 @@ public class FlowTeamSettlementBizService {
|
||||
@Autowired
|
||||
private FlowTeamBaseService flowTeamBaseService;
|
||||
|
||||
|
||||
@Transactional(rollbackFor = Exception.class, transactionManager = "mybatisplusTransactionManager")
|
||||
public List<FlowTeamSettlementInfo> listTeamSettlementData(String teamIds) {
|
||||
if (StringUtils.isBlank(teamIds)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<String> teamIdList = Arrays.asList(teamIds.split(","));
|
||||
|
||||
// // 获取往月的固化数据
|
||||
// List<FlowTeamSettlementInfo> oldMonthSettlementInfos = flowTeamSettlementInfoService.listByTeamId(teamId);
|
||||
// if (CollectionUtils.isEmpty(oldMonthSettlementInfos)) {
|
||||
// oldMonthSettlementInfos = initFlowTeamMonthSettlementData(teamId);
|
||||
// }
|
||||
// // 实时查询本月的结算数据
|
||||
// Date now = new Date();
|
||||
// String month = DateTimeUtil.convertDate(now, DateTimeUtil.DEFAULT_DATE_PATTERN_YEAR_MONTH);
|
||||
// List<FlowTeamSettlementInfo> currMonthSettlementInfo = flowTeamSettlementInfoMapper.listFlowTeamSettlementInfo(teamId, false, month);
|
||||
|
||||
List<FlowTeamSettlementInfo> flowTeamSettlementInfos =
|
||||
flowTeamSettlementInfoMapper.listFlowTeamSettlementInfoV2(teamIdList, null, null);
|
||||
|
||||
List<FlowTeamSettlementInfo> flowTeamSettlementInfos = flowTeamSettlementInfoMapper.listFlowTeamSettlementInfoV2(teamIdList, null, null);
|
||||
// 数据组合返回
|
||||
return buildResList(flowTeamSettlementInfos);
|
||||
}
|
||||
|
@@ -29,20 +29,35 @@ public class FlowTeamSettlementInfo {
|
||||
|
||||
@TableField(value = "month")
|
||||
private String month;
|
||||
|
||||
@TableField(value = "team_id")
|
||||
private String teamId;
|
||||
|
||||
@TableField(value = "new_user_num")
|
||||
private Integer newUserNum;
|
||||
|
||||
@TableField(value = "new_user_charge_amount")
|
||||
private Double newUserChargeAmount;
|
||||
|
||||
@TableField(value = "total_charge_amount")
|
||||
private Double totalChargeAmount;
|
||||
|
||||
@TableField(value = "total_charge_user_num")
|
||||
private Integer totalChargeUserNum;
|
||||
|
||||
@TableField(value = "total_charge_num")
|
||||
private Integer totalChargeNum;
|
||||
|
||||
@TableField(value = "total_give_num")
|
||||
private Integer totalGiveNum;
|
||||
|
||||
@TableField(value = "total_give_amount")
|
||||
private Double totalGiveAmount;
|
||||
|
||||
@TableField(value = "create_time")
|
||||
private Date createTime;
|
||||
|
||||
@TableField(value = "update_time")
|
||||
private Date updateTime;
|
||||
|
||||
}
|
||||
|
@@ -93,64 +93,113 @@
|
||||
</select>
|
||||
|
||||
<select id="listFlowTeamSettlementInfoV2" resultType="com.xuanyin.flowteam.model.FlowTeamSettlementInfo">
|
||||
select month, sum(a.newUserNum) newUserNum, sum(a.newUserChargeAmount) newUserChargeAmount,
|
||||
sum(a.totalChargeAmount) totalChargeAmount, sum(a.totalChargeUserNum) totalChargeUserNum, sum(a.totalChargeNum) totalChargeNum
|
||||
select
|
||||
a.`month`,
|
||||
sum(a.newUserNum) as newUserNum,
|
||||
sum(a.newUserChargeAmount) as newUserChargeAmount,
|
||||
sum(a.totalChargeAmount) as totalChargeAmount,
|
||||
sum(a.totalChargeUserNum) as totalChargeUserNum,
|
||||
sum(a.totalChargeNum) as totalChargeNum,
|
||||
sum(a.totalGiveNum) as totalGiveNum,
|
||||
sum(a.totalGiveAmount) as totalGiveAmount
|
||||
from (
|
||||
-- 小组N月新增用户概况
|
||||
select date_format(u.create_time, '%Y-%m') month, count(distinct fm.uid) newUserNum, 0 newUserChargeAmount,
|
||||
0 totalChargeAmount, 0 totalChargeUserNum, 0 totalChargeNum
|
||||
from flow_team_member_invite_user fm, users u
|
||||
where fm.uid = u.uid
|
||||
<if test="teamIds != null and teamIds.size > 0">
|
||||
and fm.team_id in
|
||||
<foreach collection="teamIds" item="teamId" open="(" close=")" separator=",">
|
||||
#{teamId}
|
||||
</foreach>
|
||||
</if>
|
||||
group by month
|
||||
union
|
||||
-- 小组N月新增用户充值概况
|
||||
select date_format(r.create_time, '%Y-%m') month, 0 newUserNum
|
||||
, ifnull(sum(r.amount / 100), 0) newUserChargeAmount , 0 totalChargeAmount, 0 totalChargeUserNum, 0 totalChargeNum
|
||||
from
|
||||
flow_team_member_invite_user fi, users u, charge_record r
|
||||
where fi.uid = r.uid
|
||||
and u.uid = r.uid
|
||||
and r.charge_status = 2
|
||||
and r.charge_prod_id != 'exchange'
|
||||
and r.buss_type in (0,4)
|
||||
and date_format(r.create_time, '%Y-%m') = date_format(u.create_time, '%Y-%m')
|
||||
<if test="teamIds != null and teamIds.size > 0">
|
||||
and fi.team_id in
|
||||
<foreach collection="teamIds" item="teamId" open="(" close=")" separator=",">
|
||||
#{teamId}
|
||||
</foreach>
|
||||
</if>
|
||||
group by month
|
||||
union
|
||||
-- 小组过去1年邀请的用户在N月的充值概况
|
||||
select date_format(r.create_time, '%Y-%m') month, 0 newUserNum ,
|
||||
0 newUserChargeAmount, ifnull(sum(r.amount/100), 0) totalChargeAmount,
|
||||
count(distinct r.uid) totalChargeUserNum, count(r.charge_record_id) totalChargeNum
|
||||
from flow_team_member_invite_user fi , charge_record r
|
||||
where fi.uid = r.uid and r.charge_status in (2,6) and r.charge_prod_id != 'exchange'
|
||||
and r.buss_type in (0,4)
|
||||
<if test="queryLimitTime != null">
|
||||
and r.create_time >= #{queryLimitTime}
|
||||
</if>
|
||||
<if test="teamIds != null and teamIds.size > 0">
|
||||
and fi.team_id in
|
||||
<foreach collection="teamIds" item="teamId" open="(" close=")" separator=",">
|
||||
#{teamId}
|
||||
</foreach>
|
||||
</if>
|
||||
group by month, fi.team_id) a
|
||||
group by a.month
|
||||
<if test="month != null and month != ''">
|
||||
having month = #{month}
|
||||
</if>
|
||||
order by a.month
|
||||
;
|
||||
select
|
||||
date_format(u.create_time, '%Y-%m') as `month`,
|
||||
count(distinct fm.uid) as newUserNum,
|
||||
0 as newUserChargeAmount,
|
||||
0 as totalChargeAmount,
|
||||
0 as totalChargeUserNum,
|
||||
0 as totalChargeNum,
|
||||
0 as totalGiveNum,
|
||||
0 as totalGiveAmount
|
||||
from flow_team_member_invite_user as fm, users as u
|
||||
where fm.uid = u.uid
|
||||
<if test="teamIds != null and teamIds.size > 0">
|
||||
and fm.team_id in
|
||||
<foreach collection="teamIds" item="teamId" open="(" close=")" separator=",">
|
||||
#{teamId}
|
||||
</foreach>
|
||||
</if>
|
||||
group by `month`
|
||||
union
|
||||
select
|
||||
date_format(r.create_time, '%Y-%m') as `month`,
|
||||
0 as newUserNum,
|
||||
ifnull(sum(r.amount / 100), 0) as newUserChargeAmount,
|
||||
0 as totalChargeAmount,
|
||||
0 as totalChargeUserNum,
|
||||
0 as totalChargeNum,
|
||||
0 as totalGiveNum,
|
||||
0 as totalGiveAmount
|
||||
from
|
||||
flow_team_member_invite_user as fi, users as u, charge_record as r
|
||||
where fi.uid = r.uid
|
||||
and u.uid = r.uid
|
||||
and r.charge_status = 2
|
||||
and r.charge_prod_id != 'exchange'
|
||||
and r.buss_type in (0,4)
|
||||
and date_format(r.create_time, '%Y-%m') = date_format(u.create_time, '%Y-%m')
|
||||
<if test="teamIds != null and teamIds.size > 0">
|
||||
and fi.team_id in
|
||||
<foreach collection="teamIds" item="teamId" open="(" close=")" separator=",">
|
||||
#{teamId}
|
||||
</foreach>
|
||||
</if>
|
||||
group by `month`
|
||||
union
|
||||
select
|
||||
date_format(r.create_time, '%Y-%m') as `month`,
|
||||
0 as newUserNum,
|
||||
0 as newUserChargeAmount,
|
||||
ifnull(sum(r.amount / 100), 0) as totalChargeAmount,
|
||||
count(distinct r.uid) as totalChargeUserNum,
|
||||
count(r.charge_record_id) as totalChargeNum,
|
||||
0 as totalGiveNum,
|
||||
0 as totalGiveAmount
|
||||
from flow_team_member_invite_user as fi, charge_record as r
|
||||
where fi.uid = r.uid
|
||||
and r.charge_status in (2,6)
|
||||
and r.charge_prod_id != 'exchange'
|
||||
and r.buss_type in (0,4)
|
||||
<if test="queryLimitTime != null">
|
||||
and r.create_time >= #{queryLimitTime}
|
||||
</if>
|
||||
<if test="teamIds != null and teamIds.size > 0">
|
||||
and fi.team_id in
|
||||
<foreach collection="teamIds" item="teamId" open="(" close=")" separator=",">
|
||||
#{teamId}
|
||||
</foreach>
|
||||
</if>
|
||||
group by `month`, fi.team_id
|
||||
union
|
||||
select
|
||||
date_format(dgh.create_time, '%Y-%m') as `month`,
|
||||
0 as newUserNum,
|
||||
0 as newUserChargeAmount,
|
||||
0 as totalChargeAmount,
|
||||
0 as totalChargeUserNum,
|
||||
0 as totalChargeNum,
|
||||
count(1) as totalGiveNum,
|
||||
ifnull(sum(dgh.diamond_num / 1000), 0) as totalGiveAmount
|
||||
from flow_team_member_invite_user as fi
|
||||
left join diamond_give_history as dgh on dgh.to_uid = fi.uid
|
||||
where 1 = 1
|
||||
<if test="queryLimitTime != null">
|
||||
and dgh.create_time >= #{queryLimitTime}
|
||||
</if>
|
||||
<if test="teamIds != null and teamIds.size > 0">
|
||||
and fi.team_id in
|
||||
<foreach collection="teamIds" item="teamId" open="(" close=")" separator=",">
|
||||
#{teamId}
|
||||
</foreach>
|
||||
</if>
|
||||
group by `month`, fi.team_id
|
||||
) as a
|
||||
group by a.`month`
|
||||
<if test="month != null and month != ''">
|
||||
having a.`month = #{month}
|
||||
</if>
|
||||
order by a.`month`
|
||||
</select>
|
||||
|
||||
<select id="listFlowTeamSettleDetailV2" resultType="com.xuanyin.flowteam.dto.FlowTeamSettlementDetail">
|
||||
|
Reference in New Issue
Block a user