ResidentPointGrowthLevelConfigMapper.xml 5.9 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="cn.com.glsx.dj.mindworkplate.mapper.ResidentPointGrowthLevelConfigMapper">
    <resultMap id="BaseResultMap" type="cn.com.glsx.dj.mindworkplate.model.ResidentPointGrowthLevelConfig">
        <!--
          WARNING - @mbg.generated
        -->
        <id column="id" property="id" jdbcType="INTEGER"/>
        <result column="level_type" property="levelType" jdbcType="TINYINT"/>
        <result column="level_name" property="levelName" jdbcType="VARCHAR"/>
        <result column="ranking" property="ranking" jdbcType="INTEGER"/>
        <result column="rating_project_type" property="ratingProjectType" jdbcType="VARCHAR"/>
        <result column="high_ranking" property="highRanking" jdbcType="INTEGER"/>
        <result column="min_ranking" property="minRanking" jdbcType="INTEGER"/>
        <result column="rating_cycle" property="ratingCycle" jdbcType="INTEGER"/>
        <result column="open_state" property="openState" jdbcType="BIT"/>
        <result column="created_by" property="createdBy" jdbcType="VARCHAR"/>
        <result column="created_date" property="createdDate" jdbcType="TIMESTAMP"/>
        <result column="updated_by" property="updatedBy" jdbcType="VARCHAR"/>
        <result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP"/>
        <result column="deleted_flag" property="deletedFlag" jdbcType="CHAR"/>
        <result column="medal_type" property="medalType" jdbcType="INTEGER"/>
        <result column="growth_type" property="growthType" jdbcType="INTEGER"/>
        <result column="other_rewards" property="otherRewards" jdbcType="LONGVARCHAR"/>
        <result column="point_type" property="pointType" jdbcType="VARCHAR"/>
        <result column="point_classification" property="pointClassification" jdbcType="VARCHAR"/>
        <result column="rating_method" property="ratingMethod" jdbcType="INTEGER"/>
    </resultMap>
    <resultMap id="DTOResultMap" extends="BaseResultMap"
               type="cn.com.glsx.dj.mindworkplate.dto.ResidentPointGrowthLevelConfigDTO">
        <result column="points_category_name" property="pointsCategoryName" jdbcType="VARCHAR"/>
        <result column="points_type_name" property="pointsTypeName" jdbcType="VARCHAR"/>
        <result column="lineation_price_total" property="lineationPriceTotal" jdbcType="VARCHAR"/>
        <result column="cost_price_total" property="costPriceTotal" jdbcType="VARCHAR"/>
<!--        <collection property="relCouponList" columnPrefix="rcl_"  javaType="java.util.List"-->
<!--                    resultMap="cn.com.glsx.dj.mindworkplate.mapper.ResidentPointLevelCouponRefMapper.DTOResultMap">-->
<!--        </collection>-->
    </resultMap>
    <sql id="Base_Column_List">
        <!--
          WARNING - @mbg.generated
        -->
        id, level_type, level_name, ranking, rating_project_type, high_ranking, min_ranking,
        rating_cycle, open_state, created_by, created_date, updated_by, updated_date,
        deleted_flag, medal_type, growth_type, other_rewards, point_type, point_classification, rating_method
    </sql>

    <select id="page" resultMap="DTOResultMap">
        select rpglc.*,spc.points_category_name,spt.points_type_name,rplcr.coup_id AS rcl_coup_id,
        rplcr.coupon_brand_name rcl_coupon_brand_name,rplcr.coupon_name rcl_coupon_name,
        rplcr.lineation_price rcl_lineation_price,rplcr.cost_price rcl_cost_price,rplcr.id rcl_id,
        rplcr.coupon_count rcl_coupon_count,rplcr.coupon_goods_id rcl_coupon_goods_id
        from resident_point_growth_level_config rpglc
        left join store_points_category spc on rpglc.point_classification = spc.category_code and spc.deleted_flag = 'N'
        left join store_points_type spt on rpglc.point_type = spt.type_code and spt.deleted_flag = 'N'
        left join resident_point_level_coupon_ref rplcr on rpglc.id = rplcr.level_config_id and rplcr.deleted_flag = 'N'
        where rpglc.deleted_flag = 'N'
        <if test="levelName != null and levelName != ''">
            and rpglc.level_name = #{levelName}
        </if>
        <if test="levelType != null">
            and rpglc.level_type = #{levelType}
        </if>
        <if test="openState != null">
            and rpglc.open_state = #{openState}
        </if>
        group by rpglc.id
        order by rpglc.level_type,rpglc.high_ranking desc
    </select>

    <select id="queryExistConfigCount" resultType="java.lang.Integer">
        select count(1)
        from resident_point_growth_level_config rpglc
        where rpglc.deleted_flag = 'N'
        <if test="levelType != null">
            and rpglc.level_type = #{levelType}
        </if>
        <if test="ratingMethod != null">
            and rpglc.rating_method = #{ratingMethod}
            <if test="ratingMethod == 1">
                and (
                <choose>
                    <when test="highRanking != null and minRanking != null">
                        (rpglc.high_ranking > #{highRanking} and #{highRanking} > rpglc.min_ranking)
                        or (rpglc.high_ranking > #{minRanking} and #{minRanking} > rpglc.min_ranking)
                    </when>
                    <when test="highRanking != null">
                        (rpglc.high_ranking > #{highRanking} and #{highRanking} > rpglc.min_ranking)
                    </when>
                    <when test="minRanking != null">
                        (rpglc.high_ranking > #{minRanking} and #{minRanking} > rpglc.min_ranking)
                    </when>
                    <otherwise>
                    </otherwise>
                </choose>
                )
            </if>
        </if>
        <if test="pointClassification != null and pointClassification != ''">
            and rpglc.point_classification = #{pointClassification}
        </if>
        <if test="id != null">
            and rpglc.id != #{id}
        </if>
    </select>
</mapper>