ReceptionMaterialMerchantConfigMapper.xml 9.49 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.ReceptionMaterialMerchantConfigMapper">
    <resultMap id="BaseResultMap" type="cn.com.glsx.dj.mindworkplate.model.ReceptionMaterialMerchantConfigDTO">
        <!--
          WARNING - @mbg.generated
        -->
        <id column="id" property="id" jdbcType="INTEGER"/>
        <result column="merchant_id" property="merchantId" jdbcType="INTEGER"/>
        <result column="merchant_name" property="merchantName" jdbcType="VARCHAR"/>
        <result column="status" property="status" jdbcType="TINYINT"/>
        <result column="is_default" property="isDefault" jdbcType="BIT"/>
        <result column="business_scene" property="businessScene" jdbcType="VARCHAR"/>
        <result column="config_type" property="configType" jdbcType="TINYINT"/>
        <result column="recommend_package_config_type" property="recommendPackageConfigType"/>
        <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="hide_package" property="hidePackage" jdbcType="BIT"/>
    </resultMap>

    <resultMap id="ReceptionMaterialInfoResponseMap" extends="BaseResultMap"
               type="cn.com.glsx.dj.mindworkplate.response.reception.ReceptionMaterialInfoVO">
        <!--    <id column="id" property="id" jdbcType="INTEGER" />-->
        <!--    <result column="merchant_id" property="merchantId" jdbcType="INTEGER" />-->
        <!--    <result column="merchant_name" property="merchantName" jdbcType="VARCHAR" />-->
        <!--    <collection property="materials" javaType="java.util.List"-->
        <!--                ofType="cn.com.glsx.dj.mindworkplate.response.reception.Material">-->
        <!--      <result column="car_model_id" property="carModelId" jdbcType="INTEGER" />-->
        <!--      <result column="car_model_name" property="carModelName" jdbcType="VARCHAR" />-->
        <!--      <collection property="packages" javaType="java.util.List" columnPrefix="rmpi_"-->
        <!--                  ofType="cn.com.glsx.dj.mindworkplate.response.reception.Package">-->
        <!--        <result column="category" property="category" jdbcType="VARCHAR" />-->
        <!--        <collection property="packageInfoList" javaType="java.util.List" columnPrefix="rmpi_"-->
        <!--                    ofType="cn.com.glsx.dj.mindworkplate.model.ReceptionMaterialPackageInfoDTO">-->
        <!--          <result column="package_name" property="packageName" jdbcType="VARCHAR" />-->
        <!--          <result column="model_display_picurl" property="modelDisplayPicurl" jdbcType="VARCHAR" />-->
        <!--          <result column="choose_card_picurl" property="chooseCardPicurl" jdbcType="VARCHAR" />-->
        <!--          <result column="detail_picurl" property="detailPicurl" jdbcType="VARCHAR" />-->
        <!--          <result column="description" property="description" jdbcType="VARCHAR" />-->
        <!--        </collection>-->
        <!--      </collection>-->
        <!--    </collection>-->
        <!--        <association property="materials" resultMap="cn.com.glsx.dj.mindworkplate.mapper.ReceptionMaterialCarModelInfoMapper.BaseResultMap"-->
        <!--                     columnPrefix="rmcmi_" />-->

        <collection property="materials" javaType="java.util.List"
                    resultMap="cn.com.glsx.dj.mindworkplate.mapper.ReceptionMaterialCarModelInfoMapper.VOMaterialMap"
                    columnPrefix="rmcmi_"/>
    </resultMap>

    <sql id="Base_Column_List">
        <!--
          WARNING - @mbg.generated
        -->
        id, merchant_id, merchant_name, status, isDefault, business_scene, config_type,recommend_package_config_type, created_by,
        created_date, updated_by, updated_date, deleted_flag, hide_package
    </sql>

    <insert id="insertBatchMaterial" useGeneratedKeys="true" keyProperty="id">
        <choose>
            <when test="business == 'CarModel'">
                <include refid="cn.com.glsx.dj.mindworkplate.mapper.ReceptionMaterialCarModelInfoMapper.insert_material_sql"/>
            </when>
<!--            <when test="business == Package">-->
<!--                <include refid="cn.com.glsx.dj.mindworkplate.mapper.ReceptionMaterialPackageInfoMapper.insert_material_sql"/>-->
<!--            </when>-->
<!--            <when test="business == Film">-->
<!--                <include refid="cn.com.glsx.dj.mindworkplate.mapper.ReceptionMaterialFilmInfoMapper.insert_material_sql"/>-->
<!--            </when>-->
<!--            <when test="business == Product">-->
<!--                <include refid="cn.com.glsx.dj.mindworkplate.mapper.ReceptionMaterialProductInfoMapper.insert_material_sql"/>-->
<!--            </when>-->
<!--            <when test="business == Case">-->
<!--                <include refid="cn.com.glsx.dj.mindworkplate.mapper.ReceptionMaterialCaseInfoMapper.insert_material_sql"/>-->
<!--            </when>-->
<!--            <when test="business == Optional">-->
<!--                <include refid="cn.com.glsx.dj.mindworkplate.mapper.ReceptionMaterialOptionalInfoDTOMapper.insert_material_sql"/>-->
<!--            </when>-->
            <otherwise>
            </otherwise>
        </choose>
    </insert>

    <insert id="insertBatchMaterial1" parameterType="java.util.List">
        insert INTO
        <include refid="cn.com.glsx.dj.mindworkplate.mapper.ReceptionMaterialCarModelInfoMapper.Insert_Column_List"/>
        VALUES
        <foreach collection="list" item="info" index="index" separator=",">
            (
            <include
                    refid="cn.com.glsx.dj.mindworkplate.mapper.ReceptionMaterialCarModelInfoMapper.Insert_Property_List">
                <property name="prefix" value="info"/>
            </include>
            )
        </foreach>
    </insert>

    <insert id="insertByDefault" useGeneratedKeys="true" keyProperty="id">
        INSERT INTO reception_material_merchant_config
        ( merchant_id, merchant_name, config_type,recommend_package_config_type, hide_package )
        select #{merchantId},#{merchantName},#{configType},#{recommendPackageConfigType},t1.hide_package
        from reception_material_merchant_config t1
        where t1.id = 1
    </insert>

    <select id="selectMerchantConfig" resultMap="ReceptionMaterialInfoResponseMap">
        select
        t.id,t.merchant_id,t.merchant_name,t.business_scene,t.config_type,t.recommend_package_config_type,t.status,t.hide_package,
        <include refid="cn.com.glsx.dj.mindworkplate.mapper.ReceptionMaterialCarModelInfoMapper.Prefix_Column">
            <property name="prefix" value="rmcmi"/>
        </include>
        from (
        select * from reception_material_merchant_config rmmc
        where rmmc.deleted_flag = 'N' and (rmmc.config_type = 1
        <choose>
            <when test="merchantId != null">
                and rmmc.merchant_id = #{merchantId}
            </when>
            <otherwise>
                and rmmc.merchant_id is null
            </otherwise>
        </choose>
        or rmmc.is_default = 1)
        order by rmmc.id desc limit 1
        ) t
        left join reception_material_car_model_info rmcmi on t.id = rmcmi.merchant_config_id
        and rmcmi.deleted_flag = 'N'
        order by rmcmi.sort
    </select>

    <select id="selectReceptionMaterialCategory" resultType="java.util.Map">
        select t1.* from(
        select t.car_model_name carModelName, t.category
<!--        case when t.car_model_name is null then '其他' else t.car_model_name end as carModelName,-->
<!--        case when t.category is null then '其他' else t.category end as t.category-->
        from reception_material_merchant_config rmmc
        left join
        <choose>
            <when test="business != null">
                reception_material_${business}_info
            </when>
            <otherwise>
                reception_material_case_info
            </otherwise>
        </choose>
        t
        on t.merchant_config_id = rmmc.id
        and t.deleted_flag = 'N'
        where rmmc.deleted_flag = 'N' and t.car_model_name is not null and t.category is not null
        <if test="merchantId != null">
            and rmmc.merchant_id = #{merchantId}
        </if>
        <if test="condition.materialName != null and condition.materialName != ''">
            and t.name like CONCAT ('%',#{condition.materialName},'%')
        </if>
        having 1
        order by t.sort
        )t1 group by t1.carModelName,t1.category
    </select>
    <select id="findHomePageConfigPage"
            resultType="cn.com.glsx.dj.mindworkplate.model.ReceptionMaterialMerchantConfigDTO">
        select rhpmc.*,
        concat_ws(',', group_concat(case when rhpcr.rel_type = 1 then rhpcr.rel_item_name else null end)) merchant_list,
        concat_ws(',', group_concat(case when rhpcr.rel_type = 2 then rhpcr.rel_item_name else null end)) brand_list,
        concat_ws(',', group_concat(case when rhpcr.rel_type = 3 then rhpcr.rel_item_name else null end)) sub_brand_list
        from reception_home_page_material_config rhpmc
        left join reception_home_page_config_rel rhpcr on rhpmc.id = rhpcr.config_id and rhpcr.deleted_flag = 'N'
        group by rhpmc.id
    </select>
</mapper>