package com.fzm.mall.server.admin.finance_center.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.fzm.mall.server.admin.finance_center.entity.vo.MerchantAssetsVO;
import com.fzm.mall.server.admin.finance_center.service.IMerchantAssetsFlowService;
import com.fzm.mall.server.admin.finance_center.service.IMerchantAssetsService;
import com.fzm.mall.server.admin.home_page.enums.type.AdminTypeEnum;
import com.fzm.mall.server.admin.home_page.model.Admin;
import com.fzm.mall.server.admin.home_page.service.IAdminService;
import com.fzm.mall.server.admin.repo.ResponseFactory;
import com.fzm.mall.server.admin.repo.ResponseVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author wangp
 * @date 2021/4/27 10:44
 * @description 商户资产
 * @since JDK 1.8
 */
@Api(tags = "财务中心-商户资产")
@RestController
@RequestMapping("/merchantAssets")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class MerchantAssetsController {
    private final IMerchantAssetsService merchantAssetsService;
    private final ResponseFactory resFac;
    private final IAdminService adminService;

    //TODO 商户资产 充值|扣除

    @ApiOperation(value = "分页查询-商户资产")
    @GetMapping("/page")
    public ResponseVO page(
            @ApiParam(name = "merchantId", value = "商户编号")
            @RequestParam(required = false) String merchantId,
            @ApiParam(name = "account", value = "商户登陆账号")
            @RequestParam(required = false) String account,
            @ApiParam(name = "type", value = "资产类型")
            @RequestParam(required = false) String type,
            @RequestParam Integer pageNum,
            @RequestParam Integer pageSize,
            @RequestHeader String adminId) {
        adminService.adminAuthChecks(adminId, AdminTypeEnum.getPlatFormTypeArr());
        IPage<MerchantAssetsVO> page = merchantAssetsService.page(merchantId, account, type, pageNum, pageSize);
        return resFac.getSuccessResponseWithData(page);
    }

    @ApiOperation(value = "资产类型")
    @GetMapping("/assetsType")
    public ResponseVO assetsType(@RequestHeader String adminId) {
        adminService.adminAuthChecks(adminId, AdminTypeEnum.getPlatFormTypeArr());
        List<String> assetsTypes = merchantAssetsService.assetsType();
        return resFac.getSuccessResponseWithData(assetsTypes);
    }
}
