IntegralRuleMapper.xml 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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="ruleTerms" column="rule_terms" />
  19. <result property="gread" column="gread" />
  20. <result property="oilName" column="oil_name" />
  21. <result property="saleAmt" column="sale_amt" />
  22. <result property="integral" column="integral" />
  23. <result property="oilType" column="oil_type" />
  24. <result property="integralFlag" column="integral_flag" />
  25. </resultMap>
  26. <sql id="selectIntegralRuleVo">
  27. select id, station_id, station_name, rule_type, term_date_manage, empty_date, integral_activity, date_picker, integral_proportion,date_picker_time,integral_term_setting from integral_rule
  28. </sql>
  29. <select id="selectIntegralRuleList" parameterType="IntegralRule" resultMap="IntegralRuleResult">
  30. <include refid="selectIntegralRuleVo"/>
  31. <where>
  32. <if test="stationId != null "> and station_id = #{stationId}</if>
  33. <if test="stationName != null and stationName != ''"> and station_name like concat('%', #{stationName}, '%')</if>
  34. <if test="ruleType != null and ruleType != ''"> and rule_type = #{ruleType}</if>
  35. <if test="termDateManage != null and termDateManage != ''"> and term_date_manage = #{termDateManage}</if>
  36. <if test="emptyDate != null "> and empty_date = #{emptyDate}</if>
  37. <if test="integralActivity != null and integralActivity != ''"> and integral_activity = #{integralActivity}</if>
  38. <if test="datePicker != null and datePicker != ''"> and date_picker = #{datePicker}</if>
  39. <if test="integralProportion != null and integralProportion != ''"> and integral_proportion = #{integralProportion}</if>
  40. <if test="datePickerTime != null and datePickerTime != ''"> and date_picker_time = #{datePickerTime}</if>
  41. <if test="integralTermSetting != null and integralTermSetting != ''"> and integral_term_setting = #{integralTermSetting}</if>
  42. <if test="stationIdList != null ">
  43. and station_id in
  44. <foreach item="item" index="index" collection="stationIdList"
  45. open="(" separator="," close=")">
  46. #{item}
  47. </foreach>
  48. </if>
  49. </where>
  50. order by id desc
  51. </select>
  52. <select id="selectIntegralRuleById" parameterType="Long" resultMap="IntegralRuleResult">
  53. <include refid="selectIntegralRuleVo"/>
  54. where id = #{id}
  55. </select>
  56. <insert id="insertIntegralRule" parameterType="IntegralRule" useGeneratedKeys="true" keyProperty="id">
  57. insert into integral_rule
  58. <trim prefix="(" suffix=")" suffixOverrides=",">
  59. <if test="stationId != null">station_id,</if>
  60. <if test="stationName != null">station_name,</if>
  61. <if test="ruleType != null">rule_type,</if>
  62. <if test="termDateManage != null">term_date_manage,</if>
  63. <if test="emptyDate != null">empty_date,</if>
  64. <if test="integralActivity != null">integral_activity,</if>
  65. <if test="datePicker != null">date_picker,</if>
  66. <if test="integralProportion != null">integral_proportion,</if>
  67. <if test="datePickerTime != null">date_picker_time,</if>
  68. <if test="integralTermSetting != null">integral_term_setting,</if>
  69. </trim>
  70. <trim prefix="values (" suffix=")" suffixOverrides=",">
  71. <if test="stationId != null">#{stationId},</if>
  72. <if test="stationName != null">#{stationName},</if>
  73. <if test="ruleType != null">#{ruleType},</if>
  74. <if test="termDateManage != null">#{termDateManage},</if>
  75. <if test="emptyDate != null">#{emptyDate},</if>
  76. <if test="expirationReminder != null">#{expirationReminder},</if>
  77. <if test="remindDate != null">#{remindDate},</if>
  78. <if test="integralActivity != null">#{integralActivity},</if>
  79. <if test="datePicker != null">#{datePicker},</if>
  80. <if test="integralProportion != null">#{integralProportion},</if>
  81. <if test="integralDeductionOil != null">#{integralDeductionOil},</if>
  82. <if test="datePickerTime != null">#{datePickerTime},</if>
  83. <if test="integralEmptyTime != null">#{integralEmptyTime},</if>
  84. <if test="integralTermSetting != null">#{integralTermSetting},</if>
  85. </trim>
  86. </insert>
  87. <update id="updateIntegralRule" parameterType="IntegralRule">
  88. update integral_rule
  89. <trim prefix="SET" suffixOverrides=",">
  90. <if test="stationId != null">station_id = #{stationId},</if>
  91. <if test="stationName != null">station_name = #{stationName},</if>
  92. <if test="ruleType != null">rule_type = #{ruleType},</if>
  93. <if test="termDateManage != null">term_date_manage = #{termDateManage},</if>
  94. <if test="emptyDate != null">empty_date = #{emptyDate},</if>
  95. <if test="integralActivity != null">integral_activity = #{integralActivity},</if>
  96. <if test="datePicker != null">date_picker = #{datePicker},</if>
  97. <if test="integralProportion != null">integral_proportion = #{integralProportion},</if>
  98. <if test="datePickerTime != null "> date_picker_time = #{datePickerTime},</if>
  99. <if test="integralTermSetting != null "> integral_term_setting = #{integralTermSetting},</if>
  100. </trim>
  101. where id = #{id}
  102. </update>
  103. <delete id="deleteIntegralRuleById" parameterType="Long">
  104. delete from integral_rule where id = #{id}
  105. </delete>
  106. <delete id="deleteIntegralRuleByIds" parameterType="String">
  107. delete from integral_rule where id in
  108. <foreach item="id" collection="array" open="(" separator="," close=")">
  109. #{id}
  110. </foreach>
  111. </delete>
  112. <select id="selectIntegralRule" parameterType="IntegralRule" resultMap="IntegralRuleResult">
  113. <include refid="selectIntegralRuleVo"/>
  114. <where>
  115. <if test="stationId != null "> and station_id = #{stationId}</if>
  116. <if test="stationName != null and stationName != ''"> and station_name like concat('%', #{stationName}, '%')</if>
  117. <if test="ruleType != null and ruleType != ''"> and rule_type = #{ruleType}</if>
  118. <if test="termDateManage != null and termDateManage != ''"> and term_date_manage = #{termDateManage}</if>
  119. <if test="emptyDate != null "> and empty_date = #{emptyDate}</if>
  120. <if test="integralActivity != null and integralActivity != ''"> and integral_activity = #{integralActivity}</if>
  121. <if test="datePicker != null and datePicker != ''"> and date_picker = #{datePicker}</if>
  122. <if test="integralProportion != null and integralProportion != ''"> and integral_proportion = #{integralProportion}</if>
  123. <if test="datePickerTime != null and datePickerTime != ''"> and date_picker_time = #{datePickerTime}</if>
  124. <if test="integralTermSetting != null and integralTermSetting != ''"> and integral_term_setting = #{integralTermSetting}</if>
  125. <if test="stationIdList != null ">
  126. and station_id in
  127. <foreach item="item" index="index" collection="stationIdList"
  128. open="(" separator="," close=")">
  129. #{item}
  130. </foreach>
  131. </if>
  132. </where>
  133. order by id desc limit 1
  134. </select>
  135. <select id="listRuleInfo" parameterType="IntegralRule" resultMap="IntegralRuleResult">
  136. SELECT a.station_id,a.station_name,a.term_date_manage,a.integral_activity,empty_date,date_picker,integral_proportion,b.rule_type,rule_terms,gread,oil_name,sale_amt,integral,oil_type,c.integral_flag
  137. from integral_rule a
  138. join integral_rule_detail b on a.id =b.parent_id
  139. join station_pay c on a.station_id =c.station_id
  140. <where>
  141. <if test="stationId != null "> and a.station_id = #{stationId}</if>
  142. <if test="stationName != null and stationName != ''"> and a.station_name like concat('%', #{stationName}, '%')</if>
  143. <if test="stationIdList != null ">
  144. and a.station_id in
  145. <foreach item="item" index="index" collection="stationIdList"
  146. open="(" separator="," close=")">
  147. #{item}
  148. </foreach>
  149. </if>
  150. </where>
  151. </select>
  152. </mapper>