Mall2PointsRulesDao.xml 9.1 KB

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