TdClSubCardInfoSMapper.xml 9.07 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.TdClSubCardInfoSMapper">
    <resultMap id="BaseResultMap" type="com.zteits.bill.domain.TdClSubCardInfo">
        <id column="id" jdbcType="BIGINT" property="id" />
        <result column="card_no" jdbcType="VARCHAR" property="cardNo" />
        <result column="card_name" jdbcType="VARCHAR" property="cardName" />
        <result column="pl_no" jdbcType="VARCHAR" property="plNo" />
        <result column="pl_name" jdbcType="VARCHAR" property="plName" />
        <result column="effect_time" jdbcType="TIMESTAMP" property="effectTime" />
        <result column="expire_time" jdbcType="TIMESTAMP" property="expireTime" />
        <result column="customer_no" jdbcType="VARCHAR" property="customerNo" />
        <result column="area_no" jdbcType="VARCHAR" property="areaNo" />
        <result column="area_name" jdbcType="VARCHAR" property="areaName" />
        <result column="data_status" jdbcType="INTEGER" property="dataStatus" />
        <result column="customer_name" jdbcType="VARCHAR" property="customerName" />
        <result column="card_status" jdbcType="INTEGER" property="cardStatus" />
        <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
        <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
        <result column="phone_no" jdbcType="VARCHAR" property="phoneNo" />
        <result column="push_state" jdbcType="INTEGER" property="pushState" />
        <result column="record_no" jdbcType="VARCHAR" property="recordNo" />
        <result column="card_buy_type" jdbcType="INTEGER" property="cardBuyType" />
    </resultMap>
    <sql id="Example_Where_Clause">
        <where>
            <foreach collection="oredCriteria" item="criteria" separator="or">
                <if test="criteria.valid">
                    <trim prefix="(" prefixOverrides="and" suffix=")">
                        <foreach collection="criteria.criteria" item="criterion">
                            <choose>
                                <when test="criterion.noValue">
                                    and ${criterion.condition}
                                </when>
                                <when test="criterion.singleValue">
                                    and ${criterion.condition} #{criterion.value}
                                </when>
                                <when test="criterion.betweenValue">
                                    and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                                </when>
                                <when test="criterion.listValue">
                                    and ${criterion.condition}
                                    <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                                        #{listItem}
                                    </foreach>
                                </when>
                            </choose>
                        </foreach>
                    </trim>
                </if>
            </foreach>
        </where>
    </sql>
    <sql id="Update_By_Example_Where_Clause">
        <where>
            <foreach collection="example.oredCriteria" item="criteria" separator="or">
                <if test="criteria.valid">
                    <trim prefix="(" prefixOverrides="and" suffix=")">
                        <foreach collection="criteria.criteria" item="criterion">
                            <choose>
                                <when test="criterion.noValue">
                                    and ${criterion.condition}
                                </when>
                                <when test="criterion.singleValue">
                                    and ${criterion.condition} #{criterion.value}
                                </when>
                                <when test="criterion.betweenValue">
                                    and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                                </when>
                                <when test="criterion.listValue">
                                    and ${criterion.condition}
                                    <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                                        #{listItem}
                                    </foreach>
                                </when>
                            </choose>
                        </foreach>
                    </trim>
                </if>
            </foreach>
        </where>
    </sql>
    <sql id="Base_Column_List">
    id, card_no, card_name, pl_no, pl_name, effect_time, expire_time, customer_no, area_no,
    area_name, data_status, customer_name, card_status, create_date, update_date
  </sql>


    <select id="selectDataByExample" parameterType="com.zteits.bill.domain.TdClSubCardInfoExample" resultMap="BaseResultMap">
        SELECT
        s.id,
        s.card_no,
        s.card_name,
        s.pl_no,
        s.pl_name,
        s.effect_time,
        s.expire_time,
        s.customer_no,
        IF
        (
        s.card_status = 0,
        0,
        IF
        ( now( ) &lt;s.effect_time, 1, IF ( now( ) &lt; s.expire_time, 2, 3 ) )
        ) card_status,
        s.customer_name
        FROM
        td_cl_sub_card_info s

        <if test="_parameter != null">
            <include refid="Example_Where_Clause" />
        </if>
        <if test="orderByClause != null">
            order by ${orderByClause}
        </if>
    </select>

    <select id="selectDataDtoByExample" parameterType="com.zteits.clouds.api.dto.bill.closecarpark.param.SubCardInfoManageInfoRequest"
            resultType="com.zteits.clouds.api.dto.bill.closecarpark.dto.SubCardInfoDTO">
        SELECT
        s.id,
        s.card_no cardNo,
        s.card_name cardName,
        s.pl_no plNo,
        s.effect_time effectTime,
        s.expire_time expireTime,
        s.customer_no customerNo,
        s.phone_no phoneNo,
        IF
        (
        s.card_status = 0,
        0,
        IF
        ( now( ) &lt;s.effect_time, 1, IF ( now( ) &lt; s.expire_time, 2, 3 ) )
        ) cardStatus,
        s.customer_name customerName,
        s.push_state pushState,
        s.record_no recordNo
        FROM
        td_cl_sub_card_info s
        where 1=1
        <if test="cardName != null and cardName != ''">
            and s.card_name like concat('%',#{cardName,jdbcType=VARCHAR},'%')
        </if>
        <if test="cardNo != null and cardNo != ''">
            and s.card_no like concat('%',#{cardNo,jdbcType=VARCHAR},'%')
        </if>
        <if test="plNo != null and plNo != ''">
            and s.pl_no = #{plNo}
        </if>
        <if test="phoneNo != null and phoneNo != ''">
            and s.phone_no like concat('%',#{phoneNo,jdbcType=VARCHAR},'%')
        </if>
        <if test="orgId != null and orgId != ''">
            and s.org_id = #{orgId}
        </if>
            order by s.update_date desc
    </select>


    <select id="selectChargeByPrimaryKey" parameterType="java.lang.Long"
            resultType="com.zteits.clouds.api.dto.bill.closecarpark.dto.SubCardChargeInfoDTO">
        select
        t.card_no cardNo,
        t.card_name cardName,
        t.pl_no plNo,
        t.pl_name plName,
        t.customer_no customerNo,
        t.customer_name customerName,
        t.org_id orgId,
        c.card_rule_name cardRuleName,
        c.unit_price unitPrice,
        c.discount discount,
        c.count count,
        c.effect_time effectTime,
        c.expire_time expireTime,
        c.charge_type chargeType,
        c.charge charge
        from td_cl_sub_card_info t
        left join td_cl_sub_charge_information c
        on t.card_no = c.card_no
        where t.id = #{id,jdbcType=BIGINT}
        and t.data_status = 1
   </select>

    <!-- 查询未推送的子母车卡信息(用于定时任务下发到道闸) -->
    <select id="queryNoPushSubCardInfo" resultType="com.zteits.clouds.api.dto.bill.closecarpark.dto.SubCardPushDTO">
        SELECT
            s.id,
            s.card_no AS cardNo,
            s.card_name AS cardName,
            s.pl_no AS plNo,
            s.customer_name AS customerName,
            s.phone_no AS phoneNo,
            s.effect_time AS effectTime,
            s.expire_time AS expireTime,
            s.push_state AS pushState,
            s.record_no AS recordNo,
            s.card_buy_type AS cardBuyType
        FROM td_cl_sub_card_info s
        WHERE s.push_state = 0
          AND s.data_status = 1
          AND s.effect_time &lt;= NOW()
          AND s.expire_time &gt;= NOW()
          AND s.card_status != 0
        ORDER BY s.id
    </select>

    <!-- 更新子母车推送状态 -->
    <update id="updateSubCardPushState">
        UPDATE td_cl_sub_card_info
        SET push_state = #{pushState},
            record_no = #{recordNo},
            update_date = NOW()
        WHERE id = #{id}
          AND card_no = #{cardNo}
    </update>

</mapper>