| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251 |
- package com.kym.admin.controller;
- import cn.dev33.satoken.annotation.SaCheckPermission;
- import com.kym.common.R;
- import com.kym.common.annotation.SysLog;
- import com.kym.entity.queryParams.*;
- import com.kym.entity.queryParams.WalletDetailQueryParam;
- import com.kym.service.*;
- import com.kym.service.wechat.WxPayService;
- import jakarta.validation.Valid;
- import java.util.Map;
- import org.springframework.web.bind.annotation.*;
- /**
- * 财务
- *
- * @author skyline
- * @since 2025-02-24
- */
- @RestController
- @RequestMapping("/finance")
- public class FinanceController {
- private final SplitRecordService splitRecordService;
- private final StationAccountService stationAccountService;
- private final WithdrawnRecordService withdrawnRecordService;
- private final SettlementService settlementService;
- private final WxPayService wxPayService;
- private final RefundLogService refundLogService;
- private final PlatformAccountService platformAccountService;
- private final PlatformRevenueRecordService platformRevenueRecordService;
- private final WalletDetailService walletDetailService;
- public FinanceController(SplitRecordService splitRecordService, StationAccountService stationAccountService,
- WithdrawnRecordService withdrawnRecordService, SettlementService settlementService,
- WxPayService wxPayService, RefundLogService refundLogService,
- PlatformAccountService platformAccountService, PlatformRevenueRecordService platformRevenueRecordService,
- WalletDetailService walletDetailService) {
- this.splitRecordService = splitRecordService;
- this.stationAccountService = stationAccountService;
- this.withdrawnRecordService = withdrawnRecordService;
- this.settlementService = settlementService;
- this.wxPayService = wxPayService;
- this.refundLogService = refundLogService;
- this.platformAccountService = platformAccountService;
- this.platformRevenueRecordService = platformRevenueRecordService;
- this.walletDetailService = walletDetailService;
- }
- /**
- * 站点账户列表
- *
- * @param params
- * @return
- */
- @PostMapping("/stationAccounts")
- public R<?> stationAccounts(@RequestBody StationQueryParam params) {
- return R.success(stationAccountService.listStationAccounts(params));
- }
- /**
- * 分账记录列表
- *
- * @param params
- * @return
- */
- @PostMapping("/splitRecords")
- public R<?> splitRecords(@RequestBody SplitRecordQueryParams params) {
- return R.success(splitRecordService.listSplitRecords(params));
- }
- /**
- * 申请提现
- *
- * @param params
- * @return
- */
- @SaCheckPermission("withdrawnRecord.modify")
- @PostMapping("/applyWithdrawn")
- public R<?> applyWithdrawn(@RequestBody WithdrawnQueryParam params) {
- stationAccountService.applyWithdrawn(params);
- return R.success();
- }
- /**
- * 提现记录列表
- *
- * @param params
- * @return
- */
- @PostMapping("/withdrawnRecords")
- public R<?> withdrawnRecords(@RequestBody WithdrawnQueryParam params) {
- return R.success(withdrawnRecordService.listWithdrawnRecords(params));
- }
- /**
- * 提现记录审核
- *
- * @param params
- * @return
- */
- @SaCheckPermission("withdrawnRecord.modify")
- @PostMapping("/reviewWithdrawn")
- public R<?> reviewWithdrawn(@RequestBody WithdrawnQueryParam params) {
- withdrawnRecordService.reviewWithdrawn(params);
- return R.success();
- }
- /**
- * 提现记录打款确认
- *
- * @param params
- * @return
- */
- @SaCheckPermission("withdrawnRecord.modify")
- @PostMapping("/confirmWithdrawnPayment")
- public R<?> confirmWithdrawnPayment(@RequestBody WithdrawnQueryParam params) {
- withdrawnRecordService.confirmWithdrawnPayment(params);
- return R.success();
- }
- /**
- * 处理用户退款
- *
- * @param refundLogId
- * @return
- */
- @SaCheckPermission("refundLog.modify")
- @SysLog("处理用户微信退款")
- @GetMapping("/customWxRefund/{refundLogId}")
- R<?> customWxRefund(@PathVariable("refundLogId") long refundLogId) {
- wxPayService.wxRefund(refundLogId);
- return R.success();
- }
- /**
- * 批量处理用户退款
- */
- @SaCheckPermission("refundLog.modify")
- @SysLog("批量处理用户微信退款")
- @PostMapping("/batchWxRefund")
- R<?> batchWxRefund(@RequestBody java.util.List<Long> refundLogIds) {
- wxPayService.batchWxRefund(refundLogIds);
- return R.success();
- }
- /**
- * 退款记录列表
- *
- * @param params
- * @return
- */
- @SysLog("退款记录列表")
- @GetMapping("/listRefundLog")
- public R<?> listRefundLog(@ModelAttribute CommonQueryParam params) {
- return R.success(refundLogService.listRefundLog(params));
- }
- /**
- * 处理用户退款
- *
- * @param param
- * @return
- */
- @SaCheckPermission("refundLog.modify")
- @SysLog("用户退款申请")
- @PostMapping("/applyRefund")
- @ResponseBody
- R<?> wxAppRefund(@Valid @RequestBody RefundParam param) {
- wxPayService.applyWxRefund(param.getUserId(), param.getReason());
- return R.success();
- }
- /**
- * 结算记录列表
- */
- @PostMapping("/settlementRecords")
- public R<?> settlementRecords(@RequestBody SettlementQueryParam params) {
- return R.success(settlementService.listSettlementRecords(params));
- }
- /**
- * 手动触发结算(运维用)
- */
- @SaCheckPermission("settlement.modify")
- @SysLog("手动触发月度结算")
- @PostMapping("/triggerSettlement")
- public R<?> triggerSettlement() {
- settlementService.executeMonthlySettlement();
- return R.success();
- }
- /**
- * 确认结算 — 将待结算金额转入站点可提现余额
- */
- @SaCheckPermission("settlement.modify")
- @SysLog("确认结算")
- @PostMapping("/confirmSettlement")
- public R<?> confirmSettlement(@RequestBody Map<String, Long> params) {
- settlementService.confirmSettlement(params.get("id"));
- return R.success();
- }
- /**
- * 平台账户信息
- */
- @PostMapping("/platformAccount")
- public R<?> platformAccount() {
- return R.success(platformAccountService.getPlatformAccount());
- }
- /**
- * 平台收入记录列表
- */
- @PostMapping("/platformRevenueRecords")
- public R<?> platformRevenueRecords(@RequestBody CommonQueryParam params) {
- return R.success(platformRevenueRecordService.listRevenueRecords(params));
- }
- /**
- * 用户资金流水列表
- */
- @GetMapping("/walletDetails")
- public R<?> walletDetails(@ModelAttribute WalletDetailQueryParam params) {
- return R.success(walletDetailService.listAdminWalletDetail(params));
- }
- @SysLog("提现记录详情")
- @GetMapping("/withdrawnRecord/{id}")
- public R<?> withdrawnRecordDetail(@PathVariable String id) {
- return R.success(withdrawnRecordService.detail(id));
- }
- @SysLog("退款详情")
- @GetMapping("/refundLog/detail/{outRefundNo}")
- public R<?> refundLogDetail(@PathVariable String outRefundNo) {
- return R.success(refundLogService.detail(outRefundNo));
- }
- @SaCheckPermission("offlineRecharge")
- @SysLog("线下充值")
- @PostMapping("/offlineRecharge")
- public R<?> offlineRecharge(@RequestBody OfflineRechargeParam param) {
- wxPayService.offlineRecharge(param.getUserId(), param.getAmount(),
- param.getGrantsAmount(), param.getRemark());
- return R.success();
- }
- }
|