2025-01-13 10:54:30 +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.central.order.mapper.OrderMapper" >
2025-01-30 10:10:12 +08:00
2025-01-13 10:54:30 +08:00
<select id= "findList" resultType= "com.central.order.model.Order" >
2025-03-30 15:49:18 +08:00
select * from orders t
<where>
<if test= "p.orderNo != null and p.orderNo != ''" >
AND t.order_no LIKE CONCAT('%', #{p.orderNo}, '%')
</if>
2025-06-19 22:53:22 +08:00
<if test= "p.deviceSn != null and p.deviceSn != ''" >
AND t.deviceSn LIKE CONCAT('%', #{p.deviceSn}, '%')
</if>
2025-03-30 15:49:18 +08:00
<if test= "p.orderStatus != null" >
AND t.order_status = #{p.orderStatus}
</if>
</where>
ORDER BY t.id DESC
2025-01-13 10:54:30 +08:00
</select>
2025-01-18 19:05:51 +08:00
<!-- 动态获取参数采用备参 -->
<select id= "findListByUser" resultType= "com.central.order.model.Order" >
2025-07-16 21:58:09 +08:00
select id,order_no,tourism_id,device_sn,workspace_id,code_id,user_id,order_amount,order_status,create_time,update_time from orders t WHERE t.user_id = #{param2.userId}
2025-07-18 14:48:25 +08:00
<if test= "param2.orderStatusList != null and param2.orderStatusList.size() > 0" >
and t.order_status in
<foreach collection= "param2.orderStatusList" item= "status" open= "(" separator= "," close= ")" >
#{status}
</foreach>
2025-07-16 21:58:09 +08:00
</if>
ORDER BY id DESC
2025-01-18 19:05:51 +08:00
</select>
2025-01-13 10:54:30 +08:00
<!-- 根据订单状态查询订单列表 -->
<select id= "getOrdersByStatus" resultMap= "OrderResultMap" >
2025-01-20 09:29:33 +08:00
SELECT * FROM orders WHERE order_status = #{status} ORDER BY id DESC
2025-01-13 10:54:30 +08:00
</select>
<!-- 新增订单 -->
<insert id= "insertOrder" keyProperty= "order_id" useGeneratedKeys= "true" >
INSERT INTO orders (user_id, order_amount, order_status)
VALUES (#{userId}, #{orderAmount}, #{orderStatus})
</insert>
<!-- 根据订单编号查询订单信息 -->
<resultMap id= "OrderResultMap" type= "com.central.order.model.Order" ></resultMap>
<select id= "getOrderById" resultMap= "OrderResultMap" >
SELECT * FROM orders WHERE id = #{orderId}
</select>
<!-- 更新订单状态 -->
<update id= "updateOrderStatus" >
UPDATE orders
SET order_status = #{newStatus}
WHERE id = #{orderId}
</update>
<!-- 查询所有处于排队状态的订单 -->
<select id= "getOrdersInQueue" resultType= "com.central.order.model.Order" >
2025-01-25 13:21:29 +08:00
SELECT * FROM orders WHERE order_status = 1 order by id asc
2025-01-13 10:54:30 +08:00
</select>
<!-- 根据店铺编号和创建时间(当天)查询订单数量 -->
<select id= "findByShopIdAndCreateTimeGreaterThanEqualAndCreateTimeLessThanEqual" resultMap= "OrderResultMap" >
SELECT * FROM orders
WHERE tourism_id = #{tourismId}
AND create_time >= #{startDate}
AND create_time < = #{endDate}
</select>
<!-- 根据订单编号查询订单信息 -->
<select id= "getOrderByNumber" resultMap= "OrderResultMap" >
2025-01-21 10:31:51 +08:00
SELECT * FROM orders WHERE order_no = #{orderNumber}
2025-01-13 10:54:30 +08:00
</select>
2025-01-30 10:10:12 +08:00
2025-01-13 10:54:30 +08:00
</mapper>