This commit is contained in:
zhaohengkun 2024-10-24 18:10:18 +08:00
parent 03673579f5
commit f035fda9e1
2 changed files with 42 additions and 187 deletions

View File

@ -2,7 +2,8 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.fuint.business.order.mapper.CashierOrderMapper">
<sql id="selectOrders">
select * from cashier_order
select *
from cashier_order
</sql>
<select id="selectCashierOrderList" resultType="com.fuint.business.order.entity.CashierOrder">
@ -35,33 +36,33 @@
</select>
<select id="selectCashierOrderById" resultType="com.fuint.business.order.vo.CashierOrderVo"
parameterType="int">
select co.*,st.real_name,st.mobile from cashier_order co
left join mt_staff st on co.staff_id = st.id
where co.id = #{id}
select co.*, st.real_name, st.mobile
from cashier_order co
left join mt_staff st on co.staff_id = st.id
where co.id = #{id}
</select>
<select id="selectCashierOrderListExport" resultType="com.fuint.business.order.vo.Excel.CashierOrderExcel">
select
st.real_name realName,
st.mobile,
co.order_no orderNo,
co.amount amount,
co.pay_amount payAmount,
co.oil_order_amount oilOrderAmount,
co.goods_order_amount goodsOrderAmount,
co.pay_user payUser,
CASE
WHEN co.status = 'paid' THEN '已支付'
WHEN co.status = 'payFail' THEN '支付失败'
WHEN co.status = 'unpaid' THEN '未支付'
WHEN co.status = 'refund' THEN '已退款'
ELSE '未知'
END AS status,
co.pay_time payTime
st.real_name realName,
st.mobile,
co.order_no orderNo,
co.amount amount,
co.pay_amount payAmount,
co.oil_order_amount oilOrderAmount,
co.goods_order_amount goodsOrderAmount,
co.pay_user payUser,
CASE
WHEN co.status = 'paid' THEN '已支付'
WHEN co.status = 'payFail' THEN '支付失败'
WHEN co.status = 'unpaid' THEN '未支付'
WHEN co.status = 'refund' THEN '已退款'
ELSE '未知'
END AS status,
co.pay_time payTime
from cashier_order co
left join mt_staff st on co.staff_id = st.id
left join mt_staff st on co.staff_id = st.id
<where>
co.store_id = #{order.storeId}
<if test="order.staffId != null and order.staffId != ''">
@ -79,36 +80,23 @@
<if test="order.params.endTime != null and order.params.endTime != ''"><!-- 结束时间检索 -->
and date_format(pay_time,'%y%m%d') &lt;= date_format(#{order.params.endTime},'%y%m%d')
</if>
order by co.create_time Desc
order by co.create_time Desc
</where>
</select>
<select id="orderStatistics" resultType="java.util.Map">
SELECT
(SELECT count(*) FROM cashier_order
<where>
store_id = #{order.storeId}
<if test="order.staffId != null and order.staffId != ''">
and staff_id = #{order.staffId}
</if>
<if test="order.orderNo != null and order.orderNo != ''">
and order_no like concat('%', #{order.orderNo}, '%')
</if>
<if test="order.terminal != null and order.terminal != ''">
and terminal like concat('%', #{order.terminal}, '%')
</if>
<if test="order.params.beginTime != null and order.params.beginTime != ''">
and date_format(pay_time,'%y%m%d') &gt;= date_format(#{order.params.beginTime},'%y%m%d')
</if>
<if test="order.params.endTime != null and order.params.endTime != ''">
and date_format(pay_time,'%y%m%d') &lt;= date_format(#{order.params.endTime},'%y%m%d')
</if>
</where>
) AS numberOfStrokes, -- 笔数
(SELECT count(*) FROM cashier_order
select
count(*) as s1, -- 订单总笔数
sum(amount) as s2, -- 订单总金额
sum(pay_amount) as s3, -- 实付总金额
sum(goods_discount_amount + oil_discount_amount) as s4, -- 总优惠
sum(seek_zero) as s5 , -- 总找零
sum(CASE WHEN oil_order_amount > 0 THEN oil_pay_amount ELSE 0 END) AS s6, -- 油品订单实付
count(CASE WHEN oil_order_amount > 0 THEN 1 ELSE null END) AS s7 , -- 油品订单数量
sum(CASE WHEN goods_order_amount > 0 THEN goods_pay_amount ELSE 0 END) AS s8, -- 商品订单实付
count(CASE WHEN goods_order_amount > 0 THEN 1 ELSE null END) AS s9 -- 商品订单数量
from cashier_order
<where>
store_id = #{order.storeId}
and oil_order_id is not null
<if test="order.staffId != null and order.staffId != ''">
and staff_id = #{order.staffId}
</if>
@ -124,132 +112,9 @@
<if test="order.params.endTime != null and order.params.endTime != ''">
and date_format(pay_time,'%y%m%d') &lt;= date_format(#{order.params.endTime},'%y%m%d')
</if>
</where>
) AS numberOfStrokesByOil, -- 笔数
(SELECT count(*) FROM cashier_order
<where>
store_id = #{order.storeId}
and goods_order_id is not null
<if test="order.staffId != null and order.staffId != ''">
and staff_id = #{order.staffId}
</if>
<if test="order.orderNo != null and order.orderNo != ''">
and order_no like concat('%', #{order.orderNo}, '%')
</if>
<if test="order.terminal != null and order.terminal != ''">
and terminal like concat('%', #{order.terminal}, '%')
</if>
<if test="order.params.beginTime != null and order.params.beginTime != ''">
and date_format(pay_time,'%y%m%d') &gt;= date_format(#{order.params.beginTime},'%y%m%d')
</if>
<if test="order.params.endTime != null and order.params.endTime != ''">
and date_format(pay_time,'%y%m%d') &lt;= date_format(#{order.params.endTime},'%y%m%d')
</if>
</where>
) AS numberOfStrokesByGoods, -- 笔数
(SELECT sum(amount) FROM cashier_order
<where>
store_id = #{order.storeId}
<if test="order.staffId != null and order.staffId != ''">
and staff_id = #{order.staffId}
</if>
<if test="order.orderNo != null and order.orderNo != ''">
and order_no like concat('%', #{order.orderNo}, '%')
</if>
<if test="order.terminal != null and order.terminal != ''">
and terminal like concat('%', #{order.terminal}, '%')
</if>
<if test="order.params.beginTime != null and order.params.beginTime != ''">
and date_format(pay_time,'%y%m%d') &gt;= date_format(#{order.params.beginTime},'%y%m%d')
</if>
<if test="order.params.endTime != null and order.params.endTime != ''">
and date_format(pay_time,'%y%m%d') &lt;= date_format(#{order.params.endTime},'%y%m%d')
</if>
</where>
) AS theTotalAmountOfTheOrder, -- 订单总金额
(SELECT sum(pay_amount) FROM cashier_order
<where>
store_id = #{order.storeId}
<if test="order.staffId != null and order.staffId != ''">
and staff_id = #{order.staffId}
</if>
<if test="order.orderNo != null and order.orderNo != ''">
and order_no like concat('%', #{order.orderNo}, '%')
</if>
<if test="order.terminal != null and order.terminal != ''">
and terminal like concat('%', #{order.terminal}, '%')
</if>
<if test="order.params.beginTime != null and order.params.beginTime != ''">
and date_format(pay_time,'%y%m%d') &gt;= date_format(#{order.params.beginTime},'%y%m%d')
</if>
<if test="order.params.endTime != null and order.params.endTime != ''">
and date_format(pay_time,'%y%m%d') &lt;= date_format(#{order.params.endTime},'%y%m%d')
</if>
</where>
) AS theTotalAmountPaid, -- 实付总金额
(SELECT sum(oil_discount_amount) FROM cashier_order
<where>
store_id = #{order.storeId}
<if test="order.staffId != null and order.staffId != ''">
and staff_id = #{order.staffId}
</if>
<if test="order.orderNo != null and order.orderNo != ''">
and order_no like concat('%', #{order.orderNo}, '%')
</if>
<if test="order.terminal != null and order.terminal != ''">
and terminal like concat('%', #{order.terminal}, '%')
</if>
<if test="order.params.beginTime != null and order.params.beginTime != ''"><!-- 开始时间检索 -->
and date_format(pay_time,'%y%m%d') &gt;= date_format(#{order.params.beginTime},'%y%m%d')
</if>
<if test="order.params.endTime != null and order.params.endTime != ''"><!-- 结束时间检索 -->
and date_format(pay_time,'%y%m%d') &lt;= date_format(#{order.params.endTime},'%y%m%d')
</if>
order by pay_time desc
</where>
) AS oilDiscounts, -- 油品优惠
(SELECT sum(oil_order_amount) FROM cashier_order
<where>
store_id = #{order.storeId}
<if test="order.staffId != null and order.staffId != ''">
and staff_id = #{order.staffId}
</if>
<if test="order.orderNo != null and order.orderNo != ''">
and order_no like concat('%', #{order.orderNo}, '%')
</if>
<if test="order.terminal != null and order.terminal != ''">
and terminal like concat('%', #{order.terminal}, '%')
</if>
<if test="order.params.beginTime != null and order.params.beginTime != ''"><!-- 开始时间检索 -->
and date_format(pay_time,'%y%m%d') &gt;= date_format(#{order.params.beginTime},'%y%m%d')
</if>
<if test="order.params.endTime != null and order.params.endTime != ''"><!-- 结束时间检索 -->
and date_format(pay_time,'%y%m%d') &lt;= date_format(#{order.params.endTime},'%y%m%d')
</if>
order by pay_time desc
</where>
) AS theTotalAmountOfOil, -- 油品总金额
(SELECT sum(goods_order_amount) FROM cashier_order
<where>
store_id = #{order.storeId}
<if test="order.staffId != null and order.staffId != ''">
and staff_id = #{order.staffId}
</if>
<if test="order.orderNo != null and order.orderNo != ''">
and order_no like concat('%', #{order.orderNo}, '%')
</if>
<if test="order.terminal != null and order.terminal != ''">
and terminal like concat('%', #{order.terminal}, '%')
</if>
<if test="order.params.beginTime != null and order.params.beginTime != ''"><!-- 开始时间检索 -->
and date_format(pay_time,'%y%m%d') &gt;= date_format(#{order.params.beginTime},'%y%m%d')
</if>
<if test="order.params.endTime != null and order.params.endTime != ''"><!-- 结束时间检索 -->
and date_format(pay_time,'%y%m%d') &lt;= date_format(#{order.params.endTime},'%y%m%d')
</if>
order by pay_time desc
</where>
) AS theTotalAmountOfTheItem -- 商品总金额
</select>
<select id="selectCashierOrderSeekZeroAmount" resultType="java.lang.Double">
@ -274,15 +139,6 @@
order by create_time desc
</where>
</select>
<!-- <select id="orderStatistics" resultType="java.util.Map">-->
<!-- SELECT-->
<!-- (SELECT count(*) FROM cashier_order) AS 笔数,-->
<!-- (SELECT sum(amount) FROM cashier_order) AS 订单总金额,-->
<!-- (SELECT sum(pay_amount) FROM cashier_order) AS 实付总金额,-->
<!-- (SELECT sum(oil_discount_amount) FROM cashier_order) AS 油品优惠,-->
<!-- (SELECT sum(oil_order_amount) FROM cashier_order) AS 油品总金额,-->
<!-- (SELECT sum(goods_order_amount) FROM cashier_order) AS 商品总金额-->
<!-- </select>-->
</mapper>

View File

@ -65,7 +65,7 @@
<div class="box-gang">
<div class="box2">
<div style="font-size: 26px;color: #0DC291;font-weight: bold;margin-top: 5px">
{{ orderStatistics.theTotalAmountOfTheOrder ? orderStatistics.theTotalAmountOfTheOrder : 0 }}/{{ orderStatistics.numberOfStrokes ? orderStatistics.numberOfStrokes : 0 }}
{{ orderStatistics.s2 || 0 }}/{{ orderStatistics.s1 || 0 }}
</div>
<div class="size-hui">
<div style="width: 8px;height: 8px;border-radius: 4px;background: #0DC291"></div>
@ -74,7 +74,7 @@
</div>
<div class="box2">
<div style="font-size: 26px;color: #00CAFF;font-weight: bold;margin-top: 5px">
{{ orderStatistics.theTotalAmountPaid ? orderStatistics.theTotalAmountPaid : 0 }}
{{ orderStatistics.s3 || 0 }}
</div>
<div class="size-hui">
<div style="width: 8px;height: 8px;border-radius: 4px;background: #00CAFF"></div>
@ -83,7 +83,7 @@
</div>
<div class="box2">
<div style="font-size: 26px;color: #F44522;font-weight: bold;margin-top: 5px">
{{ orderStatistics.oilDiscounts ? orderStatistics.oilDiscounts : 0 }}/{{ seekZeroAmount }}
{{ orderStatistics.s4 || 0}}/{{ orderStatistics.s5 || 0 }}
</div>
<div class="size-hui">
<div style="width: 8px;height: 8px;border-radius: 4px;background: #F44522"></div>
@ -92,7 +92,7 @@
</div>
<div class="box2">
<div style="font-size: 26px;color: #FA6400;font-weight: bold;margin-top: 5px">
{{ orderStatistics.numberOfStrokesByOil ? orderStatistics.numberOfStrokesByOil : 0 }}/{{ orderStatistics.theTotalAmountOfOil ? orderStatistics.theTotalAmountOfOil : 0 }}
{{ orderStatistics.s7 || 0}}/{{ orderStatistics.s6 || 0}}
</div>
<div class="size-hui">
<div style="width: 8px;height: 8px;border-radius: 4px;background: #FA6400"></div>
@ -101,8 +101,7 @@
</div>
<div class="box2">
<div style="font-size: 26px;color: #FE59E5;font-weight: bold;margin-top: 5px">
{{ orderStatistics.numberOfStrokesByGoods ? orderStatistics.numberOfStrokesByGoods : 0 }}/{{ orderStatistics.theTotalAmountOfTheItem ? orderStatistics.theTotalAmountOfTheItem : 0 }}
</div>
{{ orderStatistics.s9 || 0}}/{{ orderStatistics.s8 || 0}} </div>
<div class="size-hui">
<div style="width: 8px;height: 8px;border-radius: 4px;background: #FE59E5"></div>
<div style="font-weight: bold;font-size: 13px;margin-left: 5px">商品订单/实付总金额</div>