Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 

269 строки
12 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="owe" jdbcType="VARCHAR" property="owe"/>
  16. <result column="status" jdbcType="INTEGER" property="status" />
  17. <result column="apply_status" jdbcType="INTEGER" property="applyStatus"/>
  18. <result column="apply_pay_img" jdbcType="INTEGER" property="applyPayImg"/>
  19. <result column="apply_update_time" jdbcType="INTEGER" property="applyUpdateTime"/>
  20. <result column="is_del" jdbcType="INTEGER" property="isDel" />
  21. <result column="need_pay" jdbcType="VARCHAR" property="needPay"/>
  22. <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
  23. <result column="user_id" jdbcType="BIGINT" property="userId" />
  24. <result column="shop_id" jdbcType="BIGINT" property="shopId" />
  25. <result column="updatetime" jdbcType="TIMESTAMP" property="updatetime" />
  26. <result column="rent_shop_type" jdbcType="INTEGER" property="rentShopType"/>
  27. <result column="return_price" jdbcType="VARCHAR" property="returnPrice"/>
  28. <result column="pay_way" jdbcType="INTEGER" property="payWay"/>
  29. <result column="service_charge_pay" property="serviceChargePay"/>
  30. <result column="shop_info" property="shopInfo"/>
  31. <result column="freeze" property="freeze"/>
  32. <result column="merchant_name" property="merchantName"/>
  33. <result column="shop_number" property="shopNumber"/>
  34. </resultMap>
  35. <sql id="allColumns">
  36. `id`,`tenant_id`,`parent_tenant_id`,`rent_contract_id`,`receive_pay`,`pay`,`receive_date`,`pay_date`,`createtime`,
  37. `expired_day`,`owe`,`status`,`is_del`,`need_pay`,`merchant_id`,`user_id`,`shop_id`,`updatetime`,`apply_status`,`apply_pay_img`,`apply_update_time`,
  38. `rent_shop_type`,`return_price`,`pay_way`,service_charge_pay
  39. </sql>
  40. <sql id="dynamicWhereConditions">
  41. where 1 = 1
  42. <if test=" null != id "> and `id` = #{id} </if>
  43. <if test=" null != tenantId and '' != tenantId">
  44. and `tenant_id` = #{tenantId}
  45. </if>
  46. <if test=" null != parentTenantId and '' != parentTenantId">
  47. and `parent_tenant_id` = #{parentTenantId}
  48. </if>
  49. <if test=" null != rentContractId "> and `rent_contract_id` = #{rentContractId} </if>
  50. <if test=" null != receivePay "> and `receive_pay` = #{receivePay} </if>
  51. <if test=" null != pay "> and `pay` = #{pay} </if>
  52. <if test=" null != receiveDate "> and `receive_date` = #{receiveDate} </if>
  53. <if test=" null != payDate "> and `pay_date` = #{payDate} </if>
  54. <if test=" null != createtime "> and `createtime` = #{createtime} </if>
  55. <if test=" null != expiredDay "> and `expired_day` = #{expiredDay} </if>
  56. <if test=" null != owe "> and `owe` = #{owe} </if>
  57. <if test=" null != status "> and `status` = #{status} </if>
  58. <if test=" null != applyStatus ">and `apply_status` = #{applyStatus}</if>
  59. <if test=" null != isDel "> and `is_del` = #{isDel} </if>
  60. <if test=" null != needPay "> and `need_pay` = #{needPay} </if>
  61. <if test=" null != merchantId "> and `merchant_id` = #{merchantId} </if>
  62. <if test=" null != userId "> and `user_id` = #{userId} </if>
  63. <if test=" null != shopId "> and `shop_id` = #{shopId} </if>
  64. <if test=" null != updatetime ">and `updatetime` = #{updatetime}</if>
  65. <if test=" null != rentShopType ">and `rent_shop_type` = #{rentShopType}</if>
  66. <if test=" null != payWay ">and `pay_way` = #{payWay}</if>
  67. <if test=" null != rentContractIdList ">
  68. and rent_contract_id in
  69. <foreach collection="rentContractIdList" index="index" item="rdItem" open="(" separator="," close=")">
  70. #{rdItem}
  71. </foreach>
  72. </if>
  73. <if test=" null != ids ">
  74. and id in
  75. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  76. #{idItem}
  77. </foreach>
  78. </if>
  79. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  80. </sql>
  81. <select id="findList" parameterType="com.iformall.domain.po.WxBillDeposit" resultMap="BaseResultMap">
  82. select <include refid="allColumns" /> from wx_bill_rent_deposit
  83. <include refid="dynamicWhereConditions" />
  84. </select>
  85. <select id="findRentContractIds" parameterType="com.iformall.domain.po.WxBillDeposit" resultType="Long">
  86. select distinct rent_contract_id from wx_bill_rent_deposit
  87. <include refid="dynamicWhereConditions" />
  88. </select>
  89. <select id="queryBillDepositList" parameterType="com.iformall.domain.po.WxBillDeposit" resultMap="BaseResultMap">
  90. select br.`id`,br.`receive_pay`,br.`pay`,br.`receive_date`,br.`pay_date`,br.`createtime`,br.`expired_day`,
  91. br.`owe`,br.`status`,br.`need_pay`,br.`updatetime`,br.`merchant_id`,br.`apply_status`,br.`apply_pay_img`,br.`apply_update_time`,
  92. br.`rent_shop_type`,br.`return_price`, br.pay_way,br.shop_info ,br.freeze,br.service_charge_pay
  93. from wx_bill_rent_deposit br
  94. <include refid="queryBillRentListCondition"/>
  95. order by br.id desc
  96. </select>
  97. <sql id="queryBillRentListCondition">
  98. <where>
  99. 1 = 1
  100. <if test=" null != id ">and br.`id` = #{id}</if>
  101. <if test=" null != merchantId ">and br.`merchant_id` = #{merchantId}</if>
  102. <if test=" null != tenantId and '' != tenantId">
  103. and br.`tenant_id` = #{tenantId}
  104. </if>
  105. <if test=" null != parentTenantId and '' != parentTenantId">
  106. and br.`parent_tenant_id` = #{parentTenantId}
  107. </if>
  108. <if test=" null != status ">and br.`status` = #{status}</if>
  109. <if test=" null != applyStatus ">and br.`apply_status` = #{applyStatus}</if>
  110. <if test=" null != isDel ">and br.`is_del` = #{isDel}</if>
  111. <if test=" null != rentShopType ">and br.`rent_shop_type` = #{rentShopType}</if>
  112. <if test=" null != rentContractId ">and br.`rent_contract_id` = #{rentContractId}</if>
  113. <if test=" null != payWay ">and br.`pay_way` = #{payWay}</if>
  114. <if test=" null != starttime">and br.`starttime` &lt;= #{starttime}</if>
  115. <if test=" null != endtime">and br.`endtime` &gt;= #{endtime}</if>
  116. <if test=" null != month and '' != month">
  117. and date_format(br.starttime,'%Y-%m') &lt;= #{month} and date_format(br.endtime,'%Y-%m') &gt;= #{month}
  118. </if>
  119. <if test=" 1 == onlyOwe">and br.`owe` &gt; 0</if>
  120. <if test=" null != merchantIds ">
  121. and br.`merchant_id` in
  122. <foreach collection="merchantIds" index="index" item="midItem" open="(" separator="," close=")">
  123. #{midItem}
  124. </foreach>
  125. </if>
  126. </where>
  127. </sql>
  128. <resultMap id="SumBaseResultMap" type="com.iformall.domain.vo.WxBillSum">
  129. <result column="receive_pay" jdbcType="VARCHAR" property="needPay"/>
  130. <result column="paid" jdbcType="VARCHAR" property="paid" />
  131. <result column="owe" jdbcType="VARCHAR" property="owe"/>
  132. </resultMap>
  133. <select id="getBillMonthSum" parameterType="com.iformall.domain.po.WxBillDeposit" resultMap="SumBaseResultMap">
  134. select sum(br.receive_pay) receive_pay , sum(br.pay) paid, sum(br.owe) owe from wx_bill_rent_deposit br
  135. <include refid="queryBillRentListCondition"/>
  136. </select>
  137. <select id="getMerchantIdList" parameterType="com.iformall.domain.po.WxBillDeposit" resultType="Long">
  138. select distinct merchant_id from wx_bill_rent_deposit br
  139. <include refid="queryBillRentListCondition"/>
  140. </select>
  141. <select id="queryPayInfo" resultType="hashmap" parameterType="hashmap">
  142. select IFNULL(sum(receive_pay),0) receivepay,IFNULL(sum(pay),0) pay,tenant_id,parent_tenant_id from wx_bill_rent_deposit
  143. where 1=1
  144. <if test=" null != tenantId and '' != tenantId">
  145. and `tenant_id` = #{tenantId}
  146. </if>
  147. <if test=" null != parentTenantId and '' != parentTenantId">
  148. and `parent_tenant_id` = #{parentTenantId}
  149. </if>
  150. and date_format(receive_date,'%Y-%m')=#{receiveDate}
  151. group by tenant_id,parent_tenant_id
  152. </select>
  153. <select id="queryPayInfoAllTotal" resultType="hashmap" parameterType="hashmap">
  154. select round(sum(res.receivepay)/100,2) receivepay,round(sum(res.pay)/100,2) pay,res.tenant_id from
  155. (
  156. select IFNULL(sum(receive_pay),0) receivepay,IFNULL(sum(pay),0) pay,tenant_id from wx_bill_rent_deposit
  157. where 1=1
  158. <if test=" null != tenantId and '' != tenantId">
  159. and `tenant_id` = #{tenantId}
  160. </if>
  161. <if test=" null != parentTenantId and '' != parentTenantId">
  162. and `parent_tenant_id` = #{parentTenantId}
  163. </if>
  164. and receive_date between #{startdate} and #{enddate}
  165. union all
  166. select IFNULL(sum(receive_pay),0) receivepay,IFNULL(sum(pay),0) pay,tenant_id from wx_bill_property_deposit
  167. where 1=1
  168. <if test=" null != tenantId and '' != tenantId">
  169. and `tenant_id` = #{tenantId}
  170. </if>
  171. <if test=" null != parentTenantId and '' != parentTenantId">
  172. and `parent_tenant_id` = #{parentTenantId}
  173. </if>
  174. and receive_date between #{startdate} and #{enddate}
  175. union all
  176. select IFNULL(sum(receive_pay),0) receivepay,IFNULL(sum(pay),0) pay,tenant_id from wx_bill_other_deposit
  177. where 1=1
  178. <if test=" null != tenantId and '' != tenantId">
  179. and `tenant_id` = #{tenantId}
  180. </if>
  181. <if test=" null != parentTenantId and '' != parentTenantId">
  182. and `parent_tenant_id` = #{parentTenantId}
  183. </if>
  184. and receive_date between #{startdate} and #{enddate}
  185. ) res
  186. </select>
  187. <select id="queryOweInfoAll" resultType="hashmap" parameterType="hashmap">
  188. select IFNULL(round(sum(res.owe)/100,2),0) owe,res.tenant_id from
  189. (
  190. select IFNULL(sum(owe),0) owe,tenant_id from wx_bill_rent_deposit
  191. where status = 1
  192. <if test=" null != tenantId and '' != tenantId">
  193. and `tenant_id` = #{tenantId}
  194. </if>
  195. <if test=" null != parentTenantId and '' != parentTenantId">
  196. and `parent_tenant_id` = #{parentTenantId}
  197. </if>
  198. and receive_date between #{startdate} and #{enddate}
  199. union all
  200. select IFNULL(sum(owe),0) owe,tenant_id from wx_bill_property_deposit
  201. where status = 1
  202. <if test=" null != tenantId and '' != tenantId">
  203. and `tenant_id` = #{tenantId}
  204. </if>
  205. <if test=" null != parentTenantId and '' != parentTenantId">
  206. and `parent_tenant_id` = #{parentTenantId}
  207. </if>
  208. and receive_date between #{startdate} and #{enddate}
  209. union all
  210. select IFNULL(sum(owe),0) owe,tenant_id from wx_bill_other_deposit
  211. where status = 1
  212. <if test=" null != tenantId and '' != tenantId">
  213. and `tenant_id` = #{tenantId}
  214. </if>
  215. <if test=" null != parentTenantId and '' != parentTenantId">
  216. and `parent_tenant_id` = #{parentTenantId}
  217. </if>
  218. and receive_date between #{startdate} and #{enddate}
  219. ) res
  220. </select>
  221. <update id="updateNotPaidStatus" parameterType="hashmap">
  222. update wx_bill_rent_deposit set status=#{notPaid},expired_day=DATEDIFF(now(),receive_date)
  223. where status!=#{paid}
  224. <if test=" null != tenantId and '' != tenantId">
  225. and `tenant_id` = #{tenantId}
  226. </if>
  227. <if test=" null != parentTenantId and '' != parentTenantId">
  228. and `parent_tenant_id` = #{parentTenantId}
  229. </if>
  230. and status!=5 and DATEDIFF(now(),receive_date)>0
  231. </update>
  232. <update id="updateWaitPayStatus" parameterType="hashmap">
  233. update wx_bill_rent_deposit set status=#{waitPay} where id in(
  234. select a.id from (select br.id,rc.receive_period,br.rent_contract_id,br.receive_date from wx_bill_rent_deposit br
  235. left join wx_rent_contract rc on br.rent_contract_id=rc.id
  236. where br.status!=#{paid}
  237. <if test=" null != tenantId and '' != tenantId">
  238. and br.`tenant_id` = #{tenantId}
  239. </if>
  240. <if test=" null != parentTenantId and '' != parentTenantId">
  241. and br.`parent_tenant_id` = #{parentTenantId}
  242. </if>
  243. and br.status!=5 and now() &lt; br.receive_date
  244. and DATE_ADD(now(),INTERVAL 1 MONTH)>br.receive_date) a)
  245. </update>
  246. <select id="queryOweCount" parameterType="com.iformall.domain.po.WxRentContract" resultType="Long">
  247. select count(*) c from wx_rent_contract r,wx_bill_rent_deposit b
  248. where b.rent_contract_id = r.id and b.status = 1 and r.id = #{id}
  249. </select>
  250. </mapper>