package com.fs.company.controller;

import com.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.core.page.TableDataInfo;
import com.fs.common.enums.BusinessType;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.company.domain.*;
import com.fs.company.service.ICompanyMoneyLogsService;
import com.fs.company.service.ICompanyProfitLogsService;
import com.fs.company.service.ICompanyProfitService;
import com.fs.company.service.ICompanyService;
import com.fs.framework.web.service.TokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 提现Controller
 *
 * @author fs
 * @date 2022-07-04
 */
@RestController
@RequestMapping("/company/redPackage")
public class CompanyRedPackageController extends BaseController
{
    @Autowired
    private ICompanyMoneyLogsService moneyLogsService;
    /**
     * 查询提现列表
     */
    @PreAuthorize("@ss.hasPermi('company:redPackage:list')")
    @GetMapping("/list")
    public TableDataInfo list(CompanyRedPackage companyRedPackage)
    {
        startPage();
        List<CompanyRedPackage> list = moneyLogsService.selectCompanyRedPackageListVO(companyRedPackage);
        String dateTime = companyRedPackage.getDateTime();
        list.forEach(m -> m.setDateTime(dateTime));
        return getDataTable(list);
    }

    /**
     * 导出提现列表
     */
    @PreAuthorize("@ss.hasPermi('company:redPackage:export')")
    @Log(title = "提现", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CompanyRedPackage companyRedPackage)
    {
        List<CompanyRedPackage> list = moneyLogsService.selectCompanyRedPackageListVO(companyRedPackage);
        String dateTime = companyRedPackage.getDateTime();
        list.forEach(m -> m.setDateTime(dateTime));
        ExcelUtil<CompanyRedPackage> util = new ExcelUtil<CompanyRedPackage>(CompanyRedPackage.class);
        return util.exportExcel(list, "红包金额记录");
    }


}
