后台服务
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.

228 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="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="BIGINT" 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="BIGINT" 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 != ids ">
  68. and id in
  69. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  70. #{idItem}
  71. </foreach>
  72. </if>
  73. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  74. </sql>
  75. <select id="findList" parameterType="com.iformall.domain.po.WxBillDeposit" resultMap="BaseResultMap">
  76. select <include refid="allColumns" /> from wx_bill_rent_deposit
  77. <include refid="dynamicWhereConditions" />
  78. </select>
  79. <select id="queryBillDepositList" parameterType="com.iformall.domain.po.WxBillDeposit" resultMap="BaseResultMap">
  80. select br.`id`,br.`receive_pay`,br.`pay`,br.`receive_date`,br.`pay_date`,br.`createtime`,br.`expired_day`,
  81. br.`owe`,br.`status`,br.`need_pay`,m.`name` merchant_name,s.shop_number,br.`updatetime`,br.`merchant_id`,
  82. br.`apply_status`,br.`apply_pay_img`,br.`apply_update_time`,
  83. br.`rent_shop_type`,br.`return_price`, br.pay_way,br.shop_info ,br.freeze,br.service_charge_pay
  84. from wx_bill_rent_deposit br left join wx_merchant m on br.merchant_id=m.id
  85. left join wx_shop s on br.shop_id=s.id
  86. <where>
  87. <if test=" null != id ">and br.`id` = #{id}</if>
  88. <if test=" null != merchantId ">and br.`merchant_id` = #{merchantId}</if>
  89. <if test=" null != merchantName and ''!=merchantName ">and m.`name` like concat('%',#{merchantName},'%')</if>
  90. <if test=" null != tenantId and '' != tenantId">
  91. and br.`tenant_id` = #{tenantId}
  92. </if>
  93. <if test=" null != parentTenantId and '' != parentTenantId">
  94. and br.`parent_tenant_id` = #{parentTenantId}
  95. </if>
  96. <if test=" null != status ">and br.`status` = #{status}</if>
  97. <if test=" null != applyStatus ">and br.`apply_status` = #{applyStatus}</if>
  98. <if test=" null != isDel ">and br.`is_del` = #{isDel}</if>
  99. <if test=" null != rentShopType ">and br.`rent_shop_type` = #{rentShopType}</if>
  100. <if test=" null != rentContractId ">and br.`rent_contract_id` = #{rentContractId}</if>
  101. <if test=" null != payWay ">and br.`pay_way` = #{payWay}</if>
  102. </where>
  103. order by br.id desc
  104. </select>
  105. <select id="queryPayInfo" resultType="hashmap" parameterType="hashmap">
  106. select IFNULL(sum(receive_pay),0) receivepay,IFNULL(sum(pay),0) pay,tenant_id,parent_tenant_id from wx_bill_rent_deposit
  107. where 1=1
  108. <if test=" null != tenantId and '' != tenantId">
  109. and `tenant_id` = #{tenantId}
  110. </if>
  111. <if test=" null != parentTenantId and '' != parentTenantId">
  112. and `parent_tenant_id` = #{parentTenantId}
  113. </if>
  114. and date_format(receive_date,'%Y-%m')=#{receiveDate}
  115. group by tenant_id,parent_tenant_id
  116. </select>
  117. <select id="queryPayInfoAllTotal" resultType="hashmap" parameterType="hashmap">
  118. select round(sum(res.receivepay)/100,2) receivepay,round(sum(res.pay)/100,2) pay,res.tenant_id from
  119. (
  120. select IFNULL(sum(receive_pay),0) receivepay,IFNULL(sum(pay),0) pay,tenant_id from wx_bill_rent_deposit
  121. where 1=1
  122. <if test=" null != tenantId and '' != tenantId">
  123. and `tenant_id` = #{tenantId}
  124. </if>
  125. <if test=" null != parentTenantId and '' != parentTenantId">
  126. and `parent_tenant_id` = #{parentTenantId}
  127. </if>
  128. and receive_date between #{startdate} and #{enddate}
  129. union all
  130. select IFNULL(sum(receive_pay),0) receivepay,IFNULL(sum(pay),0) pay,tenant_id from wx_bill_property_deposit
  131. where 1=1
  132. <if test=" null != tenantId and '' != tenantId">
  133. and `tenant_id` = #{tenantId}
  134. </if>
  135. <if test=" null != parentTenantId and '' != parentTenantId">
  136. and `parent_tenant_id` = #{parentTenantId}
  137. </if>
  138. and receive_date between #{startdate} and #{enddate}
  139. union all
  140. select IFNULL(sum(receive_pay),0) receivepay,IFNULL(sum(pay),0) pay,tenant_id from wx_bill_other_deposit
  141. where 1=1
  142. <if test=" null != tenantId and '' != tenantId">
  143. and `tenant_id` = #{tenantId}
  144. </if>
  145. <if test=" null != parentTenantId and '' != parentTenantId">
  146. and `parent_tenant_id` = #{parentTenantId}
  147. </if>
  148. and receive_date between #{startdate} and #{enddate}
  149. ) res
  150. </select>
  151. <select id="queryOweInfoAll" resultType="hashmap" parameterType="hashmap">
  152. select IFNULL(round(sum(res.owe)/100,2),0) owe,res.tenant_id from
  153. (
  154. select IFNULL(sum(owe),0) owe,tenant_id from wx_bill_rent_deposit
  155. where status = 1
  156. <if test=" null != tenantId and '' != tenantId">
  157. and `tenant_id` = #{tenantId}
  158. </if>
  159. <if test=" null != parentTenantId and '' != parentTenantId">
  160. and `parent_tenant_id` = #{parentTenantId}
  161. </if>
  162. and receive_date between #{startdate} and #{enddate}
  163. union all
  164. select IFNULL(sum(owe),0) owe,tenant_id from wx_bill_property_deposit
  165. where status = 1
  166. <if test=" null != tenantId and '' != tenantId">
  167. and `tenant_id` = #{tenantId}
  168. </if>
  169. <if test=" null != parentTenantId and '' != parentTenantId">
  170. and `parent_tenant_id` = #{parentTenantId}
  171. </if>
  172. and receive_date between #{startdate} and #{enddate}
  173. union all
  174. select IFNULL(sum(owe),0) owe,tenant_id from wx_bill_other_deposit
  175. where status = 1
  176. <if test=" null != tenantId and '' != tenantId">
  177. and `tenant_id` = #{tenantId}
  178. </if>
  179. <if test=" null != parentTenantId and '' != parentTenantId">
  180. and `parent_tenant_id` = #{parentTenantId}
  181. </if>
  182. and receive_date between #{startdate} and #{enddate}
  183. ) res
  184. </select>
  185. <update id="updateNotPaidStatus" parameterType="hashmap">
  186. update wx_bill_rent_deposit set status=#{notPaid},expired_day=DATEDIFF(now(),receive_date)
  187. where status!=#{paid}
  188. <if test=" null != tenantId and '' != tenantId">
  189. and `tenant_id` = #{tenantId}
  190. </if>
  191. <if test=" null != parentTenantId and '' != parentTenantId">
  192. and `parent_tenant_id` = #{parentTenantId}
  193. </if>
  194. and status!=5 and DATEDIFF(now(),receive_date)>0
  195. </update>
  196. <update id="updateWaitPayStatus" parameterType="hashmap">
  197. update wx_bill_rent_deposit set status=#{waitPay} where id in(
  198. select a.id from (select br.id,rc.receive_period,br.rent_contract_id,br.receive_date from wx_bill_rent_deposit br
  199. left join wx_rent_contract rc on br.rent_contract_id=rc.id
  200. where br.status!=#{paid}
  201. <if test=" null != tenantId and '' != tenantId">
  202. and br.`tenant_id` = #{tenantId}
  203. </if>
  204. <if test=" null != parentTenantId and '' != parentTenantId">
  205. and br.`parent_tenant_id` = #{parentTenantId}
  206. </if>
  207. and br.status!=5 and now() &lt; br.receive_date
  208. and DATE_ADD(now(),INTERVAL 1 MONTH)>br.receive_date) a)
  209. </update>
  210. <select id="queryOweCount" parameterType="com.iformall.domain.po.WxRentContract" resultType="Long">
  211. select count(*) c from wx_rent_contract r,wx_bill_rent_deposit b
  212. where b.rent_contract_id = r.id and b.status = 1 and r.id = #{id}
  213. </select>
  214. </mapper>