IntegralRuleMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.yijia.integral.mapper.IntegralRuleMapper">
  6. <resultMap type="IntegralRule" id="IntegralRuleResult">
  7. <result property="id" column="id" />
  8. <result property="stationId" column="station_id" />
  9. <result property="stationName" column="station_name" />
  10. <result property="ruleType" column="rule_type" />
  11. <result property="termDateManage" column="term_date_manage" />
  12. <result property="emptyDate" column="empty_date" />
  13. <result property="integralActivity" column="integral_activity" />
  14. <result property="datePicker" column="date_picker" />
  15. <result property="integralProportion" column="integral_proportion" />
  16. <result property="datePickerTime" column="date_picker_time" />
  17. <result property="integralTermSetting" column="integral_term_setting" />
  18. <result property="integralEmptyTime" column="integral_empty_time" />
  19. <result property="ruleTerms" column="rule_terms" />
  20. <result property="grade" column="grade" />
  21. <result property="gradeName" column="grade_name" />
  22. <result property="oilName" column="oil_name" />
  23. <result property="saleAmt" column="sale_amt" />
  24. <result property="integral" column="integral" />
  25. <result property="oilType" column="oil_type" />
  26. <result property="integralFlag" column="integral_flag" />
  27. <result property="createBy" column="create_by" />
  28. <result property="createTime" column="create_time" />
  29. <result property="updateBy" column="update_by" />
  30. <result property="updateTime" column="update_time" />
  31. <result property="integralFlag" column="integral_flag" />
  32. <result property="image1" column="image1" />
  33. <result property="image2" column="image2" />
  34. <result property="image3" column="image3" />
  35. <result property="image4" column="image4" />
  36. <result property="image5" column="image5" />
  37. </resultMap>
  38. <sql id="selectIntegralRuleVo">
  39. select id, station_id,d.dept_name as station_name, term_date_manage, empty_date, integral_activity,
  40. date_picker, integral_proportion,date_picker_time,integral_term_setting,r.create_by,r.create_time,
  41. r.update_by,r.update_time,d.integral_flag,r.image1,r.image2,r.image3,r.image4,r.image5,r.integral_empty_time
  42. from integral_rule r join sys_dept d on r.station_id =d.dept_id
  43. </sql>
  44. <select id="selectIntegralRuleList" parameterType="IntegralRule" resultMap="IntegralRuleResult">
  45. <include refid="selectIntegralRuleVo"/>
  46. <where>
  47. <if test="stationId != null "> and station_id = #{stationId}</if>
  48. <if test="stationName != null and stationName != ''"> and d.dept_name like concat('%', #{stationName}, '%')</if>
  49. <if test="termDateManage != null and termDateManage != ''"> and term_date_manage = #{termDateManage}</if>
  50. <if test="emptyDate != null "> and empty_date = #{emptyDate}</if>
  51. <if test="integralActivity != null and integralActivity != ''"> and integral_activity = #{integralActivity}</if>
  52. <if test="datePicker != null"> and date_picker = #{datePicker}</if>
  53. <if test="integralProportion != null "> and integral_proportion = #{integralProportion}</if>
  54. <if test="datePickerTime != null "> and date_picker_time = #{datePickerTime}</if>
  55. <if test="integralTermSetting != null and integralTermSetting != ''"> and integral_term_setting = #{integralTermSetting}</if>
  56. <if test="stationIdList != null ">
  57. and station_id in
  58. <foreach item="item" index="index" collection="stationIdList"
  59. open="(" separator="," close=")">
  60. #{item}
  61. </foreach>
  62. </if>
  63. </where>
  64. order by id desc
  65. </select>
  66. <select id="selectIntegralRuleById" parameterType="Long" resultMap="IntegralRuleResult">
  67. <include refid="selectIntegralRuleVo"/>
  68. where id = #{id}
  69. </select>
  70. <insert id="insertIntegralRule" parameterType="IntegralRule" useGeneratedKeys="true" keyProperty="id">
  71. insert into integral_rule
  72. <trim prefix="(" suffix=")" suffixOverrides=",">
  73. <if test="stationId != null">station_id,</if>
  74. <if test="termDateManage != null">term_date_manage,</if>
  75. <if test="emptyDate != null">empty_date,</if>
  76. <if test="integralActivity != null">integral_activity,</if>
  77. <if test="datePicker != null">date_picker,</if>
  78. <if test="integralProportion != null">integral_proportion,</if>
  79. <if test="datePickerTime != null">date_picker_time,</if>
  80. <if test="integralTermSetting != null">integral_term_setting,</if>
  81. <if test="integralEmptyTime != null">integral_empty_time,</if>
  82. <if test="createBy != null">create_by,</if>
  83. <if test="createTime != null">create_time,</if>
  84. <if test="updateBy != null">update_by,</if>
  85. <if test="updateTime != null">update_time,</if>
  86. <if test="image1 != null">image1,</if>
  87. <if test="image2 != null">image2,</if>
  88. <if test="image3 != null">image3,</if>
  89. <if test="image4 != null">image4,</if>
  90. <if test="image5 != null">image5,</if>
  91. </trim>
  92. <trim prefix="values (" suffix=")" suffixOverrides=",">
  93. <if test="stationId != null">#{stationId},</if>
  94. <if test="termDateManage != null">#{termDateManage},</if>
  95. <if test="emptyDate != null">#{emptyDate},</if>
  96. <if test="integralActivity != null">#{integralActivity},</if>
  97. <if test="datePicker != null">#{datePicker},</if>
  98. <if test="integralProportion != null">#{integralProportion},</if>
  99. <if test="datePickerTime != null">#{datePickerTime},</if>
  100. <if test="integralTermSetting != null">#{integralTermSetting},</if>
  101. <if test="integralEmptyTime != null">#{integralEmptyTime},</if>
  102. <if test="createBy != null">#{createBy},</if>
  103. <if test="createTime != null">#{createTime},</if>
  104. <if test="updateBy != null">#{updateBy},</if>
  105. <if test="updateTime != null">#{updateTime},</if>
  106. <if test="image1 != null">#{image1},</if>
  107. <if test="image2 != null">#{image2},</if>
  108. <if test="image3 != null">#{image3},</if>
  109. <if test="image4 != null">#{image4},</if>
  110. <if test="image5 != null">#{image5},</if>
  111. </trim>
  112. </insert>
  113. <update id="updateIntegralRule" parameterType="IntegralRule">
  114. update integral_rule
  115. <trim prefix="SET" suffixOverrides=",">
  116. <if test="stationId != null">station_id = #{stationId},</if>
  117. <if test="termDateManage != null">term_date_manage = #{termDateManage},</if>
  118. <if test="emptyDate != null">empty_date = #{emptyDate},</if>
  119. <if test="integralActivity != null">integral_activity = #{integralActivity},</if>
  120. <if test="datePicker != null">date_picker = #{datePicker},</if>
  121. <if test="integralProportion != null">integral_proportion = #{integralProportion},</if>
  122. <if test="datePickerTime != null "> date_picker_time = #{datePickerTime},</if>
  123. <if test="integralTermSetting != null "> integral_term_setting = #{integralTermSetting},</if>
  124. <if test="integralEmptyTime != null"> integral_empty_time=#{integralEmptyTime},</if>
  125. <if test="createBy != null "> create_by = #{createBy},</if>
  126. <if test="createTime != null "> create_time = #{createTime},</if>
  127. <if test="updateBy != null "> update_by = #{updateBy},</if>
  128. <if test="updateTime != null "> update_time = #{updateTime},</if>
  129. <if test="image1 != null">image1=#{image1},</if>
  130. <if test="image2 != null">image2=#{image2},</if>
  131. <if test="image3 != null">image3=#{image3},</if>
  132. <if test="image4 != null">image4=#{image4},</if>
  133. <if test="image5 != null">image5=#{image5},</if>
  134. </trim>
  135. where id = #{id}
  136. </update>
  137. <delete id="deleteIntegralRuleById" parameterType="Long">
  138. delete from integral_rule where id = #{id}
  139. </delete>
  140. <delete id="deleteIntegralRuleByIds" parameterType="String">
  141. delete from integral_rule where id in
  142. <foreach item="id" collection="array" open="(" separator="," close=")">
  143. #{id}
  144. </foreach>
  145. </delete>
  146. <select id="selectIntegralRule" parameterType="IntegralRule" resultMap="IntegralRuleResult">
  147. <include refid="selectIntegralRuleVo"/>
  148. <where>
  149. <if test="stationId != null "> and station_id = #{stationId}</if>
  150. <if test="stationName != null and stationName != ''"> and dept_name like concat('%', #{stationName}, '%')</if>
  151. <if test="termDateManage != null and termDateManage != ''"> and term_date_manage = #{termDateManage}</if>
  152. <if test="emptyDate != null "> and empty_date = #{emptyDate}</if>
  153. <if test="integralActivity != null and integralActivity != ''"> and integral_activity = #{integralActivity}</if>
  154. <if test="datePicker != null and datePicker != ''"> and date_picker = #{datePicker}</if>
  155. <if test="integralProportion != null and integralProportion != ''"> and integral_proportion = #{integralProportion}</if>
  156. <if test="datePickerTime != null and datePickerTime != ''"> and date_picker_time = #{datePickerTime}</if>
  157. <if test="integralTermSetting != null and integralTermSetting != ''"> and integral_term_setting = #{integralTermSetting}</if>
  158. <if test="integralEmptyTime != null and integralEmptyTime != ''"> and integral_empty_time = #{integralEmptyTime}</if>
  159. <if test="stationIdList != null ">
  160. and station_id in
  161. <foreach item="item" index="index" collection="stationIdList"
  162. open="(" separator="," close=")">
  163. #{item}
  164. </foreach>
  165. </if>
  166. </where>
  167. order by id desc limit 1
  168. </select>
  169. <select id="listRuleInfo" parameterType="IntegralRule" resultMap="IntegralRuleResult">
  170. SELECT a.station_id,d.dept_name as station_name,a.term_date_manage,a.integral_activity,empty_date,date_picker,integral_proportion,s.grade as grade_name,
  171. b.rule_type,rule_terms,b.grade,b.oil_name,b.sale_amt,b.integral,b.oil_type,d.integral_flag,a.integral_empty_time
  172. from integral_rule a
  173. join integral_rule_detail b on a.id =b.parent_id
  174. join sys_dept d on a.station_id =d.dept_id
  175. left join customer_grade_setting s on s.id = b.grade
  176. <where>
  177. <if test="stationId != null "> and a.station_id = #{stationId}</if>
  178. <if test="stationName != null and stationName != ''"> and d.dept_name like concat('%', #{stationName}, '%')</if>
  179. <if test="stationIdList != null ">
  180. and a.station_id in
  181. <foreach item="item" index="index" collection="stationIdList"
  182. open="(" separator="," close=")">
  183. #{item}
  184. </foreach>
  185. </if>
  186. </where>
  187. order by b.oil_name desc
  188. </select>
  189. </mapper>