TBillingRuleCollectSMapper.xml 5.24 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.TBillingRuleCollectSMapper">
    <resultMap id="BaseResultMap" type="com.zteits.bill.domain.TBillingRuleCollect">
        <id column="id" property="id" jdbcType="INTEGER"/>
        <result column="rule_collect_no" property="ruleCollectNo" jdbcType="VARCHAR"/>
        <result column="rule_no" property="ruleNo" jdbcType="VARCHAR"/>
        <result column="rule_collect_name" property="ruleCollectName" jdbcType="VARCHAR"/>
        <result column="free_time_type" property="freeTimeType" jdbcType="INTEGER"/>
        <result column="day_start_time" property="dayStartTime" jdbcType="TIME"/>
        <result column="day_end_time" property="dayEndTime" jdbcType="TIME"/>
        <result column="org_id" property="orgId" jdbcType="BIGINT"/>
        <result column="data_state" property="dataState" jdbcType="INTEGER"/>
        <result column="create_op" property="createOp" jdbcType="BIGINT"/>
        <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
        <result column="modify_op" property="modifyOp" jdbcType="BIGINT"/>
        <result column="modify_time" property="modifyTime" jdbcType="TIMESTAMP"/>
    </resultMap>


    <resultMap id="queryBillingRuleCollectsByOrgIdResultMap" type="com.zteits.bill.domain.TBillingRuleCollect">
        <id column="id" property="id" jdbcType="INTEGER"/>
        <result column="rule_collect_no" property="ruleCollectNo" jdbcType="VARCHAR"/>
        <result column="rule_no" property="ruleNo" jdbcType="VARCHAR"/>
        <result column="rule_collect_name" property="ruleCollectName" jdbcType="VARCHAR"/>
        <result column="free_time_type" property="freeTimeType" jdbcType="INTEGER"/>
        <result column="day_start_time" property="dayStartTime" javaType="DATE"/>
        <result column="day_end_time" property="dayEndTime" javaType="DATE"/>
        <result column="org_id" property="orgId" jdbcType="BIGINT"/>
        <result column="data_state" property="dataState" jdbcType="INTEGER"/>
        <result column="create_op" property="createOp" jdbcType="BIGINT"/>
        <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
        <result column="modify_op" property="modifyOp" jdbcType="BIGINT"/>
        <result column="modify_time" property="modifyTime" jdbcType="TIMESTAMP"/>
        <result column="frist_free_time" property="freeTime" jdbcType="BIGINT"/>
        <result column="max_charge" property="maxCharge" jdbcType="BIGINT"/>
        <result column="day_max_charge" property="dayMaxCharge" jdbcType="BIGINT"/>
    </resultMap>

    <sql id="Base_Column_List">
        id,
        rule_collect_no,
        rule_no,
        rule_collect_name,
        free_time_type,
        day_start_time,
        day_end_time,
        org_id,
        data_state,
        create_op,
        create_time,
        modify_op,
        modify_time
    </sql>
    <update id="deleteBillingRuleCollect">
        UPDATE t_billing_rule_collect
        set data_state = 0
        WHERE data_state = 1
        AND rule_collect_no IN
        <foreach collection="collectionNos" item="collectionNo" open="(" close=")" separator=",">
            #{collectionNo}
        </foreach>
    </update>

    <select id="queryBillingRuleCollectsByOrgId" resultMap="queryBillingRuleCollectsByOrgIdResultMap">

        SELECT
        m.*,
        n.frist_free_time,
        n.max_charge,
        n.day_max_charge
        FROM (
        SELECT *
        FROM t_billing_rule_collect
        WHERE id IN (
        SELECT max(id)
        FROM t_billing_rule_collect
        <if test="null!=orgId">
            WHERE org_id = #{orgId}
        </if>
        and data_state = 1
        GROUP BY rule_collect_no)) m, t_billing_rule n
        WHERE m.rule_no = n.rule_no

        ORDER BY n.frist_free_time DESC ;


    </select>


    <select id="queryBillingRuleCollectByPlNo" resultMap="BaseResultMap">
        SELECT n.id,
               n.rule_collect_no,
               n.rule_no,
               n.rule_collect_name,
               n.free_time_type,
               n.day_start_time,
               n.day_end_time,
               n.org_id,
               n.data_state,
               n.create_op,
               n.create_time,
               n.modify_op,
               n.modify_time
        FROM t_billing_park_rule_rel m,
             t_billing_rule_collect n
        WHERE m.data_state = 1
          AND n.data_state = 1
          AND m.check_state = 3
          AND #{inTime} &gt;= m.effect_time
          AND #{inTime} &lt;= m.expire_time
          AND m.rule_collect_no = n.rule_collect_no
          AND m.pl_no = #{plNo}

    </select>
    <select id="queryBillingRuleCollectByCollectionNo" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from t_billing_rule_collect
        where rule_collect_no = #{collectionNo}
        and data_state = 1


    </select>
    <select id="queryEffectRuleCollect" resultType="java.lang.Integer">
        SELECT count(DISTINCT pl_no)
        FROM t_billing_park_rule_rel
        WHERE rule_collect_no = #{collectionNo}
          AND data_state = 1
          AND expire_time >= #{queryDate}
    </select>


</mapper>