<?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="cn.iocoder.yudao.module.stockTransfer.mapper.DlRepairStMapper">

    <resultMap id="BaseResultMap" type="cn.iocoder.yudao.module.stockTransfer.entity.DlRepairSt">
        <id property="id" column="id" jdbcType="VARCHAR"/>
        <result property="outCorpId" column="out_corp_id" jdbcType="VARCHAR"/>
        <result property="inCorpId" column="in_corp_id" jdbcType="VARCHAR"/>
        <result property="stNo" column="st_no" jdbcType="VARCHAR"/>
        <result property="userId" column="user_id" jdbcType="BIGINT"/>
        <result property="userName" column="user_name" jdbcType="VARCHAR"/>
        <result property="itemCount" column="item_count" jdbcType="INTEGER"/>
        <result property="totalPrice" column="total_price" jdbcType="DECIMAL"/>
        <result property="discountPrice" column="discount_price" jdbcType="DECIMAL"/>
        <result property="thisCollection" column="this_collection" jdbcType="DECIMAL"/>
        <result property="thisDebt" column="this_debt" jdbcType="DECIMAL"/>
        <result property="stStatus" column="st_status" jdbcType="VARCHAR"/>
        <result property="stTime" column="st_time" jdbcType="TIMESTAMP"/>
        <result property="remark" column="remark" jdbcType="VARCHAR"/>
        <result property="deptId" column="dept_id" jdbcType="BIGINT"/>
    </resultMap>

    <sql id="Base_SQL">
        select id,
               out_corp_id,
               in_corp_id,
               st_no,
               user_id,
               user_name,
               item_count,
               total_price,
               discount_price,
               this_collection,
               this_debt,
               st_status,
               st_time,
               remark,
               dept_id,
               create_time
        from dl_repair_st st
        where st.deleted = '0'
    </sql>

    <select id="getStPage" resultMap="BaseResultMap">
        <include refid="Base_SQL" />
        <if test="map.outCorpId != null and map.outCorpId != ''">
            and st.out_corp_id = #{map.outCorpId}
        </if>
        <if test="map.inCorpId != null and map.inCorpId != ''">
            and st.in_corp_id = #{map.inCorpId}
        </if>
        <if test="map.stStatus != null and map.stStatus != ''">
            and st.st_status = #{map.stStatus}
        </if>
        <if test="map.stStatus == null">
            and st.st_status != '04'
        </if>
        <if test="map.searchTimeArray != null and map.searchTimeArray.length > 0">
            and (st.st_time between #{map.searchTimeArray[0]} and #{map.searchTimeArray[1]})
        </if>
        <if test="map.stNo != null and map.stNo != ''">
            and (st.st_no like concat('%', #{map.stNo}, '%') or st.remark like concat('%', #{map.stNo}, '%'))
        </if>
    </select>
</mapper>
