You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

644 lines
24 KiB

6 months ago
6 months ago
6 months ago
5 months ago
6 months ago
5 months ago
6 months ago
6 months ago
5 months ago
2 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
1 month ago
1 month ago
6 months ago
6 months ago
6 months ago
5 months ago
5 months ago
1 month ago
6 months ago
6 months ago
5 months ago
5 months ago
5 months ago
1 month ago
1 month ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
2 months ago
2 months ago
2 months ago
6 months ago
  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.example.demo.mapper.cash.CashRefundMapper">
  4. <insert id="insert" useGeneratedKeys="true"
  5. keyProperty="id"
  6. keyColumn="id">
  7. INSERT INTO cash_record_refund (
  8. jwcode,
  9. name,
  10. market,
  11. order_code,
  12. bank_code,
  13. permanent_gold,
  14. free_gold,
  15. submitter_id,
  16. submitter_market,
  17. remark,
  18. reject_reason,
  19. refund_reason,
  20. refund_model,
  21. executor,
  22. refund_channels,
  23. refund_time,
  24. refund_remark,
  25. refund_voucher,
  26. refund_currency,
  27. refund_amount,
  28. related_id,
  29. audit_id,
  30. status
  31. ) VALUES (
  32. #{jwcode},
  33. #{name},
  34. #{market},
  35. #{orderCode},
  36. #{bankCode},
  37. #{partRefundGold},
  38. #{partRefundFree},
  39. #{submitterId},
  40. #{submitterMarket},
  41. #{remark},
  42. #{rejectReason},
  43. #{refundReason},
  44. #{refundModel},
  45. #{executor},
  46. #{refundChannels},
  47. #{refundTime},
  48. #{refundRemark},
  49. #{refundVoucher},
  50. #{refundCurrency},
  51. #{refundAmount},
  52. #{originalOrderId},
  53. #{auditId},
  54. #{status}
  55. );
  56. </insert>
  57. <insert id="addAudit" parameterType="com.example.demo.domain.vo.cash.CashRecordDone" useGeneratedKeys="true" keyProperty="id">
  58. insert into lhl_audit
  59. (
  60. area_servise,
  61. area_finance,
  62. area_charge,
  63. head_finance
  64. )
  65. values(
  66. #{areaServise},
  67. #{areaFinance},
  68. #{areaCharge},
  69. #{headFinance}
  70. )
  71. </insert>
  72. <!-- ✅ 正确写法:CashRefundMapper.xml -->
  73. <update id="update">
  74. UPDATE cash_record_refund
  75. <set>
  76. status = 10,
  77. refund_model = #{refundModel},
  78. refund_reason = #{refundReason},
  79. <if test="newRefundGold != null">
  80. permanent_gold = #{newRefundGold},
  81. </if>
  82. <if test="newRefundFree != null">
  83. free_gold = #{newRefundFree}
  84. <!-- 注意:最后一个字段不要加逗号!<set> 会自动处理 -->
  85. </if>
  86. </set>
  87. WHERE id = #{id}
  88. </update>
  89. <update id="withdraw">
  90. update cash_record_refund set status = 11
  91. where id = #{id}
  92. </update>
  93. <update id="review">
  94. update cash_record_refund set status = #{status},executor = #{executor},reject_reason = #{rejectReason}
  95. where id = #{id}
  96. </update>
  97. <update id="executor">
  98. update cash_record_refund set refund_currency = #{refundCurrency},
  99. refund_amount = #{refundAmount},
  100. refund_channels = #{refundChannels},
  101. refund_time = #{refundTime},
  102. refund_remark = #{refundRemark},
  103. refund_voucher = #{refundVoucher},
  104. status = #{status},
  105. executor = #{executor}
  106. where id = #{id}
  107. </update>
  108. <update id="updateStatus">
  109. update cash_record_collection
  110. set status = #{status}
  111. <where>
  112. <if test="id != null">
  113. and id = #{id}
  114. </if>
  115. <if test="orderCode != null">
  116. and order_code = #{orderCode}
  117. </if>
  118. </where>
  119. </update>
  120. <update id="updateAudit">
  121. update lhl_audit
  122. <set>
  123. <if test="areaServise != null">
  124. area_servise = #{areaServise},
  125. </if>
  126. <if test="areaFinance != null">
  127. area_finance = #{areaFinance},
  128. </if>
  129. <if test="areaCharge != null">
  130. area_charge = #{areaCharge},
  131. </if>
  132. <if test="headFinance != null">
  133. head_finance = #{headFinance},
  134. </if>
  135. </set>
  136. where id = #{auditId}
  137. </update>
  138. <update id="updategold">
  139. update user_gold_record
  140. set is_refund = 1
  141. where order_code = #{orderCode}
  142. </update>
  143. <select id="select" resultType="com.example.demo.domain.vo.cash.CashRecordDTO">
  144. select
  145. crr.id,
  146. crr.jwcode,
  147. crr.name,
  148. crr.market,
  149. crr.permanent_gold,
  150. crr.free_gold,
  151. crr.audit_id,
  152. crr.status,
  153. crr.submitter_id,
  154. crr.submitter_market,
  155. crr.executor,
  156. crr.order_code,
  157. crr.refund_channels,
  158. crr.refund_time,
  159. crr.create_time,
  160. crr.update_time,
  161. crr.audit_time,
  162. crr.related_id,
  163. la.area_servise,
  164. la.area_finance,
  165. la.area_charge,
  166. la.head_finance,
  167. crc.activity,
  168. crc.goods_name,
  169. crc.good_num as goodsNum,
  170. crc.num_unit,
  171. crc.pay_type,
  172. crc.pay_time,
  173. crc.voucher,
  174. crc.remark,
  175. crr.refund_reason,
  176. crr.refund_remark,
  177. crr.reject_reason,
  178. crc.payment_currency,
  179. crc.payment_amount
  180. from cash_record_refund crr
  181. left join lhl_audit la on la.id = crr.audit_id
  182. left join cash_record_collection crc on crc.id = crr.related_id
  183. <where>
  184. <if test="status != null">
  185. and crr.status = #{status}
  186. </if>
  187. <if test="name != null and name.length() > 0">
  188. and crr.name like CONCAT('%', #{name}, '%')
  189. </if>
  190. <if test="jwcode != null">
  191. and crr.jwcode = #{jwcode}
  192. </if>
  193. <if test="markets!= null and markets.size > 0">
  194. AND crr.market IN
  195. <foreach collection="markets" item="markets" open="(" separator="," close=")">
  196. #{markets}
  197. </foreach>
  198. </if>
  199. <if test="statuses!= null and statuses.size > 0">
  200. AND crr.status IN
  201. <foreach collection="statuses" item="statuses" open="(" separator="," close=")">
  202. #{statuses}
  203. </foreach>
  204. </if>
  205. <if test="paymentCurrency!= null and paymentCurrency.length() > 0">
  206. AND crc.payment_currency LIKE CONCAT('%', #{paymentCurrency}, '%')
  207. </if>
  208. <if test="goodsNames != null and !goodsNames.isEmpty()">
  209. AND (
  210. <foreach collection="goodsNames" item="name" separator=" OR ">
  211. crc.goods_name LIKE CONCAT('%', #{name}, '%')
  212. </foreach>
  213. )
  214. </if>
  215. <if test="payType != null and payType.length()>0">
  216. and crc.pay_type = #{payType}
  217. </if>
  218. <if test="startTime != null and endTime != null">
  219. and crc.`pay_time` BETWEEN #{startTime} AND #{endTime}
  220. </if>
  221. <if test=" submitterId!= null">
  222. and crr.submitter_id = #{submitterId}
  223. </if>
  224. </where>
  225. <choose>
  226. <when test="sortField != null and sortField.length > 0 or sortOrder != null and sortOrder.length > 0">
  227. ORDER BY ${sortField} ${sortOrder}
  228. </when>
  229. <otherwise>
  230. ORDER BY crr.update_time DESC
  231. </otherwise>
  232. </choose>
  233. </select>
  234. <select id="financeSelect" resultType="com.example.demo.domain.vo.cash.CashRecordDTO">
  235. select crr.id,
  236. crr.jwcode,
  237. crr.name,
  238. crr.market,
  239. crc.goods_name,
  240. crr.order_code,
  241. crc.good_num as goodsNum,
  242. crc.num_unit,
  243. crr.refund_model,
  244. crr.submitter_id,
  245. crr.executor,
  246. crr.refund_reason,
  247. crr.remark,
  248. crr.status,
  249. crr.permanent_gold,
  250. crr.free_gold,
  251. crr.audit_id,
  252. crr.related_id,
  253. crr.reject_reason,
  254. la.area_servise,
  255. la.area_finance,
  256. la.area_charge,
  257. la.head_finance
  258. from cash_record_refund crr
  259. left join cash_record_collection crc on crc.id = crr.related_id
  260. left join lhl_audit la on la.id = crr.audit_id
  261. <where>
  262. <if test="status != null">
  263. and crr.status = #{status}
  264. </if>
  265. <if test="name != null and name.length() > 0">
  266. and crr.name like CONCAT('%', #{name}, '%')
  267. </if>
  268. <if test="jwcode != null">
  269. and crr.jwcode = #{jwcode}
  270. </if>
  271. <if test="markets!= null and markets.size > 0">
  272. AND crr.market IN
  273. <foreach collection="markets" item="markets" open="(" separator="," close=")">
  274. #{markets}
  275. </foreach>
  276. </if>
  277. <if test="statuses!= null and statuses.size > 0">
  278. AND crr.status IN
  279. <foreach collection="statuses" item="statuses" open="(" separator="," close=")">
  280. #{statuses}
  281. </foreach>
  282. </if>
  283. <if test="paymentCurrency!= null and paymentCurrency.length() > 0">
  284. AND crc.payment_currency LIKE CONCAT('%', #{paymentCurrency}, '%')
  285. </if>
  286. <!-- <if test="goodsNames!= null and goodsNames.size > 0">-->
  287. <!-- AND crc.goods_name IN-->
  288. <!-- <foreach collection="goodsNames" item="goodsNames" open="(" separator="," close=")">-->
  289. <!-- #{goodsNames}-->
  290. <!-- </foreach>-->
  291. <!-- </if>-->
  292. <if test="goodsName!= null and goodsName.length() > 0">
  293. and crc.goods_name like CONCAT('%', #{goodsName}, '%')
  294. </if>
  295. <if test="payType != null and payType.length()>0">
  296. and crc.pay_type = #{payType}
  297. </if>
  298. <if test="startTime != null and endTime != null">
  299. and crc.`pay_time` BETWEEN #{startTime} AND #{endTime}
  300. </if>
  301. <if test=" submitterId!= null">
  302. and crr.submitter_id = #{submitterId}
  303. </if>
  304. </where>
  305. <choose>
  306. <when test="sortField != null and sortField.length > 0 or sortOrder != null and sortOrder.length > 0">
  307. ORDER BY ${sortField} ${sortOrder}
  308. </when>
  309. <otherwise>
  310. ORDER BY crr.update_time DESC
  311. </otherwise>
  312. </choose>
  313. </select>
  314. <select id="getAudit" resultType="com.example.demo.domain.vo.cash.LhlAudit">
  315. select la.id,
  316. la.area_servise,
  317. la.area_finance,
  318. la.area_charge,
  319. la.head_finance
  320. from lhl_audit la
  321. where la.id = #{id}
  322. </select>
  323. <select id="exSelect" resultType="com.example.demo.domain.vo.cash.CashRecordDTO">
  324. select crr.id,
  325. crr.jwcode,
  326. crr.name,
  327. crr.market,
  328. crc.goods_name,
  329. crc.order_code,
  330. crc.good_num as goodsNum,
  331. crc.num_unit,
  332. crr.refund_model,
  333. r.rate_name as refund_currency,
  334. crr.refund_amount,
  335. crr.refund_channels,
  336. crr.refund_voucher,
  337. crr.refund_time,
  338. crr.executor,
  339. crr.permanent_gold,
  340. crr.free_gold,
  341. crr.status,
  342. crr.audit_id,
  343. crr.submitter_id,
  344. crr.related_id,
  345. crr.refund_reason,
  346. la.area_servise,
  347. la.area_finance,
  348. la.area_charge,
  349. la.head_finance
  350. from cash_record_refund crr
  351. left join cash_record_collection crc on crc.id = crr.related_id
  352. left join lhl_audit la on la.id = crr.audit_id
  353. left join rate r on r.id = crr.refund_currency
  354. <where>
  355. <if test="status != null">
  356. and crr.status = #{status}
  357. </if>
  358. <if test="name != null and name.length() > 0">
  359. and crr.name like CONCAT('%', #{name}, '%')
  360. </if>
  361. <if test="jwcode != null">
  362. and crr.jwcode = #{jwcode}
  363. </if>
  364. <if test="markets!= null and markets.size > 0">
  365. AND crr.market IN
  366. <foreach collection="markets" item="markets" open="(" separator="," close=")">
  367. #{markets}
  368. </foreach>
  369. </if>
  370. <if test="statuses!= null and statuses.size > 0">
  371. AND crr.status IN
  372. <foreach collection="statuses" item="statuses" open="(" separator="," close=")">
  373. #{statuses}
  374. </foreach>
  375. </if>
  376. <if test="goodsNames != null and !goodsNames.isEmpty()">
  377. AND (
  378. <foreach collection="goodsNames" item="name" separator=" OR ">
  379. crc.goods_name LIKE CONCAT('%', #{name}, '%')
  380. </foreach>
  381. )
  382. </if>
  383. <if test="refundCurrency != null and refundCurrency.length() > 0">
  384. AND r.rate_name like CONCAT('%', #{refundCurrency}, '%')
  385. </if>
  386. <if test="refundChannels != null and refundChannels.length()>0">
  387. and crr.refund_channels like CONCAT('%', #{refundChannels}, '%')
  388. </if>
  389. <if test="sTime != null and eTime != null">
  390. and crr.`refund_time` BETWEEN #{sTime} AND #{eTime}
  391. </if>
  392. <if test=" executor!= null">
  393. and crr.executor = #{executor}
  394. </if>
  395. </where>
  396. <choose>
  397. <when test="sortField != null and sortField.length > 0 or sortOrder != null and sortOrder.length > 0">
  398. ORDER BY ${sortField} ${sortOrder}
  399. </when>
  400. <otherwise>
  401. ORDER BY crr.create_time DESC
  402. </otherwise>
  403. </choose>
  404. </select>
  405. <!-- 批量获取审核人信息 -->
  406. <select id="getAuditBatch" resultType="com.example.demo.domain.vo.cash.LhlAudit">
  407. SELECT *
  408. FROM lhl_audit
  409. WHERE 1 = 0
  410. <if test="auditIds != null and auditIds.size() > 0">
  411. OR id IN
  412. <foreach collection="auditIds" item="id" open="(" separator="," close=")">
  413. #{id}
  414. </foreach>
  415. </if>
  416. </select>
  417. <select id="selectById" resultType="com.example.demo.domain.vo.cash.CashRecordDTO">
  418. select crr.id,
  419. crr.jwcode,
  420. crr.name,
  421. crr.status,
  422. crr.market,
  423. crr.audit_id,
  424. crr.submitter_id,
  425. crr.executor,
  426. crr.related_id,
  427. crr.order_code,
  428. crr.refund_reason,
  429. crr.remark,
  430. crr.reject_reason,
  431. crr.refund_model,
  432. r.rate_name as refund_currency,
  433. crr.refund_amount,
  434. crr.refund_channels,
  435. crr.refund_time,
  436. crr.refund_remark,
  437. crr.refund_voucher
  438. from cash_record_refund crr
  439. left join rate r on r.id = crr.refund_currency
  440. where crr.id = #{id}
  441. </select>
  442. <select id="selectfunds" resultType="com.example.demo.domain.vo.cash.FundsDTO">
  443. SELECT * FROM (
  444. SELECT
  445. crc.id,
  446. crc.jwcode,
  447. ra.activity_name,
  448. crc.goods_name,
  449. crc.remark,
  450. crc.good_num,
  451. crc.performance_market,
  452. crc.received_market,
  453. crc.name,
  454. crc.market,
  455. crc.order_code,
  456. crc.payment_currency,
  457. ROUND(crc.payment_amount / 100.0, 2) as paymentAmount,
  458. crc.received_currency,
  459. ROUND(crc.received_amount / 100.0, 2) as receivedAmount,
  460. ROUND(crc.handling_charge / 100.0, 2) as handlingCharge,
  461. ROUND(crc.permanent_gold / 100.0, 2) as permanentGold,
  462. ROUND(crc.free_gold / 100.0, 2) as freeGold,
  463. crc.pay_type,
  464. crc.pay_time,
  465. crc.received_time,
  466. crc.voucher,
  467. crc.status,
  468. NULL as refundCurrency,
  469. NULL as refundAmount,
  470. NULL as relatedId,
  471. 0 as isRefundRow
  472. FROM cash_record_collection crc
  473. left join recharge_activity ra on ra.id = crc.activity
  474. WHERE 1=1
  475. <if test="jwcode != null">
  476. and crc.jwcode = #{jwcode}
  477. </if>
  478. <if test="markets!= null and markets.size > 0">
  479. AND crc.received_market IN
  480. <foreach collection="markets" item="markets" open="(" separator="," close=")">
  481. #{markets}
  482. </foreach>
  483. </if>
  484. <if test="performanceMarkets!= null and performanceMarkets.size > 0">
  485. AND crc.performance_market IN
  486. <foreach collection="performanceMarkets" item="performanceMarkets" open="(" separator="," close=")">
  487. #{performanceMarkets}
  488. </foreach>
  489. </if>
  490. <if test="localMarket != null and localMarket.size > 0">
  491. AND crc.market IN
  492. <foreach collection="localMarket" item="localMarket" open="(" separator="," close=")">
  493. #{localMarket}
  494. </foreach>
  495. </if>
  496. <if test="startTime != null and endTime != null">
  497. and crc.`pay_time` BETWEEN #{startTime} AND #{endTime}
  498. </if>
  499. <if test="orderCode!= null and orderCode.length > 0">
  500. AND crc.order_code like CONCAT('%', #{orderCode}, '%')
  501. </if>
  502. <if test="statuses!=null and statuses.size()>0">
  503. and crc.status IN
  504. <foreach collection="statuses" item="statuses" open="(" separator="," close=")">
  505. #{statuses}
  506. </foreach>
  507. </if>
  508. <if test="areaPayTypeList != null and areaPayTypeList.size() > 0">
  509. <bind name="hasValidCondition" value="false" />
  510. <foreach collection="areaPayTypeList" item="item">
  511. <if test="item.areaId != null and item.areaId != '' and item.payType != null and item.payType != ''">
  512. <bind name="hasValidCondition" value="true" />
  513. </if>
  514. </foreach>
  515. <if test="hasValidCondition">
  516. AND (
  517. <foreach collection="areaPayTypeList" item="item" separator=" OR ">
  518. <if test="item.areaId != null and item.areaId != '' and item.payType != null and item.payType != ''">
  519. (crc.received_market = #{item.areaId,jdbcType=INTEGER} AND crc.pay_type = #{item.payType,jdbcType=VARCHAR})
  520. </if>
  521. </foreach>
  522. )
  523. </if>
  524. </if>
  525. UNION ALL
  526. SELECT
  527. crc.id,
  528. crc.jwcode,
  529. ra.activity_name,
  530. crc.goods_name,
  531. crc.remark,
  532. crc.good_num,
  533. crc.performance_market,
  534. crc.received_market,
  535. crc.name,
  536. crc.market,
  537. CONCAT('TK', crc.order_code) as order_code,
  538. NULL as payment_currency,
  539. NULL as paymentAmount,
  540. crc.received_currency as received_currency,
  541. ROUND(-crr.refund_amount / 100.0, 2) as receivedAmount,
  542. NULL as handlingCharge,
  543. NULL as permanentGold,
  544. NULL as freeGold,
  545. crc.pay_type,
  546. crr.refund_time as pay_time,
  547. crc.received_time,
  548. crc.voucher,
  549. crc.status,
  550. crr.refund_currency as refundCurrency,
  551. ROUND(crr.refund_amount / 100.0, 2) as refundAmount,
  552. crr.related_id as relatedId,
  553. 1 as isRefundRow
  554. FROM cash_record_refund crr
  555. INNER JOIN cash_record_collection crc ON crr.related_id = crc.id
  556. left join recharge_activity ra on ra.id = crc.activity
  557. WHERE crr.status =41
  558. <if test="jwcode != null">
  559. and crc.jwcode = #{jwcode}
  560. </if>
  561. <if test="markets!= null and markets.size > 0">
  562. AND crc.received_market IN
  563. <foreach collection="markets" item="markets" open="(" separator="," close=")">
  564. #{markets}
  565. </foreach>
  566. </if>
  567. <if test="statuses!=null and statuses.size()>0">
  568. and crc.status IN
  569. <foreach collection="statuses" item="statuses" open="(" separator="," close=")">
  570. #{statuses}
  571. </foreach>
  572. </if>
  573. <if test="performanceMarkets!= null and performanceMarkets.size > 0">
  574. AND crc.performance_market IN
  575. <foreach collection="performanceMarkets" item="performanceMarkets" open="(" separator="," close=")">
  576. #{performanceMarkets}
  577. </foreach>
  578. </if>
  579. <if test="localMarket != null and localMarket.size > 0">
  580. AND crc.market IN
  581. <foreach collection="localMarket" item="localMarket" open="(" separator="," close=")">
  582. #{localMarket}
  583. </foreach>
  584. </if>
  585. <if test="startTime != null and endTime != null">
  586. and crc.`pay_time` BETWEEN #{startTime} AND #{endTime}
  587. </if>
  588. <if test="orderCode!= null and orderCode.length > 0">
  589. AND crc.order_code like CONCAT('%', #{orderCode}, '%')
  590. </if>
  591. <if test="areaPayTypeList != null and areaPayTypeList.size() > 0">
  592. <bind name="hasValidCondition" value="false" />
  593. <foreach collection="areaPayTypeList" item="item">
  594. <if test="item.areaId != null and item.areaId != '' and item.payType != null and item.payType != ''">
  595. <bind name="hasValidCondition" value="true" />
  596. </if>
  597. </foreach>
  598. <if test="hasValidCondition">
  599. AND (
  600. <foreach collection="areaPayTypeList" item="item" separator=" OR ">
  601. <if test="item.areaId != null and item.areaId != '' and item.payType != null and item.payType != ''">
  602. (crc.received_market = #{item.areaId,jdbcType=INTEGER} AND crc.pay_type = #{item.payType,jdbcType=VARCHAR})
  603. </if>
  604. </foreach>
  605. )
  606. </if>
  607. </if>
  608. ) AS combined_result
  609. ORDER BY
  610. id,
  611. isRefundRow DESC,
  612. pay_time DESC
  613. </select>
  614. <select id="selectRefundCount" resultType="com.example.demo.domain.vo.cash.FundsDTO">
  615. select crr.refund_currency,
  616. crr.refund_amount,
  617. crr.related_id
  618. from cash_record_refund crr
  619. <where>
  620. <if test="needQueryIds != null and needQueryIds.size() > 0">
  621. and crr.related_id IN
  622. <foreach collection="needQueryIds" item="needQueryId" open="(" separator="," close=")">
  623. #{needQueryId}
  624. </foreach>
  625. </if>
  626. </where>
  627. </select>
  628. <update id="updateMessageFlagByOrderId">
  629. UPDATE message
  630. SET flag = 1
  631. WHERE type_id = #{orderId} AND type = 0
  632. </update>
  633. </mapper>