TdClCompanyAccInfoSMapper.xml 8.66 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.pay.mapper.smapper.TdClCompanyAccInfoSMapper">
    <resultMap id="BaseResultMap" type="com.zteits.pay.domain.TdClCompanyAccInfo">
        <id column="id" jdbcType="BIGINT" property="id" />
        <result column="acc_code" jdbcType="VARCHAR" property="accCode" />
        <result column="customer_no" jdbcType="VARCHAR" property="customerNo" />
        <result column="acct_balance" jdbcType="BIGINT" property="acctBalance" />
        <result column="max_arrear" jdbcType="BIGINT" property="maxArrear" />
        <result column="acc_status" jdbcType="CHAR" property="accStatus" />
        <result column="create_empid" jdbcType="VARCHAR" property="createEmpid" />
        <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
        <result column="modfiy_empid" jdbcType="VARCHAR" property="modfiyEmpid" />
        <result column="modfiy_date" jdbcType="TIMESTAMP" property="modfiyDate" />
        <result column="num" jdbcType="VARCHAR" property="plNo" />
        <result column="org_id" jdbcType="BIGINT" property="orgId" />
        <result column="customer_name" jdbcType="VARCHAR" property="customerName" />
        <collection property="parkRelationList"
                    select="com.zteits.pay.mapper.TdClCompanyAccInfoMapper.viewParkRelation"
                    column="{accCode=acc_code}">
        </collection>
    </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, acc_code, customer_no, acct_balance, max_arrear, acc_status, create_empid, create_date,
    modfiy_empid, modfiy_date,org_id
  </sql>

    <!--
        <select id="selectByDataExample" parameterType="com.zteits.clouds.api.dto.pay.param.QueryCompanyAccountRequest" resultMap="BaseResultMap">
            select * from ( SELECT
            a.acc_code,
            a.customer_no,
            a.acct_balance,
            GROUP_CONCAT( p.pl_no ) as num,
            m.customer_name,
            a.acc_status
            FROM
            td_cl_company_acc_info a
            LEFT JOIN td_cl_company_acc_park_relation p ON a.acc_code = p.acc_code
            LEFT JOIN td_cl_customer_management m ON a.customer_no = m.customer_no
            GROUP BY
            a.acc_code
            ) h
            where 1=1
            <if test="plNo != null and plNo != ''">
               and h.num like CONCAT('%',#{plNo},'%')
            </if>
            <if test="customerNo != null and customerNo != ''">
                and h.customer_no = #{customerNo}
            </if>
            <if test="accStatus != null and accStatus != ''">
                and h.acc_status = #{accStatus}
            </if>

        </select>-->


    <select id="selectByDataDtoExample" parameterType="com.zteits.clouds.api.dto.pay.param.QueryCompanyAccountRequest"
            resultMap="BaseResultMap">
        select * from ( SELECT
        a.id,
        a.acc_code,
        a.customer_no,
        a.acct_balance,
        a.max_arrear,
        GROUP_CONCAT( p.pl_no ) as num,
        m.customer_name,
        a.acc_status,
        a.modfiy_date
        FROM
        td_cl_company_acc_info a
        LEFT JOIN td_cl_company_acc_park_relation p ON a.acc_code = p.acc_code
        LEFT JOIN td_cl_customer_management m ON a.customer_no = m.customer_no
        GROUP BY
        a.acc_code
        ) h
        where 1=1
        <if test="plNo != null and plNo != ''">
            and h.num like CONCAT('%',#{plNo},'%')
        </if>
        <if test="customerNo != null and customerNo != ''">
            and h.customer_no = #{customerNo}
        </if>
        <if test="accStatus != null and accStatus != ''">
            and h.acc_status = #{accStatus}
        </if>

        order by h.modfiy_date desc
    </select>

    <select id="viewCompanyAccount" parameterType="com.zteits.clouds.api.dto.pay.param.ViewCompanyAccountRequest"  resultMap="BaseResultMap">
        SELECT
        a.id,
        a.acc_code,
        a.customer_no,
        c.customer_name,
        a.acct_balance,
        a.max_arrear,
        a.org_id
        FROM
        td_cl_company_acc_info a
        LEFT JOIN td_cl_customer_management c on a.customer_no = c.customer_no
        where 1=1
        <if test="accCode != null and accCode != ''">
            and a.acc_code = #{accCode}
        </if>

    </select>

    <select id="viewParkRelation" parameterType="com.zteits.clouds.api.dto.pay.param.ViewCompanyAccountRequest"
            resultType="com.zteits.pay.domain.TdClCompanyAccParkRelation">
        SELECT
        p.id,
        p.acc_code accCode ,
        p.pl_no plNo
        FROM
        td_cl_company_acc_park_relation p
        where 1=1
        <if test="accCode != null and accCode != ''">
            and p.acc_code = #{accCode}
        </if>

    </select>

    <!-- 更新余额 -->
    <update id="updateAccountBalance">
        update td_cl_company_acc_info
        set
            acct_balance = #{balance}
        where
            acc_code = #{accCode}
    </update>

    <!-- 根据停车场编号以及公司编号,获取对应的账户信息 -->
    <select id="queryCompanyAccInfo"
            resultType="com.zteits.pay.domain.TdClCompanyAccInfo">
         SELECT
            t.id,
            t.acc_code as accCode,
            t.customer_no as customerNo,
            t.acct_balance as acctBalance,
            t.acc_status as accStatus,
            t.max_arrear as maxArrear
        FROM
            td_cl_company_acc_info t
            LEFT JOIN td_cl_company_acc_park_relation r ON t.acc_code = r.acc_code
        WHERE
            t.acc_status = 1
            AND t.customer_no = #{customerNo}
            AND r.pl_no = #{plNo}
            limit 1
    </select>

</mapper>