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.

540 lines
19 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
3 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. crr.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. <where>
  354. <if test="status != null">
  355. and crr.status = #{status}
  356. </if>
  357. <if test="name != null and name.length() > 0">
  358. and crr.name like CONCAT('%', #{name}, '%')
  359. </if>
  360. <if test="jwcode != null">
  361. and crr.jwcode = #{jwcode}
  362. </if>
  363. <if test="markets!= null and markets.size > 0">
  364. AND crr.market IN
  365. <foreach collection="markets" item="markets" open="(" separator="," close=")">
  366. #{markets}
  367. </foreach>
  368. </if>
  369. <if test="statuses!= null and statuses.size > 0">
  370. AND crr.status IN
  371. <foreach collection="statuses" item="statuses" open="(" separator="," close=")">
  372. #{statuses}
  373. </foreach>
  374. </if>
  375. <if test="goodsNames != null and !goodsNames.isEmpty()">
  376. AND (
  377. <foreach collection="goodsNames" item="name" separator=" OR ">
  378. crc.goods_name LIKE CONCAT('%', #{name}, '%')
  379. </foreach>
  380. )
  381. </if>
  382. <if test="refundCurrency != null and refundCurrency.length() > 0">
  383. AND crr.refund_currency like CONCAT('%', #{refundCurrency}, '%')
  384. </if>
  385. <if test="refundChannels != null and refundChannels.length()>0">
  386. and crr.refund_channels like CONCAT('%', #{refundChannels}, '%')
  387. </if>
  388. <if test="sTime != null and eTime != null">
  389. and crr.`refund_time` BETWEEN #{sTime} AND #{eTime}
  390. </if>
  391. <if test=" executor!= null">
  392. and crr.executor = #{executor}
  393. </if>
  394. </where>
  395. <choose>
  396. <when test="sortField != null and sortField.length > 0 or sortOrder != null and sortOrder.length > 0">
  397. ORDER BY ${sortField} ${sortOrder}
  398. </when>
  399. <otherwise>
  400. ORDER BY crr.create_time DESC
  401. </otherwise>
  402. </choose>
  403. </select>
  404. <!-- 批量获取审核人信息 -->
  405. <select id="getAuditBatch" resultType="com.example.demo.domain.vo.cash.LhlAudit">
  406. SELECT *
  407. FROM lhl_audit
  408. WHERE 1 = 0
  409. <if test="auditIds != null and auditIds.size() > 0">
  410. OR id IN
  411. <foreach collection="auditIds" item="id" open="(" separator="," close=")">
  412. #{id}
  413. </foreach>
  414. </if>
  415. </select>
  416. <select id="selectById" resultType="com.example.demo.domain.vo.cash.CashRecordDTO">
  417. select crr.id,
  418. crr.jwcode,
  419. crr.name,
  420. crr.status,
  421. crr.market,
  422. crr.audit_id,
  423. crr.submitter_id,
  424. crr.executor,
  425. crr.related_id,
  426. crr.order_code,
  427. crr.refund_reason,
  428. crr.remark,
  429. crr.reject_reason,
  430. crr.refund_model,
  431. crr.refund_currency,
  432. crr.refund_amount,
  433. crr.refund_channels,
  434. crr.refund_time,
  435. crr.refund_remark,
  436. crr.refund_voucher
  437. from cash_record_refund crr
  438. where crr.id = #{id}
  439. </select>
  440. <select id="selectfunds" resultType="com.example.demo.domain.vo.cash.FundsDTO">
  441. SELECT
  442. crc.id,
  443. crc.jwcode,
  444. crc.income_type,
  445. crc.remark,
  446. crc.good_num,
  447. crc.performance_market,
  448. crc.received_market,
  449. crc.name,
  450. crc.market,
  451. crc.order_code,
  452. crc.payment_currency,
  453. ROUND(crc.payment_amount / 100.0, 2) as paymentAmount,
  454. crc.received_currency,
  455. ROUND(crc.received_amount / 100.0, 2) as receivedAmount,
  456. ROUND(crc.handling_charge / 100.0, 2) as handlingCharge,
  457. ROUND(crc.permanent_gold / 100.0, 2) as permanentGold,
  458. ROUND(crc.free_gold / 100.0, 2) as freeGold,
  459. crc.pay_type,
  460. crc.pay_time,
  461. crc.status
  462. FROM cash_record_collection crc
  463. <where>
  464. <if test="jwcode != null">
  465. and crc.jwcode = #{jwcode}
  466. </if>
  467. <if test="markets!= null and markets.size > 0">
  468. AND crc.received_market IN
  469. <foreach collection="markets" item="markets" open="(" separator="," close=")">
  470. #{markets}
  471. </foreach>
  472. </if>
  473. <if test="performanceMarkets!= null and performanceMarkets.size > 0">
  474. AND crc.performance_market IN
  475. <foreach collection="performanceMarkets" item="performanceMarkets" open="(" separator="," close=")">
  476. #{performanceMarkets}
  477. </foreach>
  478. </if>
  479. <if test="localMarket != null and localMarket.size > 0">
  480. AND crc.market IN
  481. <foreach collection="localMarket" item="localMarket" open="(" separator="," close=")">
  482. #{localMarket}
  483. </foreach>
  484. </if>
  485. <if test="startTime != null and endTime != null">
  486. and crc.`pay_time` BETWEEN #{startTime} AND #{endTime}
  487. </if>
  488. <if test="payType!= null and payType.length > 0">
  489. AND crc.pay_type like CONCAT('%', #{payType}, '%')
  490. </if>
  491. <if test="orderCode!= null and orderCode.length > 0">
  492. AND crc.order_code like CONCAT('%', #{orderCode}, '%')
  493. </if>
  494. <if test="statuses!=null and statuses.size()>0">
  495. and crc.status IN
  496. <foreach collection="statuses" item="statuses" open="(" separator="," close=")">
  497. #{statuses}
  498. </foreach>
  499. </if>
  500. </where>
  501. <choose>
  502. <when test="sortField != null and sortField.length > 0 or sortOrder != null and sortOrder.length > 0">
  503. ORDER BY ${sortField} ${sortOrder}
  504. </when>
  505. <otherwise>
  506. ORDER BY crc.create_time DESC
  507. </otherwise>
  508. </choose>
  509. </select>
  510. <select id="selectRefundCount" resultType="com.example.demo.domain.vo.cash.FundsDTO">
  511. select crr.refund_currency,
  512. crr.refund_amount,
  513. crr.related_id
  514. from cash_record_refund crr
  515. <where>
  516. <if test="needQueryIds != null and needQueryIds.size() > 0">
  517. and crr.related_id IN
  518. <foreach collection="needQueryIds" item="needQueryId" open="(" separator="," close=")">
  519. #{needQueryId}
  520. </foreach>
  521. </if>
  522. </where>
  523. </select>
  524. <update id="updateMessageFlagByOrderId">
  525. UPDATE message
  526. SET flag = 1
  527. WHERE type_id = #{orderId} AND type = 0
  528. </update>
  529. </mapper>