Mall2PointsRulesDao.xml 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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.vip.Mall2PointsRulesDao">
  4. <resultMap type="com.kmall.admin.entity.vip.Mall2PointsRulesEntity" id="mall2PointsRulesMap">
  5. <result property="mprId" column="mpr_id"/>
  6. <result property="pointsType" column="points_type"/>
  7. <result property="pointsBeginTime" column="points_begin_time"/>
  8. <result property="pointsEndTime" column="points_end_time"/>
  9. <result property="isValid" column="is_valid"/>
  10. <result property="ratio" column="ratio"/>
  11. <result property="createrSn" column="creater_sn"/>
  12. <result property="createTime" column="create_time"/>
  13. <result property="moderSn" column="moder_sn"/>
  14. <result property="modTime" column="mod_time"/>
  15. <result property="tstm" column="tstm"/>
  16. </resultMap>
  17. <select id="queryObject" resultType="com.kmall.admin.entity.vip.Mall2PointsRulesEntity">
  18. select
  19. `mpr_id`,
  20. `points_type` as pointsType,
  21. `ratio`,
  22. `points_begin_time`,
  23. `points_end_time`,
  24. `is_valid`,
  25. `creater_sn`,
  26. `create_time`,
  27. `moder_sn`,
  28. `mod_time`,
  29. `tstm`
  30. from mall2_points_rules
  31. where mpr_id = #{id}
  32. </select>
  33. <select id="queryList" resultType="com.kmall.admin.entity.vip.Mall2PointsRulesEntity">
  34. select
  35. `mpr_id`,
  36. `points_type`,
  37. `ratio`,
  38. `points_begin_time`,
  39. `points_end_time`,
  40. `is_valid`,
  41. `creater_sn`,
  42. `create_time`,
  43. `moder_sn`,
  44. `mod_time`,
  45. `tstm`
  46. from mall2_points_rules
  47. WHERE 1=1
  48. <if test="name != null and name.trim() != ''">
  49. AND points_type = #{name}
  50. </if>
  51. <if test="isValid != null and isValid != ''">
  52. AND is_valid = #{isValid}
  53. </if>
  54. <if test="pointsType != null and pointsType != ''">
  55. AND points_type = #{pointsType}
  56. </if>
  57. <choose>
  58. <when test="sidx != null and sidx.trim() != ''">
  59. order by ${sidx} ${order}
  60. </when>
  61. <otherwise>
  62. order by mpr_id desc
  63. </otherwise>
  64. </choose>
  65. <if test="offset != null and limit != null">
  66. limit #{offset}, #{limit}
  67. </if>
  68. </select>
  69. <select id="queryTotal" resultType="int">
  70. select count(*) from mall2_points_rules
  71. WHERE 1=1
  72. <if test="name != null and name.trim() != ''">
  73. AND points_type = #{name}
  74. </if>
  75. </select>
  76. <insert id="save" parameterType="com.kmall.admin.entity.vip.Mall2PointsRulesEntity" useGeneratedKeys="true" keyProperty="id">
  77. insert into mall2_points_rules(
  78. `mpr_id`,
  79. `points_type`,
  80. `ratio`,
  81. `points_begin_time`,
  82. `points_end_time`,
  83. `is_valid`,
  84. `creater_sn`,
  85. `create_time`,
  86. `moder_sn`,
  87. `mod_time`,
  88. `tstm`)
  89. values(
  90. #{mprId},
  91. #{pointsType},
  92. #{ratio},
  93. #{pointsBeginTime},
  94. #{pointsEndTime},
  95. #{isValid},
  96. #{createrSn},
  97. #{createTime},
  98. #{moderSn},
  99. #{modTime},
  100. #{tstm})
  101. </insert>
  102. <update id="update" parameterType="com.kmall.admin.entity.vip.Mall2PointsRulesEntity">
  103. update mall2_points_rules
  104. <set>
  105. <if test="pointsType != null">`points_type` = #{pointsType}, </if>
  106. <if test="pointsBeginTime != null">`points_begin_time` = #{pointsBeginTime}, </if>
  107. <if test="pointsEndTime != null">`points_end_time` = #{pointsEndTime}, </if>
  108. <if test="isValid != null">`is_valid` = #{isValid}, </if>
  109. <if test="ratio != null">`ratio` = #{ratio}, </if>
  110. <if test="createrSn != null">`creater_sn` = #{createrSn}, </if>
  111. <if test="createTime != null">`create_time` = #{createTime}, </if>
  112. <if test="moderSn != null">`moder_sn` = #{moderSn}, </if>
  113. <if test="modTime != null">`mod_time` = #{modTime}, </if>
  114. <if test="tstm != null">`tstm` = #{tstm}</if>
  115. </set>
  116. where mpr_id = #{mprId}
  117. </update>
  118. <delete id="delete">
  119. delete from mall2_points_rules where mpr_id = #{value}
  120. </delete>
  121. <delete id="deleteBatch">
  122. delete from mall2_points_rules where mpr_id in
  123. <foreach item="mprId" collection="array" open="(" separator="," close=")">
  124. #{mprId}
  125. </foreach>
  126. </delete>
  127. <select id="queryRulesDetilId" parameterType="java.lang.Long" resultType="java.lang.Integer">
  128. select points_type from mall2_points_rules where mpr_id=#{mkaId}
  129. </select>
  130. <select id="queryListByTime" resultType="com.kmall.admin.haikong.vo.PointsRulesAndDetailVO">
  131. select
  132. mpr.`mpr_id` as mprId,
  133. mpr.`points_type` as pointsType,
  134. mpr.`points_begin_time` as pointsBeginTime,
  135. mpr.`points_end_time` as pointsEndTime,
  136. mpr.`is_valid` as isValid,
  137. mpr.`ratio` as ratio,
  138. mpr.`creater_sn` as createrSn,
  139. mpr.`create_time` as createTime,
  140. mpr.`moder_sn` as moderSn,
  141. mpr.`mod_time` as modTime,
  142. mpr.`tstm` as tstm,
  143. mprs.`id` as id,
  144. mprs.`father_id` as fatherId,
  145. mprs.`points_rules_type` as pointRulesType,
  146. mprs.`points_detil_name` as pointsDetailName,
  147. mprs.`points_detil_name_id` as pointsDetailNameId,
  148. mprs.`points_store_name` as pointsStoreName,
  149. mprs.`points_store_id` as pointsStoreId,
  150. mprs.`remark` as remark
  151. from mall2_points_rules mpr
  152. left join mall2_points_rules_detil mprs on mpr.mpr_id = mprs.father_id
  153. where mprs.id is not null and mpr.is_valid = 0 and mpr.points_begin_time &lt;= #{nowTime} and mpr.points_end_time &gt;= #{nowTime}
  154. and mprs.points_store_id = #{pointsStoreId}
  155. order by mpr.points_type desc
  156. </select>
  157. <select id="queryListBy" resultType="com.kmall.admin.haikong.vo.PointsRulesAndDetailVO" parameterType="com.kmall.admin.dto.Mall2PointsRulesDto">
  158. select
  159. mpr.`mpr_id` as mprId,
  160. mpr.`points_type` as pointsType,
  161. mpr.`points_begin_time` as pointsBeginTime,
  162. mpr.`points_end_time` as pointsEndTime,
  163. mpr.`is_valid` as isValid,
  164. mpr.`ratio` as ratio,
  165. mpr.`creater_sn` as createrSn,
  166. mpr.`create_time` as createTime,
  167. mpr.`moder_sn` as moderSn,
  168. mpr.`mod_time` as modTime,
  169. mpr.`tstm` as tstm,
  170. mprs.`id` as id,
  171. mprs.`father_id` as fatherId,
  172. mprs.`points_rules_type` as pointRulesType,
  173. mprs.`points_detil_name` as pointsDetailName,
  174. mprs.`points_detil_name_id` as pointsDetailNameId,
  175. mprs.`points_store_name` as pointsStoreName,
  176. mprs.`points_store_id` as pointsStoreId,
  177. mprs.`remark` as remark
  178. from mall2_points_rules mpr
  179. left join mall2_points_rules_detil mprs on mpr.mpr_id = mprs.father_id
  180. <where>
  181. <if test="pointsType!=null">
  182. and mpr.points_type=#{pointsType}
  183. </if>
  184. <if test="isValid!=null">
  185. and mpr.is_valid=#{isValid}
  186. </if>
  187. <if test="nowTime!=null">
  188. and mpr.points_begin_time &lt;= #{nowTime} and mpr.points_end_time &gt;= #{nowTime}
  189. </if>
  190. <if test="pointsStoreId!=null">
  191. and mprs.points_store_id =#{pointsStoreId}
  192. </if>
  193. </where>
  194. order by mpr.points_type desc
  195. </select>
  196. <insert id="saveMall2PointsRulesDetil" parameterType="com.kmall.admin.dto.Mall2RulesDto">
  197. insert into mall2_points_rules_detil(
  198. father_id,
  199. points_rules_type,
  200. points_detil_name,
  201. points_detil_name_id,
  202. points_store_name,
  203. points_store_id)
  204. values
  205. <foreach collection="list" item="item" separator=",">
  206. (
  207. #{item.mkaId},
  208. #{item.pointsRulesType},
  209. #{item.pointsRulesName},
  210. #{item.rulesId},
  211. #{item.storeName},
  212. #{item.storeId}
  213. )
  214. </foreach>
  215. </insert>
  216. <update id="updateMall2PointsRulesDetil" parameterType="com.kmall.admin.dto.Mall2RulesDto">
  217. <foreach collection="list" item="item" separator=";">
  218. update mall2_points_rules_detil
  219. <set>
  220. <if test="item.mkaId != null and item.mkaId !=''">
  221. father_id=#{item.mkaId},
  222. </if>
  223. <if test="item.pointsRulesType != null and item.pointsRulesType !=''">
  224. points_rules_type=#{item.pointsRulesType},
  225. </if>
  226. <if test="item.rulesId != null and item.rulesId !=''">
  227. points_detil_name=#{item.pointsRulesName},
  228. </if>
  229. <if test="item.pointsRulesName != null and item.pointsRulesName !=''">
  230. points_detil_name_id=#{item.rulesId},
  231. </if>
  232. <if test="item.storeName != null and item.storeName !=''">
  233. points_store_name=#{item.storeName},
  234. </if>
  235. <if test="item.storeId != null and item.storeId !=''">
  236. points_store_id=#{item.storeId}
  237. </if>
  238. </set>
  239. where id=#{item.id}
  240. </foreach>
  241. </update>
  242. <select id="querymall2PointsRulesDetil" resultType="com.kmall.admin.dto.Mall2RulesDto">
  243. select
  244. id,
  245. father_id as mkaId,
  246. points_rules_type as rulesType,
  247. points_detil_name as pointsRulesName,
  248. points_store_name as storeName,
  249. points_detil_name_id as rulesId
  250. from mall2_points_rules_detil
  251. WHERE
  252. father_id = #{mkaId}
  253. <if test="pointsDetilNameId !=null and pointsDetilNameId !=''">
  254. and points_detil_name_id=#{pointsDetilNameId}
  255. </if>
  256. <if test="pointsDetilName !=null and pointsDetilName.trim() !=''">
  257. and points_detil_name like concat('%',#{pointsDetilName},'%')
  258. </if>
  259. <if test="storeName !=null and storeName !=''">
  260. and points_store_name=#{storeName}
  261. </if>
  262. <if test="offset != null and limit != null">
  263. limit #{offset}, #{limit}
  264. </if>
  265. </select>
  266. <select id="querymall2PointsRulesDetilTotal" parameterType="java.lang.Long" resultType="java.lang.Integer">
  267. select count(*) from mall2_points_rules_detil
  268. where father_id = #{id}
  269. </select>
  270. <delete id="deleteRulesDetil">
  271. delete from mall2_points_rules_detil where id in
  272. <foreach item="mprId" collection="array" open="(" separator="," close=")">
  273. #{mprId}
  274. </foreach>
  275. </delete>
  276. </mapper>