Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 

340 righe
16 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.WxBillDepositMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxBillDeposit">
  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="rent_contract_id" jdbcType="BIGINT" property="rentContractId" />
  9. <result column="receive_pay" jdbcType="VARCHAR" property="receivePay"/>
  10. <result column="pay" jdbcType="VARCHAR" property="pay"/>
  11. <result column="receive_date" jdbcType="TIMESTAMP" property="receiveDate" />
  12. <result column="pay_date" jdbcType="TIMESTAMP" property="payDate" />
  13. <result column="createtime" jdbcType="TIMESTAMP" property="createtime" />
  14. <result column="expired_day" jdbcType="BIGINT" property="expiredDay" />
  15. <result column="status" jdbcType="INTEGER" property="status" />
  16. <result column="apply_status" jdbcType="INTEGER" property="applyStatus"/>
  17. <result column="apply_pay_img" jdbcType="INTEGER" property="applyPayImg"/>
  18. <result column="apply_update_time" jdbcType="INTEGER" property="applyUpdateTime"/>
  19. <result column="is_del" jdbcType="INTEGER" property="isDel" />
  20. <result column="need_pay" jdbcType="VARCHAR" property="needPay"/>
  21. <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
  22. <result column="user_id" jdbcType="BIGINT" property="userId" />
  23. <result column="shop_id" jdbcType="BIGINT" property="shopId" />
  24. <result column="updatetime" jdbcType="TIMESTAMP" property="updatetime" />
  25. <result column="rent_shop_type" jdbcType="INTEGER" property="rentShopType"/>
  26. <result column="return_price" jdbcType="VARCHAR" property="returnPrice"/>
  27. <result column="pay_way" jdbcType="INTEGER" property="payWay"/>
  28. <result column="service_charge_pay" property="serviceChargePay"/>
  29. <result column="shop_info" property="shopInfo"/>
  30. <result column="freeze" property="freeze"/>
  31. <result column="merchant_name" property="merchantName"/>
  32. <result column="shop_number" property="shopNumber"/>
  33. <result column="contract_depoist_detail" property="contractDepoistDetail"/>
  34. <result column="last_owe_call_time" jdbcType="TIMESTAMP" property="lastOweCallTime"/>
  35. <result column="last_owe_call_user" jdbcType="VARCHAR" property="lastOweCallUser"/>
  36. </resultMap>
  37. <sql id="allColumns">
  38. `id`,`tenant_id`,`parent_tenant_id`,`rent_contract_id`,`receive_pay`,`pay`,`receive_date`,`pay_date`,`createtime`,`last_owe_call_time`,
  39. `expired_day`,`status`,`is_del`,`need_pay`,`merchant_id`,`user_id`,`shop_id`,`updatetime`,`apply_status`,`apply_pay_img`,`apply_update_time`,
  40. `last_owe_call_user`,`rent_shop_type`,`return_price`,`pay_way`,service_charge_pay,contract_depoist_detail
  41. </sql>
  42. <sql id="dynamicWhereConditions">
  43. where 1 = 1
  44. <if test=" null != id "> and `id` = #{id} </if>
  45. <if test=" null != tenantId and '' != tenantId">
  46. and `tenant_id` = #{tenantId}
  47. </if>
  48. <if test=" null != parentTenantId and '' != parentTenantId">
  49. and `parent_tenant_id` = #{parentTenantId}
  50. </if>
  51. <if test=" null != rentContractId "> and `rent_contract_id` = #{rentContractId} </if>
  52. <if test=" null != receivePay "> and `receive_pay` = #{receivePay} </if>
  53. <if test=" null != pay "> and `pay` = #{pay} </if>
  54. <if test=" null != receiveDate "> and `receive_date` = #{receiveDate} </if>
  55. <if test=" null != payDate "> and `pay_date` = #{payDate} </if>
  56. <if test=" null != createtime "> and `createtime` = #{createtime} </if>
  57. <if test=" null != expiredDay "> and `expired_day` = #{expiredDay} </if>
  58. <if test=" null != status "> and `status` = #{status} </if>
  59. <if test=" null != applyStatus ">and `apply_status` = #{applyStatus}</if>
  60. <if test=" null != isDel "> and `is_del` = #{isDel} </if>
  61. <if test=" null != needPay "> and `need_pay` = #{needPay} </if>
  62. <if test=" null != merchantId "> and `merchant_id` = #{merchantId} </if>
  63. <if test=" null != userId "> and `user_id` = #{userId} </if>
  64. <if test=" null != shopId "> and `shop_id` = #{shopId} </if>
  65. <if test=" null != updatetime ">and `updatetime` = #{updatetime}</if>
  66. <if test=" null != rentShopType ">and `rent_shop_type` = #{rentShopType}</if>
  67. <if test=" null != payWay ">and `pay_way` = #{payWay}</if>
  68. <if test=" null != contractDepoistDetail and '' != contractDepoistDetail">
  69. and `contract_depoist_detail` like concat('%', #{contractDepoistDetail},'%')
  70. </if>
  71. <if test=" null != starttime">and `starttime` &lt;= #{starttime}</if>
  72. <if test=" null != endtime">and `endtime` &gt;= #{endtime}</if>
  73. <if test=" null != month and '' != month">
  74. and date_format(starttime,'%Y-%m') &lt;= #{month} and date_format(endtime,'%Y-%m') &gt;= #{month}
  75. </if>
  76. <if test=" null == nearBillLastTime and null != oweBillLastTime">
  77. and (`starttime` &lt;= #{oweBillLastTime} and `receive_pay` - `pay` &gt; 0 and status not in (3,6,7))
  78. </if>
  79. <if test=" null != nearBillLastTime and null != oweBillLastTime">
  80. and (`starttime` &gt; #{oweBillLastTime} and `starttime` &lt;= #{nearBillLastTime} and status not in (3,6,7))
  81. </if>
  82. <if test=" 1 == notifyed ">and (`last_owe_call_time` is not null and `receive_pay` - `pay` &gt; 0 and status not in (3,6,7) )</if>
  83. <if test=" null != merchantIds ">
  84. and `merchant_id` in
  85. <foreach collection="merchantIds" index="index" item="midItem" open="(" separator="," close=")">
  86. #{midItem}
  87. </foreach>
  88. </if>
  89. <if test=" null != rentContractIdList ">
  90. and rent_contract_id in
  91. <foreach collection="rentContractIdList" index="index" item="rdItem" open="(" separator="," close=")">
  92. #{rdItem}
  93. </foreach>
  94. </if>
  95. <if test=" null != ids ">
  96. and id in
  97. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  98. #{idItem}
  99. </foreach>
  100. </if>
  101. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  102. </sql>
  103. <select id="findList" parameterType="com.iformall.domain.po.WxBillDeposit" resultMap="BaseResultMap">
  104. select <include refid="allColumns" /> from wx_bill_rent_deposit
  105. <include refid="dynamicWhereConditions" />
  106. </select>
  107. <select id="selectById" parameterType="HashMap" resultMap="BaseResultMap">
  108. select <include refid="allColumns" /> from wx_bill_rent_deposit
  109. where id = #{id} and tenant_id = #{tenantId}
  110. </select>
  111. <select id="findRentContractIds" parameterType="com.iformall.domain.po.WxBillDeposit" resultType="Long">
  112. select distinct rent_contract_id from wx_bill_rent_deposit
  113. <include refid="dynamicWhereConditions" />
  114. </select>
  115. <select id="queryBillDepositList" parameterType="com.iformall.domain.po.WxBillDeposit" resultMap="BaseResultMap">
  116. select br.`id`,br.`tenant_id`,br.`parent_tenant_id`,br.`rent_contract_id`,br.`receive_pay`,br.`pay`,br.`receive_date`,br.`pay_date`,br.`createtime`,br.`expired_day`,br.`last_owe_call_time`,
  117. br.`status`,br.`need_pay`,br.`updatetime`,br.`merchant_id`,br.`apply_status`,br.`apply_pay_img`,br.`apply_update_time`,br.`contract_depoist_detail`,br.`last_owe_call_user`,
  118. br.`rent_shop_type`,br.`return_price`, br.pay_way,br.shop_info ,br.freeze,br.service_charge_pay
  119. from wx_bill_rent_deposit br
  120. <include refid="queryBillRentListCondition"/>
  121. order by br.id desc
  122. </select>
  123. <sql id="queryBillRentListCondition">
  124. <where>
  125. 1 = 1
  126. <if test=" null != id ">and br.`id` = #{id}</if>
  127. <if test=" null != merchantId ">and br.`merchant_id` = #{merchantId}</if>
  128. <if test=" null != tenantId and '' != tenantId">
  129. and br.`tenant_id` = #{tenantId}
  130. </if>
  131. <if test=" null != parentTenantId and '' != parentTenantId">
  132. and br.`parent_tenant_id` = #{parentTenantId}
  133. </if>
  134. <if test=" null != status ">and br.`status` = #{status}</if>
  135. <if test=" null != applyStatus ">and br.`apply_status` = #{applyStatus}</if>
  136. <if test=" null != isDel ">and br.`is_del` = #{isDel}</if>
  137. <if test=" null != rentShopType ">and br.`rent_shop_type` = #{rentShopType}</if>
  138. <if test=" null != rentContractId ">and br.`rent_contract_id` = #{rentContractId}</if>
  139. <if test=" null != payWay ">and br.`pay_way` = #{payWay}</if>
  140. <if test=" null != contractDepoistDetail and '' != contractDepoistDetail">
  141. and br.`contract_depoist_detail` like concat('%', #{contractDepoistDetail},'%')
  142. </if>
  143. <if test=" null != starttime">and br.`starttime` &lt;= #{starttime}</if>
  144. <if test=" null != endtime">and br.`endtime` &gt;= #{endtime}</if>
  145. <if test=" null != month and '' != month">
  146. and date_format(br.starttime,'%Y-%m') &lt;= #{month} and date_format(br.endtime,'%Y-%m') &gt;= #{month}
  147. </if>
  148. <if test=" null == nearBillLastTime and null != oweBillLastTime">
  149. and (br.`starttime` &lt;= #{oweBillLastTime} and br.`receive_pay` - br.`pay` &gt; 0 and br.status not in (3,6,7))
  150. </if>
  151. <if test=" null != nearBillLastTime and null != oweBillLastTime">
  152. and (br.`starttime` &gt; #{oweBillLastTime} and br.`starttime` &lt;= #{nearBillLastTime} and br.status not in (3,6,7))
  153. </if>
  154. <if test=" 1 == notifyed ">and (br.`last_owe_call_time` is not null and br.`receive_pay` - br.`pay` &gt; 0 and br.status not in (3,6,7) )</if>
  155. <if test=" null != merchantIds ">
  156. and br.`merchant_id` in
  157. <foreach collection="merchantIds" index="index" item="midItem" open="(" separator="," close=")">
  158. #{midItem}
  159. </foreach>
  160. </if>
  161. </where>
  162. </sql>
  163. <resultMap id="SumBaseResultMap" type="com.iformall.domain.vo.WxBillSum">
  164. <result column="receive_pay" jdbcType="VARCHAR" property="needPay"/>
  165. <result column="paid" jdbcType="VARCHAR" property="paid" />
  166. <result column="min_date" jdbcType="TIMESTAMP" property="minDate" />
  167. <result column="max_date" jdbcType="TIMESTAMP" property="maxDate" />
  168. </resultMap>
  169. <select id="getBillMonthSum" parameterType="com.iformall.domain.po.WxBillDeposit" resultMap="SumBaseResultMap">
  170. select
  171. sum(CAST(br.receive_pay AS DECIMAL(20,2))) receive_pay ,
  172. sum(CAST(br.pay AS DECIMAL(20,2))) paid,
  173. min(starttime) min_date,
  174. max(endtime) max_date
  175. from wx_bill_rent_deposit br
  176. <include refid="queryBillRentListCondition"/>
  177. </select>
  178. <select id="getMerchantIdList" parameterType="com.iformall.domain.po.WxBillDeposit" resultType="Long">
  179. select distinct merchant_id from wx_bill_rent_deposit br
  180. <include refid="queryBillRentListCondition"/>
  181. </select>
  182. <resultMap id="HotNotifyBaseResultMap" type="com.iformall.domain.vo.WxBillHotNotify">
  183. <result column="total_count" jdbcType="INTEGER" property="totalCount"/>
  184. <result column="total_money" jdbcType="VARCHAR" property="totalMoney" />
  185. <result column="min_begin_time" jdbcType="TIMESTAMP" property="minBeginTime"/>
  186. </resultMap>
  187. <select id="getBillHotNotify" parameterType="com.iformall.domain.po.WxBillDeposit" resultMap="HotNotifyBaseResultMap">
  188. select count(1) total_count , sum(CAST(br.`receive_pay` AS DECIMAL(20,2)) - CAST(br.`pay` AS DECIMAL(20,2))) total_money,MIN(br.starttime) min_begin_time from wx_bill_rent_deposit br
  189. <include refid="queryBillRentListCondition"/>
  190. </select>
  191. <resultMap id="NotifyResultMap" type="com.iformall.domain.vo.WxBillNotify">
  192. <result column="bill_type" jdbcType="INTEGER" property="billType"/>
  193. <result column="bill_type_name" jdbcType="VARCHAR" property="billTypeName" />
  194. <result column="bill_id" jdbcType="BIGINT" property="billId" />
  195. <result column="starttime" jdbcType="TIMESTAMP" property="starttime"/>
  196. <result column="endtime" jdbcType="TIMESTAMP" property="endtime"/>
  197. <result column="receive_pay" jdbcType="VARCHAR" property="receivePay"/>
  198. <result column="pay" jdbcType="VARCHAR" property="pay"/>
  199. <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
  200. </resultMap>
  201. <select id="getBillNotifyList" parameterType="com.iformall.domain.po.WxBillDeposit" resultMap="NotifyResultMap">
  202. 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_rent_deposit br
  203. <include refid="queryBillRentListCondition"/>
  204. </select>
  205. <select id="queryPayInfo" resultType="hashmap" parameterType="hashmap">
  206. select IFNULL(sum(receive_pay),0) receivepay,IFNULL(sum(pay),0) pay,tenant_id,parent_tenant_id from wx_bill_rent_deposit
  207. where 1=1
  208. <if test=" null != tenantId and '' != tenantId">
  209. and `tenant_id` = #{tenantId}
  210. </if>
  211. <if test=" null != parentTenantId and '' != parentTenantId">
  212. and `parent_tenant_id` = #{parentTenantId}
  213. </if>
  214. and date_format(receive_date,'%Y-%m')=#{receiveDate}
  215. group by tenant_id,parent_tenant_id
  216. </select>
  217. <select id="queryPayInfoAllTotal" resultType="hashmap" parameterType="hashmap">
  218. select round(sum(res.receivepay)/100,2) receivepay,round(sum(res.pay)/100,2) pay,res.tenant_id from
  219. (
  220. select IFNULL(sum(receive_pay),0) receivepay,IFNULL(sum(pay),0) pay,tenant_id from wx_bill_rent_deposit
  221. where 1=1
  222. <if test=" null != tenantId and '' != tenantId">
  223. and `tenant_id` = #{tenantId}
  224. </if>
  225. <if test=" null != parentTenantId and '' != parentTenantId">
  226. and `parent_tenant_id` = #{parentTenantId}
  227. </if>
  228. and receive_date between #{startdate} and #{enddate}
  229. union all
  230. select IFNULL(sum(receive_pay),0) receivepay,IFNULL(sum(pay),0) pay,tenant_id from wx_bill_property_deposit
  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 receive_date between #{startdate} and #{enddate}
  239. union all
  240. select IFNULL(sum(receive_pay),0) receivepay,IFNULL(sum(pay),0) pay,tenant_id from wx_bill_other_deposit
  241. where 1=1
  242. <if test=" null != tenantId and '' != tenantId">
  243. and `tenant_id` = #{tenantId}
  244. </if>
  245. <if test=" null != parentTenantId and '' != parentTenantId">
  246. and `parent_tenant_id` = #{parentTenantId}
  247. </if>
  248. and receive_date between #{startdate} and #{enddate}
  249. ) res
  250. </select>
  251. <select id="queryOweInfoAll" resultType="hashmap" parameterType="hashmap">
  252. select IFNULL(round(sum(res.owe)/100,2),0) owe,res.tenant_id from
  253. (
  254. select IFNULL(sum(receive_pay - pay),0) owe,tenant_id from wx_bill_rent_deposit
  255. where status = 1
  256. <if test=" null != tenantId and '' != tenantId">
  257. and `tenant_id` = #{tenantId}
  258. </if>
  259. <if test=" null != parentTenantId and '' != parentTenantId">
  260. and `parent_tenant_id` = #{parentTenantId}
  261. </if>
  262. and receive_date between #{startdate} and #{enddate}
  263. union all
  264. select IFNULL(sum(receive_pay - pay),0) owe,tenant_id from wx_bill_property_deposit
  265. where status = 1
  266. <if test=" null != tenantId and '' != tenantId">
  267. and `tenant_id` = #{tenantId}
  268. </if>
  269. <if test=" null != parentTenantId and '' != parentTenantId">
  270. and `parent_tenant_id` = #{parentTenantId}
  271. </if>
  272. and receive_date between #{startdate} and #{enddate}
  273. union all
  274. select IFNULL(sum(receive_pay - pay),0) owe,tenant_id from wx_bill_other_deposit
  275. where status = 1
  276. <if test=" null != tenantId and '' != tenantId">
  277. and `tenant_id` = #{tenantId}
  278. </if>
  279. <if test=" null != parentTenantId and '' != parentTenantId">
  280. and `parent_tenant_id` = #{parentTenantId}
  281. </if>
  282. and receive_date between #{startdate} and #{enddate}
  283. ) res
  284. </select>
  285. <update id="updateNotPaidStatus" parameterType="hashmap">
  286. update wx_bill_rent_deposit set status=#{notPaid},expired_day=DATEDIFF(now(),receive_date)
  287. where status!=#{paid}
  288. <if test=" null != tenantId and '' != tenantId">
  289. and `tenant_id` = #{tenantId}
  290. </if>
  291. <if test=" null != parentTenantId and '' != parentTenantId">
  292. and `parent_tenant_id` = #{parentTenantId}
  293. </if>
  294. and status!=5 and DATEDIFF(now(),receive_date)>0
  295. </update>
  296. <update id="updateWaitPayStatus" parameterType="hashmap">
  297. update wx_bill_rent_deposit set status=#{waitPay} where id in(
  298. select a.id from (select br.id,rc.receive_period,br.rent_contract_id,br.receive_date from wx_bill_rent_deposit br
  299. left join wx_rent_contract rc on br.rent_contract_id=rc.id
  300. where br.status!=#{paid}
  301. <if test=" null != tenantId and '' != tenantId">
  302. and br.`tenant_id` = #{tenantId}
  303. </if>
  304. <if test=" null != parentTenantId and '' != parentTenantId">
  305. and br.`parent_tenant_id` = #{parentTenantId}
  306. </if>
  307. and br.status!=5 and now() &lt; br.receive_date
  308. and DATE_ADD(now(),INTERVAL 1 MONTH)>br.receive_date) a)
  309. </update>
  310. <select id="queryOweCount" parameterType="com.iformall.domain.po.WxRentContract" resultType="Long">
  311. select count(*) c from wx_rent_contract r,wx_bill_rent_deposit b
  312. where b.rent_contract_id = r.id and b.status = 1 and r.id = #{id}
  313. </select>
  314. <delete id = "deleteById" parameterType="HashMap">
  315. delete from wx_bill_rent_deposit where id = #{id} and tenant_id = #{tenantId}
  316. </delete>
  317. </mapper>