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.IntegralListVO;
import com.fzm.mall.server.admin.finance_center.entity.vo.MerchantAssetsFlowVO;
import com.fzm.mall.server.admin.finance_center.entity.vo.UserAssetsRecordVO;
import com.fzm.mall.server.admin.finance_center.service.IMerchantAssetsFlowService;
import com.fzm.mall.server.admin.finance_center.service.IUserAssetRecordService;
import com.fzm.mall.server.admin.finance_center.service.IUserAssetService;
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("/userAssetRecord")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class UserAssetRecordController {
    private final IUserAssetRecordService userAssetRecordService;
    private final ResponseFactory resFac;
    private final IAdminService adminService;
    private final IUserAssetService userAssetService;

    @ApiOperation(value = "分页查询-用户流水")
    @GetMapping("/page")
    public ResponseVO page(
            @ApiParam(name = "flowId", value = "流水号")
            @RequestParam(required = false) String flowId,
            @ApiParam(name = "uid", value = "用户编号")
            @RequestParam(required = false) String uid,
            @ApiParam(name = "coin", value = "资产类型")
            @RequestParam(required = false) String coin,
            @ApiParam(name = "type", value = "记录类型")
            @RequestParam(required = false) Integer type,
            @RequestParam Integer pageNum,
            @RequestParam Integer pageSize,
            @RequestHeader String adminId) {
        adminService.adminAuthChecks(adminId, AdminTypeEnum.getPlatFormTypeArr());
        IPage<UserAssetsRecordVO> page = userAssetRecordService.page(flowId, uid, coin, 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 = userAssetService.assetsType();
        return resFac.getSuccessResponseWithData(assetsTypes);
    }
}