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.
 
 
 
 
 

148 line
7.0 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.WxFinanceReceiveMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxFinanceReceive">
  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="create_time" jdbcType="TIMESTAMP" property="createTime"/>
  9. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
  10. <result column="receive_money" jdbcType="VARCHAR" property="receiveMoney"/>
  11. <result column="pay_money" jdbcType="VARCHAR" property="payMoney"/>
  12. <result column="set_off_money" jdbcType="VARCHAR" property="setOffMoney"/>
  13. <result column="use_money" jdbcType="VARCHAR" property="useMoney"/>
  14. <result column="status" jdbcType="INTEGER" property="status"/>
  15. <result column="type" jdbcType="INTEGER" property="type"/>
  16. <result column="receive_type" jdbcType="INTEGER" property="receiveType"/>
  17. <result column="money_detail" jdbcType="VARCHAR" property="moneyDetail"/>
  18. <result column="create_by" jdbcType="BIGINT" property="createBy"/>
  19. <result column="create_by_name" jdbcType="VARCHAR" property="createByName"/>
  20. <result column="update_by" jdbcType="BIGINT" property="updateBy"/>
  21. <result column="update_by_name" jdbcType="VARCHAR" property="updateByName"/>
  22. <result column="merchant_id" jdbcType="BIGINT" property="merchantId"/>
  23. <result column="rent_shop_type" jdbcType="INTEGER" property="rentShopType"/>
  24. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  25. <result column="fees_id" jdbcType="BIGINT" property="feesId"/>
  26. <result column="is_print" jdbcType="INTEGER" property="isPrint"/>
  27. <result column="is_finish" jdbcType="INTEGER" property="isFinish"/>
  28. </resultMap>
  29. <sql id="allColumns">
  30. `id`,`tenant_id`,`parent_tenant_id`,`create_time`,`update_time`,`receive_money`,`pay_money`,`set_off_money`,`use_money`,`status`,`type`,
  31. `receive_type`,`money_detail`,`create_by`,`create_by_name`,`update_by`,`update_by_name`,`merchant_id`,`rent_shop_type`,`remark`,
  32. `fees_id`,`is_print`,`is_finish`
  33. </sql>
  34. <sql id="dynamicWhereConditions">
  35. where 1=1
  36. <if test=" null != id ">and `id` = #{id}</if>
  37. <if test=" null != tenantId and '' != tenantId">
  38. and `tenant_id` = #{tenantId}
  39. </if>
  40. <if test=" null != parentTenantId and '' != parentTenantId">
  41. and `parent_tenant_id` = #{parentTenantId}
  42. </if>
  43. <if test=" null != status ">and `status` = #{status}</if>
  44. <if test=" null != type ">and `type` = #{type}</if>
  45. <if test=" null != receiveType ">and `receive_type` = #{receiveType}</if>
  46. <if test=" null != merchantId ">and `merchant_id` = #{merchantId}</if>
  47. <if test=" null != rentShopType ">and `rent_shop_type` = #{rentShopType}</if>
  48. <if test=" null != createTimeBegin ">and `create_time` &gt;= #{createTimeBegin}</if>
  49. <if test=" null != createTimeEnd ">and `create_time` &lt;= #{createTimeEnd}</if>
  50. <if test=" null != feesId ">and `fees_id` = #{feesId}</if>
  51. <if test=" null != rentShopType ">and `rent_shop_type` = #{rentShopType}</if>
  52. <if test=" null != isPrint ">and `is_print` = #{isPrint}</if>
  53. <if test=" null != isFinish ">and `is_finish` = #{isFinish}</if>
  54. <if test=" null != finishStatus ">and `status` in (1,3)</if>
  55. <if test=" null != hasExtraMoney ">and receive_money - IFNULL(use_money,'0') &gt; 0</if>
  56. <if test=" null != merchantIdList ">
  57. and merchant_id in
  58. <foreach collection="merchantIdList" index="index" item="midItem" open="(" separator="," close=")">
  59. #{midItem}
  60. </foreach>
  61. </if>
  62. <if test=" null != feesIdList ">
  63. and fees_id in
  64. <foreach collection="feesIdList" index="index" item="fidItem" open="(" separator="," close=")">
  65. #{fidItem}
  66. </foreach>
  67. </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 != sortColumns">order by ${sortColumns}</if>
  75. </sql>
  76. <select id="findList" parameterType="com.iformall.domain.po.WxFinanceReceive" resultMap="BaseResultMap">
  77. select
  78. <include refid="allColumns"/>
  79. from wx_finance_receive
  80. <include refid="dynamicWhereConditions"/>
  81. </select>
  82. <select id="findCount" parameterType="com.iformall.domain.po.WxFinanceReceive" resultType="Integer">
  83. select count(1)
  84. from wx_finance_receive
  85. <include refid="dynamicWhereConditions"/>
  86. </select>
  87. <select id="selectById" parameterType="HashMap" resultMap="BaseResultMap">
  88. select
  89. <include refid="allColumns"/>
  90. from wx_finance_receive where id = #{id} and `tenant_id` = #{tenantId}
  91. </select>
  92. <update id = "setIsDel" parameterType="HashMap">
  93. update wx_finance_receive set is_del = #{isDel} where id = #{id} and `tenant_id` = #{tenantId}
  94. </update>
  95. <select id="getMerchantAdvanceGroupSumList" parameterType="com.iformall.domain.po.WxFinanceReceive" resultMap="BaseResultMap">
  96. select fees_id,sum(CAST(receive_money AS DECIMAL(20,4))) as receive_money,sum(CAST(IFNULL(use_money,'0') AS DECIMAL(20,4))) as use_money
  97. from wx_finance_receive
  98. <include refid="dynamicWhereConditions"/>
  99. and receive_money - IFNULL(use_money,'0') &gt; 0
  100. group by fees_id
  101. </select>
  102. <resultMap id="SumResultMap" type="com.iformall.domain.vo.WxFinanceReceiveSumVo">
  103. <result column="total_receive" jdbcType="VARCHAR" property="totalReceive"/>
  104. <result column="total_setoff" jdbcType="VARCHAR" property="totalSetoff" />
  105. <result column="total_pay" jdbcType="VARCHAR" property="totalPay"/>
  106. </resultMap>
  107. <select id="getReceiveSum" parameterType="com.iformall.domain.po.WxFinanceReceive" resultMap="SumResultMap">
  108. select
  109. sum(CAST(ifnull(receive_money,'0') AS DECIMAL(20,2))) total_receive ,
  110. sum(CAST(ifnull(set_off_money,'0') AS DECIMAL(20,2))) total_setoff,
  111. sum(CAST(ifnull(pay_money,'0') AS DECIMAL(20,2))) total_pay
  112. from wx_finance_receive
  113. <include refid="dynamicWhereConditions"/>
  114. </select>
  115. <resultMap id="PayWaySumResultMap" type="com.iformall.domain.po.WxFinanceReceivePayway">
  116. <result column="pay_way" jdbcType="BIGINT" property="payWay"/>
  117. <result column="receive" jdbcType="VARCHAR" property="receive"/>
  118. </resultMap>
  119. <select id="getReceivePayWaySum" parameterType="com.iformall.domain.po.WxFinanceReceive" resultMap="PayWaySumResultMap">
  120. select pay_way, sum(CAST(ifnull(receive,'0') AS DECIMAL(20,2))) receive
  121. from wx_finance_receive_payway where is_del = 0 and receive_id in (
  122. select id from wx_finance_receive
  123. <include refid="dynamicWhereConditions"/>
  124. )
  125. group by pay_way
  126. </select>
  127. <update id="finish" parameterType="com.iformall.domain.po.WxFinanceReceive">
  128. update wx_finance_receive set is_finish = 1
  129. <include refid="dynamicWhereConditions"/>
  130. </update>
  131. <update id="updatePrint" parameterType="com.iformall.domain.po.WxFinanceReceive">
  132. update wx_finance_receive set is_print = 1 where id = #{id} and tenant_id = #{tenantId}
  133. </update>
  134. </mapper>