后台服务
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

295 linhas
12 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="tenant_id" jdbcType="VARCHAR" property="tenantId" />
  125. <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/>
  126. <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
  127. <result column="b_tenant_id" jdbcType="VARCHAR" property="bTenantId" />
  128. <result column="pay_merchant_id" jdbcType="BIGINT" property="payMerchantId" />
  129. <result column="pay_merchant_mch_id" jdbcType="VARCHAR" property="payMerchantMchId" />
  130. <result column="sharing_merchant_id" jdbcType="BIGINT" property="sharingMerchantId" />
  131. <result column="merchant_name" jdbcType="VARCHAR" property="merchantName" />
  132. <result column="pay_merchant_name" jdbcType="VARCHAR" property="payMerchantName" />
  133. <result column="order_id" jdbcType="BIGINT" property="orderId" />
  134. <result column="pay_amount" jdbcType="INTEGER" property="payAmount" />
  135. <result column="single_order_amount" jdbcType="INTEGER" property="singleOrderAmount" />
  136. <result column="single_order_id" jdbcType="BIGINT" property="singleOrderId" />
  137. <result column="pay_time_end" jdbcType="TIMESTAMP" property="payTimeEnd" />
  138. <result column="pay_time_start" jdbcType="TIMESTAMP" property="payTimeStart" />
  139. <result column="transaction_id" jdbcType="VARCHAR" property="transactionId" />
  140. <result column="sharing_order_no" jdbcType="VARCHAR" property="sharingOrderNo" />
  141. <result column="type" jdbcType="INTEGER" property="type" />
  142. <result column="point_deduction" jdbcType="VARCHAR" property="pointDeduction" />
  143. <result column="receivers" jdbcType="VARCHAR" property="receivers" />
  144. <result column="error_msg" jdbcType="VARCHAR" property="errorMsg" />
  145. <result column="sharing_status" jdbcType="INTEGER" property="sharingStatus" />
  146. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  147. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
  148. </resultMap>
  149. <select id="findOrderList" parameterType="com.iformall.domain.vo.WxProfitSharingOrderQueryVo" resultMap="orderMap">
  150. select pso.*,m.`name` merchant_name,m1.`name` pay_merchant_name
  151. from wx_profit_sharing_order pso
  152. left join wx_merchant m on pso.merchant_id=m.id
  153. left join wx_merchant m1 on pso.pay_merchant_id=m1.id
  154. <where>
  155. <if test=" null != tenantId and '' != tenantId">
  156. and pso.`tenant_id` = #{tenantId}
  157. </if>
  158. <if test=" null != parentTenantId and '' != parentTenantId">
  159. and pso.`parent_tenant_id` = #{parentTenantId}
  160. </if>
  161. <if test="id!=null">
  162. and pso.id =#{id}
  163. </if>
  164. <if test="merchantName!=null and ''!=merchantName">
  165. and m.`name` like concat('%',#{merchantName},'%')
  166. </if>
  167. <if test="startdate!=null and enddate!=null">
  168. and pso.create_time between #{startdate} and #{enddate}
  169. </if>
  170. <if test="sharingStatus!=null">
  171. and pso.sharing_status = #{sharingStatus}
  172. </if>
  173. <if test="type!=null">
  174. and pso.type = #{type}
  175. </if>
  176. <if test=" null != bTenantId and '' != bTenantId">
  177. and pso.`b_tenant_id` = #{bTenantId}
  178. </if>
  179. </where>
  180. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  181. <if test=" null == sortColumns">order by pso.id desc</if>
  182. <if test=" null != begin ">
  183. limit #{begin}, #{limit}
  184. </if>
  185. </select>
  186. <select id="queryOrderForMerchantCount" resultType="Long" parameterType="hashmap">
  187. select count(*) merchantCount from (
  188. select distinct merchant_id from wx_profit_sharing_order
  189. <where>
  190. <if test=" null != tenantId and '' != tenantId">
  191. and `tenant_id` = #{tenantId}
  192. </if>
  193. <if test=" null != parentTenantId and '' != parentTenantId">
  194. and `parent_tenant_id` = #{parentTenantId}
  195. </if>
  196. <if test="startdate!=null and enddate!=null">
  197. and create_time between #{startdate} and #{enddate}
  198. </if>
  199. </where>
  200. ) o
  201. </select>
  202. <select id="queryOrderForSum" resultType="Long" parameterType="hashmap">
  203. select ifnull(sum(pay_amount),0) payment from wx_profit_sharing_order
  204. <where>
  205. <if test=" null != tenantId and '' != tenantId">
  206. and `tenant_id` = #{tenantId}
  207. </if>
  208. <if test=" null != parentTenantId and '' != parentTenantId">
  209. and `parent_tenant_id` = #{parentTenantId}
  210. </if>
  211. <if test="startdate!=null and enddate!=null">
  212. and create_time between #{startdate} and #{enddate}
  213. </if>
  214. </where>
  215. </select>
  216. <resultMap id="orderDetailsMap" type="com.iformall.domain.vo.WxProfitSharingOrderDetailsVo">
  217. <id column="id" jdbcType="BIGINT" property="id" />
  218. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
  219. <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/>
  220. <result column="pay_amount" jdbcType="INTEGER" property="payAmount" />
  221. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  222. <result column="sharing_status" jdbcType="INTEGER" property="sharingStatus" />
  223. <result column="finish_time" jdbcType="VARCHAR" property="finishTime" />
  224. <result column="failed_reason" jdbcType="VARCHAR" property="failedReason" />
  225. <result column="description" jdbcType="VARCHAR" property="description" />
  226. <result column="sharing_receiver_id" jdbcType="BIGINT" property="sharingReceiverId" />
  227. <result column="receiver_type" jdbcType="INTEGER" property="receiverType" />
  228. <result column="receiver_account" jdbcType="VARCHAR" property="receiverAccount" />
  229. <result column="receiver_comments" jdbcType="VARCHAR" property="receiverComments" />
  230. <result column="sharing_type" jdbcType="INTEGER" property="sharingType" />
  231. <result column="status" jdbcType="VARCHAR" property="status" />
  232. </resultMap>
  233. <select id="findOrderDetails" parameterType="java.util.HashMap" resultMap="orderDetailsMap">
  234. select psr.id,psr.tenant_id,psr.parent_tenant_id,psr.pay_amount,psr.create_time,sharing_status,finish_time,failed_reason,description,
  235. psr.sharing_receiver_id,psre.receiver_type,psre.receiver_account,psre.receiver_comments,psre.sharing_type,psre.`status`
  236. from wx_profit_sharing_result psr
  237. left join wx_profit_sharing_receiver psre on psr.sharing_receiver_id = psre.id
  238. where psr.sharing_order_id = #{id} and psr.tenant_id = #{tenantId}
  239. <if test=" null != isPrivate ">
  240. and psr.`is_private` = #{isPrivate}
  241. </if>
  242. </select>
  243. </mapper>