Files
gofly-platform-services/zlt-business/order-center/src/main/resources/mapper/OrderMapper.xml
T

68 lines
2.7 KiB
XML

<?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">
<select id="findList" resultType="com.central.order.model.Order">
select * from orders t
<where>
<if test="p.orderNo != null and p.orderNo != ''">
AND t.order_no LIKE CONCAT('%', #{p.orderNo}, '%')
</if>
<if test="p.deviceSn != null and p.deviceSn != ''">
AND t.deviceSn LIKE CONCAT('%', #{p.deviceSn}, '%')
</if>
<if test="p.orderStatus != null">
AND t.order_status = #{p.orderStatus}
</if>
</where>
ORDER BY t.id DESC
</select>
<!-- 动态获取参数采用备参 -->
<select id="findListByUser" resultType="com.central.order.model.Order">
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} ORDER BY id DESC
</select>
<!-- 根据订单状态查询订单列表 -->
<select id="getOrdersByStatus" resultMap="OrderResultMap">
SELECT * FROM orders WHERE order_status = #{status} ORDER BY id DESC
</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">
SELECT * FROM orders WHERE order_status = 1 order by id asc
</select>
<!-- 根据店铺编号和创建时间(当天)查询订单数量 -->
<select id="findByShopIdAndCreateTimeGreaterThanEqualAndCreateTimeLessThanEqual" resultMap="OrderResultMap">
SELECT * FROM orders
WHERE tourism_id = #{tourismId}
AND create_time >= #{startDate}
AND create_time &lt;= #{endDate}
</select>
<!-- 根据订单编号查询订单信息 -->
<select id="getOrderByNumber" resultMap="OrderResultMap">
SELECT * FROM orders WHERE order_no = #{orderNumber}
</select>
</mapper>