You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

133 lines
6.0 KiB

<?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="cc.hiver.mall.dao.mapper.MallOrderMapper">
<!-- 通用结果映射 -->
<resultMap id="mallOrderVOMap" type="cc.hiver.mall.pojo.vo.MallOrderVO">
<id column="id" property="id"/>
<result column="user_id" property="userId"/>
<result column="shop_id" property="shopId"/>
<result column="order_type" property="orderType"/>
<result column="delivery_type" property="deliveryType"/>
<result column="status" property="status"/>
<result column="total_amount" property="totalAmount"/>
<result column="goods_amount" property="goodsAmount"/>
<result column="delivery_fee" property="deliveryFee"/>
<result column="package_fee" property="packageFee"/>
<result column="address_id" property="addressId"/>
<result column="remark" property="remark"/>
<result column="receiver_name" property="receiverName"/>
<result column="receiver_phone" property="receiverPhone"/>
<result column="receiver_address" property="receiverAddress"/>
<result column="shop_name" property="shopName"/>
<result column="shop_phone" property="shopPhone"/>
<result column="shop_address" property="shopAddress"/>
<result column="create_time" property="createTime"/>
<result column="pay_time" property="payTime"/>
<result column="number_code" property="numberCode"/>
<result column="region_id" property="regionId"/>
<result column="settlement_status" property="settlementStatus"/>
<result column="shop_make_time" property="shopMakeTime"/>
<result column="other_order" property="otherOrder"/>
</resultMap>
<!-- 分页查询订单(不挂载商品明细,由Service层补填) -->
<select id="selectPageVO" resultMap="mallOrderVOMap">
SELECT
o.id, o.user_id, o.shop_id, o.order_type, o.delivery_type,
o.status, o.total_amount, o.goods_amount, o.delivery_fee,
o.package_fee, o.address_id, o.remark, o.create_time, o.pay_time,
o.receiver_name, o.receiver_phone, o.receiver_address,
o.shop_name, o.shop_phone, o.shop_address,o.number_code,o.region_id,o.settlement_status,o.shop_make_time,o.other_order
FROM mall_order o
<where>
<if test="q.userId != null and q.userId != ''">
AND o.user_id = #{q.userId}
</if>
<if test="q.shopName != null and q.shopName != ''">
and (
o.shop_name like concat('%',#{q.shopName},'%')
)
</if>
<if test="q.shopId != null and q.shopId != ''">
AND o.shop_id = #{q.shopId}
</if>
<if test="q.regionId != null and q.regionId != ''">
AND o.region_id = #{q.regionId}
</if>
<if test="q.status != null">
AND o.status = #{q.status}
</if>
<if test="q.orderType != null">
AND o.order_type = #{q.orderType}
</if>
<if test="q.searchType != null and q.searchType == 1">
AND o.order_type in (1,2,3) AND o.other_order is null
</if>
<if test="q.searchType != null and q.searchType == 2">
AND o.other_order = 1
</if>
<if test="q.searchType != null and q.searchType == 3">
AND o.other_order = 2
</if>
<if test="q.searchStatus != null and q.searchStatus == 0">
AND o.status = 0
</if>
<if test="q.searchStatus != null and q.searchStatus == 1">
AND o.status = 10
</if>
<if test="q.searchStatus != null and q.searchStatus == 2">
AND o.status = 3 and o.delivery_type = 2
</if>
<if test="q.searchStatus != null and q.searchStatus == 3">
AND o.status = 2
</if>
<if test="q.searchStatus != null and q.searchStatus == 4">
AND o.status = 3 and o.delivery_type = 1
</if>
<if test="q.searchStatus != null and q.searchStatus == 5">
AND o.status = 4
</if>
<if test="q.searchStatus != null and q.searchStatus == 6">
AND o.status = 5
</if>
<if test="q.searchStatus != null and q.searchStatus == 7">
AND o.status = 7
</if>
<if test="q.searchStatus != null and q.searchStatus == 8">
AND o.status = 8
</if>
<if test="q.searchStatus != null and q.searchStatus == 9">
AND o.status = 6
</if>
<if test="q.deliveryType != null">
AND o.delivery_type = #{q.deliveryType}
</if>
<if test="q.startDate != null and q.startDate != ''">
AND DATE(o.create_time) &gt;= #{q.startDate}
</if>
<if test="q.endDate != null and q.endDate != ''">
AND DATE(o.create_time) &lt;= #{q.endDate}
</if>
</where>
ORDER BY o.create_time DESC
</select>
<select id="selectMallOrderByGroupId" resultMap="mallOrderVOMap">
SELECT
o.id, o.user_id, o.shop_id, o.order_type, o.delivery_type,
o.status, o.total_amount, o.goods_amount, o.delivery_fee,
o.package_fee, o.address_id, o.remark, o.create_time, o.pay_time,
o.receiver_name, o.receiver_phone, o.receiver_address,
o.shop_name, o.shop_phone, o.shop_address,o.number_code,o.region_id,o.settlement_status,o.shop_make_time
FROM mall_order o LEFT JOIN mall_order_group og ON o.id = og.head_order_id
<where>
<if test="groupId != null and groupId != ''">
AND og.id = #{groupId}
</if>
</where>
</select>
</mapper>