后台服务
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

WxPayOrderMapper.xml 12 KiB

2 年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  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.WxPayOrderMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxPayOrder">
  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="order_id" jdbcType="BIGINT" property="orderId"/>
  11. <result column="c_user_id" jdbcType="BIGINT" property="cUserId"/>
  12. <result column="open_id" jdbcType="VARCHAR" property="openId"/>
  13. <result column="b_user_id" jdbcType="BIGINT" property="bUserId"/>
  14. <result column="auth_code" jdbcType="VARCHAR" property="authCode"/>
  15. <result column="ip" jdbcType="VARCHAR" property="ip"/>
  16. <result column="pay_amount" jdbcType="INTEGER" property="payAmount"/>
  17. <result column="pay_time_start" jdbcType="TIMESTAMP" property="payTimeStart"/>
  18. <result column="pay_time_end" jdbcType="TIMESTAMP" property="payTimeEnd"/>
  19. <result column="prepay_id" jdbcType="VARCHAR" property="prepayId"/>
  20. <result column="transaction_id" jdbcType="VARCHAR" property="transactionId"/>
  21. <result column="pay_vendor" jdbcType="INTEGER" property="payVendor"/>
  22. <result column="pay_version" jdbcType="INTEGER" property="payVersion"/>
  23. <result column="tt_pay_way" jdbcType="INTEGER" property="ttPayWay"/>
  24. <result column="pay_order_no" jdbcType="VARCHAR" property="payOrderNo"/>
  25. <result column="pay_order_status" jdbcType="INTEGER" property="payOrderStatus"/>
  26. <result column="pay_param" jdbcType="VARCHAR" property="payParam"/>
  27. <result column="mch_type" jdbcType="INTEGER" property="mchType"/>
  28. <result column="share" jdbcType="INTEGER" property="share"/>
  29. <result column="share_amount" jdbcType="INTEGER" property="shareAmount"/>
  30. <result column="system_amount" jdbcType="INTEGER" property="systemAmount"/>
  31. <result column="commission_amount" jdbcType="INTEGER" property="commissionAmount"/>
  32. <result column="rate_amount" jdbcType="INTEGER" property="rateAmount"/>
  33. <result column="fail_reason" jdbcType="VARCHAR" property="failReason"/>
  34. <result column="pos_pay_order_id" jdbcType="BIGINT" property="posPayOrderId"/>
  35. <result column="pos_pay_order_time" jdbcType="BIGINT" property="posPayOrderTime"/>
  36. <result column="pos_payment_type" jdbcType="INTEGER" property="posPaymentType"/>
  37. <result column="pos_pay_order_no" jdbcType="INTEGER" property="posPayOrderNo"/>
  38. <result column="pos_pay_des" jdbcType="INTEGER" property="posPayDes"/>
  39. <result column="compose_order" jdbcType="INTEGER" property="composeOrder"/>
  40. <result column="child_order_share" jdbcType="VARCHAR" property="childOrderShare"/>
  41. </resultMap>
  42. <sql id="allColumns">
  43. `id`,`tenant_id`,`parent_tenant_id`,`create_time`,`update_time`,`order_id`,`c_user_id`,`open_id`,`b_user_id`,
  44. `auth_code`,`ip`,`pay_amount`,`pay_time_start`,`pay_time_end`,
  45. `prepay_id`,`transaction_id`,`pay_vendor`,`pay_version`,`tt_pay_way`,`pay_order_no`,
  46. `pay_order_status`,`pay_param`,`mch_type`,`share`,`share_amount`,`system_amount`,`commission_amount`,`rate_amount`,`fail_reason`,
  47. `pos_pay_order_id`,`pos_pay_order_time`,`pos_payment_type`,`pos_pay_order_no`,`pos_pay_des`,`compose_order`,
  48. `child_order_share`
  49. </sql>
  50. <sql id="dynamicWhereConditions">
  51. where 1 = 1
  52. <if test=" null != id ">
  53. and `id` = #{id}
  54. </if>
  55. <if test=" null != tenantId and '' != tenantId">
  56. and `tenant_id` = #{tenantId}
  57. </if>
  58. <if test=" null != parentTenantId and '' != parentTenantId">
  59. and `parent_tenant_id` = #{parentTenantId}
  60. </if>
  61. <if test=" null != createTime ">
  62. and `create_time` = #{createTime}
  63. </if>
  64. <if test=" null != updateTime ">
  65. and `update_time` = #{updateTime}
  66. </if>
  67. <if test=" null != orderId ">
  68. and `order_id` = #{orderId}
  69. </if>
  70. <if test=" null != cUserId ">
  71. and `c_user_id` = #{cUserId}
  72. </if>
  73. <if test=" null != openId ">
  74. and `open_id` = #{openId}
  75. </if>
  76. <if test=" null != bUserId ">
  77. and `b_user_id` = #{bUserId}
  78. </if>
  79. <if test=" null != authCode ">
  80. and `auth_code` = #{authCode}
  81. </if>
  82. <if test=" null != ip ">
  83. and `ip` like concat('%', #{ip},'%')
  84. </if>
  85. <if test=" null != payAmount ">
  86. and `pay_amount` = #{payAmount}
  87. </if>
  88. <if test=" null != payTimeStart ">
  89. and `pay_time_start` = #{payTimeStart}
  90. </if>
  91. <if test=" null != payTimeEnd ">
  92. and `pay_time_end` = #{payTimeEnd}
  93. </if>
  94. <if test=" null != prepayId ">
  95. and `prepay_id` like concat('%', #{prepayId},'%')
  96. </if>
  97. <if test=" null != transactionId ">
  98. and `transaction_id` like concat('%', #{transactionId},'%')
  99. </if>
  100. <if test=" null != payVendor ">
  101. and `pay_vendor` = #{payVendor}
  102. </if>
  103. <if test=" null != payVersion ">
  104. and `pay_version` = #{payVersion}
  105. </if>
  106. <if test=" null != ttPayWay ">
  107. and `tt_pay_way` = #{ttPayWay}
  108. </if>
  109. <if test=" null != payOrderNo ">
  110. and `pay_order_no` like concat('%', #{payOrderNo},'%')
  111. </if>
  112. <if test=" null != payOrderStatus ">
  113. and `pay_order_status` = #{payOrderStatus}
  114. </if>
  115. <if test=" null != share ">
  116. and `share` = #{share}
  117. </if>
  118. <if test=" null != shareAmount ">
  119. and `share_amount` = #{shareAmount}
  120. </if>
  121. <if test=" null != failReason ">
  122. and `fail_reason` like concat('%', #{failReason},'%')
  123. </if>
  124. <if test=" null != posPayOrderId ">
  125. and `pos_pay_order_id` = #{posPayOrderId}
  126. </if>
  127. <if test=" null != posPayOrderTime ">
  128. and `pos_pay_order_time` = #{posPayOrderTime}
  129. </if>
  130. <if test=" null != posPaymentType ">
  131. and `pos_payment_type` = #{posPaymentType}
  132. </if>
  133. <if test=" null != posPayOrderNo ">
  134. and `pos_pay_order_no` = #{posPayOrderNo}
  135. </if>
  136. <if test=" null != composeOrder ">
  137. and `compose_order` = #{composeOrder}
  138. </if>
  139. <if test=" null != orderIds ">
  140. and order_id in
  141. <foreach collection="orderIds" index="index" item="orderIdItem" open="(" separator="," close=")">
  142. #{orderIdItem}
  143. </foreach>
  144. </if>
  145. <if test=" null != ids ">
  146. and id in
  147. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  148. #{idItem}
  149. </foreach>
  150. </if>
  151. <if test=" null != sortColumns">order by ${sortColumns}</if>
  152. </sql>
  153. <select id="selectById" parameterType="java.util.HashMap" resultMap="BaseResultMap">
  154. select <include refid="allColumns"/> from wx_pay_order where id = #{id} and tenant_id = #{tenantId}
  155. </select>
  156. <select id="findList" parameterType="com.iformall.domain.po.WxPayOrder" resultMap="BaseResultMap">
  157. select
  158. <include refid="allColumns"/>
  159. from wx_pay_order
  160. <include refid="dynamicWhereConditions"/>
  161. </select>
  162. <select id="findListForUnPs" parameterType="com.iformall.domain.po.WxPayOrder" resultMap="BaseResultMap">
  163. select
  164. <include refid="allColumns"/>
  165. from wx_pay_order
  166. where 1=1
  167. <if test=" null != tenantId and '' != tenantId">
  168. and `tenant_id` = #{tenantId}
  169. </if>
  170. <if test=" null != parentTenantId and '' != parentTenantId">
  171. and `parent_tenant_id` = #{parentTenantId}
  172. </if>
  173. and id not in (
  174. select order_id from wx_profit_sharing_order where create_time>'2019-10-15'
  175. )
  176. and `create_time` > '2019-10-15'
  177. and share = 1 and pay_order_status = 1 and `prepay_id` is null
  178. and tenant_id in (select tenant_id from wx_pay_account where share =1) and tenant_id != '789' and tenant_id != '1000' ;
  179. </select>
  180. <select id="findExpListForMicroPay" parameterType="com.iformall.domain.po.WxPayOrder" resultMap="BaseResultMap">
  181. select
  182. <include refid="allColumns"/>
  183. from wx_pay_order
  184. where 1=1
  185. <if test=" null != tenantId and '' != tenantId">
  186. and `tenant_id` = #{tenantId}
  187. </if>
  188. <if test=" null != parentTenantId and '' != parentTenantId">
  189. and `parent_tenant_id` = #{parentTenantId}
  190. </if>
  191. and order_id in (
  192. select id from wx_order where `tenant_id` = #{tenantId} and type = 1 and order_status = 0
  193. );
  194. </select>
  195. <resultMap id="VBaseResultMap" type="com.iformall.domain.vo.WxPayOrderVo">
  196. <id column="id" jdbcType="BIGINT" property="id"/>
  197. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  198. <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
  199. <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
  200. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
  201. <result column="order_id" jdbcType="BIGINT" property="orderId"/>
  202. <result column="c_user_id" jdbcType="BIGINT" property="cUserId"/>
  203. <result column="open_id" jdbcType="VARCHAR" property="openId"/>
  204. <result column="b_user_id" jdbcType="BIGINT" property="bUserId"/>
  205. <result column="auth_code" jdbcType="VARCHAR" property="authCode"/>
  206. <result column="ip" jdbcType="VARCHAR" property="ip"/>
  207. <result column="pay_amount" jdbcType="INTEGER" property="payAmount"/>
  208. <result column="pay_time_start" jdbcType="TIMESTAMP" property="payTimeStart"/>
  209. <result column="pay_time_end" jdbcType="TIMESTAMP" property="payTimeEnd"/>
  210. <result column="prepay_id" jdbcType="VARCHAR" property="prepayId"/>
  211. <result column="transaction_id" jdbcType="VARCHAR" property="transactionId"/>
  212. <result column="pay_vendor" jdbcType="INTEGER" property="payVendor"/>
  213. <result column="pay_version" jdbcType="INTEGER" property="payVersion"/>
  214. <result column="pay_order_no" jdbcType="VARCHAR" property="payOrderNo"/>
  215. <result column="pay_order_status" jdbcType="INTEGER" property="payOrderStatus"/>
  216. <result column="share" jdbcType="INTEGER" property="share"/>
  217. <result column="share_amount" jdbcType="INTEGER" property="shareAmount"/>
  218. <result column="system_amount" jdbcType="INTEGER" property="systemAmount"/>
  219. <result column="commission_amount" jdbcType="INTEGER" property="commissionAmount"/>
  220. <result column="rate_amount" jdbcType="INTEGER" property="rateAmount"/>
  221. <result column="fail_reason" jdbcType="VARCHAR" property="failReason"/>
  222. <result column="app_id" jdbcType="VARCHAR" property="appId"/>
  223. <result column="pay_id" jdbcType="BIGINT" property="payId"/>
  224. </resultMap>
  225. <sql id="allVColumns">
  226. p.`id`,p.`tenant_id`,p.`parent_tenant_id`,p.`create_time`,p.`update_time`,p.`order_id`,p.`c_user_id`,p.`open_id`,p.`b_user_id`,
  227. p.`auth_code`,p.`ip`,p.`pay_amount`,p.`pay_time_start`,p.`pay_time_end`,
  228. p.`prepay_id`,p.`transaction_id`,p.`pay_vendor`,p.`pay_version`,p.`pay_order_no`,
  229. p.`pay_order_status`,p.`share`,p.`share_amount`,p.`system_amount`,p.`commission_amount`,p.`rate_amount`,p.`fail_reason`,
  230. a.`app_id`, a.`pay_id`
  231. </sql>
  232. <select id="findListOfPaidOrderByDate" parameterType="map" resultMap="VBaseResultMap">
  233. select
  234. <include refid="allVColumns"/>
  235. from wx_pay_order p
  236. left join wx_appinfo a on a.`tenant_id` = p.`tenant_id` and a.`type` = 2
  237. where p.`pay_order_status` = '1' and p.`pay_vendor` = 0
  238. <if test="startDate != null">
  239. AND unix_timestamp(p.`pay_time_end`) &gt; unix_timestamp(#{startDate,jdbcType=TIMESTAMP})
  240. </if>
  241. </select>
  242. </mapper>