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-08-06 10:41:44 +08:00
SELECT o.*, t.tourism_name as tourismName
FROM orders o
LEFT JOIN tourisms t ON o.tourism_id = t.id
2025-03-30 15:49:18 +08:00
<where>
2025-10-09 14:33:15 +08:00
<!-- 业务筛选条件 -->
2025-03-30 15:49:18 +08:00
<if test= "p.orderNo != null and p.orderNo != ''" >
2025-10-28 11:21:31 +08:00
AND o.order_no = #{p.orderNo}
2025-06-19 22:53:22 +08:00
</if>
2025-03-30 15:49:18 +08:00
<if test= "p.orderStatus != null" >
2025-08-06 10:41:44 +08:00
AND o.order_status = #{p.orderStatus}
</if>
2025-10-28 11:21:31 +08:00
<if test= "p.payType != null" >
AND o.pay_type = #{p.payType}
</if>
2025-08-06 10:41:44 +08:00
<if test= "p.tourismId != null" >
AND o.tourism_id = #{p.tourismId}
</if>
<if test= "p.deviceSn != null and p.deviceSn != ''" >
AND o.device_sn LIKE CONCAT('%', #{p.deviceSn}, '%')
</if>
2025-10-09 14:33:15 +08:00
<!-- 兼容 dashboard 透传的 qrcodeId 与现有 codeId 参数名 -->
2025-08-06 10:41:44 +08:00
<if test= "p.codeId != null and p.codeId != ''" >
AND o.code_id LIKE CONCAT('%', #{p.codeId}, '%')
</if>
2025-10-09 14:33:15 +08:00
<if test= "p.qrcodeId != null and p.qrcodeId != ''" >
AND o.code_id LIKE CONCAT('%', #{p.qrcodeId}, '%')
</if>
2025-08-06 10:41:44 +08:00
<if test= "p.userId != null and p.userId != ''" >
AND o.user_id LIKE CONCAT('%', #{p.userId}, '%')
</if>
<if test= "p.mobile != null and p.mobile != ''" >
AND o.mobile LIKE CONCAT('%', #{p.mobile}, '%')
2025-03-30 15:49:18 +08:00
</if>
2025-10-09 14:33:15 +08:00
<!-- 时间范围(与仪表盘统计口径一致) -->
<if test= "p.startTime != null and p.startTime != ''" >
AND o.create_time > = #{p.startTime}
</if>
<if test= "p.endTime != null and p.endTime != ''" >
AND o.create_time < = #{p.endTime}
</if>
<!-- 景区集合过滤(由租户+子孙→景区ID集合的去重结果提供) -->
<if test= "p.tourismIds != null and p.tourismIds.size > 0" >
AND o.tourism_id IN
<foreach collection= "p.tourismIds" item= "tid" open= "(" separator= "," close= ")" > #{tid}</foreach>
</if>
2025-03-30 15:49:18 +08:00
</where>
2025-08-06 10:41:44 +08:00
ORDER BY o.create_time 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-24 10:58:00 +08:00
and t.is_del = 0
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>