package com.jeesharp.business.modules.pay.payfundbalance.controller;

import com.jeesharp.business.modules.pay.payfundbalance.application.PayFundBalanceApplicationService;
import com.jeesharp.business.modules.pay.payfundbalance.vo.PayFundBalanceOverviewVO;
import com.jeesharp.framework.pojo.AjaxResult;
import com.jeesharp.framework.web.controller.BaseController;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 账户资金余额管理端 REST 接口，代理微信 V3 查询平台/特约商户余额。
 *
 * @author jeesharp
 * @since 2026-06-12
 */
@RestController
@RequestMapping(value = "${jeesharp.web.adminPath}/manager/business/pay/payFundBalance/v1")
@Tag(name = "账户资金余额")
@AllArgsConstructor
public class PayFundBalanceController extends BaseController {

    private final PayFundBalanceApplicationService payFundBalanceApplicationService;

    @GetMapping("platform/balance")
    @Operation(summary = "平台服务商账户余额")
    @PreAuthorize("@ss.hasPermission('manager:business:pay:payFundWithdraw:platform')")
    public AjaxResult<PayFundBalanceOverviewVO> platformBalance() {
        return AjaxResult.okData(payFundBalanceApplicationService.getPlatformBalance());
    }

    @GetMapping("merchant/balance")
    @Operation(summary = "当前租户特约商户账户余额")
    @PreAuthorize("@ss.hasPermission('manager:business:pay:payFundWithdraw:merchant')")
    public AjaxResult<PayFundBalanceOverviewVO> merchantBalance() {
        return AjaxResult.okData(payFundBalanceApplicationService.getMerchantBalance());
    }
}
