Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 

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