No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 
 

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