TActivityDiscountSMapper.xml 4.63 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.zteits.bill.mapper.smapper.TActivityDiscountSMapper">
    <resultMap id="BaseResultMap" type="com.zteits.bill.domain.TActivityDiscount">
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="pl_no" jdbcType="VARCHAR" property="plNo"/>
        <result column="disc_no" jdbcType="VARCHAR" property="discNo"/>
        <result column="disc_name" jdbcType="VARCHAR" property="discName"/>
        <result column="begin_time" jdbcType="TIMESTAMP" property="beginTime"/>
        <result column="end_time" jdbcType="TIMESTAMP" property="endTime"/>
        <result column="disc_res" jdbcType="INTEGER" property="discRes"/>
        <result column="disc_type" jdbcType="INTEGER" property="discType"/>
        <result column="disc_state" jdbcType="INTEGER" property="discState"/>
        <result column="auditor_status" jdbcType="INTEGER" property="auditorStatus"/>
        <result column="remarks" jdbcType="VARCHAR" property="remarks"/>
        <result column="data_state" jdbcType="INTEGER" property="dataState"/>
        <result column="create_empid" jdbcType="VARCHAR" property="createEmpid"/>
        <result column="create_name" jdbcType="VARCHAR" property="createName"/>
        <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
        <result column="modify_empid" jdbcType="VARCHAR" property="modifyEmpid"/>
        <result column="modify_name" jdbcType="VARCHAR" property="modifyName"/>
        <result column="modify_date" jdbcType="TIMESTAMP" property="modifyDate"/>
    </resultMap>
    <sql id="Base_Column_List">
        id,
        pl_no,
        disc_no,
        disc_name,
        begin_time,
        end_time,
        disc_res,
        disc_type,
        disc_state,
        auditor_status,
        remarks,
        data_state,
        create_empid,
        create_name,
        create_date,
        modify_empid,
        modify_name,
        modify_date
    </sql>
    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from t_activity_discount
        where id = #{id,jdbcType=BIGINT}
    </select>

    <!-- 分页查询 -->
    <select id="queryDiscountRuleForPage" resultMap="BaseResultMap"
            parameterType="com.zteits.clouds.api.dto.bill.discount.param.DiscountRuleForPageRequest">
        select
        a.id,
        a.disc_no,
        a.disc_name,
        a.pl_no,
        a.disc_type,
        a.begin_time,
        a.end_time,
        a.disc_state
        FROM t_activity_discount a
        where a.data_state = 1
        <if test="discName != null and discName !=''">
            and a.disc_name like CONCAT('%','${discName}','%' )
        </if>
        <if test="plNos != null and plNos.size >0">
            and a.pl_no in
            <foreach collection="plNos" open="(" close=")" item="plNo" separator=",">
                #{plNo}
            </foreach>
        </if>
        <if test="discState != null and discState != 3 ">
            and a.disc_state = #{discState}
        </if>
        <if test="endDate != null ">
            and DATE(a.end_time) = #{endDate}
        </if>
        Order by a.create_date desc
    </select>

    <!--通过停车场编码校验折扣唯一性-->
    <select id="checkDiscountUniqueByPlNo"
            parameterType="com.zteits.clouds.api.dto.bill.discount.param.CheckDiscountUniqueByPlNoRequest"
            resultType="java.lang.Integer">
        SELECT
            count(1)
        FROM
            t_activity_discount a
        WHERE
            a.data_state = 1
          and a.pl_no = #{plNo}
          and a.disc_type = #{discType}
    </select>

    <select id="queryDiscountByPlNos" resultType="com.zteits.bill.domain.TActivityDiscount">
        SELECT
            a.pl_no AS plNo,
            a.disc_no AS discNo,
            a.disc_name AS discName,
            a.begin_time AS beginTime,
            a.end_time AS endTime,
            a.disc_res AS discRes,
            a.disc_type AS discType,
            a.disc_state AS discState,
            a.auditor_status AS auditorStatus,
            a.data_state AS dataState
        FROM
            t_activity_discount a
        WHERE
            a.data_state = 1
            AND a.pl_no = #{plNo}
    </select>

    <update id="updateDiscountRuleExpireDateByPlNos">
        UPDATE t_activity_discount
        SET data_state = 0,
        modify_date = #{nowDate}
        WHERE data_state = 1
          and disc_type = #{discType}
          and disc_no = #{discNo}
    </update>

</mapper>