FinanceController.java 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. package com.kym.admin.controller;
  2. import cn.dev33.satoken.annotation.SaCheckPermission;
  3. import com.kym.common.R;
  4. import com.kym.common.annotation.SysLog;
  5. import com.kym.entity.queryParams.*;
  6. import com.kym.entity.queryParams.WalletDetailQueryParam;
  7. import com.kym.service.*;
  8. import com.kym.service.wechat.WxPayService;
  9. import jakarta.validation.Valid;
  10. import java.util.Map;
  11. import org.springframework.web.bind.annotation.*;
  12. /**
  13. * 财务
  14. *
  15. * @author skyline
  16. * @since 2025-02-24
  17. */
  18. @RestController
  19. @RequestMapping("/finance")
  20. public class FinanceController {
  21. private final SplitRecordService splitRecordService;
  22. private final StationAccountService stationAccountService;
  23. private final WithdrawnRecordService withdrawnRecordService;
  24. private final SettlementService settlementService;
  25. private final WxPayService wxPayService;
  26. private final RefundLogService refundLogService;
  27. private final PlatformAccountService platformAccountService;
  28. private final PlatformRevenueRecordService platformRevenueRecordService;
  29. private final WalletDetailService walletDetailService;
  30. public FinanceController(SplitRecordService splitRecordService, StationAccountService stationAccountService,
  31. WithdrawnRecordService withdrawnRecordService, SettlementService settlementService,
  32. WxPayService wxPayService, RefundLogService refundLogService,
  33. PlatformAccountService platformAccountService, PlatformRevenueRecordService platformRevenueRecordService,
  34. WalletDetailService walletDetailService) {
  35. this.splitRecordService = splitRecordService;
  36. this.stationAccountService = stationAccountService;
  37. this.withdrawnRecordService = withdrawnRecordService;
  38. this.settlementService = settlementService;
  39. this.wxPayService = wxPayService;
  40. this.refundLogService = refundLogService;
  41. this.platformAccountService = platformAccountService;
  42. this.platformRevenueRecordService = platformRevenueRecordService;
  43. this.walletDetailService = walletDetailService;
  44. }
  45. /**
  46. * 站点账户列表
  47. *
  48. * @param params
  49. * @return
  50. */
  51. @PostMapping("/stationAccounts")
  52. public R<?> stationAccounts(@RequestBody StationQueryParam params) {
  53. return R.success(stationAccountService.listStationAccounts(params));
  54. }
  55. /**
  56. * 分账记录列表
  57. *
  58. * @param params
  59. * @return
  60. */
  61. @PostMapping("/splitRecords")
  62. public R<?> splitRecords(@RequestBody SplitRecordQueryParams params) {
  63. return R.success(splitRecordService.listSplitRecords(params));
  64. }
  65. /**
  66. * 申请提现
  67. *
  68. * @param params
  69. * @return
  70. */
  71. @SaCheckPermission("withdrawnRecord.modify")
  72. @PostMapping("/applyWithdrawn")
  73. public R<?> applyWithdrawn(@RequestBody WithdrawnQueryParam params) {
  74. stationAccountService.applyWithdrawn(params);
  75. return R.success();
  76. }
  77. /**
  78. * 提现记录列表
  79. *
  80. * @param params
  81. * @return
  82. */
  83. @PostMapping("/withdrawnRecords")
  84. public R<?> withdrawnRecords(@RequestBody WithdrawnQueryParam params) {
  85. return R.success(withdrawnRecordService.listWithdrawnRecords(params));
  86. }
  87. /**
  88. * 提现记录审核
  89. *
  90. * @param params
  91. * @return
  92. */
  93. @SaCheckPermission("withdrawnRecord.modify")
  94. @PostMapping("/reviewWithdrawn")
  95. public R<?> reviewWithdrawn(@RequestBody WithdrawnQueryParam params) {
  96. withdrawnRecordService.reviewWithdrawn(params);
  97. return R.success();
  98. }
  99. /**
  100. * 提现记录打款确认
  101. *
  102. * @param params
  103. * @return
  104. */
  105. @SaCheckPermission("withdrawnRecord.modify")
  106. @PostMapping("/confirmWithdrawnPayment")
  107. public R<?> confirmWithdrawnPayment(@RequestBody WithdrawnQueryParam params) {
  108. withdrawnRecordService.confirmWithdrawnPayment(params);
  109. return R.success();
  110. }
  111. /**
  112. * 处理用户退款
  113. *
  114. * @param refundLogId
  115. * @return
  116. */
  117. @SaCheckPermission("refundLog.modify")
  118. @SysLog("处理用户微信退款")
  119. @GetMapping("/customWxRefund/{refundLogId}")
  120. R<?> customWxRefund(@PathVariable("refundLogId") long refundLogId) {
  121. wxPayService.wxRefund(refundLogId);
  122. return R.success();
  123. }
  124. /**
  125. * 批量处理用户退款
  126. */
  127. @SaCheckPermission("refundLog.modify")
  128. @SysLog("批量处理用户微信退款")
  129. @PostMapping("/batchWxRefund")
  130. R<?> batchWxRefund(@RequestBody java.util.List<Long> refundLogIds) {
  131. wxPayService.batchWxRefund(refundLogIds);
  132. return R.success();
  133. }
  134. /**
  135. * 退款记录列表
  136. *
  137. * @param params
  138. * @return
  139. */
  140. @SysLog("退款记录列表")
  141. @GetMapping("/listRefundLog")
  142. public R<?> listRefundLog(@ModelAttribute CommonQueryParam params) {
  143. return R.success(refundLogService.listRefundLog(params));
  144. }
  145. /**
  146. * 处理用户退款
  147. *
  148. * @param param
  149. * @return
  150. */
  151. @SaCheckPermission("refundLog.modify")
  152. @SysLog("用户退款申请")
  153. @PostMapping("/applyRefund")
  154. @ResponseBody
  155. R<?> wxAppRefund(@Valid @RequestBody RefundParam param) {
  156. wxPayService.applyWxRefund(param.getUserId(), param.getReason());
  157. return R.success();
  158. }
  159. /**
  160. * 结算记录列表
  161. */
  162. @PostMapping("/settlementRecords")
  163. public R<?> settlementRecords(@RequestBody SettlementQueryParam params) {
  164. return R.success(settlementService.listSettlementRecords(params));
  165. }
  166. /**
  167. * 手动触发结算(运维用)
  168. */
  169. @SaCheckPermission("settlement.modify")
  170. @SysLog("手动触发月度结算")
  171. @PostMapping("/triggerSettlement")
  172. public R<?> triggerSettlement() {
  173. settlementService.executeMonthlySettlement();
  174. return R.success();
  175. }
  176. /**
  177. * 确认结算 — 将待结算金额转入站点可提现余额
  178. */
  179. @SaCheckPermission("settlement.modify")
  180. @SysLog("确认结算")
  181. @PostMapping("/confirmSettlement")
  182. public R<?> confirmSettlement(@RequestBody Map<String, Long> params) {
  183. settlementService.confirmSettlement(params.get("id"));
  184. return R.success();
  185. }
  186. /**
  187. * 平台账户信息
  188. */
  189. @PostMapping("/platformAccount")
  190. public R<?> platformAccount() {
  191. return R.success(platformAccountService.getPlatformAccount());
  192. }
  193. /**
  194. * 平台收入记录列表
  195. */
  196. @PostMapping("/platformRevenueRecords")
  197. public R<?> platformRevenueRecords(@RequestBody CommonQueryParam params) {
  198. return R.success(platformRevenueRecordService.listRevenueRecords(params));
  199. }
  200. /**
  201. * 用户资金流水列表
  202. */
  203. @GetMapping("/walletDetails")
  204. public R<?> walletDetails(@ModelAttribute WalletDetailQueryParam params) {
  205. return R.success(walletDetailService.listAdminWalletDetail(params));
  206. }
  207. @SysLog("提现记录详情")
  208. @GetMapping("/withdrawnRecord/{id}")
  209. public R<?> withdrawnRecordDetail(@PathVariable String id) {
  210. return R.success(withdrawnRecordService.detail(id));
  211. }
  212. @SysLog("退款详情")
  213. @GetMapping("/refundLog/detail/{outRefundNo}")
  214. public R<?> refundLogDetail(@PathVariable String outRefundNo) {
  215. return R.success(refundLogService.detail(outRefundNo));
  216. }
  217. @SaCheckPermission("offlineRecharge")
  218. @SysLog("线下充值")
  219. @PostMapping("/offlineRecharge")
  220. public R<?> offlineRecharge(@RequestBody OfflineRechargeParam param) {
  221. wxPayService.offlineRecharge(param.getUserId(), param.getAmount(),
  222. param.getGrantsAmount(), param.getRemark());
  223. return R.success();
  224. }
  225. }