导粉进粉通过率统计,食谱计划生成优化
This commit is contained in:
@ -138,4 +138,21 @@
|
||||
where fwc.del_flag = 0 and fwc.import_fan_record_id = #{id}
|
||||
</select>
|
||||
|
||||
<!-- 根据时间范围统计各个渠道的总导粉数量 -->
|
||||
<select id="getTotalFanNumGroupByChannel" parameterType="SysWxFanStatistics" resultType="Map" >
|
||||
select s.channelId,acc.dict_label as channelName, s.totalFanNum from
|
||||
(
|
||||
select fr.import_fan_channel as channelId,sum(wa.import_fan_num) as totalFanNum from sys_import_fan_wx_account wa
|
||||
left join sys_import_fan_record fr on fr.id = wa.import_fan_record_id and fr.del_flag = 0
|
||||
where wa.del_flag = 0
|
||||
<if test="fanStartTime != null and fanEndTime != null">
|
||||
and fr.import_fan_date >= #{fanStartTime} and #{fanEndTime} >= fr.import_fan_date
|
||||
</if>
|
||||
group by fr.import_fan_channel
|
||||
)
|
||||
s LEFT JOIN (SELECT dict_label, dict_value FROM sys_dict_data WHERE dict_type = 'cus_account') AS acc ON acc.dict_value = s.channelId
|
||||
order by s.channelId asc
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
@ -218,5 +218,16 @@
|
||||
) ing USING(id)
|
||||
</select>
|
||||
|
||||
<!-- 根据 recipesId查询食谱具体每天详情 -->
|
||||
<select id="getRecipesListByRecipesId" parameterType="Long" resultType="SysRecipesDaily">
|
||||
SELECT id, num_day as numDay FROM sys_customer_daily_menu WHERE recipes_id = #{recipesId} order by num_day asc
|
||||
</select>
|
||||
|
||||
<update id="updateRecipesById" parameterType="SysRecipesDaily">
|
||||
update sys_customer_daily_menu
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="numDay != null">num_day = #{numDay},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
</mapper>
|
@ -287,13 +287,13 @@
|
||||
|
||||
<!-- 查询食谱计划中对应食谱存在天数缺失的食谱计划,食谱计划发生变化时,可能会导致sys_customer_daily_menu表中天数缺失,需要查询出来进行补充 -->
|
||||
<select id="getNeedSupplyRecipesByCusId" parameterType="Long" resultType="Map">
|
||||
select plan.recipes_id as recipesId,plan.end_num_day as enNumDay,s.maxNumDay from sys_recipes_plan as plan left join
|
||||
|
||||
select plan.cus_id as cusId,plan.recipes_id as recipesId,plan.start_num_day as startNumDay, plan.end_num_day as endNumDay from sys_recipes_plan as plan left join
|
||||
(
|
||||
select recipes_id,count(1) as dayNum,max(num_day) as maxNumDay from sys_customer_daily_menu where cus_id = #{cusId} and recipes_id is not null group by recipes_id
|
||||
select recipes_id,count(1) as dayNum,min(num_day) as minNumDay,max(num_day) as maxNumDay from sys_customer_daily_menu where cus_id = #{cusId} and recipes_id is not null group by recipes_id
|
||||
)
|
||||
as s on s.recipes_id = plan.recipes_id
|
||||
|
||||
where plan.cus_id = #{cusId} and plan.del_flag = 0 and plan.recipes_id is not null and plan.end_num_day > s.maxNumDay
|
||||
where plan.cus_id = #{cusId} and plan.del_flag = 0 and plan.recipes_id is not null and (s.minNumDay <![CDATA[ <> ]]> plan.start_num_day or s.maxNumDay <![CDATA[ <> ]]> plan.end_num_day)
|
||||
order by plan.start_num_day asc
|
||||
</select>
|
||||
</mapper>
|
@ -153,4 +153,22 @@
|
||||
<if test="wxId != null">and swfs.wx_id = #{wxId}</if>
|
||||
</select>
|
||||
|
||||
<!-- 根据时间范围统计每个渠道的总进粉量 -->
|
||||
<select id="getTotalFanNumGroupByChannel" parameterType="SysWxFanStatistics" resultType="Map">
|
||||
select s.channelId,acc.dict_label as channelName,s.totalFanNum from
|
||||
(
|
||||
select
|
||||
swd.account_id as channelId, sum(swfs.fan_num) as totalFanNum
|
||||
from sys_wx_fan_statistics swfs
|
||||
left join sys_wx_distribution swd on swd.wechat_account = swfs.wx_id and swd.del_flag = 0
|
||||
where swfs.del_flag = 0
|
||||
<if test="fanStartTime != null and fanEndTime != null">
|
||||
and swfs.fan_time >= #{fanStartTime} and #{fanEndTime} >= swfs.fan_time
|
||||
</if>
|
||||
group by swd.account_id
|
||||
) s
|
||||
LEFT JOIN (SELECT dict_label, dict_value FROM sys_dict_data WHERE dict_type = 'cus_account') AS acc ON acc.dict_value = s.channelId
|
||||
order by s.channelId asc
|
||||
</select>
|
||||
|
||||
</mapper>
|
Reference in New Issue
Block a user