1
0

MkDistDao.xml 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.kmall.admin.dao.mk.dist.MkDistDao">
  4. <resultMap type="com.kmall.admin.entity.mk.dist.MkDistEntity" id="mkDistMap">
  5. <result property="distId" column="dist_id"/>
  6. <result property="distName" column="dist_name"/>
  7. <result property="distEname" column="dist_ename"/>
  8. <result property="distFlag" column="dist_flag"/>
  9. <result property="thirdMerchSn" column="third_merch_sn"/>
  10. <result property="supplierId" column="supplier_id"/>
  11. <result property="sortOrder" column="sort_order"/>
  12. <result property="isValid" column="is_valid"/>
  13. <result property="note" column="note"/>
  14. <result property="createrSn" column="creater_sn"/>
  15. <result property="createTime" column="create_time"/>
  16. <result property="moderSn" column="moder_sn"/>
  17. <result property="modTime" column="mod_time"/>
  18. <result property="tstm" column="tstm"/>
  19. <result property="thirdPartyMerchName" column="thirdPartyMerchName"/>
  20. <result property="childSupplierName" column="childSupplierName"/>
  21. <result property="storeId" column="store_id"/>
  22. </resultMap>
  23. <select id="queryObject" resultType="com.kmall.admin.entity.mk.dist.MkDistEntity">
  24. select
  25. `dist_id`,
  26. `dist_name`,
  27. `dist_ename`,
  28. `dist_flag`,
  29. `third_merch_sn`,
  30. `supplier_id`,
  31. `sort_order`,
  32. `is_valid`,
  33. `note`,
  34. `creater_sn`,
  35. `create_time`,
  36. `moder_sn`,
  37. `mod_time`,
  38. `tstm`,store_id
  39. from mk_dist
  40. where dist_id = #{id}
  41. </select>
  42. <select id="queryDistByGoodsId" resultType="com.kmall.admin.entity.mk.dist.MkDistEntity">
  43. SELECT
  44. d.*
  45. FROM
  46. mk_dist d
  47. LEFT JOIN mall_store s ON d.store_id = s.id
  48. LEFT JOIN mall_product_store_rela r ON s.id = r.store_id
  49. WHERE
  50. r.goods_id = #{goodsId} and r.store_id = #{storeId}
  51. </select>
  52. <select id="queryObjectByDistName" resultType="com.kmall.admin.entity.mk.dist.MkDistEntity">
  53. select
  54. `dist_id`,
  55. `dist_name`,
  56. `dist_ename`,
  57. `dist_flag`,
  58. `third_merch_sn`,
  59. `supplier_id`,
  60. `sort_order`,
  61. `is_valid`,
  62. `note`,
  63. `creater_sn`,
  64. `create_time`,
  65. `moder_sn`,
  66. `mod_time`,
  67. `tstm`,store_id
  68. from mk_dist
  69. where dist_name = #{distName}
  70. </select>
  71. <select id="queryDistByStoreId" resultType="com.kmall.admin.entity.mk.dist.MkDistEntity">
  72. select
  73. `dist_id`,
  74. `dist_name`,
  75. `dist_ename`,
  76. `dist_flag`,
  77. `third_merch_sn`,
  78. `supplier_id`,
  79. `sort_order`,
  80. `is_valid`,
  81. `note`,
  82. `creater_sn`,
  83. `create_time`,
  84. `moder_sn`,
  85. `mod_time`,
  86. `tstm`,store_id
  87. from mk_dist
  88. where store_id = #{storeId}
  89. </select>
  90. <select id="queryList" resultType="com.kmall.admin.entity.mk.dist.MkDistEntity">
  91. select
  92. d.`dist_id`,
  93. d.`dist_name`,
  94. d.`dist_ename`,
  95. d.`dist_flag`,
  96. d.`third_merch_sn`,
  97. d.`supplier_id`,
  98. d.`sort_order`,
  99. d.`is_valid`,
  100. d.`note`,
  101. d.`creater_sn`,
  102. d.`create_time`,
  103. d.`moder_sn`,
  104. d.`mod_time`,
  105. d.`tstm`,t.third_party_merch_name thirdPartyMerchName,s.child_supplier_name childSupplierName,st.store_name storeName
  106. from mk_dist d left join third_merchant_biz t on d.third_merch_sn = t.third_merch_sn
  107. left join mall_supplier s on d.supplier_id = s.id
  108. left join mall_store st on d.store_id = st.id
  109. WHERE 1=1
  110. <if test="distName != null and distName.trim() != ''">
  111. AND dist_name LIKE concat('%',#{distName},'%')
  112. </if>
  113. <if test="distId != null and distId != ''">
  114. and d.dist_id = #{distId}
  115. </if>
  116. <if test="thirdMerchSn != null and thirdMerchSn != ''">
  117. and d.third_merch_sn = #{thirdMerchSn}
  118. </if>
  119. <if test="storeId != null and storeId != ''">
  120. AND d.store_id = #{storeId}
  121. </if>
  122. <if test="merchSn != null and merchSn != ''">
  123. AND t.merch_sn = #{merchSn}
  124. </if>
  125. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode != ''">
  126. AND t.third_party_merch_code = #{thirdPartyMerchCode}
  127. </if>
  128. <if test="childDistId != null and childDistId != ''">
  129. AND d.dist_id != #{childDistId}
  130. </if>
  131. <choose>
  132. <when test="sidx != null and sidx.trim() != ''">
  133. order by ${sidx} ${order}
  134. </when>
  135. <otherwise>
  136. order by d.dist_id desc
  137. </otherwise>
  138. </choose>
  139. <if test="offset != null and limit != null">
  140. limit #{offset}, #{limit}
  141. </if>
  142. </select>
  143. <select id="queryTotal" resultType="int">
  144. select count(*) from mk_dist d left join third_merchant_biz t on d.third_merch_sn = t.third_merch_sn
  145. left join mall_supplier s on d.supplier_id = s.id
  146. left join mall_store st on d.store_id = st.id
  147. WHERE 1=1
  148. <if test="distName != null and distName.trim() != ''">
  149. AND dist_name LIKE concat('%',#{distName},'%')
  150. </if>
  151. <if test="distId != null and distId != ''">
  152. and d.dist_id = #{distId}
  153. </if>
  154. <if test="thirdMerchSn != null and thirdMerchSn != ''">
  155. and d.third_merch_sn = #{thirdMerchSn}
  156. </if>
  157. <if test="storeId != null and storeId != ''">
  158. AND d.store_id = #{storeId}
  159. </if>
  160. <if test="merchSn != null and merchSn != ''">
  161. AND t.merch_sn = #{merchSn}
  162. </if>
  163. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode != ''">
  164. AND t.third_party_merch_code = #{thirdPartyMerchCode}
  165. </if>
  166. <if test="childDistId != null and childDistId != ''">
  167. AND d.dist_id != #{childDistId}
  168. </if>
  169. </select>
  170. <select id="queryAllByHier" resultType="com.kmall.admin.entity.mk.dist.MkDistEntity">
  171. select
  172. d.`dist_id`,
  173. d.`dist_name`,
  174. d.`dist_ename`,
  175. d.`dist_flag`,
  176. d.`third_merch_sn`,
  177. d.`supplier_id`,
  178. d.`sort_order`,
  179. d.`is_valid`,
  180. d.`note`,
  181. d.`creater_sn`,
  182. d.`create_time`,
  183. d.`moder_sn`,
  184. d.`mod_time`,
  185. d.`tstm`,t.third_party_merch_name thirdPartyMerchName,s.child_supplier_name childSupplierName,st.store_name storeName
  186. from mk_dist d left join third_merchant_biz t on d.third_merch_sn = t.third_merch_sn
  187. left join mall_supplier s on d.supplier_id = s.id
  188. left join mall_store st on d.store_id = st.id
  189. WHERE 1=1
  190. and dist_id in (select dist_id from mk_dist_hier where 1=1
  191. <if test="hierLvl != null and hierLvl != ''">
  192. AND hier_lvl = #{hierLvl}
  193. </if>)
  194. <if test="distName != null and distName.trim() != ''">
  195. AND dist_name LIKE concat('%',#{distName},'%')
  196. </if>
  197. <if test="distId != null and distId != ''">
  198. and d.dist_id = #{distId}
  199. </if>
  200. <if test="thirdMerchSn != null and thirdMerchSn != ''">
  201. and d.third_merch_sn = #{thirdMerchSn}
  202. </if>
  203. <if test="storeId != null and storeId != ''">
  204. AND d.store_id = #{storeId}
  205. </if>
  206. <if test="merchSn != null and merchSn != ''">
  207. AND t.merch_sn = #{merchSn}
  208. </if>
  209. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode != ''">
  210. AND t.third_party_merch_code = #{thirdPartyMerchCode}
  211. </if>
  212. <if test="childDistId != null and childDistId != ''">
  213. AND d.dist_id != #{childDistId}
  214. </if>
  215. </select>
  216. <insert id="save" parameterType="com.kmall.admin.entity.mk.dist.MkDistEntity" useGeneratedKeys="true" keyProperty="distId">
  217. insert into mk_dist(
  218. `dist_name`,
  219. `dist_ename`,
  220. `dist_flag`,
  221. `third_merch_sn`,
  222. `supplier_id`,
  223. store_id,
  224. `sort_order`,
  225. `is_valid`,
  226. `note`,
  227. `creater_sn`,
  228. `create_time`,
  229. `moder_sn`,
  230. `mod_time`,
  231. `tstm`)
  232. values(
  233. #{distName},
  234. #{distEname},
  235. #{distFlag},
  236. #{thirdMerchSn},
  237. #{supplierId},
  238. #{storeId},
  239. #{sortOrder},
  240. #{isValid},
  241. #{note},
  242. #{createrSn},
  243. #{createTime},
  244. #{moderSn},
  245. #{modTime},
  246. #{tstm})
  247. </insert>
  248. <update id="update" parameterType="com.kmall.admin.entity.mk.dist.MkDistEntity">
  249. update mk_dist
  250. <set>
  251. <if test="distName != null">`dist_name` = #{distName}, </if>
  252. <if test="distEname != null">`dist_ename` = #{distEname}, </if>
  253. <if test="distFlag != null">`dist_flag` = #{distFlag}, </if>
  254. <if test="thirdMerchSn != null">`third_merch_sn` = #{thirdMerchSn}, </if>
  255. <if test="supplierId != null">`supplier_id` = #{supplierId}, </if>
  256. <if test="storeId != null">`store_id` = #{storeId}, </if>
  257. <if test="sortOrder != null">`sort_order` = #{sortOrder}, </if>
  258. <if test="isValid != null">`is_valid` = #{isValid}, </if>
  259. <if test="note != null">`note` = #{note}, </if>
  260. <if test="createrSn != null">`creater_sn` = #{createrSn}, </if>
  261. <if test="createTime != null">`create_time` = #{createTime}, </if>
  262. <if test="moderSn != null">`moder_sn` = #{moderSn}, </if>
  263. <if test="modTime != null">`mod_time` = #{modTime}, </if>
  264. <if test="tstm != null">`tstm` = #{tstm}</if>
  265. </set>
  266. where dist_id = #{distId}
  267. </update>
  268. <delete id="delete">
  269. delete from mk_dist where dist_id = #{value}
  270. </delete>
  271. <delete id="deleteBatch">
  272. delete from mk_dist where dist_id in
  273. <foreach item="distId" collection="array" open="(" separator="," close=")">
  274. #{distId}
  275. </foreach>
  276. </delete>
  277. </mapper>