MarkertPlanMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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.markert.mapper.MarkertPlanMapper">
  6. <resultMap type="MarkertPlan" id="MarkertPlanResult">
  7. <result property="id" column="id" />
  8. <result property="grade" column="grade" />
  9. <result property="discountTerm" column="discount_term" />
  10. <result property="discountAmt" column="discount_amt" />
  11. <result property="discountAmtEnd" column="discount_amt_end" />
  12. <result property="gasoilDiscountAmt" column="gasoil_discount_amt" />
  13. <result property="vipDiscountyPlus" column="vip_discounty_plus" />
  14. <result property="couponPlus" column="coupon_plus" />
  15. <result property="discountPlanType" column="discount_plan_type" />
  16. <result property="oilName" column="oil_name" />
  17. <result property="stationId" column="station_id" />
  18. <result property="stationName" column="station_name" />
  19. <result property="status" column="status" />
  20. <result property="createBy" column="create_by" />
  21. <result property="createTime" column="create_time" />
  22. <result property="updateBy" column="update_by" />
  23. <result property="updateTime" column="update_time" />
  24. <result property="discountSettingFlag" column="discount_setting_flag" />
  25. <result property="discountType" column="discount_type" />
  26. <result property="discountDate" column="discount_date" />
  27. <result property="discountActivityAmt" column="discount_activity_amt"/>
  28. </resultMap>
  29. <sql id="selectMarkertPlanVo">
  30. select p.id, p.grade, p.discount_term, p.discount_amt, p.gasoil_discount_amt, p.vip_discounty_plus, p.coupon_plus, p.discount_plan_type,
  31. p.oil_name, p.station_id,d.dept_name as station_name, p.status,p.create_by,p.create_time,p.update_by,p.update_time,
  32. p.discount_setting_flag,p.discount_type,p.discount_date,p.discount_activity_amt,p.discount_amt_end
  33. from markert_plan p join sys_dept d on p.station_id = d.dept_id
  34. </sql>
  35. <select id="selectMarkertPlanList" parameterType="MarkertPlan" resultMap="MarkertPlanResult">
  36. select p.id, p.grade, p.discount_term, p.discount_amt, p.gasoil_discount_amt, p.vip_discounty_plus, p.coupon_plus, p.discount_plan_type,
  37. p.oil_name, station_id, p.status,p.create_by,p.create_time,p.update_by,p.update_time,d.dept_name as station_name,
  38. p.discount_setting_flag,p.discount_type,p.discount_date,p.discount_activity_amt,p.discount_amt_end
  39. from markert_plan p join sys_dept d on d.dept_id =p.station_id
  40. <where>
  41. <if test="grade != null and grade != ''"> and p.grade = #{grade}</if>
  42. <if test="discountTerm != null and discountTerm != ''"> and p.discount_term = #{discountTerm}</if>
  43. <if test="discountAmt != null and discountAmt != ''"> and p.discount_amt = #{discountAmt}</if>
  44. <if test="gasoilDiscountAmt != null and gasoilDiscountAmt != ''"> and p.gasoil_discount_amt = #{gasoilDiscountAmt}</if>
  45. <if test="vipDiscountyPlus != null and vipDiscountyPlus != ''"> and p.vip_discounty_plus = #{vipDiscountyPlus}</if>
  46. <if test="couponPlus != null and couponPlus != ''"> and p.coupon_plus = #{couponPlus}</if>
  47. <if test="discountPlanType != null and discountPlanType != ''"> and p.discount_plan_type = #{discountPlanType}</if>
  48. <if test="oilName != null and oilName != ''">
  49. and p.oil_name like concat('%', #{oilName}, '%')
  50. </if>
  51. <if test="stationId != null "> and p.station_id = #{stationId}</if>
  52. <if test="status != null and status != ''"> and p.status = #{status}</if>
  53. <if test="stationId != null "> and station_id = #{stationId}</if>
  54. <if test="stationIdList != null ">
  55. and station_id in
  56. <foreach item="item" index="index" collection="stationIdList"
  57. open="(" separator="," close=")">
  58. #{item}
  59. </foreach>
  60. </if>
  61. </where>
  62. order by p.oil_name,p.discount_amt_end+0
  63. </select>
  64. <select id="selectMarkertPlanById" parameterType="Long" resultMap="MarkertPlanResult">
  65. select p.id, p.grade, p.discount_term, p.discount_amt, p.gasoil_discount_amt, p.vip_discounty_plus, p.coupon_plus, p.discount_plan_type,
  66. p.oil_name, station_id, p.status,p.create_by,p.create_time,p.update_by,p.update_time,d.dept_name as station_name,
  67. p.discount_setting_flag,p.discount_type,p.discount_date,p.discount_activity_amt,p.discount_amt_end
  68. from markert_plan p join sys_dept d on d.dept_id =p.station_id
  69. where id = #{id}
  70. </select>
  71. <select id="searchMarkertPlanList" parameterType="Long" resultMap="MarkertPlanResult">
  72. SELECT DISTINCT grade,oil_name,station_id,discount_type,discount_date,coupon_plus,discount_plan_type,
  73. vip_discounty_plus,discount_term,discount_setting_flag,d.dept_name as station_name
  74. from markert_plan p join sys_dept d on d.dept_id =p.station_id
  75. <where>
  76. <if test="grade != null and grade != ''"> and p.grade = #{grade}</if>
  77. <if test="discountPlanType != null and discountPlanType != ''"> and p.discount_plan_type = #{discountPlanType}</if>
  78. <if test="status != null and status != ''"> and p.status = #{status}</if>
  79. <if test="stationId != null "> and station_id = #{stationId}</if>
  80. <if test="stationIdList != null ">
  81. and station_id in
  82. <foreach item="item" index="index" collection="stationIdList"
  83. open="(" separator="," close=")">
  84. #{item}
  85. </foreach>
  86. </if>
  87. </where>
  88. order by oil_name desc
  89. </select>
  90. <insert id="insertMarkertPlan" parameterType="MarkertPlan" useGeneratedKeys="true" keyProperty="id">
  91. insert into markert_plan
  92. <trim prefix="(" suffix=")" suffixOverrides=",">
  93. <if test="grade != null">grade,</if>
  94. <if test="discountTerm != null">discount_term,</if>
  95. <if test="discountAmt != null">discount_amt,</if>
  96. <if test="gasoilDiscountAmt != null">gasoil_discount_amt,</if>
  97. <if test="vipDiscountyPlus != null">vip_discounty_plus,</if>
  98. <if test="couponPlus != null">coupon_plus,</if>
  99. <if test="discountPlanType != null">discount_plan_type,</if>
  100. <if test="oilName != null">oil_name,</if>
  101. <if test="stationId != null">station_id,</if>
  102. <if test="status != null">status,</if>
  103. <if test="createBy != null">create_by,</if>
  104. <if test="createTime != null">create_time,</if>
  105. <if test="updateBy != null">update_by,</if>
  106. <if test="updateTime != null">update_time,</if>
  107. <if test="discountSettingFlag != null">discount_setting_flag,</if>
  108. <if test="discountType != null">discount_type,</if>
  109. <if test="discountDate != null">discount_date,</if>
  110. <if test="discountActivityAmt != null">discount_activity_amt,</if>
  111. <if test="discountAmtEnd != null">discount_amt_end,</if>
  112. </trim>
  113. <trim prefix="values (" suffix=")" suffixOverrides=",">
  114. <if test="grade != null">#{grade},</if>
  115. <if test="discountTerm != null">#{discountTerm},</if>
  116. <if test="discountAmt != null">#{discountAmt},</if>
  117. <if test="gasoilDiscountAmt != null">#{gasoilDiscountAmt},</if>
  118. <if test="vipDiscountyPlus != null">#{vipDiscountyPlus},</if>
  119. <if test="couponPlus != null">#{couponPlus},</if>
  120. <if test="discountPlanType != null">#{discountPlanType},</if>
  121. <if test="oilName != null">#{oilName},</if>
  122. <if test="stationId != null">#{stationId},</if>
  123. <if test="status != null">#{status},</if>
  124. <if test="createBy != null">#{createBy},</if>
  125. <if test="createTime != null">#{createTime},</if>
  126. <if test="updateBy != null">#{updateBy},</if>
  127. <if test="updateTime != null">#{updateTime},</if>
  128. <if test="discountSettingFlag != null">#{discountSettingFlag},</if>
  129. <if test="discountType != null">#{discountType},</if>
  130. <if test="discountDate != null">#{discountDate},</if>
  131. <if test="discountActivityAmt != null">#{discountActivityAmt},</if>
  132. <if test="discountAmtEnd != null">#{discountAmtEnd},</if>
  133. </trim>
  134. </insert>
  135. <update id="updateMarkertPlan" parameterType="MarkertPlan">
  136. update markert_plan
  137. <trim prefix="SET" suffixOverrides=",">
  138. <if test="grade != null">grade = #{grade},</if>
  139. <if test="discountTerm != null">discount_term = #{discountTerm},</if>
  140. <if test="discountAmt != null">discount_amt = #{discountAmt},</if>
  141. <if test="gasoilDiscountAmt != null">gasoil_discount_amt = #{gasoilDiscountAmt},</if>
  142. <if test="vipDiscountyPlus != null">vip_discounty_plus = #{vipDiscountyPlus},</if>
  143. <if test="couponPlus != null">coupon_plus = #{couponPlus},</if>
  144. <if test="discountPlanType != null">discount_plan_type = #{discountPlanType},</if>
  145. <if test="oilName != null">oil_name = #{oilName},</if>
  146. <if test="stationId != null">station_id = #{stationId},</if>
  147. <if test="status != null">status = #{status},</if>
  148. <if test="createBy != null">create_by = #{createBy},</if>
  149. <if test="createTime != null">create_time = #{createTime},</if>
  150. <if test="updateBy != null">update_by = #{updateBy},</if>
  151. <if test="updateTime != null">update_time = #{updateTime},</if>
  152. <if test="discountSettingFlag != null">discount_setting_flag = #{discountSettingFlag},</if>
  153. <if test="discountType != null">discount_type=#{discountType},</if>
  154. <if test="discountDate != null">discount_date =#{discountDate},</if>
  155. <if test="discountActivityAmt != null">discount_activity_amt = #{discountActivityAmt},</if>
  156. <if test="discountAmtEnd != null">discount_amt_end = #{discountAmtEnd},</if>
  157. </trim>
  158. where id = #{id}
  159. </update>
  160. <delete id="deleteMarkertPlanById" parameterType="Long">
  161. delete from markert_plan where id = #{id}
  162. </delete>
  163. <delete id="deleteMarkertPlanByIds" parameterType="String">
  164. delete from markert_plan where id in
  165. <foreach item="id" collection="array" open="(" separator="," close=")">
  166. #{id}
  167. </foreach>
  168. </delete>
  169. <delete id="deleteMarkertPlan" parameterType="MarkertPlan">
  170. delete from markert_plan
  171. <where>
  172. <if test="grade != null and grade != ''"> and grade = #{grade}</if>
  173. <if test="discountTerm != null and discountTerm != ''"> and discount_term = #{discountTerm}</if>
  174. <if test="discountAmt != null and discountAmt != ''"> and discount_amt = #{discountAmt}</if>
  175. <if test="gasoilDiscountAmt != null and gasoilDiscountAmt != ''"> and gasoil_discount_amt = #{gasoilDiscountAmt}</if>
  176. <if test="vipDiscountyPlus != null and vipDiscountyPlus != ''"> and vip_discounty_plus = #{vipDiscountyPlus}</if>
  177. <if test="couponPlus != null and couponPlus != ''"> and coupon_plus = #{couponPlus}</if>
  178. <if test="discountPlanType != null and discountPlanType != ''"> and discount_plan_type = #{discountPlanType}</if>
  179. <if test="oilName != null and oilName != ''">
  180. and oil_name = #{oilName}
  181. </if>
  182. <if test="stationId != null "> and station_id = #{stationId}</if>
  183. <if test="status != null and status != ''"> and status = #{status}</if>
  184. <if test="stationId != null "> and station_id = #{stationId}</if>
  185. <if test="stationIdList != null ">
  186. and station_id in
  187. <foreach item="item" index="index" collection="stationIdList"
  188. open="(" separator="," close=")">
  189. #{item}
  190. </foreach>
  191. </if>
  192. </where>
  193. </delete>
  194. </mapper>