<?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.matrix.system.shopXcx.dao.ShopOrderSearchDao">
|
<!-- 定义ShopOrder 的简单map ,本map不添加其他的关联属性 -->
|
<resultMap type="com.matrix.system.shopXcx.bean.ShopOrderSearch" id="ShopOrderSearchMap">
|
<!--<id property="id" column="id" />-->
|
<result property="proName" column="pro_name" />
|
<result property="proType" column="pro_type" />
|
<result property="proAttrs" column="pro_attrs" />
|
<result property="proSpecification" column="pro_specification" />
|
<result property="nickName" column="nick_name" />
|
<result property="count" column="count" />
|
<result property="orderMoney" column="order_money" />
|
<result property="orderNo" column="order_no" />
|
<result property="orderStatus" column="order_status" />
|
<result property="orderTime" column="order_time" />
|
</resultMap>
|
|
|
<!-- where sql -->
|
<sql id="where_sql">
|
|
<if test="record!=null">
|
<if test="(record.id!=null and record.id!='') or (record.id!='' and record.id==0) ">
|
and id = #{record.id}
|
</if>
|
<if test="(record.orderNo!=null and record.orderNo!='') or (record.orderNo!='' and record.orderNo==0) ">
|
and order_no like concat('%', #{record.orderNo}, '%')
|
</if>
|
<if test="(record.orderMoney!=null and record.orderMoney!='') or (record.orderMoney!='' and record.orderMoney==0) ">
|
and order_money = #{record.orderMoney}
|
</if>
|
<if test="(record.commodityPrice!=null and record.commodityPrice!='') or (record.commodityPrice!='' and record.commodityPrice==0) ">
|
and commodity_price = #{record.commodityPrice}
|
</if>
|
<if test="(record.userId!=null and record.userId!='') or (record.userId!='' and record.userId==0) ">
|
and user_id = #{record.userId}
|
</if>
|
<if test=" record.orderTime!=null ">
|
and order_time = #{record.orderTime}
|
</if>
|
<if test="(record.payStatus!=null and record.payStatus!='') or (record.payStatus!='' and record.payStatus==0) ">
|
and pay_status = #{record.payStatus}
|
</if>
|
<if test="(record.discountExplain!=null and record.discountExplain!='') or (record.discountExplain!='' and record.discountExplain==0) ">
|
and discount_explain = #{record.discountExplain}
|
</if>
|
<if test="(record.discountAmount!=null and record.discountAmount!='') or (record.discountAmount!='' and record.discountAmount==0) ">
|
and discount_amount = #{record.discountAmount}
|
</if>
|
<if test="(record.orderStatus!=null and record.orderStatus!='') or (record.orderStatus!='' and record.orderStatus==0) ">
|
and order_status = #{record.orderStatus}
|
</if>
|
<if test="(record.refundCharge!=null and record.refundCharge!='') or (record.refundCharge!='' and record.refundCharge==0) ">
|
and refund_charge = #{record.refundCharge}
|
</if>
|
<if test="(record.userName!=null and record.userName!='') or (record.userName!='' and record.userName==0) ">
|
and user_name like concat('%', #{record.userName}, '%')
|
</if>
|
<if test="(record.userTel!=null and record.userTel!='') or (record.userTel!='' and record.userTel==0) ">
|
and user_tel like concat('%', #{record.userTel}, '%')
|
</if>
|
<if test="(record.remarks!=null and record.remarks!='') or (record.remarks!='' and record.remarks==0) ">
|
and remarks = #{record.remarks}
|
</if>
|
<if test="(record.shippingMethod!=null and record.shippingMethod!='') or (record.shippingMethod!='' and record.shippingMethod==0) ">
|
and shipping_method = #{record.shippingMethod}
|
</if>
|
<if test="(record.storeId!=null and record.storeId!='') or (record.storeId!='' and record.storeId==0) ">
|
and store_id = #{record.storeId}
|
</if>
|
<if test="(record.purchaseQuantity!=null and record.purchaseQuantity!='') or (record.purchaseQuantity!='' and record.purchaseQuantity==0) ">
|
and purchase_quantity = #{record.purchaseQuantity}
|
</if>
|
<if test="(record.delFlag!=null and record.delFlag!='') or (record.delFlag!='' and record.delFlag==0) ">
|
and del_flag = #{record.delFlag}
|
</if>
|
<if test="(record.wxOrderNo!=null and record.wxOrderNo!='') or (record.wxOrderNo!='' and record.wxOrderNo==0) ">
|
and wx_order_no = #{record.wxOrderNo}
|
</if>
|
<if test="(record.payResult!=null and record.payResult!='') or (record.payResult!='' and record.payResult==0) ">
|
and pay_result = #{record.payResult}
|
</if>
|
<if test="(record.postage!=null and record.postage!='') or (record.postage!='' and record.postage==0) ">
|
and postage = #{record.postage}
|
</if>
|
</if>
|
|
</sql>
|
|
<!-- 分页查询 -->
|
<select id="selectInPageByQuery" resultMap="ShopOrderSearchMap">
|
select
|
so.order_no,so.order_status,sp.title pro_name,spa.attr_name pro_type,sp.attrs_values pro_attrs,sku.`NAME` pro_specification,sod.count 'count',sod.price*sod.count order_money,bu.nick_name nick_name,so.order_time
|
from
|
shop_order_details sod,shop_product sp,shop_product_attribute spa,shop_order so,sys_vip_info bu,shop_sku sku
|
where
|
so.del_flag = 2
|
and sod.p_id = sp.id
|
and sp.category_id = spa.attr_id
|
and sod.order_id = so.id
|
and bu.id = so.user_id
|
and sku.p_id = sod.p_id
|
and so.company_id=#{record.companyId}
|
<if test="record != null">
|
<if test="(record.proName!=null and record.proName!='')">
|
and sp.title like concat('%', #{record.proName}, '%')
|
</if>
|
<if test="(record.proType!=null and record.proType!='')">
|
and spa.attr_name like concat('%', (select attr_name from shop_product_attribute where attr_id = #{record.proType}) , '%')
|
</if>
|
<if test="(record.nickName!=null and record.nickName!='')">
|
and bu.nick_name like concat('%', #{record.nickName}, '%')
|
</if>
|
<if test="(record.orderNo!=null and record.orderNo!='')">
|
and so.order_no like concat('%', #{record.orderNo}, '%')
|
</if>
|
<if test="(record.orderStatus!=null and record.orderStatus!='')">
|
and so.order_status = #{record.orderStatus}
|
</if>
|
|
<if test="record.companyId != null and record.companyId !='' ">
|
and so.company_id = #{record.companyId}
|
</if>
|
|
<if test="(record.proAttrs!=null and record.proAttrs!='')">
|
and sp.attrs_values like concat('%', (select attr_name from shop_product_attribute where attr_id = #{record.proAttrs}) , '%')
|
</if>
|
|
<if test="record.orderBeginTime!=null ">
|
and date_format(so.order_time, '%Y-%m-%d') >= #{record.orderBeginTime}
|
</if>
|
<if test="record.orderEndTime!=null">
|
and #{record.orderEndTime} >= date_format(so.order_time, '%Y-%m-%d')
|
</if>
|
</if>
|
<if test="pageVo !=null"><!-- 判断pageVo对象是否为空 -->
|
<if test="pageVo.sort !=null and pageVo.order !=null">
|
order by
|
${pageVo.sort} ${pageVo.order}
|
</if>
|
<if test="pageVo.offset >=0 and pageVo.limit >0">
|
limit
|
#{pageVo.offset},#{pageVo.limit}
|
</if>
|
</if>
|
</select>
|
|
<!-- 查询总条数 -->
|
<select id="selectTotalRecordByQuery" resultType="java.lang.Integer">
|
select count(*)
|
from
|
shop_order_details sod,shop_product sp,shop_product_attribute spa,shop_order so,sys_vip_info bu,shop_sku sku
|
where
|
so.del_flag = 2
|
and sod.p_id = sp.id
|
and sp.category_id = spa.attr_id
|
and sod.order_id = so.id
|
and bu.id = so.user_id
|
and sku.p_id = sod.p_id
|
and so.company_id=#{record.companyId}
|
<if test="record != null">
|
<if test="(record.proName!=null and record.proName!='')">
|
and sp.title like concat('%', #{record.proName}, '%')
|
</if>
|
<if test="(record.proType!=null and record.proType!='')">
|
and spa.attr_name like concat('%', (select attr_name from shop_product_attribute where attr_id = #{record.proType}) , '%')
|
</if>
|
<if test="(record.nickName!=null and record.nickName!='')">
|
and bu.nick_name like concat('%', #{record.nickName}, '%')
|
</if>
|
<if test="(record.orderNo!=null and record.orderNo!='')">
|
and so.order_no like concat('%', #{record.orderNo}, '%')
|
</if>
|
<if test="(record.orderStatus!=null and record.orderStatus!='')">
|
and so.order_status = #{record.orderStatus}
|
</if>
|
<if test="(record.proAttrs!=null and record.proAttrs!='')">
|
and sp.attrs_values like concat('%', (select attr_name from shop_product_attribute where attr_id = #{record.proAttrs}) , '%')
|
</if>
|
<if test="record.orderBeginTime!=null ">
|
and date_format(so.order_time, '%Y-%m-%d') >= #{record.orderBeginTime}
|
</if>
|
<if test="record.orderEndTime!=null">
|
and #{record.orderEndTime} >= date_format(so.order_time, '%Y-%m-%d')
|
</if>
|
</if>
|
</select>
|
|
</mapper>
|