后台-推广后台-修复数据问题

This commit is contained in:
khalil
2023-07-03 19:54:52 +08:00
parent 6b80358916
commit 92f90a3bd9
3 changed files with 77 additions and 54 deletions

View File

@@ -50,7 +50,8 @@
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
sum(case when gsr.total_gold_num is not null then gsr.total_gold_num else 0 end) /
10 total_send_gift
from account a, users u
left join gift_send_record gsr on u.uid = gsr.uid
where u.invite_code in
@@ -176,7 +177,10 @@
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
sum(case
when gsr.total_gold_num is not null
then gsr.total_gold_num
else 0 end) / 10 total_send_gift
from flow_team_member tm,
flow_team_member_invite_code ic,
user_invite_code uic,
@@ -277,9 +281,14 @@
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
sum(case when gsr.total_gold_num is not null then gsr.total_gold_num else 0 end) /
10 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) / 10 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) / 10 total_backbag_send_gift
from flow_team_member tm,
flow_team_member_invite_code ic,
user_invite_code uic,
@@ -334,7 +343,8 @@
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 u
from flow_team_member_invite_user ftmiu
inner join users u on ftmiu.uid = u.uid
left join charge_record cr
on cr.uid = u.uid and cr.charge_status = 2
and cr.charge_prod_id <> 'exchange' and cr.buss_type in (0,4)
@@ -353,10 +363,10 @@
</if>
where 1 =1
<if test="params.teamId != null ">
and u.team_id = #{params.teamId}
and ftmiu.team_id = #{params.teamId}
</if>
<if test="params.teamIds != null and params.teamIds.size > 0">
and u.team_id in
and ftmiu.team_id in
<foreach collection="params.teamIds" item="teamId" open="(" separator="," close=")">
#{teamId}
</foreach>
@@ -372,15 +382,17 @@
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_invite_user u
sum(case when gsr.total_gold_num is not null then gsr.total_gold_num else 0 end) /
10 total_send_gift
from flow_team_member_invite_user ftmiu
inner join users u on ftmiu.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="params.teamId != null ">
and u.team_id = #{params.teamId}
and ftmiu.team_id = #{params.teamId}
</if>
<if test="params.teamIds != null and params.teamIds.size > 0">
and u.team_id in
and ftmiu.team_id in
<foreach collection="params.teamIds" item="teamId" open="(" separator="," close=")">
#{teamId}
</foreach>
@@ -412,9 +424,10 @@
0 charge_count,
0 total_charge,
0 total_send_gift
from flow_team_member_invite_user u
left join flow_team_member tm on u.member_id = tm.member_id
where u.team_id = #{teamId}
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 &gt;= #{startDate}
</if>
@@ -433,8 +446,9 @@
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 u
left join flow_team_member tm on tm.member_id = u.member_id
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 = 2 and cr.charge_prod_id &lt;&gt; 'exchange' and cr.buss_type in (0,4)
and cr.create_time >= u.create_time
@@ -457,7 +471,7 @@
<if test="endDate != null and endDate != ''">
and u.create_time &lt; #{endDate}
</if>
and u.team_id = #{teamId}
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,
@@ -469,9 +483,13 @@
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
sum(case
when gsr.total_gold_num is not null
then gsr.total_gold_num
else 0 end) / 10 total_send_gift
from flow_team_member tm
left join flow_team_member_invite_user u on tm.member_id = u.member_id
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
@@ -481,7 +499,7 @@
<if test="endDate != null and endDate != ''">
and u.create_time &lt; #{endDate}
</if>
and u.team_id = #{teamId}
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;
@@ -509,8 +527,7 @@
0 total_send_gift,
0 total_no_backbag_send_gift,
0 total_backbag_send_gift
from
flow_team_member_invite_user u
from flow_team_member_invite_user u
left join account a on u.uid = a.uid
<if test="groupApps != null and groupApps.size > 0" >
and a.signup_app in
@@ -520,7 +537,7 @@
</if>
left join flow_team_member tm on u.member_id = tm.member_id
left join charge_record cr
on cr.uid = u.uid and cr.charge_status = 2 and cr.charge_prod_id &lt;&gt; 'exchange' and cr.create_time >= u.create_time
on cr.uid = u.uid and cr.charge_status = 2 and cr.charge_prod_id &lt;&gt; 'exchange'
and cr.buss_type in (0,4)
<if test="groupApps != null and groupApps.size > 0" >
and cr.charge_app in
@@ -543,10 +560,10 @@
and u.member_id = #{memberId}
</if>
<if test="startDate != null and startDate != ''">
and u.create_time &gt;= #{startDate}
and u1.create_time &gt;= #{startDate}
</if>
<if test="endDate != null and endDate != ''">
and u.create_time &lt; #{endDate}
and u1.create_time &lt; #{endDate}
</if>
<if test="groupId != null and endDate != ''">
and u.group_id = #{groupId}
@@ -561,11 +578,17 @@
u1.create_time,
u1.phone,
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_invite_user u
0 total_charge,
sum(case when gsr.total_gold_num is not null then gsr.total_gold_num else 0 end) /
10 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) / 10 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) / 10 total_backbag_send_gift
from
flow_team_member_invite_user u
left join account a on a.uid = u.uid
<if test="groupApps != null and groupApps.size > 0" >
and a.signup_app in
@@ -574,8 +597,8 @@
</foreach>
</if>
left join flow_team_member tm on u.member_id = tm.member_id
left join gift_send_record gsr on u.uid = gsr.uid and gsr.create_time >= u.create_time
left join users u1 on u.uid = u1.uid
left join gift_send_record 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}
@@ -584,10 +607,10 @@
and u.member_id = #{memberId}
</if>
<if test="startDate != null and startDate != ''">
and u.create_time &gt;= #{startDate}
and u1.create_time &gt;= #{startDate}
</if>
<if test="endDate != null and endDate != ''">
and u.create_time &lt; #{endDate}
and u1.create_time &lt; #{endDate}
</if>
<if test="groupId != null and endDate != ''">
and u.group_id = #{groupId}
@@ -596,5 +619,6 @@
) 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.uid, t.nick,t.create_time, a.register_ip, t.phone
order by t.create_time desc, t.invite_code
;
</select>
</mapper>

View File

@@ -10,9 +10,9 @@
*/
package com.xuanyin.flowteam.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xuanyin.flowteam.dto.FlowTeamSettlementDetail;
import com.xuanyin.flowteam.model.FlowTeamSettlementInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
@@ -55,8 +55,7 @@ public interface FlowTeamSettlementInfoMapper extends BaseMapper<FlowTeamSettlem
* @return
*/
List<FlowTeamSettlementInfo> listFlowTeamSettlementInfoV2(@Param("teamIds") List<String> teamIds, @Param("month") String month,
@Param("queryLimitTime") Date queryLimitTime
);
@Param("queryLimitTime") Date queryLimitTime);
/**
* 获取小组某月结算详情 (根据小组-组员-用户固化关系查询)
*

View File

@@ -97,10 +97,10 @@
sum(a.totalChargeAmount) totalChargeAmount, sum(a.totalChargeUserNum) totalChargeUserNum, sum(a.totalChargeNum) totalChargeNum
from (
-- 小组N月新增用户概况
select date_format(fm.create_time, '%Y-%m') month, count(distinct fm.uid) newUserNum, 0 newUserChargeAmount,
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
where 1=1
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=",">
@@ -113,10 +113,13 @@
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, charge_record r
where fi.uid = r.uid and r.charge_status = 2
and r.charge_prod_id != 'exchange'
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=",">
@@ -129,8 +132,7 @@
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
from flow_team_member_invite_user fi , charge_record r
where fi.uid = r.uid and r.charge_status = 2 and r.charge_prod_id != 'exchange'
and r.buss_type in (0,4)
<if test="queryLimitTime != null">
@@ -143,10 +145,10 @@
</foreach>
</if>
group by month, fi.team_id) a
group by a.month
<if test="month != null and month != ''">
having month = #{month}
</if>
group by a.month
<if test="month != null and month != ''">
having month = #{month}
</if>
order by a.month
;
</select>
@@ -180,17 +182,15 @@
fm.member_name inviteUserNick,
sum(r.amount /100) amount
from
charge_record r, flow_team_member fm, flow_team_member_invite_user fu
left join users u on fu.uid = u.uid
where fu.uid = r.uid and r.charge_status = 2 and r.charge_prod_id != 'exchange'
and fm.member_id = fu.member_id
charge_record r, flow_team_member fm, flow_team_member_invite_user fu, users u
where fm.member_id = fu.member_id and fu.uid = u.uid and u.uid = r.uid
<if test="teamIds != null and teamIds.size > 0">
and fu.team_id in
<foreach collection="teamIds" item="teamId" open="(" close=")" separator=",">
#{teamId}
</foreach>
</if>
and r.buss_type in (0,4)
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') = #{month}
<if test="queryLimitTime != null and queryLimitTime != ''">
and u.create_time >= #{queryLimitTime}