PayRequestMapper.xml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.mofangchuxing.aska.dao.mapper.PayRequestMapper">
  6. <resultMap id="BaseResultMap" type="com.mofangchuxing.aska.dao.domain.PayRequest">
  7. <id property="id" column="id" jdbcType="INTEGER"/>
  8. <result property="requestBody" column="request_body" jdbcType="VARCHAR"/>
  9. <result property="orderSn" column="order_sn" jdbcType="VARCHAR"/>
  10. <result property="openId" column="open_id" jdbcType="VARCHAR"/>
  11. <result property="mobile" column="mobile" jdbcType="VARCHAR"/>
  12. <result property="orderId" column="order_id" jdbcType="VARCHAR"/>
  13. <result property="amount" column="amount" jdbcType="INTEGER"/>
  14. <result property="itemId" column="item_id" jdbcType="VARCHAR"/>
  15. <result property="itemType" column="item_type" jdbcType="INTEGER"/>
  16. <result property="itemName" column="item_name" jdbcType="VARCHAR"/>
  17. <result property="itemChannel" column="item_channel" jdbcType="VARCHAR"/>
  18. <result property="retailId" column="retail_id" jdbcType="VARCHAR"/>
  19. <result property="retailName" column="retail_name" jdbcType="VARCHAR"/>
  20. <result property="useCouponId" column="use_coupon_id" jdbcType="VARCHAR"/>
  21. <result property="payChannel" column="pay_channel" jdbcType="INTEGER"/>
  22. <result property="responseBody" column="response_body" jdbcType="VARCHAR"/>
  23. <result property="payStatus" column="pay_status" jdbcType="INTEGER"/>
  24. <result property="payTime" column="pay_time" jdbcType="TIMESTAMP"/>
  25. <result property="transactionId" column="transaction_id" jdbcType="VARCHAR"/>
  26. <result property="payAmount" column="pay_amount" jdbcType="DECIMAL"/>
  27. <result property="hasRefund" column="has_refund" jdbcType="INTEGER"/>
  28. <result property="refundTotal" column="refund_total" jdbcType="DECIMAL"/>
  29. <result property="clientType" column="client_type" jdbcType="VARCHAR"/>
  30. <result property="cansplit" column="canSplit" jdbcType="INTEGER"/>
  31. <result property="callbackUrl" column="callback_url" jdbcType="VARCHAR"/>
  32. <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
  33. <result property="modifiedTime" column="modified_time" jdbcType="TIMESTAMP"/>
  34. </resultMap>
  35. <sql id="Base_Column_List">
  36. id,request_body,order_sn,
  37. open_id,mobile,order_id,
  38. amount,item_id,item_type,
  39. item_name,item_channel,retail_id,
  40. retail_name,use_coupon_id,pay_channel,
  41. response_body,pay_status,pay_time,
  42. transaction_id,pay_amount,has_refund,
  43. refund_total,client_type,canSplit,
  44. callback_url,create_time,modified_time
  45. </sql>
  46. <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
  47. select
  48. <include refid="Base_Column_List" />
  49. from pay_request
  50. where id = #{id,jdbcType=INTEGER}
  51. </select>
  52. <select id="selectByOrderSn" resultMap="BaseResultMap">
  53. select
  54. <include refid="Base_Column_List" />
  55. from pay_request
  56. where order_sn = #{orderSn} limit 1
  57. </select>
  58. <select id="selectPaySuccessByOrderId" resultMap="BaseResultMap">
  59. select
  60. <include refid="Base_Column_List" />
  61. from pay_request
  62. where order_id = #{orderId} and pay_status = 1 limit 1
  63. </select>
  64. <select id="selectByUser" resultMap="BaseResultMap">
  65. select order_sn, order_id, item_id, item_name, pay_status
  66. from pay_request
  67. where mobile = #{phoneNo} and item_type = #{itemType}
  68. <if test="payStatus != null">
  69. and pay_status = #{payStatus}
  70. </if>
  71. </select>
  72. <select id="selectByMobileAndOrderId" resultMap="BaseResultMap">
  73. select order_sn, order_id, item_id, item_name, pay_status
  74. from pay_request
  75. where mobile = #{phoneNo} and order_id = #{orderId}
  76. </select>
  77. <select id="getOrderList" resultType="java.util.Map">
  78. select pr.*,
  79. ifnull(asr.channelAmount,0) as channelAmount,
  80. ifnull(asr.channelRealtimeAmount,0) as channelRealtimeAmount,
  81. ifnull(asr.channelAccountAmount,0) as channelAccountAmount,
  82. ifnull(asr.retailAmount,0) as retailAmount,
  83. ifnull(asr.retailRealtimeAmount,0) as retailRealtimeAmount,
  84. ifnull(asr.retailAccountAmount,0) as retailAccountAmount
  85. from pay_request pr left join aska_splitrecord as asr on pr.id = asr.payId
  86. where 1=1
  87. <if test="retailId != null and retailId != ''">
  88. and pr.retail_id = #{retailId}
  89. </if>
  90. <if test="couponNo != null and couponNo != ''">
  91. and pr.use_coupon_id = #{couponNo}
  92. </if>
  93. <if test="orderNo != null and orderNo != ''">
  94. and pr.order_id = #{orderNo}
  95. </if>
  96. <if test="channelId != null and channelId != ''">
  97. and pr.channel_id = #{channelId}
  98. </if>
  99. <if test="startTime != null and startTime != ''">
  100. and pr.create_time > #{startTime}
  101. </if>
  102. <if test="endTime != null and endTime != ''">
  103. and pr.create_time &lt; #{endTime}
  104. </if>
  105. order by pr.id desc
  106. </select>
  107. <select id="selectByOrderId" resultMap="BaseResultMap">
  108. select
  109. <include refid="Base_Column_List" />
  110. from pay_request
  111. where order_id = #{orderId} limit 1
  112. </select>
  113. <select id="queryPayment" resultType="java.util.Map">
  114. select retailAccountAmount as accountAmount,retailAmount as amount,retailRealtimeAmount as realtimeAmount,splitOrderId as orderSN,
  115. CASE recordType WHEN 1 THEN '收入' WHEN 2 THEN '退款' end as recordType,createTime from aska_splitrecord where 1=1
  116. <if test="retailId != null and retailId != ''">
  117. and retailId = #{retailId}
  118. </if>
  119. <if test="startTime != null and startTime != ''">
  120. and createTime > #{startTime}
  121. </if>
  122. <if test="endTime != null and endTime != ''">
  123. and createTime &lt; #{endTime}
  124. </if>
  125. order by createTime desc
  126. </select>
  127. <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
  128. delete from pay_request
  129. where id = #{id,jdbcType=INTEGER}
  130. </delete>
  131. <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.mofangchuxing.aska.dao.domain.PayRequest" useGeneratedKeys="true">
  132. insert into pay_request
  133. ( id,request_body,order_sn
  134. ,open_id,mobile,order_id
  135. ,amount,item_id,item_type
  136. ,item_name,item_channel,retail_id
  137. ,retail_name,use_coupon_id,pay_channel
  138. ,response_body,pay_status,pay_time
  139. ,transaction_id,pay_amount,has_refund
  140. ,refund_total,client_type,canSplit
  141. ,callback_url,create_time,modified_time
  142. )
  143. values (#{id,jdbcType=INTEGER},#{requestBody,jdbcType=VARCHAR},#{orderSn,jdbcType=VARCHAR}
  144. ,#{openId,jdbcType=VARCHAR},#{mobile,jdbcType=VARCHAR},#{orderId,jdbcType=VARCHAR}
  145. ,#{amount,jdbcType=DECIMAL},#{itemId,jdbcType=VARCHAR},#{itemType,jdbcType=INTEGER}
  146. ,#{itemName,jdbcType=VARCHAR},#{itemChannel,jdbcType=VARCHAR},#{retailId,jdbcType=VARCHAR}
  147. ,#{retailName,jdbcType=VARCHAR},#{useCouponId,jdbcType=VARCHAR},#{payChannel,jdbcType=INTEGER}
  148. ,#{responseBody,jdbcType=VARCHAR},#{payStatus,jdbcType=INTEGER},#{payTime,jdbcType=TIMESTAMP}
  149. ,#{transactionId,jdbcType=VARCHAR},#{payAmount,jdbcType=DECIMAL},#{hasRefund,jdbcType=INTEGER}
  150. ,#{refundTotal,jdbcType=DECIMAL},#{clientType,jdbcType=VARCHAR},#{cansplit,jdbcType=INTEGER}
  151. ,#{callbackUrl,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{modifiedTime,jdbcType=TIMESTAMP}
  152. )
  153. </insert>
  154. <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.mofangchuxing.aska.dao.domain.PayRequest" useGeneratedKeys="true">
  155. insert into pay_request
  156. <trim prefix="(" suffix=")" suffixOverrides=",">
  157. <if test="id != null">id,</if>
  158. <if test="requestBody != null">request_body,</if>
  159. <if test="orderSn != null">order_sn,</if>
  160. <if test="openId != null">open_id,</if>
  161. <if test="mobile != null">mobile,</if>
  162. <if test="orderId != null">order_id,</if>
  163. <if test="amount != null">amount,</if>
  164. <if test="itemId != null">item_id,</if>
  165. <if test="itemType != null">item_type,</if>
  166. <if test="itemName != null">item_name,</if>
  167. <if test="itemChannel != null">item_channel,</if>
  168. <if test="channelId != null">channel_id,</if>
  169. <if test="retailId != null">retail_id,</if>
  170. <if test="retailName != null">retail_name,</if>
  171. <if test="useCouponId != null">use_coupon_id,</if>
  172. <if test="payChannel != null">pay_channel,</if>
  173. <if test="responseBody != null">response_body,</if>
  174. <if test="payStatus != null">pay_status,</if>
  175. <if test="payTime != null">pay_time,</if>
  176. <if test="transactionId != null">transaction_id,</if>
  177. <if test="payAmount != null">pay_amount,</if>
  178. <if test="hasRefund != null">has_refund,</if>
  179. <if test="refundTotal != null">refund_total,</if>
  180. <if test="clientType != null">client_type,</if>
  181. <if test="cansplit != null">canSplit,</if>
  182. <if test="callbackUrl != null">callback_url,</if>
  183. <if test="createTime != null">create_time,</if>
  184. <if test="modifiedTime != null">modified_time,</if>
  185. </trim>
  186. <trim prefix="values (" suffix=")" suffixOverrides=",">
  187. <if test="id != null">#{id,jdbcType=INTEGER},</if>
  188. <if test="requestBody != null">#{requestBody,jdbcType=VARCHAR},</if>
  189. <if test="orderSn != null">#{orderSn,jdbcType=VARCHAR},</if>
  190. <if test="openId != null">#{openId,jdbcType=VARCHAR},</if>
  191. <if test="mobile != null">#{mobile,jdbcType=VARCHAR},</if>
  192. <if test="orderId != null">#{orderId,jdbcType=VARCHAR},</if>
  193. <if test="amount != null">#{amount,jdbcType=DECIMAL},</if>
  194. <if test="itemId != null">#{itemId,jdbcType=VARCHAR},</if>
  195. <if test="itemType != null">#{itemType,jdbcType=INTEGER},</if>
  196. <if test="itemName != null">#{itemName,jdbcType=VARCHAR},</if>
  197. <if test="itemChannel != null">#{itemChannel,jdbcType=VARCHAR},</if>
  198. <if test="channelId != null">#{channelId,jdbcType=INTEGER},</if>
  199. <if test="retailId != null">#{retailId,jdbcType=VARCHAR},</if>
  200. <if test="retailName != null">#{retailName,jdbcType=VARCHAR},</if>
  201. <if test="useCouponId != null">#{useCouponId,jdbcType=VARCHAR},</if>
  202. <if test="payChannel != null">#{payChannel,jdbcType=INTEGER},</if>
  203. <if test="responseBody != null">#{responseBody,jdbcType=VARCHAR},</if>
  204. <if test="payStatus != null">#{payStatus,jdbcType=INTEGER},</if>
  205. <if test="payTime != null">#{payTime,jdbcType=TIMESTAMP},</if>
  206. <if test="transactionId != null">#{transactionId,jdbcType=VARCHAR},</if>
  207. <if test="payAmount != null">#{payAmount,jdbcType=DECIMAL},</if>
  208. <if test="hasRefund != null">#{hasRefund,jdbcType=INTEGER},</if>
  209. <if test="refundTotal != null">#{refundTotal,jdbcType=DECIMAL},</if>
  210. <if test="clientType != null">#{clientType,jdbcType=VARCHAR},</if>
  211. <if test="cansplit != null">#{cansplit,jdbcType=INTEGER},</if>
  212. <if test="callbackUrl != null">#{callbackUrl,jdbcType=VARCHAR},</if>
  213. <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
  214. <if test="modifiedTime != null">#{modifiedTime,jdbcType=TIMESTAMP},</if>
  215. </trim>
  216. </insert>
  217. <update id="updateByPrimaryKeySelective" parameterType="com.mofangchuxing.aska.dao.domain.PayRequest">
  218. update pay_request
  219. <set>
  220. <if test="requestBody != null">
  221. request_body = #{requestBody,jdbcType=VARCHAR},
  222. </if>
  223. <if test="orderSn != null">
  224. order_sn = #{orderSn,jdbcType=VARCHAR},
  225. </if>
  226. <if test="openId != null">
  227. open_id = #{openId,jdbcType=VARCHAR},
  228. </if>
  229. <if test="mobile != null">
  230. mobile = #{mobile,jdbcType=VARCHAR},
  231. </if>
  232. <if test="orderId != null">
  233. order_id = #{orderId,jdbcType=VARCHAR},
  234. </if>
  235. <if test="amount != null">
  236. amount = #{amount,jdbcType=DECIMAL},
  237. </if>
  238. <if test="itemId != null">
  239. item_id = #{itemId,jdbcType=VARCHAR},
  240. </if>
  241. <if test="itemType != null">
  242. item_type = #{itemType,jdbcType=INTEGER},
  243. </if>
  244. <if test="itemName != null">
  245. item_name = #{itemName,jdbcType=VARCHAR},
  246. </if>
  247. <if test="itemChannel != null">
  248. item_channel = #{itemChannel,jdbcType=VARCHAR},
  249. </if>
  250. <if test="retailId != null">
  251. retail_id = #{retailId,jdbcType=VARCHAR},
  252. </if>
  253. <if test="retailName != null">
  254. retail_name = #{retailName,jdbcType=VARCHAR},
  255. </if>
  256. <if test="useCouponId != null">
  257. use_coupon_id = #{useCouponId,jdbcType=VARCHAR},
  258. </if>
  259. <if test="payChannel != null">
  260. pay_channel = #{payChannel,jdbcType=INTEGER},
  261. </if>
  262. <if test="responseBody != null">
  263. response_body = #{responseBody,jdbcType=VARCHAR},
  264. </if>
  265. <if test="payStatus != null">
  266. pay_status = #{payStatus,jdbcType=INTEGER},
  267. </if>
  268. <if test="payTime != null">
  269. pay_time = #{payTime,jdbcType=TIMESTAMP},
  270. </if>
  271. <if test="transactionId != null">
  272. transaction_id = #{transactionId,jdbcType=VARCHAR},
  273. </if>
  274. <if test="payAmount != null">
  275. pay_amount = #{payAmount,jdbcType=DECIMAL},
  276. </if>
  277. <if test="hasRefund != null">
  278. has_refund = #{hasRefund,jdbcType=INTEGER},
  279. </if>
  280. <if test="refundTotal != null">
  281. refund_total = #{refundTotal,jdbcType=DECIMAL},
  282. </if>
  283. <if test="clientType != null">
  284. client_type = #{clientType,jdbcType=VARCHAR},
  285. </if>
  286. <if test="cansplit != null">
  287. canSplit = #{cansplit,jdbcType=INTEGER},
  288. </if>
  289. <if test="callbackUrl != null">
  290. callback_url = #{callbackUrl,jdbcType=VARCHAR},
  291. </if>
  292. <if test="createTime != null">
  293. create_time = #{createTime,jdbcType=TIMESTAMP},
  294. </if>
  295. <if test="modifiedTime != null">
  296. modified_time = #{modifiedTime,jdbcType=TIMESTAMP},
  297. </if>
  298. </set>
  299. where id = #{id,jdbcType=INTEGER}
  300. </update>
  301. <update id="updateByPrimaryKey" parameterType="com.mofangchuxing.aska.dao.domain.PayRequest">
  302. update pay_request
  303. set
  304. request_body = #{requestBody,jdbcType=VARCHAR},
  305. order_sn = #{orderSn,jdbcType=VARCHAR},
  306. open_id = #{openId,jdbcType=VARCHAR},
  307. mobile = #{mobile,jdbcType=VARCHAR},
  308. order_id = #{orderId,jdbcType=VARCHAR},
  309. amount = #{amount,jdbcType=DECIMAL},
  310. item_id = #{itemId,jdbcType=VARCHAR},
  311. item_type = #{itemType,jdbcType=INTEGER},
  312. item_name = #{itemName,jdbcType=VARCHAR},
  313. item_channel = #{itemChannel,jdbcType=VARCHAR},
  314. retail_id = #{retailId,jdbcType=VARCHAR},
  315. retail_name = #{retailName,jdbcType=VARCHAR},
  316. use_coupon_id = #{useCouponId,jdbcType=VARCHAR},
  317. pay_channel = #{payChannel,jdbcType=INTEGER},
  318. response_body = #{responseBody,jdbcType=VARCHAR},
  319. pay_status = #{payStatus,jdbcType=INTEGER},
  320. pay_time = #{payTime,jdbcType=TIMESTAMP},
  321. transaction_id = #{transactionId,jdbcType=VARCHAR},
  322. pay_amount = #{payAmount,jdbcType=DECIMAL},
  323. has_refund = #{hasRefund,jdbcType=INTEGER},
  324. refund_total = #{refundTotal,jdbcType=DECIMAL},
  325. client_type = #{clientType,jdbcType=VARCHAR},
  326. canSplit = #{cansplit,jdbcType=INTEGER},
  327. callback_url = #{callbackUrl,jdbcType=VARCHAR},
  328. create_time = #{createTime,jdbcType=TIMESTAMP},
  329. modified_time = #{modifiedTime,jdbcType=TIMESTAMP}
  330. where id = #{id,jdbcType=INTEGER}
  331. </update>
  332. </mapper>