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.
 
 
 
 
 

310 righe
15 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.WxBillOtherMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxBillOther">
  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="last_owe_call_time" jdbcType="TIMESTAMP" property="lastOweCallTime"/>
  30. <result column="last_owe_call_user" jdbcType="VARCHAR" property="lastOweCallUser"/>
  31. <result column="comments" jdbcType="VARCHAR" property="comments" />
  32. <result column="rent_shop_type" jdbcType="INTEGER" property="rentShopType"/>
  33. <result column="pay_way" jdbcType="BIGINT" property="payWay"/>
  34. <result column="merchant_name" property="merchantName"/>
  35. <result column="starttime" property="starttime"/>
  36. <result column="endtime" property="endtime"/>
  37. <result column="freeze" property="freeze"/>
  38. <result column="service_charge_pay" property="serviceChargePay"/>
  39. <result column="energy_fees_id" jdbcType="BIGINT" property="energyFeesId"/>
  40. <result column="set_off" jdbcType="VARCHAR" property="setOff"/>
  41. </resultMap>
  42. <sql id="allColumns">
  43. `id`,`tenant_id`,`parent_tenant_id`,`receive_pay`,`pay`,`receive_date`,`pay_date`,`createtime`,`expired_day`,`last_owe_call_user`,
  44. `status`,`is_del`,`merchant_id`,`user_id`,`shop_id`,`shop_name`,`updatetime`,`name`,`comments`,`last_owe_call_time`,
  45. `rent_shop_type`,`pay_way`,`starttime`,`endtime`,endtime,service_charge_pay,`apply_status`,`apply_pay_img`,`apply_update_time`,
  46. `create_by`,`create_by_name`,`update_by`,`update_by_name`,`energy_fees_id`,`set_off`
  47. </sql>
  48. <sql id="dynamicWhereConditions">
  49. where 1 = 1
  50. <if test=" null != id "> and `id` = #{id} </if>
  51. <if test=" null != tenantId and '' != tenantId">
  52. and `tenant_id` = #{tenantId}
  53. </if>
  54. <if test=" null != parentTenantId and '' != parentTenantId">
  55. and `parent_tenant_id` = #{parentTenantId}
  56. </if>
  57. <if test=" null != receivePay "> and `receive_pay` = #{receivePay} </if>
  58. <if test=" null != pay "> and `pay` = #{pay} </if>
  59. <if test=" null != receiveDate "> and `receive_date` = #{receiveDate} </if>
  60. <if test=" null != payDate "> and `pay_date` = #{payDate} </if>
  61. <if test=" null != createtime "> and `createtime` = #{createtime} </if>
  62. <if test=" null != expiredDay "> and `expired_day` = #{expiredDay} </if>
  63. <if test=" null != status "> and `status` = #{status} </if>
  64. <if test=" null != applyStatus ">and `apply_status` = #{applyStatus}</if>
  65. <if test=" null != isDel "> and `is_del` = #{isDel} </if>
  66. <if test=" null != merchantId "> and `merchant_id` = #{merchantId} </if>
  67. <if test=" null != energyFeesId ">and `energy_fees_id` = #{energyFeesId}</if>
  68. <if test=" null != userId "> and `user_id` = #{userId} </if>
  69. <if test=" null != shopId "> and `shop_id` = #{shopId} </if>
  70. <if test=" null != updatetime "> and `updatetime` = #{updatetime} </if>
  71. <if test=" null != name "> and `name` = #{name} </if>
  72. <if test=" null != rentShopType ">and `rent_shop_type` = #{rentShopType}</if>
  73. <if test=" null != payWay ">and `pay_way` = #{payWay}</if>
  74. <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>
  75. <if test=" null != ids ">
  76. and id in
  77. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  78. #{idItem}
  79. </foreach>
  80. </if>
  81. <if test=" null != notInIds ">
  82. and id not in
  83. <foreach collection="notInIds" index="index" item="nidItem" open="(" separator="," close=")">
  84. #{nidItem}
  85. </foreach>
  86. </if>
  87. <if test=" null != statusList ">
  88. and status in
  89. <foreach collection="statusList" index="index" item="stItem" open="(" separator="," close=")">
  90. #{stItem}
  91. </foreach>
  92. </if>
  93. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  94. </sql>
  95. <select id="findList" parameterType="com.iformall.domain.po.WxBillOther" resultMap="BaseResultMap">
  96. select <include refid="allColumns" /> from wx_bill_other
  97. <include refid="dynamicWhereConditions" />
  98. </select>
  99. <select id="selectById" parameterType="HashMap" resultMap="BaseResultMap">
  100. select <include refid="allColumns" /> from wx_bill_other
  101. where id = #{id} and tenant_id = #{tenantId}
  102. </select>
  103. <sql id = "queryBillListConditions">
  104. <where>
  105. 1 = 1
  106. <if test=" null != id ">and br.`id` = #{id}</if>
  107. <if test=" null != tenantId and '' != tenantId"> and br.`tenant_id` = #{tenantId}</if>
  108. <if test=" null != parentTenantId and '' != parentTenantId">and br.`parent_tenant_id` = #{parentTenantId}</if>
  109. <if test=" null != freeze ">and br.`freeze` = #{freeze}</if>
  110. <if test=" null != merchantId ">and br.`merchant_id` = #{merchantId}</if>
  111. <if test=" null != status ">and br.`status` = #{status}</if>
  112. <if test=" null != applyStatus ">and br.`apply_status` = #{applyStatus}</if>
  113. <if test=" null != isDel ">and br.`is_del` = #{isDel}</if>
  114. <if test=" null != energyFeesId ">and br.`energy_fees_id` = #{energyFeesId}</if>
  115. <if test=" null != name and ''!=name">and br.`name` like concat('%',#{name},'%')</if>
  116. <if test=" null != rentShopType ">and br.`rent_shop_type` = #{rentShopType}</if>
  117. <if test=" null != payWay ">and br.`pay_way` = #{payWay}</if>
  118. <if test=" null != starttime">and br.`starttime` &lt;= #{starttime}</if>
  119. <if test=" null != endtime">and br.`endtime` &gt;= #{endtime}</if>
  120. <if test=" null != month and '' != month">
  121. and date_format(br.starttime,'%Y-%m') &lt;= #{month} and date_format(br.endtime,'%Y-%m') &gt;= #{month}
  122. </if>
  123. <if test=" null == nearBillLastTime and null != oweBillLastTime">
  124. and (br.`starttime` &lt;= #{oweBillLastTime} and br.`receive_pay` - br.`pay` - br.`set_off` &gt; 0 and br.status not in (3,6,7))
  125. </if>
  126. <if test=" null != nearBillLastTime and null != oweBillLastTime">
  127. 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))
  128. </if>
  129. <if test=" null != needPayStartDay">
  130. and (br.`starttime` &lt;= #{needPayStartDay} and br.`receive_pay` - br.`pay` - br.`set_off` &gt; 0 and br.status not in (3,6,7))
  131. </if>
  132. <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>
  133. <if test=" null != merchantIds ">
  134. and br.`merchant_id` in
  135. <foreach collection="merchantIds" index="index" item="midItem" open="(" separator="," close=")">
  136. #{midItem}
  137. </foreach>
  138. </if>
  139. <if test=" null != notInIds ">
  140. and br.id not in
  141. <foreach collection="notInIds" index="index" item="nidItem" open="(" separator="," close=")">
  142. #{nidItem}
  143. </foreach>
  144. </if>
  145. <if test=" null != statusList ">
  146. and br.status in
  147. <foreach collection="statusList" index="index" item="stItem" open="(" separator="," close=")">
  148. #{stItem}
  149. </foreach>
  150. </if>
  151. </where>
  152. </sql>
  153. <select id="queryBillList" parameterType="com.iformall.domain.po.WxBillOther" resultMap="BaseResultMap">
  154. 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`,
  155. br.`status`,br.shop_name,br.`updatetime`,br.`apply_status`,br.`last_owe_call_time`,br.`last_owe_call_user`,br.`set_off`,
  156. br.`apply_pay_img`,br.`apply_update_time`,br.`merchant_id`,br.shop_id,br.name,br.comments,br.`rent_shop_type`,br.`energy_fees_id`,
  157. 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`
  158. from wx_bill_other br
  159. <include refid="queryBillListConditions" />
  160. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  161. <if test=" null == sortColumns">order by id desc</if>
  162. </select>
  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. <result column="service_pay" jdbcType="VARCHAR" property="servicePay"/>
  169. <result column="late_pay" jdbcType="VARCHAR" property="latePay"/>
  170. <result column="return_pay" jdbcType="VARCHAR" property="returnPay"/>
  171. </resultMap>
  172. <select id="getBillMonthSum" parameterType="com.iformall.domain.po.WxBillOther" resultMap="SumBaseResultMap">
  173. select
  174. sum(CAST(br.receive_pay AS DECIMAL(20,2))) receive_pay ,
  175. sum(CAST(br.pay AS DECIMAL(20,2))) paid,
  176. min(starttime) min_date,
  177. max(endtime) max_date,
  178. sum(CAST(br.service_charge_pay AS DECIMAL(20,2))) service_pay ,
  179. '0' late_pay,
  180. '0' return_pay
  181. from wx_bill_other br
  182. <include refid="queryBillListConditions"/>
  183. </select>
  184. <select id="getMerchantIdList" parameterType="com.iformall.domain.po.WxBillOther" resultType="Long">
  185. select distinct merchant_id from wx_bill_other br
  186. <include refid="queryBillListConditions"/>
  187. </select>
  188. <resultMap id="HotNotifyBaseResultMap" type="com.iformall.domain.vo.WxBillHotNotify">
  189. <result column="total_count" jdbcType="INTEGER" property="totalCount"/>
  190. <result column="total_money" jdbcType="VARCHAR" property="totalMoney" />
  191. <result column="min_begin_time" jdbcType="TIMESTAMP" property="minBeginTime"/>
  192. </resultMap>
  193. <select id="getBillHotNotify" parameterType="com.iformall.domain.po.WxBillOther" resultMap="HotNotifyBaseResultMap">
  194. 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 br
  195. <include refid="queryBillListConditions"/>
  196. </select>
  197. <resultMap id="NotifyResultMap" type="com.iformall.domain.vo.WxBillNotify">
  198. <result column="bill_type" jdbcType="INTEGER" property="billType"/>
  199. <result column="bill_type_name" jdbcType="VARCHAR" property="billTypeName" />
  200. <result column="bill_id" jdbcType="BIGINT" property="billId" />
  201. <result column="starttime" jdbcType="TIMESTAMP" property="starttime"/>
  202. <result column="endtime" jdbcType="TIMESTAMP" property="endtime"/>
  203. <result column="receive_pay" jdbcType="VARCHAR" property="receivePay"/>
  204. <result column="pay" jdbcType="VARCHAR" property="pay"/>
  205. <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
  206. </resultMap>
  207. <select id="getBillNotifyList" parameterType="com.iformall.domain.po.WxBillOther" resultMap="NotifyResultMap">
  208. 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 br
  209. <include refid="queryBillListConditions"/>
  210. </select>
  211. <update id="updateNotPaidStatus" parameterType="hashmap">
  212. update wx_bill_other set status=#{notPaid},expired_day=DATEDIFF(now(),receive_date)
  213. where 1=1
  214. <if test=" null != tenantId and '' != tenantId">
  215. and `tenant_id` = #{tenantId}
  216. </if>
  217. <if test=" null != parentTenantId and '' != parentTenantId">
  218. and `parent_tenant_id` = #{parentTenantId}
  219. </if>
  220. and status!=#{paid} and DATEDIFF(now(),receive_date)>0
  221. </update>
  222. <update id="updateWaitPayStatus" parameterType="hashmap">
  223. update wx_bill_other set status=#{waitPay} where 1=1
  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!=#{paid} and DATEDIFF(now(),receive_date) &lt;=0
  231. </update>
  232. <select id="queryPayInfoTotal" resultType="hashmap" parameterType="hashmap">
  233. select round(sum(t.receivepay)/100,2) receivepay,round(sum(t.pay)/100,2) pay from
  234. (
  235. select IFNULL(sum(receive_pay),0) receivepay,IFNULL(sum(pay),0) pay,tenant_id from wx_bill_other
  236. where 1=1
  237. <if test=" null != tenantId and '' != tenantId">
  238. and `tenant_id` = #{tenantId}
  239. </if>
  240. <if test=" null != parentTenantId and '' != parentTenantId">
  241. and `parent_tenant_id` = #{parentTenantId}
  242. </if>
  243. and receive_date between #{startdate} and #{enddate}
  244. union
  245. select IFNULL(sum(receive_pay),0) receivepay,IFNULL(sum(pay),0) pay,tenant_id from wx_bill_daily
  246. where 1=1
  247. <if test=" null != tenantId and '' != tenantId">
  248. and `tenant_id` = #{tenantId}
  249. </if>
  250. <if test=" null != parentTenantId and '' != parentTenantId">
  251. and `parent_tenant_id` = #{parentTenantId}
  252. </if>
  253. and receive_date between #{startdate} and #{enddate}
  254. ) t
  255. </select>
  256. <select id="queryOweInfo" resultType="hashmap" parameterType="hashmap">
  257. select IFNULL(round(sum(res.owe)/100,2),0) owe,res.tenant_id from
  258. (
  259. select IFNULL(sum(receive_pay - pay),0) owe,tenant_id from wx_bill_daily
  260. where status = 1
  261. <if test=" null != tenantId and '' != tenantId">
  262. and `tenant_id` = #{tenantId}
  263. </if>
  264. <if test=" null != parentTenantId and '' != parentTenantId">
  265. and `parent_tenant_id` = #{parentTenantId}
  266. </if>
  267. and receive_date between #{startdate} and #{enddate}
  268. union all
  269. select IFNULL(sum(receive_pay - pay),0) owe,tenant_id from wx_bill_daily
  270. where status = 1
  271. <if test=" null != tenantId and '' != tenantId">
  272. and `tenant_id` = #{tenantId}
  273. </if>
  274. <if test=" null != parentTenantId and '' != parentTenantId">
  275. and `parent_tenant_id` = #{parentTenantId}
  276. </if>
  277. and receive_date between #{startdate} and #{enddate}
  278. ) res
  279. </select>
  280. <delete id = "deleteById" parameterType="HashMap">
  281. delete from wx_bill_other where id = #{id} and tenant_id = #{tenantId}
  282. </delete>
  283. </mapper>