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.
 
 
 
 
 

230 lines
12 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="last_owe_call_time" jdbcType="TIMESTAMP" property="lastOweCallTime"/>
  31. <result column="last_owe_call_user" jdbcType="VARCHAR" property="lastOweCallUser"/>
  32. <result column="freeze" property="freeze"/>
  33. <result column="build_way" property="buildWay"/>
  34. <result column="service_charge_pay" property="serviceChargePay"/>
  35. <result column="bill_remark" jdbcType="VARCHAR" property="billRemark"/>
  36. </resultMap>
  37. <sql id="allColumns">
  38. `id`,`receive_pay`,`pay`,`receive_date`,`pay_date`,`createtime`,`expired_day`,`apply_status`,`apply_pay_img`,`apply_update_time`,
  39. `tenant_id`,`parent_tenant_id`,`status`,`is_del`,`merchant_id`,`user_id`,`shop_id`,`shop_name`,`updatetime`,`type`,`last_owe_call_time`,
  40. `rent_shop_type`,`pay_way`,`price_detail`,`starttime`,`endtime`,freeze,build_way,service_charge_pay,`bill_remark`,`last_owe_call_user`
  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=" 1 == notifyed ">and (`last_owe_call_time` is not null and `receive_pay` - `pay` &gt; 0 and status not in (3,6) )</if>
  68. <if test=" null != ids ">
  69. and id in
  70. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  71. #{idItem}
  72. </foreach>
  73. </if>
  74. <if test=" null != notInIds ">
  75. and id not in
  76. <foreach collection="notInIds" index="index" item="nidItem" open="(" separator="," close=")">
  77. #{nidItem}
  78. </foreach>
  79. </if>
  80. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  81. </sql>
  82. <select id="findList" parameterType="com.iformall.domain.po.WxBillDaily" resultMap="BaseResultMap">
  83. select <include refid="allColumns" /> from wx_bill_daily
  84. <include refid="dynamicWhereConditions" />
  85. </select>
  86. <select id="selectById" parameterType="HashMap" resultMap="BaseResultMap">
  87. select <include refid="allColumns" /> from wx_bill_daily
  88. where id = #{id} and tenant_id = #{tenantId}
  89. </select>
  90. <sql id = "queryBillDailyListConditions" >
  91. <where>
  92. 1 = 1
  93. <if test=" null != id ">and br.`id` = #{id}</if>
  94. <if test=" null != tenantId and '' != tenantId"> and br.`tenant_id` = #{tenantId}</if>
  95. <if test=" null != parentTenantId and '' != parentTenantId">and br.`parent_tenant_id` = #{parentTenantId}</if>
  96. <if test=" null != freeze ">and br.`freeze` = #{freeze}</if>
  97. <if test=" null != id ">and br.`id` = #{id}</if>
  98. <if test=" null != merchantId ">and br.`merchant_id` = #{merchantId}</if>
  99. <if test=" null != status ">and br.`status` = #{status}</if>
  100. <if test=" null != applyStatus ">and br.`apply_status` = #{applyStatus}</if>
  101. <if test=" null != isDel ">and br.`is_del` = #{isDel}</if>
  102. <if test=" null != type ">and br.`type` = #{type}</if>
  103. <if test=" null != rentShopType ">and br.`rent_shop_type` = #{rentShopType}</if>
  104. <if test=" null != payWay ">and br.`pay_way` = #{payWay}</if>
  105. <if test=" null != starttime">and br.`starttime` &lt;= #{starttime}</if>
  106. <if test=" null != endtime">and br.`endtime` &gt;= #{endtime}</if>
  107. <if test=" null != month and '' != month">
  108. and date_format(br.starttime,'%Y-%m') &lt;= #{month} and date_format(br.endtime,'%Y-%m') &gt;= #{month}
  109. </if>
  110. <if test=" null == nearBillLastTime and null != oweBillLastTime">
  111. and (br.`starttime` &lt;= #{oweBillLastTime} and br.`receive_pay` - br.`pay` &gt; 0 and br.status not in (3,6))
  112. </if>
  113. <if test=" null != nearBillLastTime and null != oweBillLastTime">
  114. and (br.`starttime` &gt; #{oweBillLastTime} and br.`starttime` &lt;= #{nearBillLastTime} and br.status not in (3,6))
  115. </if>
  116. <if test=" null != buildWay ">and br.`build_way` = #{buildWay}</if>
  117. <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) )</if>
  118. <if test=" null != merchantIds ">
  119. and br.`merchant_id` in
  120. <foreach collection="merchantIds" index="index" item="midItem" open="(" separator="," close=")">
  121. #{midItem}
  122. </foreach>
  123. </if>
  124. <if test=" null != notInIds ">
  125. and br.`id` not in
  126. <foreach collection="notInIds" index="index" item="nidItem" open="(" separator="," close=")">
  127. #{nidItem}
  128. </foreach>
  129. </if>
  130. </where>
  131. </sql>
  132. <select id="queryBillDailyList" parameterType="com.iformall.domain.po.WxBillDaily" resultMap="BaseResultMap">
  133. 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` ,
  134. br.`status`,br.`updatetime`,br.`merchant_id`,br.shop_id,br.`last_owe_call_time`,br.`last_owe_call_user`,
  135. br.shop_name,br.type,br.`rent_shop_type`,br.pay_way,br.price_detail,br.`starttime`,br.`endtime`,br.`build_way`,
  136. br.freeze,br.service_charge_pay,br.`apply_status`,br.`apply_pay_img`,br.`apply_update_time`,br.`bill_remark`
  137. from wx_bill_daily br
  138. <include refid="queryBillDailyListConditions" />
  139. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  140. <if test=" null == sortColumns">order by id desc</if>
  141. </select>
  142. <resultMap id="SumBaseResultMap" type="com.iformall.domain.vo.WxBillSum">
  143. <result column="receive_pay" jdbcType="VARCHAR" property="needPay"/>
  144. <result column="paid" jdbcType="VARCHAR" property="paid" />
  145. <result column="min_date" jdbcType="TIMESTAMP" property="minDate" />
  146. <result column="max_date" jdbcType="TIMESTAMP" property="maxDate" />
  147. </resultMap>
  148. <select id="getBillMonthSum" parameterType="com.iformall.domain.po.WxBillDaily" resultMap="SumBaseResultMap">
  149. select
  150. sum(CAST(br.receive_pay AS DECIMAL(20,2))) receive_pay ,
  151. sum(CAST(br.pay AS DECIMAL(20,2))) paid,
  152. min(starttime) min_date,
  153. max(endtime) max_date
  154. from wx_bill_daily br
  155. <include refid="queryBillDailyListConditions"/>
  156. </select>
  157. <select id="getMerchantIdList" parameterType="com.iformall.domain.po.WxBillDaily" resultType="Long">
  158. select distinct merchant_id from wx_bill_daily br
  159. <include refid="queryBillDailyListConditions"/>
  160. </select>
  161. <resultMap id="HotNotifyBaseResultMap" type="com.iformall.domain.vo.WxBillHotNotify">
  162. <result column="total_count" jdbcType="INTEGER" property="totalCount"/>
  163. <result column="total_money" jdbcType="VARCHAR" property="totalMoney" />
  164. <result column="min_begin_time" jdbcType="TIMESTAMP" property="minBeginTime"/>
  165. </resultMap>
  166. <select id="getBillHotNotify" parameterType="com.iformall.domain.po.WxBillDaily" resultMap="HotNotifyBaseResultMap">
  167. 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
  168. <include refid="queryBillDailyListConditions"/>
  169. </select>
  170. <resultMap id="NotifyResultMap" type="com.iformall.domain.vo.WxBillNotify">
  171. <result column="bill_type" jdbcType="INTEGER" property="billType"/>
  172. <result column="bill_type_name" jdbcType="VARCHAR" property="billTypeName" />
  173. <result column="bill_id" jdbcType="BIGINT" property="billId" />
  174. <result column="starttime" jdbcType="TIMESTAMP" property="starttime"/>
  175. <result column="endtime" jdbcType="TIMESTAMP" property="endtime"/>
  176. <result column="receive_pay" jdbcType="VARCHAR" property="receivePay"/>
  177. <result column="pay" jdbcType="VARCHAR" property="pay"/>
  178. <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
  179. </resultMap>
  180. <select id="getBillNotifyList" parameterType="com.iformall.domain.po.WxBillDaily" resultMap="NotifyResultMap">
  181. 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_daily br
  182. <include refid="queryBillDailyListConditions"/>
  183. </select>
  184. <update id="updateNotPaidStatus" parameterType="hashmap">
  185. update wx_bill_daily set status=#{notPaid},expired_day=DATEDIFF(now(),receive_date)
  186. where status!=#{paid}
  187. <if test=" null != tenantId and '' != tenantId">
  188. and `tenant_id` = #{tenantId}
  189. </if>
  190. <if test=" null != parentTenantId and '' != parentTenantId">
  191. and `parent_tenant_id` = #{parentTenantId}
  192. </if>
  193. and DATEDIFF(now(),receive_date)>0
  194. </update>
  195. <update id="updateWaitPayStatus" parameterType="hashmap">
  196. update wx_bill_daily set status=#{waitPay} where status!=#{paid}
  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 DATEDIFF(now(),receive_date) &lt;=0
  204. </update>
  205. <delete id = "deleteById" parameterType="HashMap">
  206. delete from wx_bill_daily where id = #{id} and tenant_id = #{tenantId}
  207. </delete>
  208. </mapper>