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.
 
 
 
 
 

239 lines
11 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="comments" jdbcType="VARCHAR" property="comments" />
  26. <result column="rent_shop_type" jdbcType="INTEGER" property="rentShopType"/>
  27. <result column="pay_way" jdbcType="INTEGER" property="payWay"/>
  28. <result column="merchant_name" property="merchantName"/>
  29. <result column="starttime" property="starttime"/>
  30. <result column="endtime" property="endtime"/>
  31. <result column="freeze" property="freeze"/>
  32. <result column="service_charge_pay" property="serviceChargePay"/>
  33. <result column="bill_type_name" property="billTypeName"/>
  34. <result column="bill_remark" property="billRemark"/>
  35. </resultMap>
  36. <sql id="allColumns">
  37. `id`,`tenant_id`,`parent_tenant_id`,`receive_pay`,`pay`,`receive_date`,`pay_date`,`createtime`,`expired_day`,
  38. `status`,`is_del`,`merchant_id`,`user_id`,`shop_id`,`shop_name`,`updatetime`,`name`,`comments`,
  39. `rent_shop_type`,`pay_way`,`starttime`,`endtime`,endtime,service_charge_pay,`apply_status`,`apply_pay_img`,`apply_update_time`,
  40. '其他费用' bill_type_name, CONCAT(`name`,',',`comments`) bill_remark
  41. </sql>
  42. <sql id="dynamicWhereConditions">
  43. where 1 = 1
  44. <if test=" null != id "> and `id` = #{id} </if>
  45. <if test=" null != tenantId and '' != tenantId">
  46. and `tenant_id` = #{tenantId}
  47. </if>
  48. <if test=" null != parentTenantId and '' != parentTenantId">
  49. and `parent_tenant_id` = #{parentTenantId}
  50. </if>
  51. <if test=" null != receivePay "> and `receive_pay` = #{receivePay} </if>
  52. <if test=" null != pay "> and `pay` = #{pay} </if>
  53. <if test=" null != receiveDate "> and `receive_date` = #{receiveDate} </if>
  54. <if test=" null != payDate "> and `pay_date` = #{payDate} </if>
  55. <if test=" null != createtime "> and `createtime` = #{createtime} </if>
  56. <if test=" null != expiredDay "> and `expired_day` = #{expiredDay} </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 != merchantId "> and `merchant_id` = #{merchantId} </if>
  61. <if test=" null != userId "> and `user_id` = #{userId} </if>
  62. <if test=" null != shopId "> and `shop_id` = #{shopId} </if>
  63. <if test=" null != updatetime "> and `updatetime` = #{updatetime} </if>
  64. <if test=" null != name "> and `name` = #{name} </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.WxBillOther" resultMap="BaseResultMap">
  76. select <include refid="allColumns" /> from wx_bill_other
  77. <include refid="dynamicWhereConditions" />
  78. </select>
  79. <select id="selectById" parameterType="Long" resultMap="BaseResultMap">
  80. select <include refid="allColumns" /> from wx_bill_other
  81. where id = #{id}
  82. </select>
  83. <sql id = "queryBillListConditions">
  84. <where>
  85. 1 = 1
  86. <if test=" null != id ">and br.`id` = #{id}</if>
  87. <if test=" null != tenantId and '' != tenantId"> and br.`tenant_id` = #{tenantId}</if>
  88. <if test=" null != parentTenantId and '' != parentTenantId">and br.`parent_tenant_id` = #{parentTenantId}</if>
  89. <if test=" null != freeze ">and br.`freeze` = #{freeze}</if>
  90. <if test=" null != merchantId ">and br.`merchant_id` = #{merchantId}</if>
  91. <if test=" null != status ">and br.`status` = #{status}</if>
  92. <if test=" null != applyStatus ">and br.`apply_status` = #{applyStatus}</if>
  93. <if test=" null != isDel ">and br.`is_del` = #{isDel}</if>
  94. <if test=" null != name and ''!=name">and br.`name` like concat('%',#{name},'%')</if>
  95. <if test=" null != rentShopType ">and br.`rent_shop_type` = #{rentShopType}</if>
  96. <if test=" null != payWay ">and br.`pay_way` = #{payWay}</if>
  97. <if test=" null != starttime">and br.`starttime` &lt;= #{starttime}</if>
  98. <if test=" null != endtime">and br.`endtime` &gt;= #{endtime}</if>
  99. <if test=" null != month and '' != month">
  100. and date_format(br.starttime,'%Y-%m') &lt;= #{month} and date_format(br.endtime,'%Y-%m') &gt;= #{month}
  101. </if>
  102. <if test=" null == nearBillLastTime and null != oweBillLastTime">
  103. and (br.`starttime` &lt;= #{oweBillLastTime} and br.`receive_pay` - br.`pay` &gt; 0 and br.status not in (3,6))
  104. </if>
  105. <if test=" null != nearBillLastTime and null != oweBillLastTime">
  106. and (br.`starttime` &gt; #{oweBillLastTime} and br.`starttime` &lt;= #{nearBillLastTime} and br.status not in (3,6))
  107. </if>
  108. <if test=" null != merchantIds ">
  109. and br.`merchant_id` in
  110. <foreach collection="merchantIds" index="index" item="midItem" open="(" separator="," close=")">
  111. #{midItem}
  112. </foreach>
  113. </if>
  114. </where>
  115. </sql>
  116. <select id="queryBillList" parameterType="com.iformall.domain.po.WxBillOther" resultMap="BaseResultMap">
  117. 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`,
  118. br.`status`,br.shop_name,br.`updatetime`,br.`apply_status`,
  119. br.`apply_pay_img`,br.`apply_update_time`,br.`merchant_id`,br.shop_id,br.name,br.comments,br.`rent_shop_type`,
  120. br.pay_way,br.`starttime`,br.`endtime`,br.freeze,br.service_charge_pay,'其他费用' bill_type_name, CONCAT(br.`name`,',',br.`comments`) bill_remark
  121. from wx_bill_other br
  122. <include refid="queryBillListConditions" />
  123. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  124. <if test=" null == sortColumns">order by id desc</if>
  125. </select>
  126. <resultMap id="SumBaseResultMap" type="com.iformall.domain.vo.WxBillSum">
  127. <result column="receive_pay" jdbcType="VARCHAR" property="needPay"/>
  128. <result column="paid" jdbcType="VARCHAR" property="paid" />
  129. </resultMap>
  130. <select id="getBillMonthSum" parameterType="com.iformall.domain.po.WxBillOther" resultMap="SumBaseResultMap">
  131. select sum(br.receive_pay) receive_pay , sum(br.pay) paid from wx_bill_other br
  132. <include refid="queryBillListConditions"/>
  133. </select>
  134. <select id="getMerchantIdList" parameterType="com.iformall.domain.po.WxBillOther" resultType="Long">
  135. select distinct merchant_id from wx_bill_other br
  136. <include refid="queryBillListConditions"/>
  137. </select>
  138. <resultMap id="HotNotifyBaseResultMap" type="com.iformall.domain.vo.WxBillHotNotify">
  139. <result column="total_count" jdbcType="INTEGER" property="totalCount"/>
  140. <result column="total_money" jdbcType="VARCHAR" property="totalMoney" />
  141. <result column="min_begin_time" jdbcType="TIMESTAMP" property="minBeginTime"/>
  142. </resultMap>
  143. <select id="getBillHotNotify" parameterType="com.iformall.domain.po.WxBillOther" resultMap="HotNotifyBaseResultMap">
  144. select count(1) total_count , sum(br.`receive_pay` - br.`pay`) total_money,MIN(br.starttime) min_begin_time from wx_bill_other br
  145. <include refid="queryBillListConditions"/>
  146. </select>
  147. <update id="updateNotPaidStatus" parameterType="hashmap">
  148. update wx_bill_other set status=#{notPaid},expired_day=DATEDIFF(now(),receive_date)
  149. where 1=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 status!=#{paid} and DATEDIFF(now(),receive_date)>0
  157. </update>
  158. <update id="updateWaitPayStatus" parameterType="hashmap">
  159. update wx_bill_other set status=#{waitPay} where 1=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 status!=#{paid} and DATEDIFF(now(),receive_date) &lt;=0
  167. </update>
  168. <select id="queryPayInfoTotal" resultType="hashmap" parameterType="hashmap">
  169. select round(sum(t.receivepay)/100,2) receivepay,round(sum(t.pay)/100,2) pay from
  170. (
  171. select IFNULL(sum(receive_pay),0) receivepay,IFNULL(sum(pay),0) pay,tenant_id from wx_bill_other
  172. where 1=1
  173. <if test=" null != tenantId and '' != tenantId">
  174. and `tenant_id` = #{tenantId}
  175. </if>
  176. <if test=" null != parentTenantId and '' != parentTenantId">
  177. and `parent_tenant_id` = #{parentTenantId}
  178. </if>
  179. and receive_date between #{startdate} and #{enddate}
  180. union
  181. select IFNULL(sum(receive_pay),0) receivepay,IFNULL(sum(pay),0) pay,tenant_id from wx_bill_daily
  182. where 1=1
  183. <if test=" null != tenantId and '' != tenantId">
  184. and `tenant_id` = #{tenantId}
  185. </if>
  186. <if test=" null != parentTenantId and '' != parentTenantId">
  187. and `parent_tenant_id` = #{parentTenantId}
  188. </if>
  189. and receive_date between #{startdate} and #{enddate}
  190. ) t
  191. </select>
  192. <select id="queryOweInfo" resultType="hashmap" parameterType="hashmap">
  193. select IFNULL(round(sum(res.owe)/100,2),0) owe,res.tenant_id from
  194. (
  195. select IFNULL(sum(receive_pay - pay),0) owe,tenant_id from wx_bill_daily
  196. where status = 1
  197. <if test=" null != tenantId and '' != tenantId">
  198. and `tenant_id` = #{tenantId}
  199. </if>
  200. <if test=" null != parentTenantId and '' != parentTenantId">
  201. and `parent_tenant_id` = #{parentTenantId}
  202. </if>
  203. and receive_date between #{startdate} and #{enddate}
  204. union all
  205. select IFNULL(sum(receive_pay - pay),0) owe,tenant_id from wx_bill_daily
  206. where status = 1
  207. <if test=" null != tenantId and '' != tenantId">
  208. and `tenant_id` = #{tenantId}
  209. </if>
  210. <if test=" null != parentTenantId and '' != parentTenantId">
  211. and `parent_tenant_id` = #{parentTenantId}
  212. </if>
  213. and receive_date between #{startdate} and #{enddate}
  214. ) res
  215. </select>
  216. </mapper>