PayFeeDetailDiscountServiceDaoImplMapper.xml 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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="payFeeDetailDiscountServiceDaoImpl">
  6. <!-- 保存缴费优惠信息 add by wuxw 2018-07-03 -->
  7. <insert id="saveBusinessPayFeeDetailDiscountInfo" parameterType="Map">
  8. insert into business_pay_fee_detail_discount(
  9. operate,detail_discount_id,discount_price,detail_id,remark,b_id,community_id,discount_id,fee_id
  10. ) values (
  11. #{operate},#{detailDiscountId},#{discountPrice},#{detailId},#{remark},#{bId},#{communityId},#{discountId},#{feeId}
  12. )
  13. </insert>
  14. <!-- 查询缴费优惠信息(Business) add by wuxw 2018-07-03 -->
  15. <select id="getBusinessPayFeeDetailDiscountInfo" parameterType="Map" resultType="Map">
  16. select t.operate,t.create_time,t.create_time createTime,t.detail_discount_id,t.detail_discount_id
  17. detailDiscountId,t.discount_price,t.discount_price discountPrice,t.detail_id,t.detail_id
  18. detailId,t.remark,t.b_id,t.b_id bId,t.community_id,t.community_id communityId,t.discount_id,t.discount_id
  19. discountId,t.fee_id,t.fee_id feeId
  20. from business_pay_fee_detail_discount t
  21. where 1 =1
  22. <if test="operate !=null and operate != ''">
  23. and t.operate= #{operate}
  24. </if>
  25. <if test="createTime !=null and createTime != ''">
  26. and t.create_time= #{createTime}
  27. </if>
  28. <if test="detailDiscountId !=null and detailDiscountId != ''">
  29. and t.detail_discount_id= #{detailDiscountId}
  30. </if>
  31. <if test="discountPrice !=null and discountPrice != ''">
  32. and t.discount_price= #{discountPrice}
  33. </if>
  34. <if test="detailId !=null and detailId != ''">
  35. and t.detail_id= #{detailId}
  36. </if>
  37. <if test="remark !=null and remark != ''">
  38. and t.remark= #{remark}
  39. </if>
  40. <if test="bId !=null and bId != ''">
  41. and t.b_id= #{bId}
  42. </if>
  43. <if test="communityId !=null and communityId != ''">
  44. and t.community_id= #{communityId}
  45. </if>
  46. <if test="discountId !=null and discountId != ''">
  47. and t.discount_id= #{discountId}
  48. </if>
  49. <if test="feeId !=null and feeId != ''">
  50. and t.fee_id= #{feeId}
  51. </if>
  52. </select>
  53. <!-- 保存缴费优惠信息至 instance表中 add by wuxw 2018-07-03 -->
  54. <insert id="savePayFeeDetailDiscountInfoInstance" parameterType="Map">
  55. insert into pay_fee_detail_discount(
  56. create_time,detail_discount_id,discount_price,detail_id,status_cd,remark,b_id,community_id,discount_id,fee_id
  57. ) select
  58. t.create_time,t.detail_discount_id,t.discount_price,t.detail_id,'0',t.remark,t.b_id,t.community_id,t.discount_id,t.fee_id
  59. from business_pay_fee_detail_discount t where 1=1
  60. and t.operate= 'ADD'
  61. <if test="createTime !=null and createTime != ''">
  62. and t.create_time= #{createTime}
  63. </if>
  64. <if test="detailDiscountId !=null and detailDiscountId != ''">
  65. and t.detail_discount_id= #{detailDiscountId}
  66. </if>
  67. <if test="discountPrice !=null and discountPrice != ''">
  68. and t.discount_price= #{discountPrice}
  69. </if>
  70. <if test="detailId !=null and detailId != ''">
  71. and t.detail_id= #{detailId}
  72. </if>
  73. <if test="remark !=null and remark != ''">
  74. and t.remark= #{remark}
  75. </if>
  76. <if test="bId !=null and bId != ''">
  77. and t.b_id= #{bId}
  78. </if>
  79. <if test="communityId !=null and communityId != ''">
  80. and t.community_id= #{communityId}
  81. </if>
  82. <if test="discountId !=null and discountId != ''">
  83. and t.discount_id= #{discountId}
  84. </if>
  85. <if test="feeId !=null and feeId != ''">
  86. and t.fee_id= #{feeId}
  87. </if>
  88. </insert>
  89. <!-- 查询缴费优惠信息 add by wuxw 2018-07-03 -->
  90. <select id="getPayFeeDetailDiscountInfo" parameterType="Map" resultType="Map">
  91. select t.create_time,t.create_time createTime,t.detail_discount_id,t.detail_discount_id
  92. detailDiscountId,t.discount_price,t.discount_price discountPrice,t.detail_id,t.detail_id
  93. detailId,t.status_cd,t.status_cd statusCd,t.remark,t.b_id,t.b_id bId,t.community_id,t.community_id
  94. communityId,t.discount_id,t.discount_id discountId,t.fee_id,t.fee_id feeId,fd.discount_name discountName,
  95. fd.discount_type discountType,fdr.rule_name,fdr.rule_name ruleName
  96. from pay_fee_detail_discount t
  97. left join fee_discount fd on t.discount_id = fd.discount_id and t.community_id = fd.community_id and fd.status_cd = '0'
  98. left join fee_discount_rule fdr on fd.rule_id = fdr.rule_id and fdr.status_cd = '0'
  99. where 1 =1
  100. <if test="createTime !=null and createTime != ''">
  101. and t.create_time= #{createTime}
  102. </if>
  103. <if test="detailDiscountId !=null and detailDiscountId != ''">
  104. and t.detail_discount_id= #{detailDiscountId}
  105. </if>
  106. <if test="discountPrice !=null and discountPrice != ''">
  107. and t.discount_price= #{discountPrice}
  108. </if>
  109. <if test="detailId !=null and detailId != ''">
  110. and t.detail_id= #{detailId}
  111. </if>
  112. <if test="statusCd !=null and statusCd != ''">
  113. and t.status_cd= #{statusCd}
  114. </if>
  115. <if test="remark !=null and remark != ''">
  116. and t.remark= #{remark}
  117. </if>
  118. <if test="bId !=null and bId != ''">
  119. and t.b_id= #{bId}
  120. </if>
  121. <if test="communityId !=null and communityId != ''">
  122. and t.community_id= #{communityId}
  123. </if>
  124. <if test="discountId !=null and discountId != ''">
  125. and t.discount_id= #{discountId}
  126. </if>
  127. <if test="feeId !=null and feeId != ''">
  128. and t.fee_id= #{feeId}
  129. </if>
  130. order by t.create_time desc
  131. <if test="page != -1 and page != null ">
  132. limit #{page}, #{row}
  133. </if>
  134. </select>
  135. <!-- 修改缴费优惠信息 add by wuxw 2018-07-03 -->
  136. <update id="updatePayFeeDetailDiscountInfoInstance" parameterType="Map">
  137. update pay_fee_detail_discount t set t.status_cd = #{statusCd}
  138. <if test="newBId != null and newBId != ''">
  139. ,t.b_id = #{newBId}
  140. </if>
  141. <if test="createTime !=null and createTime != ''">
  142. , t.create_time= #{createTime}
  143. </if>
  144. <if test="discountPrice !=null and discountPrice != ''">
  145. , t.discount_price= #{discountPrice}
  146. </if>
  147. <if test="detailId !=null and detailId != ''">
  148. , t.detail_id= #{detailId}
  149. </if>
  150. <if test="remark !=null and remark != ''">
  151. , t.remark= #{remark}
  152. </if>
  153. <if test="communityId !=null and communityId != ''">
  154. , t.community_id= #{communityId}
  155. </if>
  156. <if test="discountId !=null and discountId != ''">
  157. , t.discount_id= #{discountId}
  158. </if>
  159. <if test="feeId !=null and feeId != ''">
  160. , t.fee_id= #{feeId}
  161. </if>
  162. where 1=1
  163. <if test="detailDiscountId !=null and detailDiscountId != ''">
  164. and t.detail_discount_id= #{detailDiscountId}
  165. </if>
  166. <if test="bId !=null and bId != ''">
  167. and t.b_id= #{bId}
  168. </if>
  169. </update>
  170. <!-- 查询缴费优惠数量 add by wuxw 2018-07-03 -->
  171. <select id="queryPayFeeDetailDiscountsCount" parameterType="Map" resultType="Map">
  172. select count(1) count
  173. from pay_fee_detail_discount t
  174. where 1 =1
  175. <if test="createTime !=null and createTime != ''">
  176. and t.create_time= #{createTime}
  177. </if>
  178. <if test="detailDiscountId !=null and detailDiscountId != ''">
  179. and t.detail_discount_id= #{detailDiscountId}
  180. </if>
  181. <if test="discountPrice !=null and discountPrice != ''">
  182. and t.discount_price= #{discountPrice}
  183. </if>
  184. <if test="detailId !=null and detailId != ''">
  185. and t.detail_id= #{detailId}
  186. </if>
  187. <if test="statusCd !=null and statusCd != ''">
  188. and t.status_cd= #{statusCd}
  189. </if>
  190. <if test="remark !=null and remark != ''">
  191. and t.remark= #{remark}
  192. </if>
  193. <if test="bId !=null and bId != ''">
  194. and t.b_id= #{bId}
  195. </if>
  196. <if test="communityId !=null and communityId != ''">
  197. and t.community_id= #{communityId}
  198. </if>
  199. <if test="discountId !=null and discountId != ''">
  200. and t.discount_id= #{discountId}
  201. </if>
  202. <if test="feeId !=null and feeId != ''">
  203. and t.fee_id= #{feeId}
  204. </if>
  205. </select>
  206. <!-- 计算费用优惠 -->
  207. <select id="computeDiscountFee" parameterType="Map" resultType="Map">
  208. select t.detail_id detailId,ifnull(sum(t.discount_price),0) discountPrice
  209. from pay_fee_detail_discount t
  210. where 1 =1
  211. <if test="detailIds !=null ">
  212. and t.detail_id in
  213. <foreach collection="detailIds" item="item" open="(" close=")" separator=",">
  214. #{item}
  215. </foreach>
  216. </if>
  217. and t.status_cd= '0'
  218. <if test="communityId !=null and communityId != ''">
  219. and t.community_id= #{communityId}
  220. </if>
  221. group by t.detail_id
  222. </select>
  223. </mapper>