OrderRefundMapper.xml 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  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.yami.shop.dao.OrderRefundMapper">
  4. <resultMap id="BaseResultMap" type="com.yami.shop.bean.model.OrderRefund">
  5. <id column="refund_id" property="refundId"/>
  6. <result column="refund_sn" property="refundSn"/>
  7. <result column="order_number" property="orderNumber"/>
  8. <result column="shop_id" property="shopId"/>
  9. <result column="user_id" property="userId"/>
  10. <result column="order_id" property="orderId"/>
  11. <result column="refund_type" property="refundType"/>
  12. <result column="order_item_id" property="orderItemId"/>
  13. <result column="goods_num" property="goodsNum"/>
  14. <result column="refund_amount" property="refundAmount"/>
  15. <result column="apply_type" property="applyType"/>
  16. <result column="is_receiver" property="isReceiver"/>
  17. <result column="buyer_reason" property="buyerReason"/>
  18. <result column="buyer_desc" property="buyerDesc"/>
  19. <result column="buyer_mobile" property="buyerMobile"/>
  20. <result column="photo_files" property="photoFiles"/>
  21. <result column="return_money_sts" property="returnMoneySts"/>
  22. <result column="reject_message" property="rejectMessage"/>
  23. <result column="seller_msg" property="sellerMsg"/>
  24. <result column="apply_time" property="applyTime"/>
  25. <result column="handel_time" property="handelTime"/>
  26. <result column="ship_time" property="shipTime"/>
  27. <result column="receive_time" property="receiveTime"/>
  28. <result column="cancel_time" property="cancelTime"/>
  29. <result column="refund_time" property="refundTime"/>
  30. <result column="decision_time" property="decisionTime"/>
  31. <result column="update_time" property="updateTime"/>
  32. <result column="reject_time" property="rejectTime"/>
  33. </resultMap>
  34. <resultMap id="OrderRefundVoMap" type="com.yami.shop.bean.vo.OrderRefundVo">
  35. <id column="refund_id" property="refundId"/>
  36. <result column="refund_sn" property="refundSn"/>
  37. <result column="order_number" property="orderNumber"/>
  38. <result column="shop_id" property="shopId"/>
  39. <result column="user_id" property="userId"/>
  40. <result column="o_dvy_type" property="dvyType"/>
  41. <result column="order_id" property="orderId"/>
  42. <result column="refund_type" property="refundType"/>
  43. <result column="order_item_id" property="orderItemId"/>
  44. <result column="goods_num" property="goodsNum"/>
  45. <result column="refund_amount" property="refundAmount"/>
  46. <result column="apply_type" property="applyType"/>
  47. <result column="is_receiver" property="isReceiver"/>
  48. <result column="buyer_reason" property="buyerReason"/>
  49. <result column="buyer_desc" property="buyerDesc"/>
  50. <result column="buyer_mobile" property="buyerMobile"/>
  51. <result column="photo_files" property="photoFiles"/>
  52. <result column="return_money_sts" property="returnMoneySts"/>
  53. <result column="reject_message" property="rejectMessage"/>
  54. <result column="seller_msg" property="sellerMsg"/>
  55. <result column="apply_time" property="applyTime"/>
  56. <result column="handel_time" property="handelTime"/>
  57. <result column="ship_time" property="shipTime"/>
  58. <result column="receive_time" property="receiveTime"/>
  59. <result column="cancel_time" property="cancelTime"/>
  60. <result column="refund_time" property="refundTime"/>
  61. <result column="decision_time" property="decisionTime"/>
  62. <result column="update_time" property="updateTime"/>
  63. <result column="reject_time" property="rejectTime"/>
  64. <result column="channel_name" property="channelName"/>
  65. <result column="real_name" property="receiver"/>
  66. <result column="refund_total_money" property="refundTotalMoney"/>
  67. </resultMap>
  68. <resultMap id="tagResultMap" type="com.yami.shop.bean.dto.OrderRefundDto">
  69. <id column="refund_id" property="refundId"/>
  70. <result column="refund_sn" property="refundSn"/>
  71. <result column="shop_id" property="shopId"/>
  72. <result column="user_id" property="userId"/>
  73. <result column="order_id" property="orderId"/>
  74. <result column="refund_type" property="refundType"/>
  75. <result column="order_item_id" property="orderItemId"/>
  76. <result column="r_goods_num" property="goodsNum"/>
  77. <result column="refund_amount" property="refundAmount"/>
  78. <result column="apply_type" property="applyType"/>
  79. <result column="is_receiver" property="isReceiver"/>
  80. <result column="buyer_reason" property="buyerReason"/>
  81. <result column="buyer_mobile" property="buyerMobile"/>
  82. <result column="photo_files" property="photoFiles"/>
  83. <result column="return_money_sts" property="returnMoneySts"/>
  84. <result column="reject_message" property="rejectMessage"/>
  85. <result column="seller_msg" property="sellerMsg"/>
  86. <result column="apply_time" property="applyTime"/>
  87. <result column="handel_time" property="handelTime"/>
  88. <result column="ship_time" property="shipTime"/>
  89. <result column="receive_time" property="receiveTime"/>
  90. <result column="cancel_time" property="cancelTime"/>
  91. <result column="refund_time" property="refundTime"/>
  92. <result column="decision_time" property="decisionTime"/>
  93. <result column="update_time" property="updateTime"/>
  94. <result column="reject_time" property="rejectTime"/>
  95. <result column="shop_name" property="shopName"/>
  96. <result column="o_dvy_type" property="dvyType"/>
  97. <!-- 扩展字段 -->
  98. <result column="o_order_number" property="orderNumber"/>
  99. <result column="o_actual_total" property="orderAmount"/>
  100. <result column="s_order_pay_no" property="orderPayNo"/>
  101. <result column="s_settlement_id" property="settlementId"/>
  102. <result column="o_pay_time" property="orderPayTime"/>
  103. <result column="o_status" property="status"/>
  104. <result column="o_refund_status" property="refundStatus"/>
  105. <result column="freight_amount" property="freightAmount"/>
  106. <result column="offset_points" property="offsetPoints"/>
  107. <!-- 退货地址信息 -->
  108. <association property="refundDelivery" javaType="com.yami.shop.bean.model.RefundDelivery">
  109. <id column="refund_delivery_id" property="refundDeliveryId"/>
  110. <result column="shop_id" property="shopId"/>
  111. <result column="refund_sn" property="refundSn"/>
  112. <result column="user_id" property="userId"/>
  113. <result column="payer" property="payer"/>
  114. <result column="price" property="price"/>
  115. <result column="dey_id" property="deyId"/>
  116. <result column="dey_name" property="deyName"/>
  117. <result column="dey_nu" property="deyNu"/>
  118. <result column="receiver_name" property="receiverName"/>
  119. <result column="receiver_mobile" property="receiverMobile"/>
  120. <result column="receiver_telephone" property="receiverTelephone"/>
  121. <result column="receiver_post_code" property="receiverPostCode"/>
  122. <result column="receiver_addr" property="receiverAddr"/>
  123. <result column="sender_mobile" property="senderMobile"/>
  124. <result column="sender_remarks" property="senderRemarks"/>
  125. <result column="imgs" property="imgs"/>
  126. <result column="create_time" property="createTime"/>
  127. </association>
  128. </resultMap>
  129. <resultMap id="InfoResultMap" type="com.yami.shop.bean.dto.OrderRefundDto">
  130. <id column="refund_id" property="refundId"/>
  131. <result column="refund_sn" property="refundSn"/>
  132. <result column="shop_id" property="shopId"/>
  133. <result column="user_id" property="userId"/>
  134. <result column="order_id" property="orderId"/>
  135. <result column="refund_type" property="refundType"/>
  136. <result column="order_item_id" property="orderItemId"/>
  137. <result column="goods_num" property="goodsNum"/>
  138. <result column="refund_amount" property="refundAmount"/>
  139. <result column="apply_type" property="applyType"/>
  140. <result column="is_receiver" property="isReceiver"/>
  141. <result column="is_return_logistics" property="isReturnLogistics"/>
  142. <result column="buyer_desc" property="buyerDesc"/>
  143. <result column="platform_refund_amount" property="platformRefundAmount"/>
  144. <result column="buyer_reason" property="buyerReason"/>
  145. <result column="buyer_mobile" property="buyerMobile"/>
  146. <result column="photo_files" property="photoFiles"/>
  147. <result column="return_money_sts" property="returnMoneySts"/>
  148. <result column="reject_message" property="rejectMessage"/>
  149. <result column="seller_msg" property="sellerMsg"/>
  150. <result column="apply_time" property="applyTime"/>
  151. <result column="handel_time" property="handelTime"/>
  152. <result column="ship_time" property="shipTime"/>
  153. <result column="receive_time" property="receiveTime"/>
  154. <result column="cancel_time" property="cancelTime"/>
  155. <result column="refund_time" property="refundTime"/>
  156. <result column="decision_time" property="decisionTime"/>
  157. <result column="update_time" property="updateTime"/>
  158. <result column="reject_time" property="rejectTime"/>
  159. <result column="shop_name" property="shopName"/>
  160. <result column="distribution_total_amount" property="distributionTotalAmount"/>
  161. <!-- 扩展字段 -->
  162. <result column="o_order_number" property="orderNumber"/>
  163. <result column="o_actual_total" property="orderAmount"/>
  164. <result column="o_status" property="status"/>
  165. <result column="s_order_pay_no" property="orderPayNo"/>
  166. <result column="s_settlement_id" property="settlementId"/>
  167. <result column="o_pay_time" property="orderPayTime"/>
  168. <result column="o_dvy_type" property="dvyType"/>
  169. <result column="freight_amount" property="freightAmount"/>
  170. <result column="offset_points" property="offsetPoints"/>
  171. <!-- 退货地址信息 -->
  172. <association property="refundDelivery" javaType="com.yami.shop.bean.model.RefundDelivery">
  173. <id column="refund_delivery_id" property="refundDeliveryId"/>
  174. <result column="shop_id" property="shopId"/>
  175. <result column="refund_sn" property="refundSn"/>
  176. <result column="user_id" property="userId"/>
  177. <result column="dey_id" property="deyId"/>
  178. <result column="dey_name" property="deyName"/>
  179. <result column="dey_nu" property="deyNu"/>
  180. <result column="receiver_name" property="receiverName"/>
  181. <result column="receiver_mobile" property="receiverMobile"/>
  182. <result column="receiver_telephone" property="receiverTelephone"/>
  183. <result column="receiver_post_code" property="receiverPostCode"/>
  184. <result column="receiver_addr" property="receiverAddr"/>
  185. <result column="sender_mobile" property="senderMobile"/>
  186. <result column="sender_remarks" property="senderRemarks"/>
  187. <result column="imgs" property="imgs"/>
  188. <result column="create_time" property="createTime"/>
  189. <result column="pay" property="pay"/>
  190. <result column="payer" property="payer"/>
  191. <result column="price" property="price"/>
  192. <result column="touch_time" property="touchTime"/>
  193. <result column="delivery_time" property="deliveryTime"/>
  194. </association>
  195. </resultMap>
  196. <sql id="selectJoinAll">
  197. SELECT r.*,
  198. o.dvy_type as o_dvy_type,
  199. o.pay_time as o_pay_time,
  200. o.order_number AS o_order_number,
  201. o.actual_total AS o_actual_total,
  202. o.hb_order_status AS o_status,
  203. s.pay_no AS s_order_pay_no,
  204. sp.shop_name AS shop_name,
  205. s.settlement_id AS s_settlement_id,
  206. d.*
  207. FROM tz_order_refund r
  208. LEFT JOIN tz_order o ON r.order_id = o.order_id
  209. LEFT JOIN tz_shop_detail sp ON sp.shop_id = o.shop_id
  210. LEFT JOIN tz_refund_delivery d ON r.refund_sn = d.refund_sn
  211. LEFT JOIN tz_order_settlement s ON o.order_number = s.order_number
  212. </sql>
  213. <!-- 分页查询列表 -->
  214. <select id="getPage" parameterType="com.yami.shop.bean.dto.OrderRefundDto" resultMap="tagResultMap">
  215. SELECT
  216. r.*,
  217. rd.payer,
  218. rd.price,
  219. IF(r.goods_num = 0,o.product_nums,r.goods_num) AS r_goods_num,
  220. o.order_number AS o_order_number,
  221. o.pay_time as o_pay_time,
  222. o.actual_total AS o_actual_total,
  223. o.product_nums AS product_nums,
  224. o.hb_order_status AS o_status,
  225. o.dvy_type as o_dvy_type,
  226. o.refund_status AS o_refund_status,
  227. sd.shop_name AS shop_name
  228. FROM tz_order_refund r
  229. LEFT JOIN tz_order o on r.order_id = o.order_id
  230. LEFT JOIN tz_shop_detail sd on sd.shop_id = r.shop_id
  231. LEFT JOIN tz_refund_delivery rd on rd.refund_sn=r.refund_sn
  232. <where>
  233. <if test="orderRefundDto.shopId != null and orderRefundDto.shopId != ''">
  234. AND r.shop_id = #{orderRefundDto.shopId}
  235. </if>
  236. <if test="orderRefundDto.userId != null and orderRefundDto.userId != ''">
  237. AND r.user_id = #{orderRefundDto.userId}
  238. </if>
  239. <if test="orderRefundDto.refundSn != null and orderRefundDto.refundSn != ''">
  240. AND r.refund_sn = #{orderRefundDto.refundSn}
  241. </if>
  242. <if test="orderRefundDto.orderNumber != null and orderRefundDto.orderNumber != ''">
  243. AND o.order_number = #{orderRefundDto.orderNumber}
  244. </if>
  245. <if test="orderRefundDto.applyType != null and orderRefundDto.applyType != ''">
  246. AND r.apply_type = #{orderRefundDto.applyType}
  247. </if>
  248. <if test="beginTime != null and beginTime != ''">
  249. AND r.apply_time &gt;= #{beginTime}
  250. </if>
  251. <if test="endTime != null and endTime != ''">
  252. AND r.apply_time &lt;= #{endTime}
  253. </if>
  254. <if test="orderRefundDto.returnMoneySts != null and orderRefundDto.returnMoneySts != ''">
  255. AND r.return_money_sts = #{orderRefundDto.returnMoneySts}
  256. </if>
  257. <if test="orderRefundDto.shopName != null">
  258. AND sd.shop_name LIKE concat("%",#{orderRefundDto.shopName},"%")
  259. </if>
  260. <if test="orderRefundDto.orderType != null and orderRefundDto.orderType != ''">
  261. AND o.order_type = #{orderRefundDto.orderType}
  262. </if>
  263. <if test="orderRefundDto.refundType != null and orderRefundDto.refundType != ''">
  264. AND r.refund_type = #{orderRefundDto.refundType}
  265. </if>
  266. </where>
  267. ORDER BY apply_time DESC
  268. </select>
  269. <!-- 查询详情信息 -->
  270. <select id="getById" resultMap="InfoResultMap">
  271. <include refid="selectJoinAll"/>
  272. WHERE r.refund_id = #{id}
  273. <if test="shopId != null">
  274. and r.shop_id = #{shopId}
  275. </if>
  276. </select>
  277. <!-- 获取退款单数量 -->
  278. <select id="getRefundCount" resultType="int">
  279. SELECT count(*)
  280. FROM tz_order_refund r
  281. LEFT JOIN tz_order o on r.order_id = o.order_id
  282. LEFT JOIN tz_shop_detail sd on sd.shop_id = r.shop_id
  283. where r.user_id = #{userId}
  284. </select>
  285. <select id="getOrderRefundByRefundSn" resultMap="InfoResultMap">
  286. <include refid="selectJoinAll"/>
  287. WHERE r.refund_sn = #{refundSn}
  288. </select>
  289. <select id="getRefundByShopId" resultType="com.yami.shop.bean.param.StatisticsRefundParam">
  290. SELECT SUM(refund_amount) as payActualTotal,count(*) as refundCount FROM tz_order_refund
  291. <where>
  292. <if test="shopId != null">
  293. and shop_id = #{shopId}
  294. </if>
  295. <if test="startTime != null">
  296. and refund_time >= #{startTime}
  297. </if>
  298. <if test="endTime != null">
  299. and refund_time &lt;= #{endTime}
  300. </if>
  301. AND return_money_sts =5
  302. </where>
  303. </select>
  304. <select id="getRefundRankingByProd" resultType="com.yami.shop.bean.param.StatisticsRefundParam">
  305. SELECT MAX(buyer_reason) as buyerReason,prod_name as refundPordName,COUNT(buyer_reason) as
  306. refundCount,SUM(refund_amount) as payActualTotal
  307. FROM `tz_order_refund` a LEFT JOIN tz_order b
  308. ON a.order_id = b.order_id
  309. <where>
  310. <if test="shopId != null">
  311. and a.shop_id = #{shopId}
  312. </if>
  313. <if test="startTime != null">
  314. and refund_time >= #{startTime}
  315. </if>
  316. <if test="endTime != null">
  317. and refund_time &lt;= #{endTime}
  318. </if>
  319. AND return_money_sts =5
  320. </where>
  321. GROUP BY prod_name ORDER BY SUM(refund_amount) DESC LIMIT 0,5
  322. </select>
  323. <select id="getRefundRankingByReason" resultType="com.yami.shop.bean.param.StatisticsRefundParam">
  324. SELECT buyer_reason as buyerReason,MAX(prod_name) as refundPordName,COUNT(buyer_reason) as
  325. refundCount,SUM(refund_amount) as payActualTotal
  326. FROM `tz_order_refund` a LEFT JOIN tz_order b
  327. ON a.order_id = b.order_id
  328. <where>
  329. <if test="shopId != null">
  330. and a.shop_id = #{shopId}
  331. </if>
  332. <if test="startTime != null">
  333. and refund_time >= #{startTime}
  334. </if>
  335. <if test="endTime != null">
  336. and refund_time &lt;= #{endTime}
  337. </if>
  338. AND return_money_sts =5
  339. </where>
  340. GROUP BY buyer_reason ORDER BY SUM(refund_amount) DESC LIMIT 0,5
  341. </select>
  342. <select id="getRefundByShopIdAndDay" resultType="com.yami.shop.bean.param.StatisticsRefundParam">
  343. SELECT dates as refundDate,MAX(payActualTotal) as payActualTotal,MAX(refundCount) as refundCount FROM(
  344. SELECT @cdate := DATE_ADD(@cdate,INTERVAL - 1 DAY) dates ,0 AS payActualTotal,0 AS 'refundCount'
  345. FROM (SELECT @cdate :=DATE_ADD(CURDATE(),INTERVAL + 1 DAY) FROM tz_user) t1
  346. <where>
  347. <if test="startTime != null">
  348. and @cdate >= #{startTime}
  349. </if>
  350. </where>
  351. UNION ALL
  352. SELECT DATE_FORMAT(refund_time, '%Y-%m-%d') AS dates,SUM(refund_amount) AS payActualTotal,COUNT(refund_id)
  353. refundCount FROM tz_order_refund
  354. <where>
  355. <if test="shopId != null">
  356. and shop_id = #{shopId}
  357. </if>
  358. <if test="startTime != null">
  359. and refund_time >= #{startTime}
  360. </if>
  361. <if test="endTime != null">
  362. and refund_time &lt;= #{endTime}
  363. </if>
  364. AND return_money_sts =5
  365. </where>
  366. GROUP BY dates)_tmpAllTable GROUP BY dates
  367. ORDER BY dates
  368. </select>
  369. <update id="updateReturnMoneySts">
  370. UPDATE tz_order_refund
  371. <set>
  372. return_money_sts = #{status},update_time = now(),
  373. <if test="status == 2">
  374. handel_time = now()
  375. </if>
  376. </set>
  377. WHERE refund_id IN (
  378. <foreach collection="refundList" separator="," item="item">
  379. #{item.refundId}
  380. </foreach>
  381. )
  382. </update>
  383. <select id="sumRefundSuccessAmountByOrderId" resultType="double">
  384. select ifnull(sum(refund_amount), 0)
  385. from tz_order_refund
  386. where order_id = #{orderId}
  387. and return_money_sts = 5
  388. </select>
  389. <select id="getProcessingOrderRefundByOrderId" resultType="com.yami.shop.bean.model.OrderRefund">
  390. SELECT r.*
  391. FROM tz_order_refund r
  392. WHERE r.`order_id` = #{orderId}
  393. -- 买家撤回申请
  394. AND r.`return_money_sts` != 6
  395. -- 商家拒绝
  396. AND r.`return_money_sts` != 7
  397. -- 退款关闭
  398. AND r.`return_money_sts` != - 1
  399. </select>
  400. <select id="sumRefundSuccessPlatformAmountByOrderId" resultType="double">
  401. select ifnull(sum(platform_refund_amount), 0)
  402. from tz_order_refund
  403. where order_id = #{orderId}
  404. and return_money_sts = 5
  405. </select>
  406. <select id="getOrderRefundCountByRefundSn" resultType="java.lang.Integer">
  407. SELECT COUNT(*)
  408. FROM tz_order_refund
  409. WHERE order_id = (SELECT order_id
  410. FROM tz_order_refund
  411. WHERE refund_sn = #{refundSn }
  412. AND return_money_sts IN (1, 2, 3, 4, 5))
  413. </select>
  414. <select id="countRefundByOrderItem" resultType="java.lang.Integer">
  415. SELECT COUNT(refund_id)
  416. FROM `tz_order_refund`
  417. WHERE order_item_id = #{orderItemId}
  418. AND (return_money_sts &gt;= #{returnMoneySts0} AND return_money_sts &lt;= #{returnMoneySts1})
  419. </select>
  420. <select id="orderRefundCount" resultType="com.yami.shop.bean.param.OrderRefundCountParam">
  421. SELECT
  422. COUNT(return_money_sts) AS allCount,
  423. COUNT(CASE WHEN return_money_sts = 10 THEN 1 END) AS sellerApplyCount,
  424. COUNT(CASE WHEN return_money_sts = 30 THEN 1 END) AS sellerRejectCount,
  425. COUNT(CASE WHEN return_money_sts = 40 THEN 1 END) AS withdrawApplyCount,
  426. COUNT(CASE WHEN return_money_sts = 60 THEN 1 END) AS sellerAcceptCount,
  427. COUNT(CASE WHEN return_money_sts = 65 THEN 1 END) AS buyerDeliveryCount,
  428. COUNT(CASE WHEN return_money_sts = 70 THEN 1 END) AS refundCompleteCount
  429. FROM tz_order_refund
  430. <where>
  431. <if test="orderRefund.orderNumber != null">
  432. and order_number = #{orderRefund.orderNumber}
  433. </if>
  434. <if test="orderRefund.refundSn != null">
  435. and refund_sn = #{orderRefund.refundSn}
  436. </if>
  437. <if test="orderRefund.buyerMobile != null">
  438. and buyer_mobile = #{orderRefund.buyerMobile}
  439. </if>
  440. <if test="orderRefund.applyType != null">
  441. and apply_type = #{orderRefund.applyType}
  442. </if>
  443. <if test="orderRefund.returnMoneySts != null and orderRefund.returnMoneySts != 0">
  444. and return_money_sts = #{orderRefund.returnMoneySts}
  445. </if>
  446. <if test="orderRefund.startTime != null">
  447. AND create_time &gt;= #{orderRefund.startTime}
  448. </if>
  449. <if test="orderRefund.endTime != null">
  450. AND create_time &lt;= #{orderRefund.endTime}
  451. </if>
  452. </where>
  453. </select>
  454. <select id="orderRefundPage" resultMap="OrderRefundVoMap">
  455. select refund.*, o.actual_total as actualTotal,o.dvy_type as o_dvy_type, o.product_nums as productNums, o.hb_order_status as hbOrderStatus,
  456. tsd.shop_name as shopName
  457. from tz_order_refund refund
  458. join tz_shop_detail tsd on refund.shop_id = tsd.shop_id
  459. join tz_order o on refund.order_id = o.order_id
  460. <where>
  461. <if test="orderRefund.orderNumber != null">
  462. and refund.order_number = #{orderRefund.orderNumber}
  463. </if>
  464. <if test="orderRefund.channelIdList != null and orderRefund.channelIdList != ''">
  465. and o.channel_id in
  466. <foreach collection="orderRefund.channelIdList" item="channelId" open="(" close=")" separator=",">
  467. #{channelId}
  468. </foreach>
  469. </if>
  470. <if test="orderRefund.refundSn != null">
  471. and refund.refund_sn = #{orderRefund.refundSn}
  472. </if>
  473. <if test="orderRefund.buyerMobile != null">
  474. and refund.buyer_mobile = #{orderRefund.buyerMobile}
  475. </if>
  476. <if test="orderRefund.applyType != null">
  477. and refund.apply_type = #{orderRefund.applyType}
  478. </if>
  479. <if test="orderRefund.returnMoneySts != null and orderRefund.returnMoneySts != 0">
  480. and refund.return_money_sts = #{orderRefund.returnMoneySts}
  481. </if>
  482. <if test="orderRefund.startTime != null">
  483. AND refund.create_time &gt;= #{orderRefund.startTime}
  484. </if>
  485. <if test="orderRefund.endTime != null">
  486. AND refund.create_time &lt;= #{orderRefund.endTime}
  487. </if>
  488. </where>
  489. order by refund.apply_time desc
  490. </select>
  491. <select id="selectInfoById" resultMap="OrderRefundVoMap">
  492. select refund.*,
  493. o.actual_total as actualTotal,
  494. o.product_nums as productNums,
  495. o.hb_order_status as hbOrderStatus,
  496. o.offset_points as OrderOffsetPoints,
  497. o.dvy_type as o_dvy_type,
  498. o.actual_total as OrderActualTotal,
  499. tsd.shop_name as shopName,
  500. uao.receiver as receiver
  501. from tz_order_refund refund
  502. join tz_shop_detail tsd on refund.shop_id = tsd.shop_id
  503. join tz_order o on refund.order_id = o.order_id
  504. left join tz_user_addr_order uao on o.addr_order_id = uao.addr_order_id
  505. where refund.refund_id = #{refundId}
  506. </select>
  507. <select id="findByOrderNumber" resultType="com.yami.shop.bean.model.OrderRefund">
  508. select * from tz_order_refund where return_money_sts=#{returnMoneySts} and order_number =#{orderNumber}
  509. </select>
  510. <select id="findOrderRefund" resultMap="OrderRefundVoMap">
  511. select refund.*, o.actual_total as actualTotal,o.dvy_type as o_dvy_type, o.product_nums as productNums, o.hb_order_status as hbOrderStatus,u.real_name,
  512. tsd.shop_name as shopName,d.channel_name
  513. from tz_order_refund refund
  514. join tz_shop_detail tsd on refund.shop_id = tsd.shop_id
  515. join tz_order o on refund.order_id = o.order_id
  516. join tz_channel d on o.channel_id = d.id
  517. join tz_user u on refund.user_id = u.user_id
  518. <where>
  519. <if test="orderRefund.orderNumber != null">
  520. and refund.order_number = #{orderRefund.orderNumber}
  521. </if>
  522. <if test="orderRefund.channelIdList != null and orderRefund.channelIdList != ''">
  523. and o.channel_id in
  524. <foreach collection="orderRefund.channelIdList" item="channelId" open="(" close=")" separator=",">
  525. #{channelId}
  526. </foreach>
  527. </if>
  528. <if test="orderRefund.refundSn != null">
  529. and refund.refund_sn = #{orderRefund.refundSn}
  530. </if>
  531. <if test="orderRefund.buyerMobile != null">
  532. and refund.buyer_mobile = #{orderRefund.buyerMobile}
  533. </if>
  534. <if test="orderRefund.applyType != null">
  535. and refund.apply_type = #{orderRefund.applyType}
  536. </if>
  537. <if test="orderRefund.returnMoneySts != null and orderRefund.returnMoneySts != 0">
  538. and refund.return_money_sts = #{orderRefund.returnMoneySts}
  539. </if>
  540. <if test="orderRefund.startTime != null">
  541. AND refund.create_time &gt;= #{orderRefund.startTime}
  542. </if>
  543. <if test="orderRefund.endTime != null">
  544. AND refund.create_time &lt;= #{orderRefund.endTime}
  545. </if>
  546. </where>
  547. order by refund.apply_time desc
  548. </select>
  549. </mapper>