package com.cool.store.controller.webb;

import com.cool.store.dto.wallet.AccountInfoDTO;
import com.cool.store.dto.wallet.BillDetailDTO;
import com.cool.store.dto.wallet.TradeRecordDTO;
import com.cool.store.request.wallet.*;
import com.cool.store.response.ResponseResult;
import com.cool.store.service.wallet.WalletService;
import com.cool.store.vo.wallet.AccountBillPageVO;
import com.cool.store.vo.wallet.AccountInfoVO;
import com.cool.store.vo.wallet.AccountPageVO;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 钱包 前端控制器
 * </p>
 *
 * @author wangff
 * @since 2025/11/18
 */
@Api(tags = "钱包")
@RestController
@RequestMapping("/pc/wallet")
@RequiredArgsConstructor
public class WalletController {
    private final WalletService walletService;

    @ApiOperation("账户列表")
    @GetMapping("/accountList")
    public ResponseResult<List<AccountInfoVO>> getAccountList(AccountQueryRequest request) {
        return ResponseResult.success(walletService.getAccountList(request).getAccountList());
    }

    @ApiOperation("账户详情")
    @PostMapping("/accountInfo")
    public ResponseResult<AccountInfoVO> getAccountInfo(@RequestBody AccountQueryRequest request) {
        return ResponseResult.success(walletService.getAccountInfo(request));
    }

    @ApiOperation("分页查询所有门店账户列表 支持条件查询")
    @PostMapping("/getAllAccountList")
    public ResponseResult<PageInfo<AccountPageVO>> getAllAccountList(@RequestBody CoolAccountBatchQueryRequest request) {
        return ResponseResult.success(walletService.getAllAccountList(request));
    }

    @ApiOperation("分页查询所有流水列表 支持条件查询")
    @PostMapping("/getTradeRecordList")
    public ResponseResult<PageInfo<TradeRecordDTO>> getTradeRecordList(@RequestBody CoolTradeRecodePageRequest request) {
        return ResponseResult.success(walletService.getTradeRecordList(request,Boolean.FALSE));
    }

    @ApiOperation("账户流水")
    @PostMapping("/billPage")
    public ResponseResult<PageInfo<TradeRecordDTO>> getBillPage(@RequestBody @Validated AccountBillQueryRequest request) {
        return ResponseResult.success(walletService.getBillPage(request).getData());
    }

    @ApiOperation("交易流水详情")
    @GetMapping("/billDetail")
    public ResponseResult<TradeRecordDTO> getBillDetail(BillDetailRequest request) {
        return ResponseResult.success(walletService.getBillDetail(request));
    }

    @ApiOperation("查询收款账户 支持条件查询")
    @PostMapping("/getOrgAccountInfoList")
    public ResponseResult<PageInfo<AccountInfoDTO>> getOrgAccountInfoList(@RequestBody CoolAccountPageRequest request) {
        return ResponseResult.success(walletService.getOrgAccountInfoList(request));
    }

    @ApiOperation("分页查询门店充值流水列表 支持条件查询")
    @PostMapping("/getRechargeTradeRecordList")
    public ResponseResult<PageInfo<TradeRecordDTO>> getRechargeTradeRecordList(@RequestBody CoolTradeRecodeRequest request) {
        return ResponseResult.success(walletService.getRechargeTradeRecordList(request));
    }

    @ApiOperation("分页立规组织下所有账号流水列表 支持条件查询")
    @PostMapping("/getLiGuiTradeRecordList")
    public ResponseResult<PageInfo<TradeRecordDTO>> getLiGuiTradeRecordList(@RequestBody CoolTradeRecodePageRequest request) {
        return ResponseResult.success(walletService.getTradeRecordList(request,Boolean.TRUE));
    }

}
