|
|
|
@ -1,23 +1,28 @@
|
|
|
|
|
<?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" >
|
|
|
|
|
<!-- 定义XML文档的版本和编码 -->
|
|
|
|
|
<mapper namespace="com.sky.mapper.OrderMapper">
|
|
|
|
|
<!-- 指定命名空间,通常对应于一个Java接口 -->
|
|
|
|
|
|
|
|
|
|
<!-- 插入订单记录 -->
|
|
|
|
|
<insert id="insert" useGeneratedKeys="true" keyProperty="id">
|
|
|
|
|
insert into orders(number, status, user_id, address_book_id, order_time,
|
|
|
|
|
checkout_time, pay_method, pay_status, amount, remark,
|
|
|
|
|
phone, address, user_name, consignee, cancel_reason,
|
|
|
|
|
rejection_reason, cancel_time, estimated_delivery_time,
|
|
|
|
|
delivery_status, delivery_time, pack_amount,
|
|
|
|
|
tableware_number, tableware_status)
|
|
|
|
|
values(#{number},#{status},#{userId},#{addressBookId},#{orderTime},#{checkoutTime},
|
|
|
|
|
#{payMethod},#{payStatus},#{amount},#{remark},#{phone},#{address},#{userName},
|
|
|
|
|
#{consignee},#{cancelReason},#{rejectionReason},#{cancelTime},#{estimatedDeliveryTime},
|
|
|
|
|
#{deliveryStatus},#{deliveryTime},#{packAmount},#{tablewareNumber},#{tablewareStatus})
|
|
|
|
|
insert into orders(number, status, user_id, address_book_id, order_time,
|
|
|
|
|
checkout_time, pay_method, pay_status, amount, remark,
|
|
|
|
|
phone, address, user_name, consignee, cancel_reason,
|
|
|
|
|
rejection_reason, cancel_time, estimated_delivery_time,
|
|
|
|
|
delivery_status, delivery_time, pack_amount,
|
|
|
|
|
tableware_number, tableware_status)
|
|
|
|
|
values(#{number},#{status},#{userId},#{addressBookId},#{orderTime},#{checkoutTime},
|
|
|
|
|
#{payMethod},#{payStatus},#{amount},#{remark},#{phone},#{address},#{userName},
|
|
|
|
|
#{consignee},#{cancelReason},#{rejectionReason},#{cancelTime},#{estimatedDeliveryTime},
|
|
|
|
|
#{deliveryStatus},#{deliveryTime},#{packAmount},#{tablewareNumber},#{tablewareStatus})
|
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
<!-- 更新订单记录 -->
|
|
|
|
|
<update id="update" parameterType="com.sky.entity.Orders">
|
|
|
|
|
update orders
|
|
|
|
|
<set>
|
|
|
|
|
<!-- 根据条件动态更新字段 -->
|
|
|
|
|
<if test="cancelReason != null and cancelReason!='' ">
|
|
|
|
|
cancel_reason=#{cancelReason},
|
|
|
|
|
</if>
|
|
|
|
@ -45,10 +50,13 @@
|
|
|
|
|
</set>
|
|
|
|
|
where id = #{id}
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
<!-- 分页查询订单 -->
|
|
|
|
|
<select id="pageQuery" resultType="com.sky.entity.Orders">
|
|
|
|
|
select *
|
|
|
|
|
from orders
|
|
|
|
|
<where>
|
|
|
|
|
<!-- 根据条件动态拼接查询语句 -->
|
|
|
|
|
<if test="number != null and number!=''">
|
|
|
|
|
and number like concat('%',#{number},'%')
|
|
|
|
|
</if>
|
|
|
|
@ -69,10 +77,13 @@
|
|
|
|
|
</if>
|
|
|
|
|
</where>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<!-- 计算订单金额总和 -->
|
|
|
|
|
<select id="sumByMap" resultType="java.lang.Double">
|
|
|
|
|
select sum(amount)
|
|
|
|
|
from orders
|
|
|
|
|
<where>
|
|
|
|
|
<!-- 根据条件动态拼接查询语句 -->
|
|
|
|
|
<if test="begin != null">
|
|
|
|
|
and order_time > #{begin}
|
|
|
|
|
</if>
|
|
|
|
@ -84,10 +95,13 @@
|
|
|
|
|
</if>
|
|
|
|
|
</where>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<!-- 统计订单数量 -->
|
|
|
|
|
<select id="countByMap" resultType="java.lang.Integer">
|
|
|
|
|
select count(id)
|
|
|
|
|
from orders
|
|
|
|
|
<where>
|
|
|
|
|
<!-- 根据条件动态拼接查询语句 -->
|
|
|
|
|
<if test="begin != null">
|
|
|
|
|
and order_time > #{begin}
|
|
|
|
|
</if>
|
|
|
|
@ -99,18 +113,21 @@
|
|
|
|
|
</if>
|
|
|
|
|
</where>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<!-- 获取销售前十的商品 -->
|
|
|
|
|
<select id="getSalesTop10" resultType="com.sky.dto.GoodsSalesDTO">
|
|
|
|
|
select od.name,sum(od.number) as number
|
|
|
|
|
from order_detail od,orders o
|
|
|
|
|
where
|
|
|
|
|
od.order_id = o.id
|
|
|
|
|
and o.status = 5
|
|
|
|
|
<if test="begin != null">
|
|
|
|
|
and o.order_time > #{begin}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="end != null">
|
|
|
|
|
and o.order_time < #{end}
|
|
|
|
|
</if>
|
|
|
|
|
od.order_id = o.id
|
|
|
|
|
and o.status = 5
|
|
|
|
|
<!-- 根据条件动态拼接查询语句 -->
|
|
|
|
|
<if test="begin != null">
|
|
|
|
|
and o.order_time > #{begin}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="end != null">
|
|
|
|
|
and o.order_time < #{end}
|
|
|
|
|
</if>
|
|
|
|
|
group by od.name
|
|
|
|
|
order by number desc
|
|
|
|
|
limit 0,10
|
|
|
|
|