zhwl/zhwl-business/zhwl-eatery/target/classes/mapper/eatery/ZdyEateryOrderMapper.xml

351 lines
14 KiB
XML
Raw Permalink Normal View History

2025-07-01 17:54:58 +08:00
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zhwl.eatery.mapper.ZdyEateryOrderMapper">
<resultMap type="ZdyEateryOrder" id="ZdyEateryOrderResult">
<result property="id" column="id"/>
<result property="customerId" column="customer_id"/>
<result property="customerName" column="customer_name"/>
<result property="tableId" column="table_id"/>
<result property="orderDate" column="order_date"/>
<result property="orderType" column="order_type"/>
<result property="orderStatus" column="order_status"/>
<result property="totalAmount" column="total_amount"/>
<result property="receivable" column="receivable"/>
<result property="discountAmount" column="discount_amount"/>
<result property="actualReceivedAmount" column="actual_received_amount"/>
<result property="changeAmount" column="change_amount"/>
<result property="zeroAmount" column="zero_amount"/>
<result property="paymentMethod" column="payment_method"/>
<result property="paymentStatus" column="payment_status"/>
<result property="productTotalCount" column="product_total_count"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="remark" column="remark"/>
<result property="merchantId" column="merchant_id"/>
<result property="shopName" column="shop_name"/>
<result property="shopAddress" column="shop_address"/>
<result property="shopPhone" column="shop_phone"/>
<result property="dinersCount" column="diners_count"/>
</resultMap>
<sql id="selectZdyEateryOrderVo">
select eo.id, eo.customer_id, eo.customer_name, eo.table_id, eo.order_date, eo.order_type, eo.order_status,
eo.total_amount, eo.receivable, eo.discount_amount, eo.actual_received_amount, eo.change_amount, eo.zero_amount,
eo.payment_method, eo.payment_status, eo.product_total_count, eo.create_by, eo.create_time, eo.update_by,
eo.update_time, eo.remark, eo.merchant_id, eo.shop_name, eo.shop_address, eo.shop_phone, eo.diners_count
from zdy_eatery_order eo
left join sys_dept d on eo.merchant_id = d.dept_id
</sql>
<select id="selectZdyEateryOrderList" parameterType="ZdyEateryOrder" resultMap="ZdyEateryOrderResult">
<include refid="selectZdyEateryOrderVo"/>
<where>
<if test="id != null ">
and id = #{id}
</if>
<if test="customerId != null ">
and customer_id = #{customerId}
</if>
<if test="customerName != null and customerName != ''">
and customer_name like concat('%', #{customerName}, '%')
</if>
<if test="tableId != null ">
and table_id = #{tableId}
</if>
<if test="orderDate != null ">
and order_date = #{orderDate}
</if>
<if test="orderType != null and orderType != ''">
and order_type = #{orderType}
</if>
<if test="orderStatus != null and orderStatus != ''">
and order_status = #{orderStatus}
</if>
<if test="totalAmount != null ">
and total_amount = #{totalAmount}
</if>
<if test="discountAmount != null ">
and discount_amount = #{discountAmount}
</if>
<if test="actualReceivedAmount != null ">
and actual_received_amount = #{actualReceivedAmount}
</if>
<if test="changeAmount != null ">
and change_amount = #{changeAmount}
</if>
<if test="zeroAmount != null ">
and zero_amount = #{zeroAmount}
</if>
<if test="paymentMethod != null and paymentMethod != ''">
and payment_method = #{paymentMethod}
</if>
<if test="paymentStatus != null and paymentStatus != ''">
and payment_status = #{paymentStatus}
</if>
<if test="productTotalCount != null ">
and product_total_count = #{productTotalCount}
</if>
<if test="merchantId != null ">
and merchant_id = #{merchantId}
</if>
<if test="params.beginTime != null and params.beginTime != '' and params.endTime != null and params.endTime != ''">
and order_date between #{params.beginTime} and #{params.endTime}
</if>
${params.dataScope}
</where>
order by order_date desc
</select>
<select id="selectZdyEateryOrderById" parameterType="String"
resultMap="ZdyEateryOrderResult">
<include refid="selectZdyEateryOrderVo"/>
where id = #{id}
</select>
<select id="statistics" resultType="com.alibaba.fastjson2.JSONObject">
SELECT
IFNULL(SUM(CASE WHEN a.order_status = 'completed' or a.order_status = 'allReturn' or a.order_status = 'partialReturn'
THEN 1 ELSE 0 END),0) AS sumOrder,
IFNULL(SUM(CASE WHEN a.order_status = 'completed' or a.order_status = 'refund' or a.order_status = 'allReturn' or
a.order_status = 'partialReturn' THEN a.receivable ELSE 0 END),0) AS turnover,
IFNULL(SUM(CASE WHEN a.order_status = 'allReturn' or a.order_status = 'partialReturn' THEN 1 ELSE 0 END),0) AS
sumRefundOrder,
IFNULL(SUM(CASE WHEN a.order_type = '2' THEN 1 ELSE 0 END),0) AS sumRefund
from (SELECT eo.*
FROM zdy_eatery_order eo
left join sys_dept d on eo.merchant_id = d.dept_id
<where>
<if test="id != null ">
and id = #{id}
</if>
<if test="merchantId != null ">
and merchant_id = #{merchantId}
</if>
<if test="params.beginTime != null and params.beginTime != '' and params.endTime != null and params.endTime != ''">
and order_date between #{params.beginTime} and #{params.endTime}
</if>
${params.dataScope}
</where>
) a
</select>
<insert id="insertZdyEateryOrder" parameterType="ZdyEateryOrder" useGeneratedKeys="true"
keyProperty="id">
insert into zdy_eatery_order
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,
</if>
<if test="refundId != null">refund_id,
</if>
<if test="customerId != null">customer_id,
</if>
<if test="customerName != null">customer_name,
</if>
<if test="tableId != null">table_id,
</if>
<if test="orderDate != null">order_date,
</if>
<if test="orderType != null">order_type,
</if>
<if test="orderStatus != null">order_status,
</if>
<if test="totalAmount != null">total_amount,
</if>
<if test="discountAmount != null">discount_amount,
</if>
<if test="actualReceivedAmount != null">actual_received_amount,
</if>
<if test="changeAmount != null">change_amount,
</if>
<if test="zeroAmount != null">zero_amount,
</if>
<if test="paymentMethod != null">payment_method,
</if>
<if test="paymentStatus != null">payment_status,
</if>
<if test="productTotalCount != null">product_total_count,
</if>
<if test="createBy != null">create_by,
</if>
<if test="createTime != null">create_time,
</if>
<if test="updateBy != null">update_by,
</if>
<if test="updateTime != null">update_time,
</if>
<if test="remark != null">remark,
</if>
<if test="merchantId != null">merchant_id,
</if>
<if test="shopName != null">shop_name,
</if>
<if test="shopAddress != null">shop_address,
</if>
<if test="shopPhone != null">shop_phone,
</if>
<if test="dinersCount != null">diners_count,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},
</if>
<if test="refundId != null">#{refundId},
</if>
<if test="customerId != null">#{customerId},
</if>
<if test="customerName != null">#{customerName},
</if>
<if test="tableId != null">#{tableId},
</if>
<if test="orderDate != null">#{orderDate},
</if>
<if test="orderType != null">#{orderType},
</if>
<if test="orderStatus != null">#{orderStatus},
</if>
<if test="totalAmount != null">#{totalAmount},
</if>
<if test="discountAmount != null">#{discountAmount},
</if>
<if test="actualReceivedAmount != null">#{actualReceivedAmount},
</if>
<if test="changeAmount != null">#{changeAmount},
</if>
<if test="zeroAmount != null">#{zeroAmount},
</if>
<if test="paymentMethod != null">#{paymentMethod},
</if>
<if test="paymentStatus != null">#{paymentStatus},
</if>
<if test="productTotalCount != null">#{productTotalCount},
</if>
<if test="createBy != null">#{createBy},
</if>
<if test="createTime != null">#{createTime},
</if>
<if test="updateBy != null">#{updateBy},
</if>
<if test="updateTime != null">#{updateTime},
</if>
<if test="remark != null">#{remark},
</if>
<if test="merchantId != null">#{merchantId},
</if>
<if test="shopName != null">#{shopName},
</if>
<if test="shopAddress != null">#{shopAddress},
</if>
<if test="shopPhone != null">#{shopPhone},
</if>
<if test="dinersCount != null">#{dinersCount},
</if>
</trim>
</insert>
<update id="updateZdyEateryOrder" parameterType="ZdyEateryOrder">
update zdy_eatery_order
<trim prefix="SET" suffixOverrides=",">
<if test="customerId != null">customer_id =
#{customerId},
</if>
<if test="customerName != null">customer_name =
#{customerName},
</if>
<if test="tableId != null">table_id =
#{tableId},
</if>
<if test="orderDate != null">order_date =
#{orderDate},
</if>
<if test="orderType != null">order_type =
#{orderType},
</if>
<if test="orderStatus != null">order_status =
#{orderStatus},
</if>
<if test="totalAmount != null">total_amount =
#{totalAmount},
</if>
<if test="receivable != null">receivable =
#{receivable},
</if>
<if test="discountAmount != null">discount_amount =
#{discountAmount},
</if>
<if test="actualReceivedAmount != null">actual_received_amount =
#{actualReceivedAmount},
</if>
<if test="changeAmount != null">change_amount =
#{changeAmount},
</if>
<if test="zeroAmount != null">zero_amount =
#{zeroAmount},
</if>
<if test="paymentMethod != null">payment_method =
#{paymentMethod},
</if>
<if test="paymentStatus != null">payment_status =
#{paymentStatus},
</if>
<if test="productTotalCount != null">product_total_count =
#{productTotalCount},
</if>
<if test="createBy != null">create_by =
#{createBy},
</if>
<if test="createTime != null">create_time =
#{createTime},
</if>
<if test="updateBy != null">update_by =
#{updateBy},
</if>
<if test="updateTime != null">update_time =
#{updateTime},
</if>
<if test="remark != null">remark =
#{remark},
</if>
<if test="shopName != null">shop_name =
#{shopName},
</if>
<if test="shopAddress != null">shop_address =
#{shopAddress},
</if>
<if test="shopPhone != null">shop_phone =
#{shopPhone},
</if>
<if test="dinersCount != null">diners_count =
#{dinersCount},
</if>
</trim>
where id = #{id}
<if test="merchantId != null">
and merchant_id = #{merchantId}
</if>
</update>
<delete id="deleteZdyEateryOrderById" parameterType="String">
delete from zdy_eatery_order where id = #{id}
</delete>
<delete id="deleteZdyEateryOrderByIds" parameterType="String">
delete from zdy_eatery_order where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="countByDeptIds" parameterType="long" resultType="int">
select count(id) from zdy_eatery_order where merchant_id in
<foreach item="deptId" collection="deptIds" open="(" separator="," close=")">
#{deptId}
</foreach>
</select>
</mapper>