数据统计

This commit is contained in:
Tankaikai
2025-03-12 10:42:43 +08:00
parent 8820338941
commit aef8116606
8 changed files with 80 additions and 25 deletions

View File

@@ -43,4 +43,35 @@
]]>
</if>
</select>
<select id="findSaleSummaryList" resultType="com.czg.order.vo.SaleSummaryInfoVo">
select
t1.prod_id,
max(t1.id) as id,
t2.NAME AS product_name,
t3.name as category_name,
sum(t1.sale_count) as sale_count,
sum(t1.sale_amount) as sale_amount,
sum(t1.refund_count) as refund_count,
sum(t1.refund_amount) as refund_amount
from tb_shop_prod_statistic t1
left join tb_product t2 on t1.prod_id = t2.id
left join tb_shop_prod_category t3 on t2.category_id = t3.id
where t1.shop_id = #{shopId}
<if test="productName != null and productName != ''">
and t2.name like concat('%', #{productName}, '%')
</if>
<if test="prodCategoryId != null">
and t2.category_id = #{prodCategoryId}
</if>
<if test="beginDate != null and beginDate != ''">
and t1.create_day >= str_to_date(#{beginDate}, '%Y-%m-%d')
</if>
<if test="endDate != null and endDate != ''">
<![CDATA[
and t1.create_day <= str_to_date(#{endDate}, '%Y-%m-%d')
]]>
</if>
group by t1.prod_id
ORDER BY sum( t1.sale_count ) DESC,max(t1.id) DESC
</select>
</mapper>