Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 

200 rindas
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.WxBillDailyMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxBillDaily">
  5. <id column="id" jdbcType="BIGINT" property="id" />
  6. <result column="receive_pay" jdbcType="VARCHAR" property="receivePay"/>
  7. <result column="pay" jdbcType="VARCHAR" property="pay"/>
  8. <result column="receive_date" jdbcType="TIMESTAMP" property="receiveDate" />
  9. <result column="pay_date" jdbcType="TIMESTAMP" property="payDate" />
  10. <result column="createtime" jdbcType="TIMESTAMP" property="createtime" />
  11. <result column="expired_day" jdbcType="INTEGER" property="expiredDay" />
  12. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
  13. <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
  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="type" jdbcType="INTEGER" property="type" />
  25. <result column="rent_shop_type" jdbcType="INTEGER" property="rentShopType"/>
  26. <result column="pay_way" jdbcType="INTEGER" property="payWay"/>
  27. <result column="price_detail" jdbcType="VARCHAR" property="priceDetail"/>
  28. <result column="starttime" property="starttime"/>
  29. <result column="endtime" property="endtime"/>
  30. <result column="freeze" property="freeze"/>
  31. <result column="build_way" property="buildWay"/>
  32. <result column="service_charge_pay" property="serviceChargePay"/>
  33. <result column="bill_type_name" property="billTypeName"/>
  34. <result column="bill_remark" jdbcType="VARCHAR" property="billRemark"/>
  35. </resultMap>
  36. <sql id="allColumns">
  37. `id`,`receive_pay`,`pay`,`receive_date`,`pay_date`,`createtime`,`expired_day`,`apply_status`,`apply_pay_img`,`apply_update_time`,
  38. `tenant_id`,`parent_tenant_id`,`status`,`is_del`,`merchant_id`,`user_id`,`shop_id`,`shop_name`,`updatetime`,`type`,
  39. `rent_shop_type`,`pay_way`,`price_detail`,`starttime`,`endtime`,freeze,build_way,service_charge_pay,`bill_remark`,
  40. case type when 1 then '水费' when 2 then '电费' when 3 then '空调费' else '日常费用' end bill_type_name
  41. </sql>
  42. <sql id="dynamicWhereConditions">
  43. where 1 = 1
  44. <if test=" null != id "> and `id` = #{id} </if>
  45. <if test=" null != receivePay "> and `receive_pay` = #{receivePay} </if>
  46. <if test=" null != pay "> and `pay` = #{pay} </if>
  47. <if test=" null != receiveDate "> and `receive_date` = #{receiveDate} </if>
  48. <if test=" null != payDate "> and `pay_date` = #{payDate} </if>
  49. <if test=" null != createtime "> and `createtime` = #{createtime} </if>
  50. <if test=" null != expiredDay "> and `expired_day` = #{expiredDay} </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 != 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 != updatetime "> and `updatetime` = #{updatetime} </if>
  63. <if test=" null != type "> and `type` = #{type} </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=" null != buildWay ">and `build_way` = #{buildWay}</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.WxBillDaily" resultMap="BaseResultMap">
  76. select <include refid="allColumns" /> from wx_bill_daily
  77. <include refid="dynamicWhereConditions" />
  78. </select>
  79. <select id="selectById" parameterType="HashMap" resultMap="BaseResultMap">
  80. select <include refid="allColumns" /> from wx_bill_daily
  81. where id = #{id} and tenant_id = #{tenantId}
  82. </select>
  83. <sql id = "queryBillDailyListConditions" >
  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 != id ">and br.`id` = #{id}</if>
  91. <if test=" null != merchantId ">and br.`merchant_id` = #{merchantId}</if>
  92. <if test=" null != status ">and br.`status` = #{status}</if>
  93. <if test=" null != applyStatus ">and br.`apply_status` = #{applyStatus}</if>
  94. <if test=" null != isDel ">and br.`is_del` = #{isDel}</if>
  95. <if test=" null != type ">and br.`type` = #{type}</if>
  96. <if test=" null != rentShopType ">and br.`rent_shop_type` = #{rentShopType}</if>
  97. <if test=" null != payWay ">and br.`pay_way` = #{payWay}</if>
  98. <if test=" null != starttime">and br.`starttime` &lt;= #{starttime}</if>
  99. <if test=" null != endtime">and br.`endtime` &gt;= #{endtime}</if>
  100. <if test=" null != month and '' != month">
  101. and date_format(br.starttime,'%Y-%m') &lt;= #{month} and date_format(br.endtime,'%Y-%m') &gt;= #{month}
  102. </if>
  103. <if test=" null == nearBillLastTime and null != oweBillLastTime">
  104. and (br.`starttime` &lt;= #{oweBillLastTime} and br.`receive_pay` - br.`pay` &gt; 0 and br.status not in (3,6))
  105. </if>
  106. <if test=" null != nearBillLastTime and null != oweBillLastTime">
  107. and (br.`starttime` &gt; #{oweBillLastTime} and br.`starttime` &lt;= #{nearBillLastTime} and br.status not in (3,6))
  108. </if>
  109. <if test=" null != buildWay ">and br.`build_way` = #{buildWay}</if>
  110. <if test=" null != merchantIds ">
  111. and br.`merchant_id` in
  112. <foreach collection="merchantIds" index="index" item="midItem" open="(" separator="," close=")">
  113. #{midItem}
  114. </foreach>
  115. </if>
  116. </where>
  117. </sql>
  118. <select id="queryBillDailyList" parameterType="com.iformall.domain.po.WxBillDaily" resultMap="BaseResultMap">
  119. 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` ,
  120. br.`status`,br.`updatetime`,br.`merchant_id`,br.shop_id,
  121. br.shop_name,br.type,br.`rent_shop_type`,br.pay_way,br.price_detail,br.`starttime`,br.`endtime`,br.`build_way`,
  122. br.freeze,br.service_charge_pay,br.`apply_status`,br.`apply_pay_img`,br.`apply_update_time`,br.`bill_remark`,
  123. case type when 1 then '水费' when 2 then '电费' when 3 then '空调费' else '日常费用' end bill_type_name
  124. from wx_bill_daily br
  125. <include refid="queryBillDailyListConditions" />
  126. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  127. <if test=" null == sortColumns">order by id desc</if>
  128. </select>
  129. <resultMap id="SumBaseResultMap" type="com.iformall.domain.vo.WxBillSum">
  130. <result column="receive_pay" jdbcType="VARCHAR" property="needPay"/>
  131. <result column="paid" jdbcType="VARCHAR" property="paid" />
  132. <result column="min_date" jdbcType="TIMESTAMP" property="minDate" />
  133. <result column="max_date" jdbcType="TIMESTAMP" property="maxDate" />
  134. </resultMap>
  135. <select id="getBillMonthSum" parameterType="com.iformall.domain.po.WxBillDaily" resultMap="SumBaseResultMap">
  136. select
  137. sum(CAST(br.receive_pay AS DECIMAL(20,2))) receive_pay ,
  138. sum(CAST(br.pay AS DECIMAL(20,2))) paid,
  139. min(starttime) min_date,
  140. max(endtime) max_date
  141. from wx_bill_daily br
  142. <include refid="queryBillDailyListConditions"/>
  143. </select>
  144. <select id="getMerchantIdList" parameterType="com.iformall.domain.po.WxBillDaily" resultType="Long">
  145. select distinct merchant_id from wx_bill_daily br
  146. <include refid="queryBillDailyListConditions"/>
  147. </select>
  148. <resultMap id="HotNotifyBaseResultMap" type="com.iformall.domain.vo.WxBillHotNotify">
  149. <result column="total_count" jdbcType="INTEGER" property="totalCount"/>
  150. <result column="total_money" jdbcType="VARCHAR" property="totalMoney" />
  151. <result column="min_begin_time" jdbcType="TIMESTAMP" property="minBeginTime"/>
  152. </resultMap>
  153. <select id="getBillHotNotify" parameterType="com.iformall.domain.po.WxBillDaily" resultMap="HotNotifyBaseResultMap">
  154. 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_daily br
  155. <include refid="queryBillDailyListConditions"/>
  156. </select>
  157. <update id="updateNotPaidStatus" parameterType="hashmap">
  158. update wx_bill_daily set status=#{notPaid},expired_day=DATEDIFF(now(),receive_date)
  159. where status!=#{paid}
  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 DATEDIFF(now(),receive_date)>0
  167. </update>
  168. <update id="updateWaitPayStatus" parameterType="hashmap">
  169. update wx_bill_daily set status=#{waitPay} where status!=#{paid}
  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 DATEDIFF(now(),receive_date) &lt;=0
  177. </update>
  178. <delete id = "deleteById" parameterType="HashMap">
  179. delete from wx_bill_daily where id = #{id} and tenant_id = #{tenantId}
  180. </delete>
  181. </mapper>