Mall2PointsRulesDao.xml 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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 name LIKE concat('%',#{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 name LIKE concat('%',#{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 pointsDetilName,
  141. mprs.`points_detil_name_id` as pointsDetilNameId,
  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. </select>
  149. <insert id="saveMall2PointsRulesDetil" parameterType="com.kmall.admin.dto.Mall2RulesDto">
  150. insert into mall2_points_rules_detil(
  151. father_id,
  152. points_rules_type,
  153. points_detil_name,
  154. points_detil_name_id,
  155. points_store_name,
  156. points_store_id)
  157. values
  158. <foreach collection="list" item="item" separator=",">
  159. (
  160. #{item.mkaId},
  161. #{item.pointsRulesType},
  162. #{item.pointsRulesName},
  163. #{item.rulesId},
  164. #{item.storeName},
  165. #{item.storeId}
  166. )
  167. </foreach>
  168. </insert>
  169. <select id="querymall2PointsRulesDetil" parameterType="java.lang.Long" resultType="com.kmall.admin.dto.Mall2RulesDto">
  170. select
  171. father_id as id,
  172. points_rules_type as rulesType,
  173. points_detil_name as pointsRulesName,
  174. points_store_name as storeName
  175. from mall2_points_rules_detil
  176. WHERE
  177. father_id = #{id}
  178. </select>
  179. <select id="querymall2PointsRulesDetilTotal" parameterType="java.lang.Long" resultType="java.lang.Integer">
  180. select count(*) from mall2_points_rules_detil
  181. where father_id = #{id}
  182. </select>
  183. <delete id="deleteRulesDetil">
  184. delete from mall2_points_rules_detil where father_id in
  185. <foreach item="mprId" collection="array" open="(" separator="," close=")">
  186. #{mprId}
  187. </foreach>
  188. </delete>
  189. </mapper>