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

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

View File

@@ -10,9 +10,9 @@
*/ */
package com.xuanyin.flowteam.mapper; package com.xuanyin.flowteam.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xuanyin.flowteam.dto.FlowTeamSettlementDetail; import com.xuanyin.flowteam.dto.FlowTeamSettlementDetail;
import com.xuanyin.flowteam.model.FlowTeamSettlementInfo; import com.xuanyin.flowteam.model.FlowTeamSettlementInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.Date; import java.util.Date;
@@ -55,8 +55,7 @@ public interface FlowTeamSettlementInfoMapper extends BaseMapper<FlowTeamSettlem
* @return * @return
*/ */
List<FlowTeamSettlementInfo> listFlowTeamSettlementInfoV2(@Param("teamIds") List<String> teamIds, @Param("month") String month, 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 sum(a.totalChargeAmount) totalChargeAmount, sum(a.totalChargeUserNum) totalChargeUserNum, sum(a.totalChargeNum) totalChargeNum
from ( from (
-- 小组N月新增用户概况 -- 小组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 0 totalChargeAmount, 0 totalChargeUserNum, 0 totalChargeNum
from flow_team_member_invite_user fm from flow_team_member_invite_user fm, users u
where 1=1 where fm.uid = u.uid
<if test="teamIds != null and teamIds.size > 0"> <if test="teamIds != null and teamIds.size > 0">
and fm.team_id in and fm.team_id in
<foreach collection="teamIds" item="teamId" open="(" close=")" separator=","> <foreach collection="teamIds" item="teamId" open="(" close=")" separator=",">
@@ -113,10 +113,13 @@
select date_format(r.create_time, '%Y-%m') month, 0 newUserNum select date_format(r.create_time, '%Y-%m') month, 0 newUserNum
, ifnull(sum(r.amount / 100), 0) newUserChargeAmount , 0 totalChargeAmount, 0 totalChargeUserNum, 0 totalChargeNum , ifnull(sum(r.amount / 100), 0) newUserChargeAmount , 0 totalChargeAmount, 0 totalChargeUserNum, 0 totalChargeNum
from from
flow_team_member_invite_user fi, charge_record r flow_team_member_invite_user fi, users u, charge_record r
where fi.uid = r.uid and r.charge_status = 2 where fi.uid = r.uid
and r.charge_prod_id != 'exchange' and u.uid = r.uid
and r.charge_status = 2
and r.charge_prod_id != 'exchange'
and r.buss_type in (0,4) 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"> <if test="teamIds != null and teamIds.size > 0">
and fi.team_id in and fi.team_id in
<foreach collection="teamIds" item="teamId" open="(" close=")" separator=","> <foreach collection="teamIds" item="teamId" open="(" close=")" separator=",">
@@ -129,8 +132,7 @@
select date_format(r.create_time, '%Y-%m') month, 0 newUserNum , select date_format(r.create_time, '%Y-%m') month, 0 newUserNum ,
0 newUserChargeAmount, ifnull(sum(r.amount/100), 0) totalChargeAmount, 0 newUserChargeAmount, ifnull(sum(r.amount/100), 0) totalChargeAmount,
count(distinct r.uid) totalChargeUserNum, count(r.charge_record_id) totalChargeNum count(distinct r.uid) totalChargeUserNum, count(r.charge_record_id) totalChargeNum
from from flow_team_member_invite_user fi , charge_record r
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' where fi.uid = r.uid and r.charge_status = 2 and r.charge_prod_id != 'exchange'
and r.buss_type in (0,4) and r.buss_type in (0,4)
<if test="queryLimitTime != null"> <if test="queryLimitTime != null">
@@ -143,10 +145,10 @@
</foreach> </foreach>
</if> </if>
group by month, fi.team_id) a group by month, fi.team_id) a
group by a.month group by a.month
<if test="month != null and month != ''"> <if test="month != null and month != ''">
having month = #{month} having month = #{month}
</if> </if>
order by a.month order by a.month
; ;
</select> </select>
@@ -180,17 +182,15 @@
fm.member_name inviteUserNick, fm.member_name inviteUserNick,
sum(r.amount /100) amount sum(r.amount /100) amount
from from
charge_record r, flow_team_member fm, flow_team_member_invite_user fu charge_record r, flow_team_member fm, flow_team_member_invite_user fu, users u
left join users u on fu.uid = u.uid where fm.member_id = fu.member_id and fu.uid = u.uid and u.uid = r.uid
where fu.uid = r.uid and r.charge_status = 2 and r.charge_prod_id != 'exchange'
and fm.member_id = fu.member_id
<if test="teamIds != null and teamIds.size > 0"> <if test="teamIds != null and teamIds.size > 0">
and fu.team_id in and fu.team_id in
<foreach collection="teamIds" item="teamId" open="(" close=")" separator=","> <foreach collection="teamIds" item="teamId" open="(" close=")" separator=",">
#{teamId} #{teamId}
</foreach> </foreach>
</if> </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} and date_format(r.create_time, '%Y-%m') = #{month}
<if test="queryLimitTime != null and queryLimitTime != ''"> <if test="queryLimitTime != null and queryLimitTime != ''">
and u.create_time >= #{queryLimitTime} and u.create_time >= #{queryLimitTime}