Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 

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