You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

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