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.

481 lines
17 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
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. <select id="select" resultType="com.example.demo.domain.vo.cash.CashRecordDTO">
  139. select
  140. crr.id,
  141. crr.jwcode,
  142. crr.name,
  143. crr.market,
  144. crr.permanent_gold,
  145. crr.free_gold,
  146. crr.audit_id,
  147. crr.status,
  148. crr.submitter_id,
  149. crr.submitter_market,
  150. crr.executor,
  151. crr.order_code,
  152. crr.refund_channels,
  153. crr.refund_time,
  154. crr.create_time,
  155. crr.update_time,
  156. crr.audit_time,
  157. crr.related_id,
  158. la.area_servise,
  159. la.area_finance,
  160. la.area_charge,
  161. la.head_finance,
  162. crc.activity,
  163. crc.goods_name,
  164. crc.good_num as goodsNum,
  165. crc.num_unit,
  166. crc.pay_type,
  167. crc.pay_time,
  168. crc.voucher,
  169. crc.remark,
  170. crc.payment_currency,
  171. crc.payment_amount
  172. from cash_record_refund crr
  173. left join lhl_audit la on la.id = crr.audit_id
  174. left join cash_record_collection crc on crc.id = crr.related_id
  175. <where>
  176. <if test="status != null">
  177. and crr.status = #{status}
  178. </if>
  179. <if test="name != null and name.length() > 0">
  180. and crr.name like CONCAT('%', #{name}, '%')
  181. </if>
  182. <if test="jwcode != null">
  183. and crr.jwcode = #{jwcode}
  184. </if>
  185. <if test="markets!= null and markets.size > 0">
  186. AND crr.market IN
  187. <foreach collection="markets" item="markets" open="(" separator="," close=")">
  188. #{markets}
  189. </foreach>
  190. </if>
  191. <if test="statuses!= null and statuses.size > 0">
  192. AND crr.status IN
  193. <foreach collection="statuses" item="statuses" open="(" separator="," close=")">
  194. #{statuses}
  195. </foreach>
  196. </if>
  197. <if test="paymentCurrency!= null and paymentCurrency.length() > 0">
  198. AND crc.payment_currency LIKE CONCAT('%', #{paymentCurrency}, '%')
  199. </if>
  200. <if test="goodsNames!= null and goodsNames.size > 0">
  201. AND crc.goods_name IN
  202. <foreach collection="goodsNames" item="goodsNames" open="(" separator="," close=")">
  203. #{goodsNames}
  204. </foreach>
  205. </if>
  206. <if test="payType != null and payType.length()>0">
  207. and crc.pay_type = #{payType}
  208. </if>
  209. <if test="startTime != null and endTime != null">
  210. and crc.`pay_time` BETWEEN #{startTime} AND #{endTime}
  211. </if>
  212. <if test=" submitterId!= null">
  213. and crr.submitter_id = #{submitterId}
  214. </if>
  215. </where>
  216. <choose>
  217. <when test="sortField != null and sortField.length > 0 or sortOrder != null and sortOrder.length > 0">
  218. ORDER BY ${sortField} ${sortOrder}
  219. </when>
  220. <otherwise>
  221. ORDER BY crr.create_time DESC
  222. </otherwise>
  223. </choose>
  224. </select>
  225. <select id="financeSelect" resultType="com.example.demo.domain.vo.cash.CashRecordDTO">
  226. select crr.id,
  227. crr.jwcode,
  228. crr.name,
  229. crr.market,
  230. crc.goods_name,
  231. crr.order_code,
  232. crc.good_num as goodsNum,
  233. crc.num_unit,
  234. crr.refund_model,
  235. crr.submitter_id,
  236. crr.executor,
  237. crr.refund_reason,
  238. crr.remark,
  239. crr.status,
  240. crr.permanent_gold,
  241. crr.free_gold,
  242. crr.audit_id,
  243. crr.related_id,
  244. la.area_servise,
  245. la.area_finance,
  246. la.area_charge,
  247. la.head_finance
  248. from cash_record_refund crr
  249. left join cash_record_collection crc on crc.id = crr.related_id
  250. left join lhl_audit la on la.id = crr.audit_id
  251. <where>
  252. <if test="status != null">
  253. and crr.status = #{status}
  254. </if>
  255. <if test="name != null and name.length() > 0">
  256. and crr.name like CONCAT('%', #{name}, '%')
  257. </if>
  258. <if test="jwcode != null">
  259. and crr.jwcode = #{jwcode}
  260. </if>
  261. <if test="markets!= null and markets.size > 0">
  262. AND crr.market IN
  263. <foreach collection="markets" item="markets" open="(" separator="," close=")">
  264. #{markets}
  265. </foreach>
  266. </if>
  267. <if test="statuses!= null and statuses.size > 0">
  268. AND crr.status IN
  269. <foreach collection="statuses" item="statuses" open="(" separator="," close=")">
  270. #{statuses}
  271. </foreach>
  272. </if>
  273. <if test="paymentCurrency!= null and paymentCurrency.length() > 0">
  274. AND crc.payment_currency LIKE CONCAT('%', #{paymentCurrency}, '%')
  275. </if>
  276. <!-- <if test="goodsNames!= null and goodsNames.size > 0">-->
  277. <!-- AND crc.goods_name IN-->
  278. <!-- <foreach collection="goodsNames" item="goodsNames" open="(" separator="," close=")">-->
  279. <!-- #{goodsNames}-->
  280. <!-- </foreach>-->
  281. <!-- </if>-->
  282. <if test="goodsName!= null and goodsName.length() > 0">
  283. and crc.goods_name = #{goodsName}
  284. </if>
  285. <if test="payType != null and payType.length()>0">
  286. and crc.pay_type = #{payType}
  287. </if>
  288. <if test="startTime != null and endTime != null">
  289. and crc.`pay_time` BETWEEN #{startTime} AND #{endTime}
  290. </if>
  291. <if test=" submitterId!= null">
  292. and crr.submitter_id = #{submitterId}
  293. </if>
  294. </where>
  295. <choose>
  296. <when test="sortField != null and sortField.length > 0 or sortOrder != null and sortOrder.length > 0">
  297. ORDER BY ${sortField} ${sortOrder}
  298. </when>
  299. <otherwise>
  300. ORDER BY crr.create_time DESC
  301. </otherwise>
  302. </choose>
  303. </select>
  304. <select id="getAudit" resultType="com.example.demo.domain.vo.cash.LhlAudit">
  305. select la.id,
  306. la.area_servise,
  307. la.area_finance,
  308. la.area_charge,
  309. la.head_finance
  310. from lhl_audit la
  311. where la.id = #{id}
  312. </select>
  313. <select id="exSelect" resultType="com.example.demo.domain.vo.cash.CashRecordDTO">
  314. select crr.id,
  315. crr.jwcode,
  316. crr.name,
  317. crr.market,
  318. crc.goods_name,
  319. crc.order_code,
  320. crc.good_num as goodsNum,
  321. crc.num_unit,
  322. crr.refund_model,
  323. crr.refund_currency,
  324. crr.refund_amount,
  325. crr.refund_channels,
  326. crr.refund_voucher,
  327. crr.refund_time,
  328. crr.executor,
  329. crr.status,
  330. crr.audit_id,
  331. crr.submitter_id,
  332. crr.related_id,
  333. la.area_servise,
  334. la.area_finance,
  335. la.area_charge,
  336. la.head_finance
  337. from cash_record_refund crr
  338. left join cash_record_collection crc on crc.id = crr.related_id
  339. left join lhl_audit la on la.id = crr.audit_id
  340. <where>
  341. <if test="status != null">
  342. and crr.status = #{status}
  343. </if>
  344. <if test="name != null and name.length() > 0">
  345. and crr.name like CONCAT('%', #{name}, '%')
  346. </if>
  347. <if test="jwcode != null">
  348. and crr.jwcode = #{jwcode}
  349. </if>
  350. <if test="markets!= null and markets.size > 0">
  351. AND crr.market IN
  352. <foreach collection="markets" item="markets" open="(" separator="," close=")">
  353. #{markets}
  354. </foreach>
  355. </if>
  356. <if test="statuses!= null and statuses.size > 0">
  357. AND crr.status IN
  358. <foreach collection="statuses" item="statuses" open="(" separator="," close=")">
  359. #{statuses}
  360. </foreach>
  361. </if>
  362. <if test="goodsNames!= null and goodsNames.size > 0">
  363. AND crc.goods_name IN
  364. <foreach collection="goodsNames" item="goodsNames" open="(" separator="," close=")">
  365. #{goodsNames}
  366. </foreach>
  367. </if>
  368. <if test="refundCurrency != null and refundCurrency.length() > 0">
  369. AND crr.refund_currency = #{refundCurrency}
  370. </if>
  371. <if test="refundChannels != null and refundChannels.length()>0">
  372. and crr.refund_channels = #{refundChannels}
  373. </if>
  374. <if test="sTime != null and eTime != null">
  375. and crr.`refund_time` BETWEEN #{sTime} AND #{eTime}
  376. </if>
  377. <if test=" executor!= null">
  378. and crr.executor = #{executor}
  379. </if>
  380. </where>
  381. <choose>
  382. <when test="sortField != null and sortField.length > 0 or sortOrder != null and sortOrder.length > 0">
  383. ORDER BY ${sortField} ${sortOrder}
  384. </when>
  385. <otherwise>
  386. ORDER BY crr.create_time DESC
  387. </otherwise>
  388. </choose>
  389. </select>
  390. <!-- 批量获取审核人信息 -->
  391. <select id="getAuditBatch" resultType="com.example.demo.domain.vo.cash.LhlAudit">
  392. SELECT *
  393. FROM lhl_audit
  394. WHERE 1 = 0
  395. <if test="auditIds != null and auditIds.size() > 0">
  396. OR id IN
  397. <foreach collection="auditIds" item="id" open="(" separator="," close=")">
  398. #{id}
  399. </foreach>
  400. </if>
  401. </select>
  402. <select id="selectById" resultType="com.example.demo.domain.vo.cash.CashRecordDTO">
  403. select crr.id,
  404. crr.jwcode,
  405. crr.name,
  406. crr.status
  407. from cash_record_refund crr
  408. where crr.id = #{id}
  409. </select>
  410. <select id="selectfunds" resultType="com.example.demo.domain.vo.cash.FundsDTO">
  411. SELECT
  412. crc.id,
  413. crc.jwcode,
  414. crc.name,
  415. crc.market,
  416. crc.order_code,
  417. crc.payment_currency,
  418. ROUND(crc.payment_amount / 100.0, 2) as paymentAmount,
  419. crc.received_currency,
  420. ROUND(crc.received_amount / 100.0, 2) as receivedAmount,
  421. ROUND(crc.handling_charge / 100.0, 2) as handlingCharge,
  422. ROUND(crc.permanent_gold / 100.0, 2) as permanentGold,
  423. ROUND(crc.free_gold / 100.0, 2) as freeGold,
  424. crc.pay_type,
  425. crc.pay_time,
  426. crc.status
  427. FROM cash_record_collection crc
  428. <where>
  429. <if test="jwcode != null">
  430. and crc.jwcode = #{jwcode}
  431. </if>
  432. <if test="markets!= null and markets.size > 0">
  433. AND crc.received_market IN
  434. <foreach collection="markets" item="markets" open="(" separator="," close=")">
  435. #{markets}
  436. </foreach>
  437. </if>
  438. <if test="startTime != null and endTime != null">
  439. and crc.`pay_time` BETWEEN #{startTime} AND #{endTime}
  440. </if>
  441. <if test="payType!= null and payType.length > 0">
  442. AND crc.pay_type like CONCAT('%', #{payType}, '%')
  443. </if>
  444. <if test="orderCode!= null and orderCode.length > 0">
  445. AND crc.order_code like CONCAT('%', #{orderCode}, '%')
  446. </if>
  447. <if test="statuses!=null and statuses.size()>0">
  448. and crc.status IN
  449. <foreach collection="statuses" item="statuses" open="(" separator="," close=")">
  450. #{statuses}
  451. </foreach>
  452. </if>
  453. </where>
  454. </select>
  455. <select id="selectRefundCount" resultType="com.example.demo.domain.vo.cash.FundsDTO">
  456. select crr.refund_currency,
  457. crr.refund_amount,
  458. crr.related_id
  459. from cash_record_refund crr
  460. <where>
  461. <if test="needQueryIds != null and needQueryIds.size() > 0">
  462. and crr.related_id IN
  463. <foreach collection="needQueryIds" item="needQueryId" open="(" separator="," close=")">
  464. #{needQueryId}
  465. </foreach>
  466. </if>
  467. </where>
  468. </select>
  469. </mapper>