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.

527 lines
19 KiB

5 months ago
5 months ago
5 months ago
3 months ago
5 months ago
3 months ago
5 months ago
5 months ago
3 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
4 months ago
4 months ago
5 months ago
5 months ago
4 months ago
3 months ago
3 months ago
5 months ago
5 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
5 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.size > 0">
  209. AND crc.goods_name IN
  210. <foreach collection="goodsNames" item="goodsNames" open="(" separator="," close=")">
  211. #{goodsNames}
  212. </foreach>
  213. </if>
  214. <if test="payType != null and payType.length()>0">
  215. and crc.pay_type = #{payType}
  216. </if>
  217. <if test="startTime != null and endTime != null">
  218. and crc.`pay_time` BETWEEN #{startTime} AND #{endTime}
  219. </if>
  220. <if test=" submitterId!= null">
  221. and crr.submitter_id = #{submitterId}
  222. </if>
  223. </where>
  224. <choose>
  225. <when test="sortField != null and sortField.length > 0 or sortOrder != null and sortOrder.length > 0">
  226. ORDER BY ${sortField} ${sortOrder}
  227. </when>
  228. <otherwise>
  229. ORDER BY crr.update_time DESC
  230. </otherwise>
  231. </choose>
  232. </select>
  233. <select id="financeSelect" resultType="com.example.demo.domain.vo.cash.CashRecordDTO">
  234. select crr.id,
  235. crr.jwcode,
  236. crr.name,
  237. crr.market,
  238. crc.goods_name,
  239. crr.order_code,
  240. crc.good_num as goodsNum,
  241. crc.num_unit,
  242. crr.refund_model,
  243. crr.submitter_id,
  244. crr.executor,
  245. crr.refund_reason,
  246. crr.remark,
  247. crr.status,
  248. crr.permanent_gold,
  249. crr.free_gold,
  250. crr.audit_id,
  251. crr.related_id,
  252. crr.reject_reason,
  253. la.area_servise,
  254. la.area_finance,
  255. la.area_charge,
  256. la.head_finance
  257. from cash_record_refund crr
  258. left join cash_record_collection crc on crc.id = crr.related_id
  259. left join lhl_audit la on la.id = crr.audit_id
  260. <where>
  261. <if test="status != null">
  262. and crr.status = #{status}
  263. </if>
  264. <if test="name != null and name.length() > 0">
  265. and crr.name like CONCAT('%', #{name}, '%')
  266. </if>
  267. <if test="jwcode != null">
  268. and crr.jwcode = #{jwcode}
  269. </if>
  270. <if test="markets!= null and markets.size > 0">
  271. AND crr.market IN
  272. <foreach collection="markets" item="markets" open="(" separator="," close=")">
  273. #{markets}
  274. </foreach>
  275. </if>
  276. <if test="statuses!= null and statuses.size > 0">
  277. AND crr.status IN
  278. <foreach collection="statuses" item="statuses" open="(" separator="," close=")">
  279. #{statuses}
  280. </foreach>
  281. </if>
  282. <if test="paymentCurrency!= null and paymentCurrency.length() > 0">
  283. AND crc.payment_currency LIKE CONCAT('%', #{paymentCurrency}, '%')
  284. </if>
  285. <!-- <if test="goodsNames!= null and goodsNames.size > 0">-->
  286. <!-- AND crc.goods_name IN-->
  287. <!-- <foreach collection="goodsNames" item="goodsNames" open="(" separator="," close=")">-->
  288. <!-- #{goodsNames}-->
  289. <!-- </foreach>-->
  290. <!-- </if>-->
  291. <if test="goodsName!= null and goodsName.length() > 0">
  292. and crc.goods_name = #{goodsName}
  293. </if>
  294. <if test="payType != null and payType.length()>0">
  295. and crc.pay_type = #{payType}
  296. </if>
  297. <if test="startTime != null and endTime != null">
  298. and crc.`pay_time` BETWEEN #{startTime} AND #{endTime}
  299. </if>
  300. <if test=" submitterId!= null">
  301. and crr.submitter_id = #{submitterId}
  302. </if>
  303. </where>
  304. <choose>
  305. <when test="sortField != null and sortField.length > 0 or sortOrder != null and sortOrder.length > 0">
  306. ORDER BY ${sortField} ${sortOrder}
  307. </when>
  308. <otherwise>
  309. ORDER BY crr.update_time DESC
  310. </otherwise>
  311. </choose>
  312. </select>
  313. <select id="getAudit" resultType="com.example.demo.domain.vo.cash.LhlAudit">
  314. select la.id,
  315. la.area_servise,
  316. la.area_finance,
  317. la.area_charge,
  318. la.head_finance
  319. from lhl_audit la
  320. where la.id = #{id}
  321. </select>
  322. <select id="exSelect" resultType="com.example.demo.domain.vo.cash.CashRecordDTO">
  323. select crr.id,
  324. crr.jwcode,
  325. crr.name,
  326. crr.market,
  327. crc.goods_name,
  328. crc.order_code,
  329. crc.good_num as goodsNum,
  330. crc.num_unit,
  331. crr.refund_model,
  332. crr.refund_currency,
  333. crr.refund_amount,
  334. crr.refund_channels,
  335. crr.refund_voucher,
  336. crr.refund_time,
  337. crr.executor,
  338. crr.permanent_gold,
  339. crr.free_gold,
  340. crr.status,
  341. crr.audit_id,
  342. crr.submitter_id,
  343. crr.related_id,
  344. crr.refund_reason,
  345. la.area_servise,
  346. la.area_finance,
  347. la.area_charge,
  348. la.head_finance
  349. from cash_record_refund crr
  350. left join cash_record_collection crc on crc.id = crr.related_id
  351. left join lhl_audit la on la.id = crr.audit_id
  352. <where>
  353. <if test="status != null">
  354. and crr.status = #{status}
  355. </if>
  356. <if test="name != null and name.length() > 0">
  357. and crr.name like CONCAT('%', #{name}, '%')
  358. </if>
  359. <if test="jwcode != null">
  360. and crr.jwcode = #{jwcode}
  361. </if>
  362. <if test="markets!= null and markets.size > 0">
  363. AND crr.market IN
  364. <foreach collection="markets" item="markets" open="(" separator="," close=")">
  365. #{markets}
  366. </foreach>
  367. </if>
  368. <if test="statuses!= null and statuses.size > 0">
  369. AND crr.status IN
  370. <foreach collection="statuses" item="statuses" open="(" separator="," close=")">
  371. #{statuses}
  372. </foreach>
  373. </if>
  374. <if test="goodsNames!= null and goodsNames.size > 0">
  375. AND crc.goods_name IN
  376. <foreach collection="goodsNames" item="goodsNames" open="(" separator="," close=")">
  377. #{goodsNames}
  378. </foreach>
  379. </if>
  380. <if test="refundCurrency != null and refundCurrency.length() > 0">
  381. AND crr.refund_currency like CONCAT('%', #{refundCurrency}, '%')
  382. </if>
  383. <if test="refundChannels != null and refundChannels.length()>0">
  384. and crr.refund_channels like CONCAT('%', #{refundChannels}, '%')
  385. </if>
  386. <if test="sTime != null and eTime != null">
  387. and crr.`refund_time` BETWEEN #{sTime} AND #{eTime}
  388. </if>
  389. <if test=" executor!= null">
  390. and crr.executor = #{executor}
  391. </if>
  392. </where>
  393. <choose>
  394. <when test="sortField != null and sortField.length > 0 or sortOrder != null and sortOrder.length > 0">
  395. ORDER BY ${sortField} ${sortOrder}
  396. </when>
  397. <otherwise>
  398. ORDER BY crr.create_time DESC
  399. </otherwise>
  400. </choose>
  401. </select>
  402. <!-- 批量获取审核人信息 -->
  403. <select id="getAuditBatch" resultType="com.example.demo.domain.vo.cash.LhlAudit">
  404. SELECT *
  405. FROM lhl_audit
  406. WHERE 1 = 0
  407. <if test="auditIds != null and auditIds.size() > 0">
  408. OR id IN
  409. <foreach collection="auditIds" item="id" open="(" separator="," close=")">
  410. #{id}
  411. </foreach>
  412. </if>
  413. </select>
  414. <select id="selectById" resultType="com.example.demo.domain.vo.cash.CashRecordDTO">
  415. select crr.id,
  416. crr.jwcode,
  417. crr.name,
  418. crr.status,
  419. crr.market,
  420. crr.audit_id,
  421. crr.submitter_id,
  422. crr.executor,
  423. crr.related_id,
  424. crr.order_code,
  425. crr.refund_reason,
  426. crr.remark,
  427. crr.reject_reason,
  428. crr.refund_model,
  429. crr.refund_currency,
  430. crr.refund_amount,
  431. crr.refund_channels,
  432. crr.refund_time,
  433. crr.refund_remark,
  434. crr.refund_voucher
  435. from cash_record_refund crr
  436. where crr.id = #{id}
  437. </select>
  438. <select id="selectfunds" resultType="com.example.demo.domain.vo.cash.FundsDTO">
  439. SELECT
  440. crc.id,
  441. crc.jwcode,
  442. crc.name,
  443. crc.market,
  444. crc.order_code,
  445. crc.payment_currency,
  446. ROUND(crc.payment_amount / 100.0, 2) as paymentAmount,
  447. crc.received_currency,
  448. ROUND(crc.received_amount / 100.0, 2) as receivedAmount,
  449. ROUND(crc.handling_charge / 100.0, 2) as handlingCharge,
  450. ROUND(crc.permanent_gold / 100.0, 2) as permanentGold,
  451. ROUND(crc.free_gold / 100.0, 2) as freeGold,
  452. crc.pay_type,
  453. crc.pay_time,
  454. crc.status
  455. FROM cash_record_collection crc
  456. <where>
  457. <if test="jwcode != null">
  458. and crc.jwcode = #{jwcode}
  459. </if>
  460. <if test="markets!= null and markets.size > 0">
  461. AND crc.received_market IN
  462. <foreach collection="markets" item="markets" open="(" separator="," close=")">
  463. #{markets}
  464. </foreach>
  465. </if>
  466. <if test="localMarket != null and localMarket.size > 0">
  467. AND crc.market IN
  468. <foreach collection="localMarket" item="localMarket" open="(" separator="," close=")">
  469. #{localMarket}
  470. </foreach>
  471. </if>
  472. <if test="startTime != null and endTime != null">
  473. and crc.`pay_time` BETWEEN #{startTime} AND #{endTime}
  474. </if>
  475. <if test="payType!= null and payType.length > 0">
  476. AND crc.pay_type like CONCAT('%', #{payType}, '%')
  477. </if>
  478. <if test="orderCode!= null and orderCode.length > 0">
  479. AND crc.order_code like CONCAT('%', #{orderCode}, '%')
  480. </if>
  481. <if test="statuses!=null and statuses.size()>0">
  482. and crc.status IN
  483. <foreach collection="statuses" item="statuses" open="(" separator="," close=")">
  484. #{statuses}
  485. </foreach>
  486. </if>
  487. </where>
  488. <choose>
  489. <when test="sortField != null and sortField.length > 0 or sortOrder != null and sortOrder.length > 0">
  490. ORDER BY ${sortField} ${sortOrder}
  491. </when>
  492. <otherwise>
  493. ORDER BY crc.create_time DESC
  494. </otherwise>
  495. </choose>
  496. </select>
  497. <select id="selectRefundCount" resultType="com.example.demo.domain.vo.cash.FundsDTO">
  498. select crr.refund_currency,
  499. crr.refund_amount,
  500. crr.related_id
  501. from cash_record_refund crr
  502. <where>
  503. <if test="needQueryIds != null and needQueryIds.size() > 0">
  504. and crr.related_id IN
  505. <foreach collection="needQueryIds" item="needQueryId" open="(" separator="," close=")">
  506. #{needQueryId}
  507. </foreach>
  508. </if>
  509. </where>
  510. </select>
  511. <update id="updateMessageFlagByOrderId">
  512. UPDATE message
  513. SET flag = 1
  514. WHERE type_id = #{orderId} AND type = 0
  515. </update>
  516. </mapper>