You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

267 lines
14 KiB

  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.iformall.mapper.WxBillOtherDepositMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxBillOtherDeposit">
  5. <id column="id" jdbcType="BIGINT" property="id"/>
  6. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  7. <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
  8. <result column="receive_pay" jdbcType="VARCHAR" property="receivePay"/>
  9. <result column="pay" jdbcType="VARCHAR" property="pay"/>
  10. <result column="receive_date" jdbcType="TIMESTAMP" property="receiveDate"/>
  11. <result column="pay_date" jdbcType="TIMESTAMP" property="payDate"/>
  12. <result column="createtime" jdbcType="TIMESTAMP" property="createtime"/>
  13. <result column="create_by" jdbcType="BIGINT" property="createBy"/>
  14. <result column="create_by_name" jdbcType="VARCHAR" property="createByName"/>
  15. <result column="update_by" jdbcType="BIGINT" property="updateBy"/>
  16. <result column="update_by_name" jdbcType="VARCHAR" property="updateByName"/>
  17. <result column="expired_day" jdbcType="INTEGER" property="expiredDay"/>
  18. <result column="status" jdbcType="INTEGER" property="status"/>
  19. <result column="apply_status" jdbcType="INTEGER" property="applyStatus"/>
  20. <result column="apply_pay_img" jdbcType="INTEGER" property="applyPayImg"/>
  21. <result column="apply_update_time" jdbcType="INTEGER" property="applyUpdateTime"/>
  22. <result column="is_del" jdbcType="INTEGER" property="isDel"/>
  23. <result column="merchant_id" jdbcType="BIGINT" property="merchantId"/>
  24. <result column="user_id" jdbcType="BIGINT" property="userId"/>
  25. <result column="shop_id" jdbcType="BIGINT" property="shopId"/>
  26. <result column="shop_name" jdbcType="VARCHAR" property="shopName" />
  27. <result column="updatetime" jdbcType="TIMESTAMP" property="updatetime"/>
  28. <result column="name" jdbcType="VARCHAR" property="name"/>
  29. <result column="comments" jdbcType="VARCHAR" property="comments"/>
  30. <result column="rent_shop_type" jdbcType="INTEGER" property="rentShopType"/>
  31. <result column="return_price" jdbcType="VARCHAR" property="returnPrice"/>
  32. <result column="pay_way" jdbcType="BIGINT" property="payWay"/>
  33. <result column="last_owe_call_time" jdbcType="TIMESTAMP" property="lastOweCallTime"/>
  34. <result column="last_owe_call_user" jdbcType="VARCHAR" property="lastOweCallUser"/>
  35. <result column="merchant_name" property="merchantName"/>
  36. <result column="starttime" property="starttime"/>
  37. <result column="endtime" property="endtime"/>
  38. <result column="freeze" property="freeze"/>
  39. <result column="service_charge_pay" property="serviceChargePay"/>
  40. <result column="energy_fees_id" jdbcType="BIGINT" property="energyFeesId"/>
  41. <result column="set_off" jdbcType="VARCHAR" property="setOff"/>
  42. </resultMap>
  43. <sql id="allColumns">
  44. `id`,`tenant_id`,`parent_tenant_id`,`receive_pay`,`pay`,`receive_date`,`pay_date`,`createtime`,`expired_day`,`last_owe_call_time`,`last_owe_call_user`,
  45. `status`,`is_del`,`merchant_id`,`user_id`,`shop_id`,`shop_name`,`updatetime`,`name`,`comments`,`apply_status`,`apply_pay_img`,`apply_update_time`,
  46. `rent_shop_type`,`return_price`,`pay_way`,`starttime`,`endtime`,freeze,service_charge_pay,`create_by`,`create_by_name`,`update_by`,`update_by_name`,
  47. `energy_fees_id`,`set_off`
  48. </sql>
  49. <sql id="dynamicWhereConditions">
  50. where 1 = 1
  51. <if test=" null != id ">and `id` = #{id}</if>
  52. <if test=" null != tenantId and '' != tenantId">
  53. and `tenant_id` = #{tenantId}
  54. </if>
  55. <if test=" null != parentTenantId and '' != parentTenantId">
  56. and `parent_tenant_id` = #{parentTenantId}
  57. </if>
  58. <if test=" null != receivePay ">and `receive_pay` = #{receivePay}</if>
  59. <if test=" null != pay ">and `pay` = #{pay}</if>
  60. <if test=" null != receiveDate ">and `receive_date` = #{receiveDate}</if>
  61. <if test=" null != payDate ">and `pay_date` = #{payDate}</if>
  62. <if test=" null != createtime ">and `createtime` = #{createtime}</if>
  63. <if test=" null != expiredDay ">and `expired_day` = #{expiredDay}</if>
  64. <if test=" null != status ">and `status` = #{status}</if>
  65. <if test=" null != energyFeesId ">and `energy_fees_id` = #{energyFeesId}</if>
  66. <if test=" null != applyStatus ">and `apply_status` = #{applyStatus}</if>
  67. <if test=" null != isDel ">and `is_del` = #{isDel}</if>
  68. <if test=" null != merchantId ">and `merchant_id` = #{merchantId}</if>
  69. <if test=" null != userId ">and `user_id` = #{userId}</if>
  70. <if test=" null != starttime">and `starttime` &lt;= #{starttime}</if>
  71. <if test=" null != endtime">and `endtime` &gt;= #{endtime}</if>
  72. <if test=" null != shopId ">and `shop_id` = #{shopId}</if>
  73. <if test=" null != updatetime ">and `updatetime` = #{updatetime}</if>
  74. <if test=" null != name ">and `name` = #{name}</if>
  75. <if test=" null != rentShopType ">and `rent_shop_type` = #{rentShopType}</if>
  76. <if test=" null != payWay ">and `pay_way` = #{payWay}</if>
  77. <if test=" 1 == notifyed ">and (`last_owe_call_time` is not null and `receive_pay` - `pay` - `set_off` &gt; 0 and status not in (3,6,7) )</if>
  78. <if test=" null != ids ">
  79. and id in
  80. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  81. #{idItem}
  82. </foreach>
  83. </if>
  84. <if test=" null != notInIds ">
  85. and id not in
  86. <foreach collection="notInIds" index="index" item="nidItem" open="(" separator="," close=")">
  87. #{nidItem}
  88. </foreach>
  89. </if>
  90. <if test=" null != statusList ">
  91. and status in
  92. <foreach collection="statusList" index="index" item="stItem" open="(" separator="," close=")">
  93. #{stItem}
  94. </foreach>
  95. </if>
  96. <if test=" null != sortColumns">order by ${sortColumns}</if>
  97. </sql>
  98. <select id="findList" parameterType="com.iformall.domain.po.WxBillOtherDeposit" resultMap="BaseResultMap">
  99. select
  100. <include refid="allColumns"/>
  101. from wx_bill_other_deposit
  102. <include refid="dynamicWhereConditions"/>
  103. </select>
  104. <select id="selectById" parameterType="HashMap" resultMap="BaseResultMap">
  105. select
  106. <include refid="allColumns"/>
  107. from wx_bill_other_deposit
  108. where id = #{id} and tenant_id = #{tenantId}
  109. </select>
  110. <sql id ="queryBillListConditions">
  111. <where>
  112. 1 = 1
  113. <if test=" null != id ">and br.`id` = #{id}</if>
  114. <if test=" null != tenantId and '' != tenantId"> and br.`tenant_id` = #{tenantId}</if>
  115. <if test=" null != parentTenantId and '' != parentTenantId">and br.`parent_tenant_id` = #{parentTenantId}</if>
  116. <if test=" null != freeze ">and br.`freeze` = #{freeze}</if>
  117. <if test=" null != merchantId ">and br.`merchant_id` = #{merchantId}</if>
  118. <if test=" null != status ">and br.`status` = #{status}</if>
  119. <if test=" null != applyStatus ">and br.`apply_status` = #{applyStatus}</if>
  120. <if test=" null != isDel ">and br.`is_del` = #{isDel}</if>
  121. <if test=" null != energyFeesId ">and br.`energy_fees_id` = #{energyFeesId}</if>
  122. <if test=" null != name and ''!=name">and br.`name` = #{name}</if>
  123. <if test=" null != rentShopType ">and br.`rent_shop_type` = #{rentShopType}</if>
  124. <if test=" null != payWay ">and br.`pay_way` = #{payWay}</if>
  125. <if test=" null != comments and ''!=comments">and br.`comments` like concat('%',#{comments},'%')</if>
  126. <if test=" null != starttime">and br.`starttime` &lt;= #{starttime}</if>
  127. <if test=" null != endtime">and br.`endtime` &gt;= #{endtime}</if>
  128. <if test=" null != month and '' != month">
  129. and date_format(br.starttime,'%Y-%m') &lt;= #{month} and date_format(br.endtime,'%Y-%m') &gt;= #{month}
  130. </if>
  131. <if test=" null == nearBillLastTime and null != oweBillLastTime">
  132. and (br.`starttime` &lt;= #{oweBillLastTime} and br.`receive_pay` - br.`pay` - br.`set_off` &gt; 0 and br.status not in (3,6,7))
  133. </if>
  134. <if test=" null != nearBillLastTime and null != oweBillLastTime">
  135. and (br.`starttime` &gt; #{oweBillLastTime} and br.`starttime` &lt;= #{nearBillLastTime} and br.`receive_pay` - br.`pay` - br.`set_off` &gt; 0 and br.status not in (3,6,7))
  136. </if>
  137. <if test=" null != needPayStartDay">
  138. and (br.`starttime` &lt;= #{needPayStartDay} and br.`receive_pay` - br.`pay` - br.`set_off` &gt; 0 and br.status not in (3,6,7))
  139. </if>
  140. <if test=" 1 == notifyed ">and (br.`last_owe_call_time` is not null and br.`receive_pay` - br.`pay` - br.`set_off` &gt; 0 and br.status not in (3,6,7) )</if>
  141. <if test=" null != merchantIds ">
  142. and br.`merchant_id` in
  143. <foreach collection="merchantIds" index="index" item="midItem" open="(" separator="," close=")">
  144. #{midItem}
  145. </foreach>
  146. <if test=" null != notInIds ">
  147. and br.id not in
  148. <foreach collection="notInIds" index="index" item="nidItem" open="(" separator="," close=")">
  149. #{nidItem}
  150. </foreach>
  151. </if>
  152. <if test=" null != statusList ">
  153. and br.status in
  154. <foreach collection="statusList" index="index" item="stItem" open="(" separator="," close=")">
  155. #{stItem}
  156. </foreach>
  157. </if>
  158. </if>
  159. </where>
  160. </sql>
  161. <select id="queryBillList" parameterType="com.iformall.domain.po.WxBillOtherDeposit" resultMap="BaseResultMap">
  162. select br.`id`,br.`tenant_id`,br.`parent_tenant_id`,br.`receive_pay`,br.`pay`,br.`receive_date`,br.`pay_date`,br.`createtime`,br.`expired_day`,br.`last_owe_call_user`,br.`set_off`,
  163. br.`status`,br.shop_name,br.`updatetime`,br.`return_price`,br.`merchant_id`,br.`apply_status`,br.`apply_pay_img`,br.`apply_update_time`,br.`last_owe_call_time`,br.`energy_fees_id`,
  164. br.shop_id,br.name,br.comments,br.`rent_shop_type`,br.pay_way,br.`starttime`,br.`endtime`,br.freeze,br.service_charge_pay,br.`create_by`,br.`create_by_name`,br.`update_by`,br.`update_by_name`
  165. from wx_bill_other_deposit br
  166. <include refid="queryBillListConditions"/>
  167. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  168. <if test=" null == sortColumns"> order by id desc </if>
  169. </select>
  170. <resultMap id="SumBaseResultMap" type="com.iformall.domain.vo.WxBillSum">
  171. <result column="receive_pay" jdbcType="VARCHAR" property="needPay"/>
  172. <result column="paid" jdbcType="VARCHAR" property="paid" />
  173. <result column="min_date" jdbcType="TIMESTAMP" property="minDate" />
  174. <result column="max_date" jdbcType="TIMESTAMP" property="maxDate" />
  175. <result column="service_pay" jdbcType="VARCHAR" property="servicePay"/>
  176. <result column="late_pay" jdbcType="VARCHAR" property="latePay"/>
  177. <result column="return_pay" jdbcType="VARCHAR" property="returnPay"/>
  178. </resultMap>
  179. <select id="getBillMonthSum" parameterType="com.iformall.domain.po.WxBillOtherDeposit" resultMap="SumBaseResultMap">
  180. select
  181. sum(CAST(br.receive_pay AS DECIMAL(20,2))) receive_pay ,
  182. sum(CAST(br.pay AS DECIMAL(20,2))) paid,
  183. min(starttime) min_date,
  184. max(endtime) max_date,
  185. sum(CAST(br.service_charge_pay AS DECIMAL(20,2))) service_pay ,
  186. '0' late_pay,
  187. sum(CAST(br.return_price AS DECIMAL(20,2))) return_pay
  188. from wx_bill_other_deposit br
  189. <include refid="queryBillListConditions"/>
  190. </select>
  191. <select id="getMerchantIdList" parameterType="com.iformall.domain.po.WxBillOtherDeposit" resultType="Long">
  192. select distinct merchant_id from wx_bill_other_deposit br
  193. <include refid="queryBillListConditions"/>
  194. </select>
  195. <resultMap id="HotNotifyBaseResultMap" type="com.iformall.domain.vo.WxBillHotNotify">
  196. <result column="total_count" jdbcType="INTEGER" property="totalCount"/>
  197. <result column="total_money" jdbcType="VARCHAR" property="totalMoney" />
  198. <result column="min_begin_time" jdbcType="TIMESTAMP" property="minBeginTime"/>
  199. </resultMap>
  200. <select id="getBillHotNotify" parameterType="com.iformall.domain.po.WxBillOtherDeposit" resultMap="HotNotifyBaseResultMap">
  201. select count(1) total_count , sum(CAST(br.`receive_pay` AS DECIMAL(20,2)) - CAST(br.`pay` AS DECIMAL(20,2)) - CAST(IFNULL(br.`set_off`,"0") AS DECIMAL(20,2))) total_money,MIN(br.starttime) min_begin_time from wx_bill_other_deposit br
  202. <include refid="queryBillListConditions"/>
  203. </select>
  204. <resultMap id="NotifyResultMap" type="com.iformall.domain.vo.WxBillNotify">
  205. <result column="bill_type" jdbcType="INTEGER" property="billType"/>
  206. <result column="bill_type_name" jdbcType="VARCHAR" property="billTypeName" />
  207. <result column="bill_id" jdbcType="BIGINT" property="billId" />
  208. <result column="starttime" jdbcType="TIMESTAMP" property="starttime"/>
  209. <result column="endtime" jdbcType="TIMESTAMP" property="endtime"/>
  210. <result column="receive_pay" jdbcType="VARCHAR" property="receivePay"/>
  211. <result column="pay" jdbcType="VARCHAR" property="pay"/>
  212. <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
  213. </resultMap>
  214. <select id="getBillNotifyList" parameterType="com.iformall.domain.po.WxBillOtherDeposit" resultMap="NotifyResultMap">
  215. select #{billType} bill_type,#{billTypeName} bill_type_name,br.id as bill_id, br.starttime,br.endtime,br.receive_pay,br.pay,br.merchant_id from wx_bill_other_deposit br
  216. <include refid="queryBillListConditions"/>
  217. </select>
  218. <update id="updateNotPaidStatus" parameterType="hashmap">
  219. update wx_bill_other_deposit set status=#{notPaid},expired_day=DATEDIFF(now(),receive_date)
  220. where status!=#{paid}
  221. <if test=" null != tenantId and '' != tenantId">
  222. and `tenant_id` = #{tenantId}
  223. </if>
  224. <if test=" null != parentTenantId and '' != parentTenantId">
  225. and `parent_tenant_id` = #{parentTenantId}
  226. </if>
  227. and status!=5 and DATEDIFF(now(),receive_date)>0
  228. </update>
  229. <update id="updateWaitPayStatus" parameterType="hashmap">
  230. update wx_bill_other_deposit set status=#{waitPay}
  231. where 1=1
  232. <if test=" null != tenantId and '' != tenantId">
  233. and `tenant_id` = #{tenantId}
  234. </if>
  235. <if test=" null != parentTenantId and '' != parentTenantId">
  236. and `parent_tenant_id` = #{parentTenantId}
  237. </if>
  238. and status!=5
  239. and status!=#{paid} and DATEDIFF(now(),receive_date) &lt;=0
  240. </update>
  241. <delete id = "deleteById" parameterType="HashMap">
  242. delete from wx_bill_other_deposit where id = #{id} and tenant_id = #{tenantId}
  243. </delete>
  244. </mapper>