OrderRefundMapper.xml 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  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` != 40
  395. -- 商家拒绝
  396. AND r.`return_money_sts` != 30
  397. </select>
  398. <select id="sumRefundSuccessPlatformAmountByOrderId" resultType="double">
  399. select ifnull(sum(platform_refund_amount), 0)
  400. from tz_order_refund
  401. where order_id = #{orderId}
  402. and return_money_sts = 5
  403. </select>
  404. <select id="getOrderRefundCountByRefundSn" resultType="java.lang.Integer">
  405. SELECT COUNT(*)
  406. FROM tz_order_refund
  407. WHERE order_id = (SELECT order_id
  408. FROM tz_order_refund
  409. WHERE refund_sn = #{refundSn }
  410. AND return_money_sts IN (1, 2, 3, 4, 5))
  411. </select>
  412. <select id="countRefundByOrderItem" resultType="java.lang.Integer">
  413. SELECT COUNT(refund_id)
  414. FROM `tz_order_refund`
  415. WHERE order_item_id = #{orderItemId}
  416. AND (return_money_sts &gt;= #{returnMoneySts0} AND return_money_sts &lt;= #{returnMoneySts1})
  417. </select>
  418. <select id="orderRefundCount" resultType="com.yami.shop.bean.param.OrderRefundCountParam">
  419. SELECT
  420. COUNT(re.return_money_sts) AS allCount,
  421. COUNT(CASE WHEN re.return_money_sts = 10 THEN 1 END) AS sellerApplyCount,
  422. COUNT(CASE WHEN re.return_money_sts = 30 THEN 1 END) AS sellerRejectCount,
  423. COUNT(CASE WHEN re.return_money_sts = 40 THEN 1 END) AS withdrawApplyCount,
  424. COUNT(CASE WHEN re.return_money_sts = 60 THEN 1 END) AS sellerAcceptCount,
  425. COUNT(CASE WHEN re.return_money_sts = 65 THEN 1 END) AS buyerDeliveryCount,
  426. COUNT(CASE WHEN re.return_money_sts = 70 THEN 1 END) AS refundCompleteCount
  427. FROM tz_order_refund re
  428. left join tz_order o on refund.order_id = o.order_id
  429. <where>
  430. <if test="orderRefund.orderNumber != null">
  431. and re.order_number = #{orderRefund.orderNumber}
  432. </if>
  433. <if test="orderRefund.channelIdList != null and !orderRefund.channelIdList.isEmpty()">
  434. and o.channel_id in
  435. <foreach collection="orderRefund.channelIdList" item="channelId" open="(" close=")" separator=",">
  436. #{channelId}
  437. </foreach>
  438. </if>
  439. <if test="orderRefund.dvyType != null and orderRefund.dvyType != ''">
  440. and o.dvy_type = #{orderParam.dvyType}
  441. </if>
  442. <if test="orderRefund.refundSn != null">
  443. and re.refund_sn = #{orderRefund.refundSn}
  444. </if>
  445. <if test="orderRefund.buyerMobile != null">
  446. and re.buyer_mobile = #{orderRefund.buyerMobile}
  447. </if>
  448. <if test="orderRefund.applyType != null">
  449. and re.apply_type = #{orderRefund.applyType}
  450. </if>
  451. <if test="orderRefund.returnMoneySts != null and orderRefund.returnMoneySts != 0">
  452. and re.return_money_sts = #{orderRefund.returnMoneySts}
  453. </if>
  454. <if test="orderRefund.startTime != null">
  455. AND re.create_time &gt;= #{orderRefund.startTime}
  456. </if>
  457. <if test="orderRefund.endTime != null">
  458. AND re.create_time &lt;= #{orderRefund.endTime}
  459. </if>
  460. </where>
  461. </select>
  462. <select id="orderRefundPage" resultMap="OrderRefundVoMap">
  463. 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,
  464. tsd.shop_name as shopName
  465. from tz_order_refund refund
  466. join tz_shop_detail tsd on refund.shop_id = tsd.shop_id
  467. join tz_order o on refund.order_id = o.order_id
  468. <where>
  469. <if test="orderRefund.orderNumber != null">
  470. and refund.order_number = #{orderRefund.orderNumber}
  471. </if>
  472. <if test="orderRefund.channelIdList != null and !orderRefund.channelIdList.isEmpty()">
  473. and o.channel_id in
  474. <foreach collection="orderRefund.channelIdList" item="channelId" open="(" close=")" separator=",">
  475. #{channelId}
  476. </foreach>
  477. </if>
  478. <if test="orderRefund.dvyType != null and orderRefund.dvyType != ''">
  479. and o.dvy_type = #{orderParam.dvyType}
  480. </if>
  481. <if test="orderRefund.refundSn != null">
  482. and refund.refund_sn = #{orderRefund.refundSn}
  483. </if>
  484. <if test="orderRefund.buyerMobile != null">
  485. and refund.buyer_mobile = #{orderRefund.buyerMobile}
  486. </if>
  487. <if test="orderRefund.applyType != null">
  488. and refund.apply_type = #{orderRefund.applyType}
  489. </if>
  490. <if test="orderRefund.returnMoneySts != null and orderRefund.returnMoneySts != 0">
  491. and refund.return_money_sts = #{orderRefund.returnMoneySts}
  492. </if>
  493. <if test="orderRefund.startTime != null">
  494. AND refund.create_time &gt;= #{orderRefund.startTime}
  495. </if>
  496. <if test="orderRefund.endTime != null">
  497. AND refund.create_time &lt;= #{orderRefund.endTime}
  498. </if>
  499. </where>
  500. order by refund.apply_time desc
  501. </select>
  502. <select id="selectInfoById" resultMap="OrderRefundVoMap">
  503. select refund.*,
  504. o.actual_total as actualTotal,
  505. o.product_nums as productNums,
  506. o.hb_order_status as hbOrderStatus,
  507. o.offset_points as OrderOffsetPoints,
  508. o.dvy_type as o_dvy_type,
  509. o.actual_total as OrderActualTotal,
  510. tsd.shop_name as shopName,
  511. uao.receiver as receiver
  512. from tz_order_refund refund
  513. join tz_shop_detail tsd on refund.shop_id = tsd.shop_id
  514. join tz_order o on refund.order_id = o.order_id
  515. left join tz_user_addr_order uao on o.addr_order_id = uao.addr_order_id
  516. where refund.refund_id = #{refundId}
  517. </select>
  518. <select id="findByOrderNumber" resultType="com.yami.shop.bean.model.OrderRefund">
  519. select * from tz_order_refund where return_money_sts=#{returnMoneySts} and order_number =#{orderNumber}
  520. </select>
  521. <select id="findOrderRefund" resultMap="OrderRefundVoMap">
  522. 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,
  523. tsd.shop_name as shopName,d.channel_name
  524. from tz_order_refund refund
  525. join tz_shop_detail tsd on refund.shop_id = tsd.shop_id
  526. join tz_order o on refund.order_id = o.order_id
  527. join tz_channel d on o.channel_id = d.id
  528. join tz_user u on refund.user_id = u.user_id
  529. <where>
  530. <if test="orderRefund.orderNumber != null">
  531. and refund.order_number = #{orderRefund.orderNumber}
  532. </if>
  533. <if test="orderRefund.channelIdList != null and !orderRefund.channelIdList.isEmpty()">
  534. and o.channel_id in
  535. <foreach collection="orderRefund.channelIdList" item="channelId" open="(" close=")" separator=",">
  536. #{channelId}
  537. </foreach>
  538. </if>
  539. <if test="orderRefund.dvyType != null and orderRefund.dvyType != ''">
  540. and o.dvy_type = #{orderParam.dvyType}
  541. </if>
  542. <if test="orderRefund.refundSn != null">
  543. and refund.refund_sn = #{orderRefund.refundSn}
  544. </if>
  545. <if test="orderRefund.buyerMobile != null">
  546. and refund.buyer_mobile = #{orderRefund.buyerMobile}
  547. </if>
  548. <if test="orderRefund.applyType != null">
  549. and refund.apply_type = #{orderRefund.applyType}
  550. </if>
  551. <if test="orderRefund.returnMoneySts != null and orderRefund.returnMoneySts != 0">
  552. and refund.return_money_sts = #{orderRefund.returnMoneySts}
  553. </if>
  554. <if test="orderRefund.startTime != null">
  555. AND refund.create_time &gt;= #{orderRefund.startTime}
  556. </if>
  557. <if test="orderRefund.endTime != null">
  558. AND refund.create_time &lt;= #{orderRefund.endTime}
  559. </if>
  560. </where>
  561. order by refund.apply_time desc
  562. </select>
  563. </mapper>