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.
 
 
 
 
 

236 lines
9.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.WxProfitSharingOrderMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxProfitSharingOrder">
  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="merchant_id" jdbcType="BIGINT" property="merchantId" />
  9. <result column="order_id" jdbcType="BIGINT" property="orderId" />
  10. <result column="pay_amount" jdbcType="INTEGER" property="payAmount" />
  11. <result column="pay_time_end" jdbcType="TIMESTAMP" property="payTimeEnd" />
  12. <result column="pay_time_start" jdbcType="TIMESTAMP" property="payTimeStart" />
  13. <result column="transaction_id" jdbcType="VARCHAR" property="transactionId" />
  14. <result column="sharing_order_no" jdbcType="VARCHAR" property="sharingOrderNo" />
  15. <result column="type" jdbcType="INTEGER" property="type" />
  16. <result column="receivers" jdbcType="VARCHAR" property="receivers" />
  17. <result column="error_msg" jdbcType="VARCHAR" property="errorMsg" />
  18. <result column="sharing_status" jdbcType="INTEGER" property="sharingStatus" />
  19. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  20. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
  21. </resultMap>
  22. <sql id="allColumns">
  23. `id`,`tenant_id`,`parent_tenant_id`,`merchant_id`,`order_id`,`pay_amount`,`pay_time_end`,`pay_time_start`,`transaction_id`,`sharing_order_no`,`type`,`receivers`,`error_msg`,`sharing_status`,`update_time`,`create_time`
  24. </sql>
  25. <sql id="dynamicWhereConditions">
  26. where 1 = 1
  27. <if test=" null != id ">
  28. and `id` = #{id}
  29. </if>
  30. <if test=" null != tenantId and '' != tenantId">
  31. and `tenant_id` = #{tenantId}
  32. </if>
  33. <if test=" null != parentTenantId and '' != parentTenantId">
  34. and `parent_tenant_id` = #{parentTenantId}
  35. </if>
  36. <if test=" null != merchantId ">
  37. and `merchant_id` = #{merchantId}
  38. </if>
  39. <if test=" null != orderId ">
  40. and `order_id` = #{orderId}
  41. </if>
  42. <if test=" null != type ">
  43. and `type` = #{type}
  44. </if>
  45. <if test=" null != payAmount ">
  46. and `pay_amount` = #{payAmount}
  47. </if>
  48. <if test=" null != payTimeEnd ">
  49. and `pay_time_end` = #{payTimeEnd}
  50. </if>
  51. <if test=" null != payTimeStart ">
  52. and `pay_time_start` = #{payTimeStart}
  53. </if>
  54. <if test=" null != transactionId ">
  55. and `transaction_id` = #{transactionId}
  56. </if>
  57. <if test=" null != sharingOrderNo ">
  58. and `sharing_order_id` = #{sharingOrderId}
  59. </if>
  60. <if test=" null != errorMsg ">
  61. and `error_msg` like concat('%', #{errorMsg},'%')
  62. </if>
  63. <if test=" null != sharingStatus ">
  64. and `sharing_status` like concat('%', #{sharingStatus},'%')
  65. </if>
  66. <if test=" null != updateTime ">
  67. and `update_time` = #{updateTime}
  68. </if>
  69. <if test=" null != createTime ">
  70. and `create_time` = #{createTime}
  71. </if>
  72. <if test=" null != ids ">
  73. and id in
  74. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  75. #{idItem}
  76. </foreach>
  77. </if>
  78. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  79. </sql>
  80. <select id="findList" parameterType="com.iformall.domain.po.WxProfitSharingOrder" resultMap="BaseResultMap">
  81. select
  82. <include refid="allColumns"/>
  83. from wx_profit_sharing_order
  84. <include refid="dynamicWhereConditions" />
  85. </select>
  86. <resultMap id="orderMap" type="com.iformall.domain.vo.WxProfitSharingOrderVo">
  87. <id column="id" jdbcType="BIGINT" property="id" />
  88. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
  89. <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/>
  90. <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
  91. <result column="merchant_name" jdbcType="VARCHAR" property="merchantName" />
  92. <result column="order_id" jdbcType="BIGINT" property="orderId" />
  93. <result column="pay_amount" jdbcType="INTEGER" property="payAmount" />
  94. <result column="pay_time_end" jdbcType="TIMESTAMP" property="payTimeEnd" />
  95. <result column="pay_time_start" jdbcType="TIMESTAMP" property="payTimeStart" />
  96. <result column="transaction_id" jdbcType="VARCHAR" property="transactionId" />
  97. <result column="sharing_order_no" jdbcType="VARCHAR" property="sharingOrderNo" />
  98. <result column="type" jdbcType="INTEGER" property="type" />
  99. <result column="receivers" jdbcType="VARCHAR" property="receivers" />
  100. <result column="error_msg" jdbcType="VARCHAR" property="errorMsg" />
  101. <result column="sharing_status" jdbcType="INTEGER" property="sharingStatus" />
  102. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  103. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
  104. </resultMap>
  105. <select id="findOrderList" parameterType="com.iformall.domain.vo.WxProfitSharingOrderQueryVo" resultMap="orderMap">
  106. select pso.*,m.`name` merchant_name from wx_profit_sharing_order pso
  107. left join wx_merchant m on pso.merchant_id=m.id
  108. <where>
  109. <if test=" null != tenantId and '' != tenantId">
  110. and pso.`tenant_id` = #{tenantId}
  111. </if>
  112. <if test=" null != parentTenantId and '' != parentTenantId">
  113. and pso.`parent_tenant_id` = #{parentTenantId}
  114. </if>
  115. <if test="id!=null">
  116. and pso.id =#{id}
  117. </if>
  118. <if test="merchantName!=null and ''!=merchantName">
  119. and m.`name` like concat('%',#{merchantName},'%')
  120. </if>
  121. <if test="startdate!=null and enddate!=null">
  122. and pso.create_time between #{startdate} and #{enddate}
  123. </if>
  124. <if test="sharingStatus!=null">
  125. and pso.sharing_status = #{sharingStatus}
  126. </if>
  127. <if test="type!=null">
  128. and pso.type = #{type}
  129. </if>
  130. </where>
  131. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  132. <if test=" null == sortColumns">order by pso.id desc</if>
  133. <if test=" null != begin ">
  134. limit #{begin}, #{limit}
  135. </if>
  136. </select>
  137. <select id="queryOrderForMerchantCount" resultType="Long" parameterType="hashmap">
  138. select count(*) merchantCount from (
  139. select distinct merchant_id from wx_profit_sharing_order
  140. <where>
  141. <if test=" null != tenantId and '' != tenantId">
  142. and `tenant_id` = #{tenantId}
  143. </if>
  144. <if test=" null != parentTenantId and '' != parentTenantId">
  145. and `parent_tenant_id` = #{parentTenantId}
  146. </if>
  147. <if test="startdate!=null and enddate!=null">
  148. and create_time between #{startdate} and #{enddate}
  149. </if>
  150. </where>
  151. ) o
  152. </select>
  153. <select id="queryOrderForSum" resultType="Long" parameterType="hashmap">
  154. select ifnull(sum(pay_amount),0) payment from wx_profit_sharing_order
  155. <where>
  156. <if test=" null != tenantId and '' != tenantId">
  157. and `tenant_id` = #{tenantId}
  158. </if>
  159. <if test=" null != parentTenantId and '' != parentTenantId">
  160. and `parent_tenant_id` = #{parentTenantId}
  161. </if>
  162. <if test="startdate!=null and enddate!=null">
  163. and create_time between #{startdate} and #{enddate}
  164. </if>
  165. </where>
  166. </select>
  167. <resultMap id="orderDetailsMap" type="com.iformall.domain.vo.WxProfitSharingOrderDetailsVo">
  168. <id column="id" jdbcType="BIGINT" property="id" />
  169. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
  170. <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/>
  171. <result column="pay_amount" jdbcType="INTEGER" property="payAmount" />
  172. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  173. <result column="sharing_status" jdbcType="INTEGER" property="sharingStatus" />
  174. <result column="finish_time" jdbcType="VARCHAR" property="finishTime" />
  175. <result column="failed_reason" jdbcType="VARCHAR" property="failedReason" />
  176. <result column="description" jdbcType="VARCHAR" property="description" />
  177. <result column="receiver_type" jdbcType="INTEGER" property="receiverType" />
  178. <result column="receiver_account" jdbcType="VARCHAR" property="receiverAccount" />
  179. <result column="receiver_comments" jdbcType="VARCHAR" property="receiverComments" />
  180. <result column="sharing_type" jdbcType="INTEGER" property="sharingType" />
  181. <result column="status" jdbcType="VARCHAR" property="status" />
  182. </resultMap>
  183. <select id="findOrderDetails" parameterType="java.util.HashMap" resultMap="orderDetailsMap">
  184. select psr.id,psr.tenant_id,psr.parent_tenant_id,psr.pay_amount,psr.create_time,sharing_status,finish_time,failed_reason,description,
  185. psre.receiver_type,psre.receiver_account,psre.receiver_comments,psre.sharing_type,psre.`status`
  186. from wx_profit_sharing_result psr left join wx_profit_sharing_receiver psre on psr.sharing_receiver_id=psre.id
  187. where psr.sharing_order_id=#{id} and psr.tenant_id=#{tenantId} and psr.sharing_receiver_id!=0
  188. </select>
  189. </mapper>