package com.ruoyi.web.controller.mch;

import com.fasterxml.jackson.annotation.JsonView;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.JsonViewProfile;
import com.ruoyi.ss.transactionBill.domain.vo.TransactionBillVO;
import com.ruoyi.ss.transactionBill.service.TransactionAssembler;
import com.ruoyi.ss.transactionBill.service.TransactionBillService;
import com.ruoyi.ss.transactionBill.service.TransactionBillValidator;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collections;

/**
 * @author wjh
 * 2024/8/1
 */
@RestController
@RequestMapping("/mch/withdraw")
public class MchWithdrawController extends BaseController {

    @Autowired
    private TransactionBillService transactionBillService;

    @Autowired
    private TransactionBillValidator transactionBillValidator;

    @ApiOperation("查询本人提现详情")
    @GetMapping("/{billId}")
    @JsonView(JsonViewProfile.AppMch.class)
    public AjaxResult getWithdrawInfo(@PathVariable Long billId) {
        TransactionBillVO bill = transactionBillService.selectWithdrawById(billId);
        if (bill == null || !transactionBillValidator.isUser(bill, getUserId())) {
            return success();
        }
        return AjaxResult.success(bill);
    }

}
