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.
 
 
 
 
 

171 lignes
8.5 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="owe" jdbcType="VARCHAR" property="owe"/>
  15. <result column="status" jdbcType="INTEGER" property="status" />
  16. <result column="apply_status" jdbcType="INTEGER" property="applyStatus"/>
  17. <result column="apply_pay_img" jdbcType="INTEGER" property="applyPayImg"/>
  18. <result column="apply_update_time" jdbcType="INTEGER" property="applyUpdateTime"/>
  19. <result column="is_del" jdbcType="INTEGER" property="isDel" />
  20. <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
  21. <result column="user_id" jdbcType="BIGINT" property="userId" />
  22. <result column="shop_id" jdbcType="BIGINT" property="shopId" />
  23. <result column="shop_name" jdbcType="VARCHAR" property="shopName" />
  24. <result column="updatetime" jdbcType="TIMESTAMP" property="updatetime" />
  25. <result column="type" jdbcType="INTEGER" property="type" />
  26. <result column="rent_shop_type" jdbcType="INTEGER" property="rentShopType"/>
  27. <result column="pay_way" jdbcType="INTEGER" property="payWay"/>
  28. <result column="price_detail" jdbcType="VARCHAR" property="priceDetail"/>
  29. <result column="starttime" property="starttime"/>
  30. <result column="endtime" property="endtime"/>
  31. <result column="freeze" property="freeze"/>
  32. <result column="build_way" property="buildWay"/>
  33. <result column="service_charge_pay" property="serviceChargePay"/>
  34. <result column="bill_type_name" property="billTypeName"/>
  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`,`owe`,`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_type_name
  40. </sql>
  41. <sql id="dynamicWhereConditions">
  42. where 1 = 1
  43. <if test=" null != id "> and `id` = #{id} </if>
  44. <if test=" null != receivePay "> and `receive_pay` = #{receivePay} </if>
  45. <if test=" null != pay "> and `pay` = #{pay} </if>
  46. <if test=" null != receiveDate "> and `receive_date` = #{receiveDate} </if>
  47. <if test=" null != payDate "> and `pay_date` = #{payDate} </if>
  48. <if test=" null != createtime "> and `createtime` = #{createtime} </if>
  49. <if test=" null != expiredDay "> and `expired_day` = #{expiredDay} </if>
  50. <if test=" null != tenantId and '' != tenantId">
  51. and `tenant_id` = #{tenantId}
  52. </if>
  53. <if test=" null != parentTenantId and '' != parentTenantId">
  54. and `parent_tenant_id` = #{parentTenantId}
  55. </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 != 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. <sql id = "queryBillDailyListConditions" >
  80. <where>
  81. 1 = 1
  82. <if test=" null != id ">and br.`id` = #{id}</if>
  83. <if test=" null != tenantId and '' != tenantId"> and br.`tenant_id` = #{tenantId}</if>
  84. <if test=" null != parentTenantId and '' != parentTenantId">and br.`parent_tenant_id` = #{parentTenantId}</if>
  85. <if test=" null != freeze ">and br.`freeze` = #{freeze}</if>
  86. <if test=" null != id ">and br.`id` = #{id}</if>
  87. <if test=" null != merchantId ">and br.`merchant_id` = #{merchantId}</if>
  88. <if test=" null != status ">and br.`status` = #{status}</if>
  89. <if test=" null != applyStatus ">and br.`apply_status` = #{applyStatus}</if>
  90. <if test=" null != isDel ">and br.`is_del` = #{isDel}</if>
  91. <if test=" null != type ">and br.`type` = #{type}</if>
  92. <if test=" null != rentShopType ">and br.`rent_shop_type` = #{rentShopType}</if>
  93. <if test=" null != payWay ">and br.`pay_way` = #{payWay}</if>
  94. <if test=" null != starttime">and br.`starttime` &lt;= #{starttime}</if>
  95. <if test=" null != endtime">and br.`endtime` &gt;= #{endtime}</if>
  96. <if test=" null != month and '' != month">
  97. and date_format(br.starttime,'%Y-%m') &lt;= #{month} and date_format(br.endtime,'%Y-%m') &gt;= #{month}
  98. </if>
  99. <if test=" 1 == onlyOwe">and br.`owe` &gt; 0</if>
  100. <if test=" null != buildWay ">and br.`build_way` = #{buildWay}</if>
  101. <if test=" null != merchantIds ">
  102. and br.`merchant_id` in
  103. <foreach collection="merchantIds" index="index" item="midItem" open="(" separator="," close=")">
  104. #{midItem}
  105. </foreach>
  106. </if>
  107. </where>
  108. </sql>
  109. <select id="queryBillDailyList" parameterType="com.iformall.domain.po.WxBillDaily" resultMap="BaseResultMap">
  110. select br.`id`,br.`receive_pay`,br.`pay`,br.`receive_date`,br.`pay_date`,br.`createtime`,br.`expired_day` ,
  111. case when br.status=1 then br.owe else 0 end owe,br.`status`,br.`updatetime`,br.`merchant_id`,br.shop_id,
  112. br.shop_name,br.type,br.`rent_shop_type`,br.pay_way,br.price_detail,br.`starttime`,br.`endtime`,br.`build_way`,
  113. br.freeze,br.service_charge_pay,br.`apply_status`,br.`apply_pay_img`,br.`apply_update_time`,'日常费用' bill_type_name
  114. from wx_bill_daily br
  115. <include refid="queryBillDailyListConditions" />
  116. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  117. <if test=" null == sortColumns">order by id desc</if>
  118. </select>
  119. <resultMap id="SumBaseResultMap" type="com.iformall.domain.vo.WxBillSum">
  120. <result column="receive_pay" jdbcType="VARCHAR" property="needPay"/>
  121. <result column="paid" jdbcType="VARCHAR" property="paid" />
  122. <result column="owe" jdbcType="VARCHAR" property="owe"/>
  123. </resultMap>
  124. <select id="getBillMonthSum" parameterType="com.iformall.domain.po.WxBillDaily" resultMap="SumBaseResultMap">
  125. select sum(br.receive_pay) receive_pay , sum(br.pay) paid, sum(br.owe) owe from wx_bill_daily br
  126. <include refid="queryBillDailyListConditions"/>
  127. </select>
  128. <select id="getMerchantIdList" parameterType="com.iformall.domain.po.WxBillDaily" resultType="Long">
  129. select distinct merchant_id from wx_bill_daily br
  130. <include refid="queryBillDailyListConditions"/>
  131. </select>
  132. <update id="updateNotPaidStatus" parameterType="hashmap">
  133. update wx_bill_daily set status=#{notPaid},expired_day=DATEDIFF(now(),receive_date)
  134. where status!=#{paid}
  135. <if test=" null != tenantId and '' != tenantId">
  136. and `tenant_id` = #{tenantId}
  137. </if>
  138. <if test=" null != parentTenantId and '' != parentTenantId">
  139. and `parent_tenant_id` = #{parentTenantId}
  140. </if>
  141. and DATEDIFF(now(),receive_date)>0
  142. </update>
  143. <update id="updateWaitPayStatus" parameterType="hashmap">
  144. update wx_bill_daily set status=#{waitPay} where status!=#{paid}
  145. <if test=" null != tenantId and '' != tenantId">
  146. and `tenant_id` = #{tenantId}
  147. </if>
  148. <if test=" null != parentTenantId and '' != parentTenantId">
  149. and `parent_tenant_id` = #{parentTenantId}
  150. </if>
  151. and DATEDIFF(now(),receive_date) &lt;=0
  152. </update>
  153. </mapper>