FreightDao.xml 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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.FreightDao">
  4. <resultMap type="com.kmall.admin.entity.FreightEntity" id="freightMap">
  5. <result property="id" column="id"/>
  6. <result property="name" column="name"/>
  7. <result property="storeId" column="store_id"/>
  8. <result property="merchSn" column="merch_sn"/>
  9. <result property="templateType" column="template_type"/>
  10. <result property="pricingManner" column="pricing_manner"/>
  11. <result property="defaultFreight" column="default_freight"/>
  12. <result property="isDefault" column="is_default"/>
  13. <result property="storeName" column="storeName"/>
  14. <result column="merchName" property="merchName" />
  15. </resultMap>
  16. <select id="queryObject" resultType="com.kmall.admin.entity.FreightEntity">
  17. select
  18. `id`,
  19. `name`,
  20. `store_id`,
  21. `merch_sn`,
  22. `template_type`,
  23. `pricing_manner`,
  24. `default_freight`,
  25. `is_default`
  26. from mall_freight
  27. where id = #{id}
  28. </select>
  29. <select id="queryObjectByName" resultType="com.kmall.admin.entity.FreightEntity">
  30. select
  31. `id`,
  32. `name`,
  33. `store_id`,
  34. `merch_sn`,
  35. `template_type`,
  36. `pricing_manner`,
  37. `default_freight`,
  38. `is_default`
  39. from mall_freight
  40. where default_freight = #{defaultFreight}
  41. <if test="merchSn != null and merchSn.trim() != ''">
  42. AND merch_sn = #{merchSn}
  43. </if>
  44. </select>
  45. <select id="queryFreightByDefaultFreightAndStoreId" resultType="com.kmall.admin.entity.FreightEntity">
  46. select
  47. `id`,
  48. `name`,
  49. `store_id`,
  50. `merch_sn`,
  51. `template_type`,
  52. `pricing_manner`,
  53. `default_freight`,
  54. `is_default`
  55. from mall_freight
  56. where 1=1
  57. <if test="defaultFreight != null and defaultFreight != ''">
  58. AND default_freight = #{defaultFreight}
  59. </if>
  60. <if test="storeId != null and storeId != ''">
  61. AND store_id = #{storeId}
  62. </if>
  63. </select>
  64. <select id="queryObjectByStoreId" resultType="com.kmall.admin.entity.FreightEntity">
  65. select
  66. `id`,
  67. `name`,
  68. `store_id`,
  69. `merch_sn`,
  70. `template_type`,
  71. `pricing_manner`,
  72. `default_freight`,
  73. `is_default`
  74. from mall_freight
  75. where store_id = #{storeId}
  76. </select>
  77. <select id="queryList" resultType="com.kmall.admin.entity.FreightEntity">
  78. select
  79. b.id,
  80. b.name,
  81. b.store_id,
  82. b.merch_sn,
  83. `template_type`,
  84. `pricing_manner`,
  85. `default_freight`,
  86. `is_default`,
  87. s.store_name storeName,
  88. m.merch_name merchName
  89. from mall_freight b
  90. left join mall_store s on b.store_id = s.id
  91. left join mall_merch m on b.merch_sn = m.merch_sn
  92. WHERE 1=1
  93. <if test="storeId != null and storeId != ''">
  94. AND b.store_id = #{storeId}
  95. </if>
  96. <if test="merchSn != null and merchSn.trim() != ''">
  97. AND b.merch_sn = #{merchSn}
  98. </if>
  99. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  100. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  101. </if>
  102. <if test="name != null and name.trim() != ''">
  103. AND b.name LIKE concat('%',#{name},'%')
  104. </if>
  105. <if test="id != null and id != ''">
  106. AND b.id LIKE concat('%',#{id},'%')
  107. </if>
  108. <choose>
  109. <when test="sidx != null and sidx.trim() != ''">
  110. order by ${sidx} ${order}
  111. </when>
  112. <otherwise>
  113. order by b.id desc
  114. </otherwise>
  115. </choose>
  116. <if test="offset != null and limit != null">
  117. limit #{offset}, #{limit}
  118. </if>
  119. </select>
  120. <select id="queryEntity" resultType="com.kmall.admin.entity.FreightEntity">
  121. select
  122. `id`,
  123. `name`,
  124. `store_id`,
  125. `merch_sn`,
  126. `template_type`,
  127. `pricing_manner`,
  128. `default_freight`,
  129. `is_default`
  130. from mall_freight
  131. WHERE 1=1
  132. <if test="storeId != null and storeId != ''">
  133. AND store_id = #{storeId}
  134. </if>
  135. <if test="merchSn != null and merchSn.trim() != ''">
  136. AND merch_sn = #{merchSn}
  137. </if>
  138. <if test="name != null and name != ''">
  139. AND name LIKE concat('%',#{name},'%')
  140. </if>
  141. <if test="id != null and id != ''">
  142. AND id NOT LIKE concat('%',#{id},'%')
  143. </if>
  144. <choose>
  145. <when test="sidx != null and sidx != ''">
  146. order by ${sidx} ${order}
  147. </when>
  148. <otherwise>
  149. order by id desc
  150. </otherwise>
  151. </choose>
  152. <if test="offset != null and limit != null">
  153. limit #{offset}, #{limit}
  154. </if>
  155. </select>
  156. <select id="queryTotal" resultType="int">
  157. select count(*) from mall_freight b
  158. left join mall_store s on b.store_id = s.id
  159. WHERE 1=1
  160. <if test="storeId != null and storeId != ''">
  161. AND b.store_id = #{storeId}
  162. </if>
  163. <if test="merchSn != null and merchSn.trim() != ''">
  164. AND b.merch_sn = #{merchSn}
  165. </if>
  166. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  167. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  168. </if>
  169. <if test="name != null and name.trim() != ''">
  170. AND b.name LIKE concat('%',#{name},'%')
  171. </if>
  172. <if test="id != null and id != ''">
  173. AND b.id NOT LIKE concat('%',#{id},'%')
  174. </if>
  175. </select>
  176. <insert id="save" parameterType="com.kmall.admin.entity.FreightEntity" useGeneratedKeys="true" keyProperty="id">
  177. insert into mall_freight(
  178. `name`,
  179. `store_id`,
  180. `merch_sn`,
  181. `template_type`,
  182. `pricing_manner`,
  183. `default_freight`,
  184. `is_default`)
  185. values(
  186. #{name},
  187. #{storeId},
  188. #{merchSn},
  189. #{templateType},
  190. #{pricingManner},
  191. #{defaultFreight},
  192. #{isDefault})
  193. </insert>
  194. <update id="update" parameterType="com.kmall.admin.entity.FreightEntity">
  195. update mall_freight
  196. <set>
  197. <if test="name != null">`name` = #{name}, </if>
  198. <if test="storeId != null">`store_id` = #{storeId}, </if>
  199. <if test="merchSn != null">`merch_sn` = #{merchSn}, </if>
  200. <if test="templateType != null">`template_type` = #{templateType}, </if>
  201. <if test="pricingManner != null">`pricing_manner` = #{pricingManner}, </if>
  202. <if test="defaultFreight != null">`default_freight` = #{defaultFreight},</if>
  203. <if test="isDefault != null">`is_default` = #{isDefault}</if>
  204. </set>
  205. where id = #{id}
  206. </update>
  207. <delete id="delete">
  208. delete from mall_freight where id = #{value}
  209. </delete>
  210. <delete id="deleteBatch">
  211. delete from mall_freight where id in
  212. <foreach item="id" collection="array" open="(" separator="," close=")">
  213. #{id}
  214. </foreach>
  215. </delete>
  216. <select id="queryMaxId" resultType="java.lang.Integer" parameterType="map">
  217. SELECT MAX(id) FROM mall_freight
  218. </select>
  219. </mapper>