155 lines
6.7 KiB
XML
155 lines
6.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.peanut.modules.book.dao.BuyOrderDao">
|
|
|
|
<!-- 可根据自己的需求,是否要使用 -->
|
|
<resultMap type="com.peanut.modules.book.entity.BuyOrder" id="buyOrderMap">
|
|
<result property="orderId" column="order_id"/>
|
|
<result property="orderSn" column="order_sn"/>
|
|
<result property="userId" column="user_id"/>
|
|
<result property="shippingUser" column="shipping_user"/>
|
|
<result property="province" column="province"/>
|
|
<result property="city" column="city"/>
|
|
<result property="district" column="district"/>
|
|
<result property="address" column="address"/>
|
|
<result property="paymentMethod" column="payment_method"/>
|
|
<result property="orderMoney" column="order_money"/>
|
|
<result property="districtMoney" column="district_money"/>
|
|
<result property="realMoney" column="real_money"/>
|
|
<result property="shippingMoney" column="shipping_money"/>
|
|
<result property="shippingCompName" column="shipping_comp_name"/>
|
|
<result property="shippingSn" column="shipping_sn"/>
|
|
<result property="createTime" column="create_time"/>
|
|
<result property="shippingTime" column="shipping_time"/>
|
|
<result property="orderStatus" column="order_status"/>
|
|
<result property="successTime" column="success_time"/>
|
|
<result property="couponId" column="coupon_id"/>
|
|
<result property="couponName" column="coupon_name"/>
|
|
<result property="userPhone" column="user_phone"/>
|
|
<result property="orderType" column="order_type"/>
|
|
<result property="delFlag" column="del_flag"/>
|
|
<result property="expNo" column="exp_no"/>
|
|
<result property="isSend" column="is_send"/>
|
|
<result property="addressId" column="address_id"/>
|
|
<result property="remark" column="remark"/>
|
|
<result property="orderCode" column="order_code"/>
|
|
<result property="paymentDate" column="payment_date"/>
|
|
|
|
|
|
<collection property="products" ofType="com.peanut.modules.book.entity.BuyOrderDetail">
|
|
<result property="orderId" column="order_id"/>
|
|
<result property="productName" column="product_name"/>
|
|
<result property="quantity" column="quantity"/>
|
|
<result property="productPrice" column="product_price"/>
|
|
<result property="weight" column="weight"/>
|
|
<result property="remark" column="remark"/>
|
|
</collection>
|
|
</resultMap>
|
|
|
|
<!-- <resultMap id="OrderDetailResult" type="com.peanut.modules.book.entity.BuyOrderDetail">-->
|
|
|
|
<!-- </resultMap>-->
|
|
|
|
<select id="queryListByOrderIds" resultType="com.peanut.modules.book.entity.BuyOrder">
|
|
select
|
|
*,
|
|
buy_order_detail.order_id,
|
|
buy_order_detail.product_name,
|
|
buy_order_detail.quantity,
|
|
buy_order_detail.product_price,
|
|
buy_order_detail.weight,
|
|
buy_order_detail.remark
|
|
from buy_order
|
|
left join buy_order_detail on buy_order.order_id = buy_order_detail.order_id
|
|
where buy_order.order_id in
|
|
<foreach collection="array" item="id" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
and del_flag = 0
|
|
</select>
|
|
|
|
<select id="orderStatusNum" resultType="com.peanut.modules.book.entity.BuyOrder">
|
|
select *,count(*) as statusNum
|
|
from buy_order
|
|
where
|
|
user_id = #{userId}
|
|
and del_flag = 0
|
|
and order_status in (0,1,2,3)
|
|
group by
|
|
order_status
|
|
|
|
</select>
|
|
|
|
<select id="orderListCount" resultType="int" parameterType="com.peanut.modules.book.vo.request.BuyOrderListRequestVo">
|
|
select count(1) from (
|
|
select b.*
|
|
from buy_order b
|
|
<if test="productName != null and productName!= ''">left join buy_order_product p on b.order_id = p.order_id
|
|
left join
|
|
shop_product s on s.product_id = p.product_id
|
|
</if>
|
|
<where>
|
|
<if test="searchKeyWord != null and searchKeyWord!= ''">
|
|
and (b.order_sn like concat('%',concat(#{searchKeyWord},'%'))
|
|
or b.shipping_user like concat('%',concat(#{searchKeyWord},'%'))
|
|
or b.user_phone like concat('%',concat(#{searchKeyWord},'%')))
|
|
</if>
|
|
<if test="productName != null and productName!= ''">
|
|
and (s.product_name like concat('%',concat(#{productName},'%')))
|
|
</if>
|
|
<if test="orderStatus != null and orderStatus!= ''">
|
|
and b.order_status = #{orderStatus}
|
|
</if>
|
|
<if test="startTime != null">
|
|
and b.create_time >= #{startTime}
|
|
</if>
|
|
<if test="endTime != null">
|
|
and b.create_time <= #{endTime}
|
|
</if>
|
|
and b.order_type = 'order'
|
|
and b.del_flag = 0
|
|
</where>
|
|
<if test="productName != null and productName!= ''">
|
|
group by b.order_id
|
|
</if>
|
|
) t
|
|
</select>
|
|
|
|
<select id="orderList" resultType="com.peanut.modules.book.entity.BuyOrder"
|
|
parameterType="com.peanut.modules.book.vo.request.BuyOrderListRequestVo" resultMap="buyOrderMap">
|
|
select b.*
|
|
from buy_order b
|
|
<if test="productName != null and productName!= ''">
|
|
left join buy_order_product p on b.order_id = p.order_id
|
|
left join shop_product s on s.product_id = p.product_id
|
|
</if>
|
|
<where>
|
|
<if test="searchKeyWord != null and searchKeyWord!= ''">
|
|
and (b.order_sn like concat('%',concat(#{searchKeyWord},'%'))
|
|
or b.shipping_user like concat('%',concat(#{searchKeyWord},'%'))
|
|
or b.user_phone like concat('%',concat(#{searchKeyWord},'%')))
|
|
</if>
|
|
<if test="productName != null and productName!= ''">
|
|
and (s.product_name like concat('%',concat(#{productName},'%')))
|
|
</if>
|
|
<if test="orderStatus != null and orderStatus!= ''">
|
|
and b.order_status = #{orderStatus}
|
|
</if>
|
|
<if test="startTime != null">
|
|
and b.create_time >= #{startTime}
|
|
</if>
|
|
<if test="endTime != null">
|
|
and b.create_time <= #{endTime}
|
|
</if>
|
|
and b.order_type = 'order'
|
|
and b.del_flag = 0
|
|
</where>
|
|
<if test="productName != null and productName!= ''">
|
|
group by b.order_id
|
|
</if>
|
|
order by b.create_time desc
|
|
limit #{index},#{pageSize}
|
|
</select>
|
|
|
|
</mapper> |