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

import com.jeesharp.business.modules.pay.bill.dto.PayBillApplyResultDTO;
import com.jeesharp.business.modules.pay.paywechatbill.application.PayWechatBillApplicationService;
import com.jeesharp.business.modules.pay.paywechatbill.vo.PayWechatBillFundFlowQueryVO;
import com.jeesharp.business.modules.pay.paywechatbill.vo.PayWechatBillTradeQueryVO;
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 jakarta.validation.Valid;
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 接口，申请交易/资金账单下载地址。
 *
 * @author jeesharp
 * @since 2026-06-12
 */
@RestController
@RequestMapping(value = "${jeesharp.web.adminPath}/manager/business/pay/payWechatBill/v1")
@Tag(name = "微信账单")
@AllArgsConstructor
public class PayWechatBillController extends BaseController {

    private final PayWechatBillApplicationService payWechatBillApplicationService;

    @GetMapping("trade/apply")
    @Operation(summary = "申请交易账单")
    @PreAuthorize("@ss.hasPermission('manager:business:pay:payWechatBill:trade')")
    public AjaxResult<PayBillApplyResultDTO> applyTradeBill(@Valid PayWechatBillTradeQueryVO query) {
        return AjaxResult.okData(payWechatBillApplicationService.applyTradeBill(query));
    }

    @GetMapping("fundFlow/apply")
    @Operation(summary = "申请资金账单")
    @PreAuthorize("@ss.hasPermission('manager:business:pay:payWechatBill:fundFlow')")
    public AjaxResult<PayBillApplyResultDTO> applyFundFlowBill(@Valid PayWechatBillFundFlowQueryVO query) {
        return AjaxResult.okData(payWechatBillApplicationService.applyFundFlowBill(query));
    }
}
