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.
 
 
 
 
 

207 lines
9.3 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_date" jdbcType="TIMESTAMP" property="receiveDate"/>
  11. <result column="receive_money" jdbcType="VARCHAR" property="receiveMoney"/>
  12. <result column="pay_money" jdbcType="VARCHAR" property="payMoney"/>
  13. <result column="set_off_money" jdbcType="VARCHAR" property="setOffMoney"/>
  14. <result column="cut_money" jdbcType="VARCHAR" property="cutMoney"/>
  15. <result column="status" jdbcType="INTEGER" property="status"/>
  16. <result column="type" jdbcType="INTEGER" property="type"/>
  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="remark" jdbcType="VARCHAR" property="remark"/>
  23. <result column="fees_id" jdbcType="BIGINT" property="feesId"/>
  24. <result column="is_print" jdbcType="INTEGER" property="isPrint"/>
  25. <result column="is_finish" jdbcType="INTEGER" property="isFinish"/>
  26. <result column="parent_id" jdbcType="BIGINT" property="parentId"/>
  27. <result column="bill_cus_name" jdbcType="VARCHAR" property="billCusName"/>
  28. <result column="bill_shop_number" jdbcType="VARCHAR" property="billShopNumber"/>
  29. </resultMap>
  30. <sql id="allColumns">
  31. `id`,`tenant_id`,`parent_tenant_id`,`create_time`,`update_time`,`receive_date`,`receive_money`,`pay_money`,`set_off_money`,`cut_money`,`status`,`type`,
  32. `money_detail`,`create_by`,`create_by_name`,`update_by`,`update_by_name`,`remark`,`fees_id`,`is_print`,`is_finish`,`parent_id`,`bill_cus_name`,`bill_shop_number`
  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 != createTimeBegin ">and `create_time` &gt;= #{createTimeBegin}</if>
  46. <if test=" null != createTimeEnd ">and `create_time` &lt;= #{createTimeEnd}</if>
  47. <if test=" null != receiveDateBegin ">and `receive_date` &gt;= #{receiveDateBegin}</if>
  48. <if test=" null != receiveDateEnd ">and `receive_date` &lt;= #{receiveDateEnd}</if>
  49. <if test=" null != feesId ">and `fees_id` = #{feesId}</if>
  50. <if test=" null != isPrint ">and `is_print` = #{isPrint}</if>
  51. <if test=" null != isFinish ">and `is_finish` = #{isFinish}</if>
  52. <if test=" null != parentId ">and `parent_id` = #{parentId}</if>
  53. <if test=" null != billCusName and '' != billCusName">
  54. and `bill_cus_name` like concat('%',#{billCusName},'%')
  55. </if>
  56. <if test=" null != billShopNumber and '' != billShopNumber">
  57. and `bill_shop_number` like concat('%',#{billShopNumber},'%')
  58. </if>
  59. <if test=" null != statusList ">
  60. and status in
  61. <foreach collection="statusList" index="index" item="sItem" open="(" separator="," close=")">
  62. #{sItem}
  63. </foreach>
  64. </if>
  65. <if test=" null != feesIdList ">
  66. and fees_id in
  67. <foreach collection="feesIdList" index="index" item="fidItem" open="(" separator="," close=")">
  68. #{fidItem}
  69. </foreach>
  70. </if>
  71. <if test=" null != notInIds ">
  72. and id not in
  73. <foreach collection="notInIds" index="index" item="nidItem" open="(" separator="," close=")">
  74. #{nidItem}
  75. </foreach>
  76. </if>
  77. <if test=" null != ids ">
  78. and id in
  79. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  80. #{idItem}
  81. </foreach>
  82. </if>
  83. <if test=" null != sortColumns">order by ${sortColumns}</if>
  84. </sql>
  85. <select id="findList" parameterType="com.iformall.domain.po.WxFinanceReceive" resultMap="BaseResultMap">
  86. select
  87. <include refid="allColumns"/>
  88. from wx_finance_receive
  89. <include refid="dynamicWhereConditions"/>
  90. </select>
  91. <select id="findCount" parameterType="com.iformall.domain.po.WxFinanceReceive" resultType="Integer">
  92. select count(1)
  93. from wx_finance_receive
  94. <include refid="dynamicWhereConditions"/>
  95. </select>
  96. <select id="selectById" parameterType="HashMap" resultMap="BaseResultMap">
  97. select
  98. <include refid="allColumns"/>
  99. from wx_finance_receive where id = #{id} and `tenant_id` = #{tenantId}
  100. </select>
  101. <update id = "setIsDel" parameterType="HashMap">
  102. update wx_finance_receive set is_del = #{isDel} where id = #{id} and `tenant_id` = #{tenantId}
  103. </update>
  104. <resultMap id="SumResultMap" type="com.iformall.domain.vo.WxFinanceReceiveSumVo">
  105. <result column="total_receive" jdbcType="VARCHAR" property="totalReceive"/>
  106. <result column="total_setoff" jdbcType="VARCHAR" property="totalSetoff" />
  107. <result column="total_pay" jdbcType="VARCHAR" property="totalPay"/>
  108. </resultMap>
  109. <select id="getReceiveSum" parameterType="com.iformall.domain.po.WxFinanceReceive" resultMap="SumResultMap">
  110. select
  111. sum(CAST(ifnull(receive_money,'0') AS DECIMAL(20,2))) total_receive ,
  112. sum(CAST(ifnull(set_off_money,'0') AS DECIMAL(20,2))) total_setoff,
  113. sum(CAST(ifnull(pay_money,'0') AS DECIMAL(20,2))) total_pay
  114. from wx_finance_receive
  115. <include refid="dynamicWhereConditions"/>
  116. </select>
  117. <resultMap id="PayWaySumResultMap" type="com.iformall.domain.po.WxFinanceReceivePayway">
  118. <result column="pay_way" jdbcType="BIGINT" property="payWay"/>
  119. <result column="receive" jdbcType="VARCHAR" property="receive"/>
  120. <result column="pay" jdbcType="VARCHAR" property="pay"/>
  121. </resultMap>
  122. <select id="getReceivePayWayReceiveSum" parameterType="com.iformall.domain.po.WxFinanceReceive" resultMap="PayWaySumResultMap">
  123. select pay_way, sum(CAST(ifnull(receive,'0') AS DECIMAL(20,2))) receive
  124. from wx_finance_receive_payway where is_del = 0 and receive_id in (
  125. select id from wx_finance_receive
  126. <include refid="dynamicWhereConditions"/>
  127. )
  128. group by pay_way
  129. </select>
  130. <select id="getReceivePayWayPaySum" parameterType="com.iformall.domain.po.WxFinanceReceive" resultMap="PayWaySumResultMap">
  131. select pay_way, sum(CAST(ifnull(pay,'0') AS DECIMAL(20,2))) pay
  132. from wx_finance_receive_payway where is_del = 0 and receive_id in (
  133. select id from wx_finance_receive
  134. <include refid="dynamicWhereConditions"/>
  135. )
  136. group by pay_way
  137. </select>
  138. <resultMap id="feesSumReceiveResultMap" type="com.iformall.domain.po.WxFinanceReceiveBill">
  139. <result column="fees_id" jdbcType="BIGINT" property="feesId"/>
  140. <result column="receive" jdbcType="VARCHAR" property="receive"/>
  141. <result column="pay" jdbcType="VARCHAR" property="pay"/>
  142. </resultMap>
  143. <select id="getReceiveFeesReceiveSum" parameterType="com.iformall.domain.po.WxFinanceReceive" resultMap="feesSumReceiveResultMap">
  144. select fees_id, sum(CAST(ifnull(receive,'0') AS DECIMAL(20,2))) receive
  145. from wx_finance_receive_bill where is_del = 0 and receive_id in (
  146. select id from wx_finance_receive
  147. <include refid="dynamicWhereConditions"/>
  148. )
  149. group by fees_id
  150. </select>
  151. <select id="getReceiveFeesPaySum" parameterType="com.iformall.domain.po.WxFinanceReceive" resultMap="feesSumReceiveResultMap">
  152. select fees_id, sum(CAST(ifnull(pay,'0') AS DECIMAL(20,2))) pay
  153. from wx_finance_receive_bill where is_del = 0 and receive_id in (
  154. select id from wx_finance_receive
  155. <include refid="dynamicWhereConditions"/>
  156. )
  157. group by fees_id
  158. </select>
  159. <update id="updateFinish" parameterType="com.iformall.domain.po.WxFinanceReceive">
  160. update wx_finance_receive set is_finish = #{isFinish}
  161. where status not in (2,4)
  162. <if test=" null != ids ">
  163. and id in
  164. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  165. #{idItem}
  166. </foreach>
  167. </if>
  168. </update>
  169. <update id="updatePrint" parameterType="com.iformall.domain.po.WxFinanceReceive">
  170. update wx_finance_receive set is_print = 1 where id = #{id} and tenant_id = #{tenantId}
  171. </update>
  172. <update id="updateStatus" parameterType="com.iformall.domain.po.WxFinanceReceive">
  173. update wx_finance_receive set status = #{status}
  174. <if test=" null != remark and '' != remark">
  175. ,`remark` = #{remark}
  176. </if>
  177. where id = #{id} and tenant_id = #{tenantId}
  178. </update>
  179. <resultMap id="countResultMap" type="com.iformall.domain.vo.WxFinanceReceiveCountVo">
  180. <result column="type" jdbcType="INTEGER" property="type"/>
  181. <result column="status" jdbcType="INTEGER" property="status" />
  182. <result column="num" jdbcType="INTEGER" property="num"/>
  183. </resultMap>
  184. <select id="findCountVo" parameterType="com.iformall.domain.po.WxFinanceReceive" resultMap="countResultMap">
  185. SELECT type,status,COUNT(1) num FROM wx_finance_receive
  186. <include refid="dynamicWhereConditions"/>
  187. GROUP BY TYPE,STATUS
  188. </select>
  189. </mapper>