AppraiseOrderMapper.xml 10.9 KB
<?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.yoho.order.dal.AppraiseOrderMapper">
    <resultMap id="BaseResultMap" type="com.yoho.order.model.AppraiseOrder">
      <result column="id" property="id" jdbcType="INTEGER" />
      <result column="uid" property="uid" jdbcType="INTEGER" />
      <result column="parent_order_code" property="parentOrderCode" jdbcType="BIGINT" />
      <result column="order_code" property="orderCode" jdbcType="BIGINT" />
      <result column="client_type" property="clientType" jdbcType="TINYINT" />
      <result column="payment" property="payment" jdbcType="TINYINT" />
      <result column="amount" property="amount" jdbcType="DECIMAL" />
      <result column="ship_fee" property="shipFee" jdbcType="DECIMAL" />
      <result column="status" property="status" jdbcType="TINYINT" />
      <result column="create_time" property="createTime" jdbcType="INTEGER" />
      <result column="update_time" property="updateTime" jdbcType="INTEGER" />
      <result column="is_del" property="isDel" jdbcType="TINYINT" />
      <result column="channel_no" property="channelNo" jdbcType="VARCHAR" />
      <result column="attributes" property="attributes" jdbcType="INTEGER" />
      <result column="platform_delivery_status" property="platformDeliveryStatus" jdbcType="TINYINT" />
    </resultMap>

    <sql id="Base_Column_List">
        id, uid, parent_order_code, order_code, client_type, payment, amount, ship_fee, 
        status, create_time, update_time, is_del, channel_no, attributes, platform_delivery_status 
    </sql>
    
      <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from appraise_order
    where id = #{id,jdbcType=INTEGER}
  </select>

  <update id="updateByPrimaryKey" parameterType="com.yoho.order.model.AppraiseOrder">
    update appraise_order
    set uid = #{uid,jdbcType=INTEGER},
      order_code = #{orderCode,jdbcType=BIGINT},
      client_type = #{clientType,jdbcType=TINYINT},
      payment = #{payment,jdbcType=TINYINT},
      amount = #{amount,jdbcType=DECIMAL},
      ship_fee = #{shipFee,jdbcType=DECIMAL},
      status = #{status,jdbcType=TINYINT},
      create_time = #{createTime,jdbcType=INTEGER},
      update_time = #{updateTime,jdbcType=INTEGER},
      is_del = #{isDel,jdbcType=TINYINT},
      channel_no = #{channelNo,jdbcType=VARCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>
    
    <select id="selectByOrderCode" resultMap="BaseResultMap">
        select <include refid="Base_Column_List" />
        from appraise_order where order_code = #{orderCode}
    </select>
    
    <select id="selectByOrderCodeList" resultMap="BaseResultMap">
        select <include refid="Base_Column_List" />
        from appraise_order where order_code in 
        <foreach collection="orderCodeList" item="orderCode" open="(" close=")" separator=",">
        #{orderCode}
        </foreach>
    </select>
    
    <select id="selectByCondition" resultMap="BaseResultMap" parameterType="com.yoho.order.model.AppraiseOrderReq">
        select distinct a.*
        from appraise_order a 
        <if test="appraiseOrderReq.depotNo != null">
        LEFT JOIN appraise_order_goods c
        ON(c.order_code=a.order_code) 
        </if>
        <if test="appraiseOrderReq.sellerWaybillCode != null and appraiseOrderReq.sellerWaybillCode != ''">
            LEFT JOIN express_record d 
            ON(a.order_code=d.order_code)
        </if>
        <if test="appraiseOrderReq.sellerWaybillCode != null and appraiseOrderReq.sellerWaybillCode != ''">
            where a.parent_order_code is null
        </if>
        <if test="appraiseOrderReq.sellerWaybillCode == null or appraiseOrderReq.sellerWaybillCode == ''">
            where ((a.attributes=7 and a.parent_order_code is not null) or (a.attributes=8))
        </if>
        <include refid="Query_Order_Sql" />
        <choose>
            <when test="appraiseOrderReq.sortRule!=null and appraiseOrderReq.sortRule=='asc'">
              order by a.status asc, a.id asc 
            </when>
            <otherwise>
              order by a.id desc 
            </otherwise>
        </choose>
        <if test="appraiseOrderReq.start!=null and appraiseOrderReq.size != null">
         limit #{appraiseOrderReq.start},#{appraiseOrderReq.size}
        </if>
    </select>
    
    <select id="selectTotalByCondition" resultType="java.lang.Integer" parameterType="com.yoho.order.model.AppraiseOrderReq">
        select count(a.id)   
        from appraise_order a 
        <if test="appraiseOrderReq.depotNo != null">
        LEFT JOIN appraise_order_goods c
        ON(c.order_code=a.order_code) 
        </if>
        <if test="appraiseOrderReq.sellerWaybillCode != null and appraiseOrderReq.sellerWaybillCode != ''">
            LEFT JOIN express_record d 
            ON(a.order_code=d.order_code)
        </if>
        <if test="appraiseOrderReq.sellerWaybillCode != null and appraiseOrderReq.sellerWaybillCode != ''">
            where a.parent_order_code is null
        </if>
        <if test="appraiseOrderReq.sellerWaybillCode == null or appraiseOrderReq.sellerWaybillCode == ''">
            where ((a.attributes=7 and a.parent_order_code is not null) or (a.attributes=8))
        </if>        
        <include refid="Query_Order_Sql" />
    </select>
    
    <select id="selectCountByStatusAndDepotNo" resultType="java.lang.Integer">
        select count(1)   
        from appraise_order a
        <if test="depotNo != null">
        LEFT JOIN appraise_order_goods c
        ON(c.order_code=a.order_code) 
        </if>
        where ((a.attributes=7 and a.parent_order_code is not null) or (a.attributes=8))
        <if test="list != null and list.size()>0">
           and a.status in 
        <foreach collection="list" item="status" open="(" close=")" separator=",">
        #{status}
        </foreach>
        </if>
        <if test="depotNo != null">
           and c.depot_no=#{depotNo}
        </if>
        <!-- 平台物流是否存在 -->
        <if test="platformExpressInfoFlag != null and platformExpressInfoFlag != '' ">
            <if test="platformExpressInfoFlag == 'haveNotExpress'">
                and a.platform_delivery_status = 0
            </if>
            <if test="platformExpressInfoFlag == 'haveExpress'">
                and a.platform_delivery_status in (1,2)
            </if>
        </if>
    </select>
    
    <sql id="Query_Order_Sql" >
     <if test="appraiseOrderReq.statusList != null and appraiseOrderReq.statusList.size() >0">
         and a.status in 
         <foreach collection="appraiseOrderReq.statusList" item="status" open="(" close=")" separator=",">
            #{status}
         </foreach>
     </if>
     <if test="appraiseOrderReq.orderCode != null and appraiseOrderReq.orderCode != '' ">
         and a.order_code = #{appraiseOrderReq.orderCode}
     </if>
     <if test="appraiseOrderReq.status != null ">
         and a.status = #{appraiseOrderReq.status}
     </if>
     <if test="appraiseOrderReq.depotNo != null">
         and c.depot_no = #{appraiseOrderReq.depotNo}
     </if>
     <if test="appraiseOrderReq.attributes != null">
         and a.attributes = #{appraiseOrderReq.attributes}
     </if>
     <if test="appraiseOrderReq.sellerWaybillCode != null and appraiseOrderReq.sellerWaybillCode != '' ">
         and d.waybill_code = #{appraiseOrderReq.sellerWaybillCode} and d.express_type=1
     </if>
    <!-- 平台物流是否存在 -->
     <if test="appraiseOrderReq.platformExpressInfoFlag != null and appraiseOrderReq.platformExpressInfoFlag != '' ">
         <if test="appraiseOrderReq.platformExpressInfoFlag == 'haveNotExpress'">
             and a.platform_delivery_status = 0
         </if>
         <if test="appraiseOrderReq.platformExpressInfoFlag == 'haveExpress'">
             and a.platform_delivery_status in (1,2)
         </if>
     </if>
  </sql>

    <select id="selectCountInfo" resultType="java.util.HashMap">
        select status, count(*) as num from appraise_order where parent_order_code = #{orderCode} and attributes = 7 group by status
    </select>

    <select id="selectParentListCount" resultType="java.lang.Integer">
        select count(*) from appraise_order
        where <include refid="list_condition"/>
    </select>
    <select id="selectParentList" resultMap="BaseResultMap">
        select * from appraise_order
        where <include refid="list_condition"/> order by create_time desc limit #{start}, #{size}
    </select>

    <sql id="list_condition" >
        parent_order_code is null and attributes = 7
        <if test="statusList != null and statusList.size()>0">
            and status in
            <foreach collection="statusList" item="status" open="(" close=")" separator=",">
                #{status}
            </foreach>
        </if>
        <if test="orderCode != null and orderCode !=''">
            and order_code = #{orderCode}
        </if>
        <if test="uid != null">
            and uid = #{uid}
        </if>
        <if test="buyStartTime != null">
            and create_time &gt;= #{buyStartTime}
        </if>
        <if test="buyEndTime != null">
            and create_time &lt;= #{buyEndTime}
        </if>
    </sql>

    <select id="selectSonListCount" resultType="java.lang.Integer">
        select count(*) from appraise_order where parent_order_code = #{orderCode}
    </select>

    <select id="selectSonList" resultMap="BaseResultMap">
        select * from appraise_order where parent_order_code = #{orderCode} order by create_time desc limit #{start}, #{size}
    </select>
    
    <select id="selectBatchSonList" resultMap="BaseResultMap">
        select * from appraise_order where parent_order_code in 
        <foreach collection="parentOrderCodeList" item="parentOrderCode" open="(" close=")" separator=",">
        #{parentOrderCode}
        </foreach>
    </select>

    <select id="selectCountByCondition" resultType="java.lang.Integer">
        select count(1)
        from appraise_order
        where attributes = 8
        <if test="appraiseServiceReq.uid != null">
            and uid = #{appraiseServiceReq.uid}
        </if>
        <if test="appraiseServiceReq.orderCode != null and appraiseServiceReq.orderCode != '' ">
            and order_code = #{appraiseServiceReq.orderCode}
        </if>
    </select>

    <select id="selectListByCondition" resultMap="BaseResultMap">
        select id,uid,order_code,amount,status
        from appraise_order
        where attributes = 8
        <if test="appraiseServiceReq.uid != null">
            and uid = #{appraiseServiceReq.uid}
        </if>
        <if test="appraiseServiceReq.orderCode != null and appraiseServiceReq.orderCode != '' ">
            and order_code = #{appraiseServiceReq.orderCode}
        </if>
        order by id DESC
        limit #{appraiseServiceReq.start},#{appraiseServiceReq.size}
    </select>

</mapper>