数据统计
This commit is contained in:
@@ -50,4 +50,74 @@
|
||||
]]>
|
||||
</if>
|
||||
</select>
|
||||
<select id="getPayTypeAmountCount" resultType="java.util.Map">
|
||||
SELECT
|
||||
t1.pay_type as payType,
|
||||
sum(t1.pay_amount) as amount,
|
||||
sum(t1.refund_amount) as refund,
|
||||
count(case when t1.refund_amount>0 then 1 end) as refundCount,
|
||||
sum(t1.discount_amount) as discount,
|
||||
count(case when t1.discount_amount>0 then 1 end) as discountCount,
|
||||
count(*) as count
|
||||
FROM
|
||||
tb_order_info t1
|
||||
WHERE t1.shop_id = #{shopId}
|
||||
and t1.paid_time is not null
|
||||
<if test="beginDate != null and beginDate != ''">
|
||||
and t1.create_time >= str_to_date(concat(#{beginDate},' 00:00:00'), '%Y-%m-%d %H:%i:%s')
|
||||
</if>
|
||||
<if test="endDate != null and endDate != ''">
|
||||
<![CDATA[
|
||||
and t1.create_time <= str_to_date(concat(#{endDate},' 23:59:59'), '%Y-%m-%d %H:%i:%s')
|
||||
]]>
|
||||
</if>
|
||||
group by t1.pay_type
|
||||
</select>
|
||||
<select id="getVipRechargeAmountCount" resultType="java.util.Map">
|
||||
select
|
||||
t1.biz_code as bizCode,sum(t1.amount) as amount,count(*) as count
|
||||
from tb_shop_user_flow t1
|
||||
where t1.shop_id = #{shopId}
|
||||
<if test="beginDate != null and beginDate != ''">
|
||||
and t1.create_time >= str_to_date(concat(#{beginDate},' 00:00:00'), '%Y-%m-%d %H:%i:%s')
|
||||
</if>
|
||||
<if test="endDate != null and endDate != ''">
|
||||
<![CDATA[
|
||||
and t1.create_time <= str_to_date(concat(#{endDate},' 23:59:59'), '%Y-%m-%d %H:%i:%s')
|
||||
]]>
|
||||
</if>
|
||||
group by t1.biz_code
|
||||
</select>
|
||||
<select id="getCustomerUnitPrice" resultType="java.math.BigDecimal">
|
||||
SELECT
|
||||
ifnull((sum(t1.pay_amount)-sum(t1.refund_amount))/count(ifnull(case t1.seat_num when 0 then 1 end,1)),0.00) as customerUnitPrice
|
||||
FROM
|
||||
tb_order_info t1
|
||||
WHERE t1.shop_id = #{shopId}
|
||||
and t1.paid_time is not null
|
||||
<if test="beginDate != null and beginDate != ''">
|
||||
and t1.create_time >= str_to_date(concat(#{beginDate},' 00:00:00'), '%Y-%m-%d %H:%i:%s')
|
||||
</if>
|
||||
<if test="endDate != null and endDate != ''">
|
||||
<![CDATA[
|
||||
and t1.create_time <= str_to_date(concat(#{endDate},' 23:59:59'), '%Y-%m-%d %H:%i:%s')
|
||||
]]>
|
||||
</if>
|
||||
</select>
|
||||
<select id="getTableTurnoverRate" resultType="java.math.BigDecimal">
|
||||
SELECT
|
||||
ifnull((count(*)-count(DISTINCT t1.table_code))/count(DISTINCT t1.table_code)*100,0.00)
|
||||
FROM
|
||||
tb_order_info t1
|
||||
WHERE t1.shop_id = #{shopId}
|
||||
and t1.paid_time is not null
|
||||
<if test="beginDate != null and beginDate != ''">
|
||||
and t1.create_time >= str_to_date(concat(#{beginDate},' 00:00:00'), '%Y-%m-%d %H:%i:%s')
|
||||
</if>
|
||||
<if test="endDate != null and endDate != ''">
|
||||
<![CDATA[
|
||||
and t1.create_time <= str_to_date(concat(#{endDate},' 23:59:59'), '%Y-%m-%d %H:%i:%s')
|
||||
]]>
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -74,4 +74,88 @@
|
||||
group by t1.prod_id
|
||||
ORDER BY sum( t1.sale_count ) DESC,max(t1.id) DESC
|
||||
</select>
|
||||
<select id="getSaleSummaryCount2" resultType="com.czg.order.vo.SaleSummaryCountVo">
|
||||
SELECT
|
||||
sum(t1.pay_amount) as totalAmount,
|
||||
sum(t1.refund_amount) as refundAmount,
|
||||
count(*) as saleCount,
|
||||
count(case when t1.refund_amount > 0 then 1 end) as refundCount
|
||||
FROM
|
||||
tb_order_info t1
|
||||
left join (
|
||||
SELECT
|
||||
x1.order_id,
|
||||
concat( ',', GROUP_CONCAT( x2.category_id ), ',' ) AS category_id,
|
||||
GROUP_CONCAT( x1.product_name ) AS product_name
|
||||
FROM
|
||||
tb_order_detail x1
|
||||
LEFT JOIN tb_product x2 ON x1.product_id = x2.id
|
||||
GROUP BY x1.order_id
|
||||
) t2 on t1.id = t2.order_id
|
||||
where t1.shop_id = #{shopId}
|
||||
<if test="productName != null and productName != ''">
|
||||
and t2.product_name like concat('%', #{productName}, '%')
|
||||
</if>
|
||||
<if test="prodCategoryId != null">
|
||||
and t2.category_id like concat('%,', #{prodCategoryId}, ',%')
|
||||
</if>
|
||||
<if test="beginDate != null and beginDate != ''">
|
||||
and t1.create_time >= str_to_date(#{beginDate}, '%Y-%m-%d')
|
||||
</if>
|
||||
<if test="endDate != null and endDate != ''">
|
||||
<![CDATA[
|
||||
and t1.create_time <= str_to_date(#{endDate}, '%Y-%m-%d')
|
||||
]]>
|
||||
</if>
|
||||
</select>
|
||||
<select id="findSaleSummaryList2" resultType="com.czg.order.vo.SaleSummaryInfoVo">
|
||||
SELECT
|
||||
t1.product_id,
|
||||
t1.product_name as productName,
|
||||
t3.name as category_name,
|
||||
sum( t1.num ) AS saleCount,
|
||||
sum( t1.pay_amount ) AS saleAmount,
|
||||
sum( t1.return_num ) AS refundCount,
|
||||
sum( t1.return_amount ) AS refundAmount
|
||||
FROM
|
||||
tb_order_detail t1
|
||||
left join tb_product t2 on t1.product_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 t1.product_name like concat('%', #{productName}, '%')
|
||||
</if>
|
||||
<if test="prodCategoryId != null">
|
||||
and t2.category_id = #{prodCategoryId}
|
||||
</if>
|
||||
<if test="beginDate != null and beginDate != ''">
|
||||
and t1.create_time >= str_to_date(#{beginDate}, '%Y-%m-%d')
|
||||
</if>
|
||||
<if test="endDate != null and endDate != ''">
|
||||
<![CDATA[
|
||||
and t1.create_time <= str_to_date(#{endDate}, '%Y-%m-%d')
|
||||
]]>
|
||||
</if>
|
||||
GROUP BY t1.product_id,t1.product_name
|
||||
ORDER BY sum( t1.num ) DESC,max(t1.product_id) DESC
|
||||
</select>
|
||||
<select id="findProdRandingSummaryPage2" resultType="com.czg.order.vo.DataSummaryProductSaleRankingVo">
|
||||
select
|
||||
t1.product_id,
|
||||
t1.product_name,
|
||||
sum(t1.num) as number,
|
||||
sum(t1.pay_amount) as amount
|
||||
from tb_order_detail t1
|
||||
where t1.shop_id = #{shopId}
|
||||
<if test="beginDate != null and beginDate != ''">
|
||||
and t1.create_time >= str_to_date(#{beginDate}, '%Y-%m-%d')
|
||||
</if>
|
||||
<if test="endDate != null and endDate != ''">
|
||||
<![CDATA[
|
||||
and t1.create_time <= str_to_date(#{endDate}, '%Y-%m-%d')
|
||||
]]>
|
||||
</if>
|
||||
GROUP BY t1.product_id,t1.product_name
|
||||
order by sum(t1.num) desc
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user