123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411 |
- <?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.kmall.admin.dao.mk.dist.MkDistHierDao">
- <resultMap type="com.kmall.admin.entity.mk.dist.MkDistHierEntity" id="mkDistHierMap">
- <result property="distHierId" column="dist_hier_id"/>
- <result property="distChnlId" column="dist_chnl_id"/>
- <result property="pdistId" column="pdist_id"/>
- <result property="distId" column="dist_id"/>
- <result property="distHierName" column="dist_hier_name"/>
- <result property="distHierNname" column="dist_hier_nname"/>
- <result property="hierLvl" column="hier_lvl"/>
- <result property="supplierId" column="supplier_id"/>
- <result property="sortOrder" column="sort_order"/>
- <result property="isValid" column="is_valid"/>
- <result property="note" column="note"/>
- <result property="createrSn" column="creater_sn"/>
- <result property="createTime" column="create_time"/>
- <result property="moderSn" column="moder_sn"/>
- <result property="modTime" column="mod_time"/>
- <result property="tstm" column="tstm"/>
- <result property="pdDistName" column="pdDistName"/>
- <result property="distName" column="distName"/>
- <result property="distFlag" column="distFlag"/>
- <result property="childSupplierName" column="childSupplierName"/>
- </resultMap>
- <select id="queryObject" resultType="com.kmall.admin.entity.mk.dist.MkDistHierEntity">
- select
- `dist_hier_id`,
- `dist_chnl_id`,
- `pdist_id`,
- `dist_id`,
- `dist_hier_name`,
- `dist_hier_nname`,
- `hier_lvl`,
- `supplier_id`,
- `sort_order`,
- `is_valid`,
- `note`,
- `creater_sn`,
- `create_time`,
- `moder_sn`,
- `mod_time`,
- `tstm`
- from mk_dist_hier
- where dist_hier_id = #{id}
- </select>
- <select id="queryObjectByName" resultType="com.kmall.admin.entity.mk.dist.MkDistHierEntity">
- select
- `dist_hier_id`,
- `dist_chnl_id`,
- `pdist_id`,
- `dist_id`,
- `dist_hier_name`,
- `dist_hier_nname`,
- `hier_lvl`,
- `supplier_id`,
- `sort_order`,
- `is_valid`,
- `note`,
- `creater_sn`,
- `create_time`,
- `moder_sn`,
- `mod_time`,
- `tstm`
- from mk_dist_hier
- where dist_hier_name = #{distHierName}
- </select>
- <select id="queryObjectByPdistIdAndChnlId" resultType="com.kmall.admin.entity.mk.dist.MkDistHierEntity">
- select
- h.`dist_hier_id`,
- h.`dist_chnl_id`,
- h.`pdist_id`,
- h.`dist_id`,
- h.`dist_hier_name`,
- h.`dist_hier_nname`,
- h.`hier_lvl`,
- h.`supplier_id`,
- h.`sort_order`,
- h.`is_valid`,
- h.`note`,
- h.`creater_sn`,
- h.`create_time`,
- h.`moder_sn`,
- h.`mod_time`,
- h.`tstm`,cc.dist_flag,d.dist_name
- from mk_dist_hier h
- left join mk_dist_chnl cc on h.dist_chnl_id = cc.dist_chnl_id
- left join mk_dist d on h.pdist_id = d.dist_id
- where 1=1
- <if test="pdistId != null and pdistId != ''">
- and h.pdist_id = #{pdistId}
- </if>
- <if test="distChnlId != null and distChnlId != ''">
- and h.dist_chnl_id = #{distChnlId}
- </if>
- order by h.mod_time desc
- </select>
- <select id="queryList" resultType="com.kmall.admin.entity.mk.dist.MkDistHierEntity">
- select
- h.`dist_hier_id`,
- h.`dist_chnl_id`,
- h.`pdist_id` 'parentId',
- h.`dist_id`,
- h.`dist_hier_name`,
- h.`dist_hier_nname`,
- h.`hier_lvl`,
- h.`supplier_id`,
- h.`sort_order`,
- h.`is_valid`,
- h.`note`,
- h.`creater_sn`,
- h.`create_time`,
- h.`moder_sn`,
- h.`mod_time`,
- h.`tstm`,d1.dist_name 'parentName',d2.dist_name 'name',dc.dist_flag 'distFlag',s.child_supplier_name 'childSupplierName'
- from mk_dist_hier h
- left join mk_dist_chnl dc on h.dist_chnl_id = dc.dist_chnl_id
- left join mk_dist d1 on h.pdist_id = d1.dist_id
- left join mk_dist d2 on h.dist_id = d2.dist_id
- left join mall_supplier s on h.supplier_id = s.id
- left join third_merchant_biz t on dc.third_merch_sn = t.third_merch_sn
- LEFT JOIN mall_store st ON d1.store_id = st.id
- LEFT JOIN mall_store st2 ON d2.store_id = st2.id
- WHERE 1=1
- <if test="distHierName != null and distHierName.trim() != ''">
- AND h.dist_hier_name LIKE concat('%',#{distHierName},'%')
- </if>
- <if test="pdistId != null and pdistId != ''">
- AND h.pdist_id = #{pdistId}
- </if>
- <if test="distId != null and distId != ''">
- AND h.dist_id = #{distId}
- </if>
- <if test="thirdMerchSn != null and thirdMerchSn != ''">
- AND dc.third_merch_sn = #{thirdMerchSn}
- </if>
- <if test="merchSn != null and merchSn != ''">
- AND t.merch_sn = #{merchSn}
- </if>
- <if test="thirdPartyMerchCode != null and thirdPartyMerchCode != ''">
- AND t.third_party_merch_code = #{thirdPartyMerchCode}
- </if>
- <if test="storeId != null and storeId != ''">
- AND st2.id = #{storeId}
- </if>
- <choose>
- <when test="sidx != null and sidx.trim() != ''">
- order by ${sidx} ${order}
- </when>
- <otherwise>
- order by h.dist_hier_id desc
- </otherwise>
- </choose>
- <if test="offset != null and limit != null">
- limit #{offset}, #{limit}
- </if>
- </select>
- <select id="queryTotal" resultType="int">
- select count(*) from mk_dist_hier h
- left join mk_dist_chnl dc on h.dist_chnl_id = dc.dist_chnl_id
- left join mk_dist d1 on h.pdist_id = d1.dist_id
- left join mk_dist d2 on h.dist_id = d2.dist_id
- left join mall_supplier s on h.supplier_id = s.id
- left join third_merchant_biz t on dc.third_merch_sn = t.third_merch_sn
- LEFT JOIN mall_store st ON d1.store_id = st.id
- LEFT JOIN mall_store st2 ON d2.store_id = st2.id
- WHERE 1=1
- <if test="distHierName != null and distHierName.trim() != ''">
- AND h.dist_hier_name LIKE concat('%',#{distHierName},'%')
- </if>
- <if test="pdistId != null">
- AND h.pdist_id = #{pdistId}
- </if>
- <if test="thirdMerchSn != null and thirdMerchSn != ''">
- AND dc.third_merch_sn = #{thirdMerchSn}
- </if>
- <if test="merchSn != null and merchSn != ''">
- AND t.merch_sn = #{merchSn}
- </if>
- <if test="thirdPartyMerchCode != null and thirdPartyMerchCode != ''">
- AND t.third_party_merch_code = #{thirdPartyMerchCode}
- </if>
- <if test="storeId != null and storeId != ''">
- AND st2.id = #{storeId}
- </if>
- </select>
- <select id="queryListByTree" resultType="com.kmall.admin.entity.mk.dist.MkDistHierEntity">
- SELECT
- h.`dist_id`,
- h.`pdist_id`,
- d2.dist_name NAME,
- d1.dist_name parentName,
- h.hier_lvl,
- h.dist_chnl_id
- FROM
- mk_dist_hier h
- LEFT JOIN mk_dist_chnl dc ON h.dist_chnl_id = dc.dist_chnl_id
- LEFT JOIN mk_dist d1 ON h.pdist_id = d1.dist_id
- LEFT JOIN mk_dist d2 ON h.dist_id = d2.dist_id
- WHERE
- 1 = 1
- <if test="pdistId != null and pdistId != ''">
- AND h.pdist_id = ( SELECT pdist_id FROM mk_dist_hier WHERE 1 = 1 and dist_id = #{pdistId})
- </if>
- <if test="distId != null and distId != ''">
- AND h.dist_id = #{distId}
- </if>
- <if test="hierLvl != null and hierLvl != ''">
- AND h.hier_lvl = #{hierLvl}
- </if>
- <choose>
- <when test="sidx != null and sidx.trim() != ''">
- order by ${sidx} ${order}
- </when>
- </choose>
- </select>
- <!--
- <select id="queryListByTree" resultType="com.kmall.admin.entity.mk.MkDistHierEntity">
- <!–select * from (–>
- select
- h.`dist_id`,
- h.`pdist_id`,
- d2.dist_name name,
- d1.dist_name parentName,
- h.hier_lvl
- from mk_dist_hier h
- left join mk_dist_chnl dc on h.dist_chnl_id = dc.dist_chnl_id
- left join mk_dist d1 on h.pdist_id = d1.dist_id
- left join mk_dist d2 on h.dist_id = d2.dist_id
- WHERE 1=1
- <if test="pdistId != null">
- AND h.pdist_id = #{pdistId}
- </if>
- <!–UNION all–>
- <!–select d1.`dist_id` dist_id,–>
- <!–d1.is_valid pdist_id,–>
- <!–d1.dist_name parentName,–>
- <!–d1.dist_name name,–>
- <!–0 'hier_lvl' from mk_dist d1–>
- <!–WHERE 1=1–>
- <!–<if test="pdistId != null">–>
- <!–AND d1.dist_id = #{pdistId}–>
- <!–</if>–>
- <!–)s–>
- <choose>
- <when test="sidx != null and sidx.trim() != ''">
- order by ${sidx} ${order}
- </when>
- </choose>
- </select>-->
- <select id="selectDistHierByChnlIdAndOneLvl" resultType="com.kmall.admin.entity.mk.dist.MkDistHierEntity">
- SELECT * FROM `mk_dist_hier` where 1=1 and dist_chnl_id = #{distChnlId} and hier_lvl = 1
- <if test="distHierId != null and distHierId != ''">
- and dist_hier_id != #{distHierId}
- </if>
- </select>
- <select id="selectDistHierByDistId" resultType="com.kmall.admin.entity.mk.dist.MkDistHierEntity">
- SELECT * FROM `mk_dist_hier` where 1=1 and dist_id = #{distId}
- </select>
- <select id="selectDistHierByDistChnlId" resultType="com.kmall.admin.entity.mk.dist.MkDistHierEntity">
- SELECT * FROM `mk_dist_hier` where 1=1 and dist_chnl_id = #{distChnlId}
- </select>
- <select id="queryListByPdistIdAndChnlIdAndDistId" resultType="com.kmall.admin.entity.mk.dist.MkDistHierEntity">
- SELECT h.*
- FROM mk_dist_hier h
- WHERE 1=1
- <if test="pdistId != null">
- AND h.pdist_id = #{pdistId}
- </if>
- <if test="distChnlId != null">
- AND h.dist_chnl_id = #{distChnlId}
- </if>
- <if test="distId != null">
- AND h.dist_id = #{distId}
- </if>
- </select>
- <select id="queryObjectByDistIdAndPdistId" resultType="com.kmall.admin.entity.mk.dist.MkDistHierEntity">
- SELECT h.*
- FROM mk_dist_hier h
- WHERE 1=1
- <if test="pdistId != null">
- AND h.pdist_id = #{pdistId}
- </if>
- <if test="distId != null">
- AND h.dist_id = #{distId}
- </if>
- <if test="distHierId != null">
- AND h.dist_hier_id != #{distHierId}
- </if>
- </select>
- <select id="queryObjectByHierMap" resultType="com.kmall.admin.entity.mk.dist.MkDistHierEntity">
- select
- h.`dist_hier_id`,
- h.`dist_chnl_id`,
- h.`pdist_id`,
- h.`dist_id`,
- h.`dist_hier_name`,
- h.`dist_hier_nname`,
- h.`hier_lvl`,
- h.`supplier_id`,
- h.`sort_order`,
- h.`is_valid`,
- h.`note`,
- h.`creater_sn`,
- h.`create_time`,
- h.`moder_sn`,
- h.`mod_time`,
- h.`tstm`,cc.dist_flag,d.dist_name
- from mk_dist_hier h
- left join mk_dist_chnl cc on h.dist_chnl_id = cc.dist_chnl_id
- left join mk_dist d on h.pdist_id = d.dist_id
- where 1=1
- <if test="pdistId != null and pdistId != ''">
- and h.pdist_id = #{pdistId}
- </if>
- <if test="distId != null and distId != ''">
- and h.dist_id = #{distId}
- </if>
- <if test="distChnlId != null and distChnlId != ''">
- and h.dist_chnl_id = #{distChnlId}
- </if>
- <if test="hierLvl != null and hierLvl != ''">
- and h.hier_lvl = #{hierLvl}
- </if>
- </select>
- <select id="querySysConfigByKey" resultType="map">
- select s.value from sys_config s where s.key = #{key}
- </select>
- <insert id="save" parameterType="com.kmall.admin.entity.mk.dist.MkDistHierEntity" useGeneratedKeys="true" keyProperty="distHierId">
- insert into mk_dist_hier(
- `dist_chnl_id`,
- `pdist_id`,
- `dist_id`,
- `dist_hier_name`,
- `dist_hier_nname`,
- `hier_lvl`,
- `supplier_id`,
- `sort_order`,
- `is_valid`,
- `note`,
- `creater_sn`,
- `create_time`,
- `moder_sn`,
- `mod_time`,
- `tstm`)
- values(
- #{distChnlId},
- #{pdistId},
- #{distId},
- #{distHierName},
- #{distHierNname},
- #{hierLvl},
- #{supplierId},
- #{sortOrder},
- #{isValid},
- #{note},
- #{createrSn},
- #{createTime},
- #{moderSn},
- #{modTime},
- #{tstm})
- </insert>
-
- <update id="update" parameterType="com.kmall.admin.entity.mk.dist.MkDistHierEntity">
- update mk_dist_hier
- <set>
- <if test="distChnlId != null">`dist_chnl_id` = #{distChnlId}, </if>
- <if test="pdistId != null">`pdist_id` = #{pdistId}, </if>
- <if test="distId != null">`dist_id` = #{distId}, </if>
- <if test="distHierName != null">`dist_hier_name` = #{distHierName}, </if>
- <if test="distHierNname != null">`dist_hier_nname` = #{distHierNname}, </if>
- <if test="hierLvl != null">`hier_lvl` = #{hierLvl}, </if>
- <if test="supplierId != null">`supplier_id` = #{supplierId}, </if>
- <if test="sortOrder != null">`sort_order` = #{sortOrder}, </if>
- <if test="isValid != null">`is_valid` = #{isValid}, </if>
- <if test="note != null">`note` = #{note}, </if>
- <if test="createrSn != null">`creater_sn` = #{createrSn}, </if>
- <if test="createTime != null">`create_time` = #{createTime}, </if>
- <if test="moderSn != null">`moder_sn` = #{moderSn}, </if>
- <if test="modTime != null">`mod_time` = #{modTime}, </if>
- <if test="tstm != null">`tstm` = #{tstm}</if>
- </set>
- where dist_hier_id = #{distHierId}
- </update>
-
- <delete id="delete">
- delete from mk_dist_hier where dist_hier_id = #{value}
- </delete>
-
- <delete id="deleteBatch">
- delete from mk_dist_hier where dist_hier_id in
- <foreach item="distHierId" collection="array" open="(" separator="," close=")">
- #{distHierId}
- </foreach>
- </delete>
- </mapper>
|