package cn.ezhizao.project.business.payment.controller;

import cn.ezhizao.common.exception.ServiceException;
import cn.ezhizao.common.utils.StringUtils;
import cn.ezhizao.common.utils.poi.ExcelUtil;
import cn.ezhizao.common.utils.uuid.SnowflakeIdWorker;
import cn.ezhizao.framework.aspectj.lang.annotation.Log;
import cn.ezhizao.framework.aspectj.lang.annotation.distributedLock;
import cn.ezhizao.framework.aspectj.lang.enums.BusinessType;
import cn.ezhizao.framework.web.controller.BaseController;
import cn.ezhizao.framework.web.domain.AjaxResult;
import cn.ezhizao.framework.web.page.TableDataInfo;
import cn.ezhizao.project.business.account.domain.BizAccount;
import cn.ezhizao.project.business.account.service.IBizAccountService;
import cn.ezhizao.project.business.collection.domain.BizCollection;
import cn.ezhizao.project.business.collection.domain.BizCollectionDetail;
import cn.ezhizao.project.business.collection.service.IBizCollectionDetailService;
import cn.ezhizao.project.business.collection.service.IBizCollectionService;
import cn.ezhizao.project.business.order.domain.BizArchiveInputDetail;
import cn.ezhizao.project.business.payment.domain.BizPayment;
import cn.ezhizao.project.business.company.domain.BizCompany;
import cn.ezhizao.project.business.company.service.IBizCompanyService;
import cn.ezhizao.project.business.order.domain.BizArchiveInput;
import cn.ezhizao.project.business.order.service.IBizArchiveInputDetailService;
import cn.ezhizao.project.business.order.service.IBizArchiveInputService;
import cn.ezhizao.project.business.payment.domain.BizPaymentDetail;
import cn.ezhizao.project.business.payment.service.IBizPaymentDetailService;
import cn.ezhizao.project.business.payment.service.IBizPaymentService;
import cn.ezhizao.project.business.paymentEntry.domain.BizPaymentSubject;
import cn.ezhizao.project.business.paymentEntry.domain.BizPaymentType;
import cn.ezhizao.project.business.paymentEntry.service.IBizPaymentSubjectService;
import cn.ezhizao.project.business.paymentEntry.service.IBizPaymentTypeService;
import cn.ezhizao.project.system.domain.SysDictData;
import cn.ezhizao.project.system.domain.SysFileStorage;
import cn.ezhizao.project.system.domain.SysUser;
import cn.ezhizao.project.system.service.ISysDictDataService;
import cn.ezhizao.project.system.service.ISysFileStorageService;
import cn.ezhizao.project.system.service.ISysUserService;
import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@RestController
@Api(tags = "支出 数据接口")
@RequestMapping(value = "/business/payment")
public class BizPaymentController extends BaseController {
    @Resource
    IBizPaymentService paymentService;
    @Resource
    IBizPaymentDetailService paymentDetailService;
    @Resource
    IBizArchiveInputDetailService contractDetailService;
    @Resource
    IBizArchiveInputService archiveInputService;
    @Resource
    ISysFileStorageService fileStorageService;
    @Resource
    IBizCompanyService companyService;
    @Resource
    ISysUserService userService;
    @Resource
    SnowflakeIdWorker snowflakeIdWorker;
    @Resource
    IBizPaymentTypeService paymentTypeService;
    @Resource
    IBizPaymentSubjectService paymentSubjectService;
    @Resource
    IBizAccountService accountService;
    @Resource
    IBizCollectionService collectionService;
    @Resource
    IBizCollectionDetailService collectionDetailService;

    @Resource
    ISysDictDataService sysDictDataService;
    @PreAuthorize("@ss.hasPermi('business:payment:query')")
    @GetMapping(value = "/{id}")
    @ResponseBody
    public AjaxResult getById(@PathVariable Long id) {
        BizPayment payment = getForId(id);
        return success(payment);
    }

    @ApiOperation(value = "主从保存", notes = "主从保存")
    @PostMapping("/save")
    @Transactional(rollbackFor = Exception.class)
    @PreAuthorize("@ss.hasPermi('business:payment:add')")
    @Log(title = "支付保存", businessType = BusinessType.INSERT)
    @ResponseBody
    @distributedLock(prefix = "financialBizPaymentSaveAll",key = "#payment.contractId")
    public AjaxResult saveAll(@RequestBody BizPayment payment) throws NoSuchFieldException, IllegalAccessException {
        boolean changeFormNo = true;
        final String redisKey = "payment_flow_no";
        setTenantId(payment);
        try {
            Long id = payment.getId();
            payment.setId(payment.getId() == null || payment.getId().equals(0L) ? snowflakeIdWorker.nextId() : payment.getId());

            if (payment.getFlowNo() == null || payment.getFlowNo().isEmpty()) {
                payment.setFlowNo(payment.getId().toString());
            }
            Long tenantId = getTenantId();
            long count = paymentService.query()
                    .eq("tenant_id", tenantId)
                    .eq("flow_no", payment.getFlowNo())
                    .ne("id", payment.getId())
                    .count();
            if (count > 0) {
//                changeFormNo = false;
                return error("流水号重复");
            }
            // 先删除明细
            SysFileStorage conditions = new SysFileStorage();

            List<SysFileStorage> files = payment.getFiles();

            files.forEach(l -> {
                l.setId(l.getId() == null || l.getId().equals(0L) ? snowflakeIdWorker.nextId() : l.getId());
                l.setMasterId(payment.getId());
                l.setMasterTableName("biz_payment");
            });

            conditions.setMasterTableName("biz_payment");
            conditions.setMasterId(payment.getId());
            fileStorageService.physicalDelete(conditions);

            List<BizPaymentDetail> details = payment.getDetails();
            details.forEach(l -> {
                l.setPaymentId(payment.getId());
                l.setTenantId(getTenantId());
            });
            BizPaymentDetail delConditions = new BizPaymentDetail();
            delConditions.setPaymentId(payment.getId());
            paymentDetailService.physicallyDelete(delConditions);

            return paymentService.saveOrUpdate(payment) && (details.isEmpty() || paymentDetailService.saveOrUpdateBatch(details)) && (files.isEmpty() || fileStorageService.saveOrUpdateBatch(files)) ? success(payment) : error();
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

    @Log(title = "修改收款的状态", businessType = BusinessType.UPDATE)
    @GetMapping ("/setPaymentZero/{id}")
    @distributedLock(prefix = "financialBizPaymentSetCollectionZero",key = "#id")
    public AjaxResult setCollectionZero(@PathVariable Long id) {

        LambdaUpdateWrapper<BizPayment> eq = new LambdaUpdateWrapper<BizPayment>()
                .set(BizPayment::getVerifyStatus, 0)
                .set(BizPayment::getPaymentStatus,0)
                .set(BizPayment::getVerifyDate, "0000-00-00 00:00:00")
                .eq(BizPayment::getId, id);

        return success(paymentService.update(eq));
    }

    @ApiOperation(value = "带条件List 分页查询", notes = "带条件List 分页查询")
    @PreAuthorize("@ss.hasPermi('business:payment:list')")
    @GetMapping("/list")
    @ResponseBody
    public TableDataInfo getList(BizPayment conditions) throws NoSuchFieldException, IllegalAccessException {
        setTenantId(conditions);
        startPage();
        startOrderBy();
        List<BizPayment> list = paymentService.getListByBean(conditions);
        return getDataTable(list);
    }

    @ApiOperation(value = "带条件List 分页查询", notes = "带条件List 分页查询")
    @PreAuthorize("@ss.hasPermi('business:payment:list')")
    @GetMapping("/listTypes")
    @ResponseBody
    public TableDataInfo getTypes() throws NoSuchFieldException, IllegalAccessException {
        BizPaymentType typeConditions = new BizPaymentType();
        setTenantId(typeConditions);
        List<BizPaymentType> list = paymentTypeService.getList(typeConditions);
        BizPaymentSubject subjectConditions = new BizPaymentSubject();
        subjectConditions.setStatus(0);
        List<BizPaymentSubject> subjects = paymentSubjectService.getList(subjectConditions);
        list.forEach(l -> {
            l.setBizPaymentSubjectList(subjects.stream().filter(v -> v.getPaymentTypeId().equals(l.getId())).collect(Collectors.toList()));
        });

        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasAnyPermi('business:payment:query')")
    @GetMapping("/listCompany")
    public TableDataInfo listCompany(BizCompany bizCompany) throws NoSuchFieldException, IllegalAccessException {
        setTenantId(bizCompany);
        startPage();
        List<BizCompany> list = companyService.getList(bizCompany);
        return getDataTable(list);
    }


    @ApiOperation("获取合同")
    @GetMapping("/listContract")
    @PreAuthorize("@ss.hasPermi('business:payment:query')")
    @ResponseBody
    public TableDataInfo listContract(BizArchiveInput condition) throws NoSuchFieldException, IllegalAccessException {
        setTenantId(condition);
        startPage();
        List<BizArchiveInput> list = archiveInputService.getList(condition);

        return getDataTable(list);
    }

    @ApiOperation("获取合同")
    @GetMapping("/listContractDetail")
    @PreAuthorize("@ss.hasPermi('business:payment:query')")
    @ResponseBody
    public TableDataInfo listContractDetail(BizArchiveInputDetail condition) throws NoSuchFieldException, IllegalAccessException {
        setTenantId(condition);
        startPage();
        List<BizArchiveInputDetail> list = contractDetailService.getList(condition);
        list.forEach(l -> {
            if(l.getTaskTypeId() == 4 && l.getBelongRegion() != null){
                SysDictData sysDictData = sysDictDataService.selectDictDataById(l.getBelongRegion().longValue());
                l.setExplain( sysDictData.getDictLabel());
            }
            if (!ObjectUtils.isEmpty(l.getAddressStyle()) && l.getAddressStyle() == 1 ){
                if (StringUtils.isNotEmpty(l.getExplain())){
                    l.setExplain(l.getExplain().concat(l.getProvince() + l.getCity() + l.getDistrict()));
                }else {
                    l.setExplain(l.getProvince() + l.getCity() + l.getDistrict());
                }
            }else {
                SysDictData sysDictData = sysDictDataService.selectDictDataById(l.getFictionAddressId());
                if (sysDictData == null){
                    return;
                }
                l.setExplain(sysDictData.getDictLabel());
            }
            if(StringUtils.isNotEmpty(l.getRemark())) {
                l.setExplain(l.getExplain().concat("," + l.getRemark()));
            }
        });
        Long contractId = condition.getContractId();
        List<BizCollection> collectionList = collectionService.list(new LambdaQueryWrapper<BizCollection>().eq(BizCollection::getContractId, contractId).eq(BizCollection::getStatus, 1).eq(BizCollection::getArriveStatus, 1));
        List<Long> idCollectionList = collectionList.stream().map(m -> m.getId()).collect(Collectors.toList());
        if (idCollectionList.size() > 0) {
            List<BizCollectionDetail> detailList = collectionDetailService.list(new LambdaQueryWrapper<BizCollectionDetail>().in(BizCollectionDetail::getCollectionId, idCollectionList));
            Map<Long, BigDecimal> collect = detailList.stream().collect(Collectors.groupingBy(BizCollectionDetail::getTaskTypeId, Collectors.reducing(BigDecimal.ZERO, BizCollectionDetail::getArriveAmount, BigDecimal::add)));
            for (BizArchiveInputDetail detail : list) {
                BigDecimal bigDecimal = collect.get(detail.getTaskTypeId());
                detail.setReallyAmount(bigDecimal);
            }
        }
        contractDetailAmount(contractId, list);
        contractDetailViewAmount(contractId, list);
        return getDataTable(list);
    }
    private void contractDetailViewAmount(Long contractId, List<BizArchiveInputDetail> list) {
        List<BizPayment> paymentList = paymentService.list(new LambdaQueryWrapper<BizPayment>()
                .eq(BizPayment::getContractId, contractId)
                .and(item->item
                        .eq(BizPayment::getVerifyStatus,0)
                        .or()
                        .eq(BizPayment::getVerifyStatus,1)
                        .or()
                        .eq(BizPayment::getVerifyStatus,3)
                ));
        List<Long> idList = paymentList.stream().map(m -> m.getId()).collect(Collectors.toList());
        if (idList.size() > 0) {
            List<BizPaymentDetail> bizPaymentDetailList = paymentDetailService.list(new LambdaQueryWrapper<BizPaymentDetail>().in(BizPaymentDetail::getPaymentId, idList));
            Map<Long, BigDecimal> taskTypeToTotalAmount = bizPaymentDetailList.stream()
                    .collect(Collectors.groupingBy(BizPaymentDetail::getTaskTypeId,
                            Collectors.reducing(BigDecimal.ZERO, BizPaymentDetail::getPaymentAmount, BigDecimal::add)));
            for (BizArchiveInputDetail detail : list) {
                BigDecimal bigDecimal = taskTypeToTotalAmount.get(detail.getTaskTypeId());
                detail.setReviewAmount(bigDecimal);
            }
        }
    }
    private void contractDetailAmount(Long contractId, List<BizArchiveInputDetail> list) {
        List<BizPayment> paymentList = paymentService.list(new LambdaQueryWrapper<BizPayment>().eq(BizPayment::getContractId, contractId).eq(BizPayment::getPaymentStatus, 1).eq(BizPayment::getVerifyStatus, 3));
        List<Long> idList = paymentList.stream().map(m -> m.getId()).collect(Collectors.toList());
        if (idList.size() > 0) {
            List<BizPaymentDetail> bizPaymentDetailList = paymentDetailService.list(new LambdaQueryWrapper<BizPaymentDetail>().in(BizPaymentDetail::getPaymentId, idList));
            Map<Long, BigDecimal> taskTypeToTotalAmount = bizPaymentDetailList.stream()
                    .collect(Collectors.groupingBy(BizPaymentDetail::getTaskTypeId,
                            Collectors.reducing(BigDecimal.ZERO, BizPaymentDetail::getPaymentAmount, BigDecimal::add)));
            for (BizArchiveInputDetail detail : list) {
                BigDecimal bigDecimal = taskTypeToTotalAmount.get(detail.getTaskTypeId());
                detail.setPayment(bigDecimal);
            }
        }
    }


    @PreAuthorize("@ss.hasPermi('expenditure:subject:remove')")
    @Log(title = "支付删除", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable List<Long> ids) {
        //查询所有需要删除的数据
        List<BizPayment> list = paymentService.getByIds(ids);
        for (BizPayment l : list) {
            //判读是否已经审核
            if (l.getVerifyStatus() == 1) {
                //已经审核无法删除
                return error("删除失败，审核通过的不能删除");
            }
        }
        //全未审核则删除
        return toAjax(paymentService.removeBatchByIds(ids) && paymentService.removePaymentDetail(ids));
    }


    private BizPayment getForId(Long paymentId) {
        BizPayment payment = new BizPayment();
        payment.setId(paymentId);
        List<BizPayment> payments = paymentService.getListByBean(payment);
        payment = payments.isEmpty() ? null : payments.get(0);
        if (payment != null) {
            BizArchiveInput condition = new BizArchiveInput();
            condition.setId(payment.getContractId());
            List<BizArchiveInput> archiveInputs = archiveInputService.getList(condition);
            BizArchiveInput archiveInput = archiveInputs.isEmpty() ? null : archiveInputs.get(0);
            if (archiveInput != null) {
                payment.setContractNo(archiveInput.getContractNo());
                payment.setContractAmount(archiveInput.getTrueAmount());
                payment.setParty(archiveInput.getParty());
                payment.setBoss(archiveInput.getBoss());
                BizPayment payemntConditions = new BizPayment();
                payemntConditions.setContractId(archiveInput.getId());
                payemntConditions.setPaymentStatus((byte) 1);
                List<BizPayment> payed = paymentService.getListByBean(payemntConditions);
//                payment.setNonpayment(archiveInput.getAmount().subtract(BigDecimal.valueOf(collections.stream().mapToDouble(v -> v.getAmount().doubleValue()).sum())).compareTo(BigDecimal.ZERO) > 0);
                payment.setPayedAmount(BigDecimal.valueOf(payed.stream().mapToDouble(v -> v.getAmount().doubleValue()).sum()));
            }
            SysFileStorage fileConditions = new SysFileStorage();
            fileConditions.setMasterId(payment.getId());
            fileConditions.setMasterTableName("biz_payment");
            List<SysFileStorage> files = fileStorageService.getList(fileConditions);
            payment.setFiles(files);
            SysUser applier = userService.selectUserById(payment.getApplierId());
            BizCompany company = companyService.getById(payment.getCompanyId());
            payment.setApplierName(applier != null ? applier.getNickName() : "系统管理员");
            payment.setCompanyName(company == null ? payment.getCompanyName() : company.getName());
            BizPaymentDetail detailCondition = new BizPaymentDetail();
            detailCondition.setPaymentId(payment.getId());
            List<BizPaymentDetail> details = paymentDetailService.getListByBean(detailCondition);
            details.forEach(l -> {
                if(l.getTaskTypeId() == 4 && l.getBelongRegion() != null){
                    SysDictData sysDictData = sysDictDataService.selectDictDataById(l.getBelongRegion().longValue());
                    l.setExplain( sysDictData.getDictLabel());
                }
                if (!ObjectUtils.isEmpty(l.getAddressStyle()) && l.getAddressStyle() == 1 ){
                    if (StringUtils.isNotEmpty(l.getExplain())){
                        l.setExplain(l.getExplain().concat(l.getProvince() + l.getCity() + l.getDistrict()));
                    }else {
                        l.setExplain(l.getProvince() + l.getCity() + l.getDistrict());
                    }
                }else {
                    SysDictData sysDictData = sysDictDataService.selectDictDataById(l.getFictionAddressId());
                    if (sysDictData== null) {
                        return;
                    }
                    l.setExplain(sysDictData.getDictLabel());
                }
                if(StringUtils.isNotEmpty(l.getInputRemark())) {
                    l.setExplain(l.getExplain().concat("," + l.getInputRemark()));
                }
            });
            payment.setDetails(details);
            totalAmountPaid(payment, details);
            totalAmountReceived(payment, details);
            totalAmountReview(payment, details);
        }
        return payment;
    }

    private void totalAmountReceived(BizPayment payment, List<BizPaymentDetail> details) {
        //-------已收款总金额
        Long contractId = payment.getContractId();
        List<BizCollection> collectionList = collectionService.list(new LambdaQueryWrapper<BizCollection>().eq(BizCollection::getContractId, contractId).eq(BizCollection::getStatus, 1).eq(BizCollection::getArriveStatus, 1));
        List<Long> idCollectionList = collectionList.stream().map(m -> m.getId()).collect(Collectors.toList());
        if (idCollectionList.size() > 0) {
            List<BizCollectionDetail> detailList = collectionDetailService.list(new LambdaQueryWrapper<BizCollectionDetail>().in(BizCollectionDetail::getCollectionId, idCollectionList));
            Map<Long, BigDecimal> collect = detailList.stream().collect(Collectors.groupingBy(BizCollectionDetail::getTaskTypeId, Collectors.reducing(BigDecimal.ZERO, BizCollectionDetail::getArriveAmount, BigDecimal::add)));
            for (BizPaymentDetail detail : details) {
                BigDecimal bigDecimal = collect.get(detail.getTaskTypeId());
                detail.setReallyAmount(bigDecimal);
            }
        }
        //-------已收款总金额
    }

    private void totalAmountPaid(BizPayment payment, List<BizPaymentDetail> details) {
        //-------已支付总金额
        List<BizPayment> list = paymentService.list(new LambdaQueryWrapper<BizPayment>().eq(BizPayment::getContractId, payment.getContractId()).eq(BizPayment::getPaymentStatus, 1).eq(BizPayment::getVerifyStatus, 3));
        List<Long> idList = list.stream().map(m -> m.getId()).collect(Collectors.toList());
        if (idList.size() > 0) {
            List<BizPaymentDetail> bizPaymentDetailList = paymentDetailService.list(new LambdaQueryWrapper<BizPaymentDetail>().in(BizPaymentDetail::getPaymentId, idList));
            Map<Long, BigDecimal> taskTypeToTotalAmount = bizPaymentDetailList.stream()
                    .collect(Collectors.groupingBy(BizPaymentDetail::getTaskTypeId,
                            Collectors.reducing(BigDecimal.ZERO, BizPaymentDetail::getPaymentAmount, BigDecimal::add)));
            for (BizPaymentDetail detail : details) {
                BigDecimal bigDecimal = taskTypeToTotalAmount.get(detail.getTaskTypeId());
                detail.setPayment(bigDecimal);
            }
        }
        //-------
    }
    private void totalAmountReview(BizPayment payment, List<BizPaymentDetail> details) {
        //-------所有审核状态全部通过的金额加上未审核金额
        List<BizPayment> list = paymentService.list(new LambdaQueryWrapper<BizPayment>()
                .eq(BizPayment::getContractId, payment.getContractId())
                .and(item->item
                        .eq(BizPayment::getVerifyStatus,0)
                        .or()
                        .eq(BizPayment::getVerifyStatus,1)
                        .or()
                        .eq(BizPayment::getVerifyStatus,3)
                ));
        List<Long> idList = list.stream().map(m -> m.getId()).collect(Collectors.toList());
        if (idList.size() > 0) {
            List<BizPaymentDetail> bizPaymentDetailList = paymentDetailService.list(new LambdaQueryWrapper<BizPaymentDetail>().in(BizPaymentDetail::getPaymentId, idList));
            Map<Long, BigDecimal> taskTypeToTotalAmount = bizPaymentDetailList.stream()
                    .collect(Collectors.groupingBy(BizPaymentDetail::getTaskTypeId,
                            Collectors.reducing(BigDecimal.ZERO, BizPaymentDetail::getPaymentAmount, BigDecimal::add)));
            for (BizPaymentDetail detail : details) {
                BigDecimal bigDecimal = taskTypeToTotalAmount.get(detail.getTaskTypeId());
                detail.setReviewAmount(bigDecimal);
                detail.setThisPaymentAmount(detail.getPaymentAmount());
            }
        }
        //-------
    }
    @ApiOperation("审核")
    @PostMapping("/verified")
    @Log(title = "支付审核", businessType = BusinessType.UPDATE)
    @PreAuthorize("@ss.hasAnyPermi('business:payment:submitVerify,business:payment:financialVerify,business:payment:cashierVerify')")
    @Transactional(rollbackFor = Exception.class)
    @distributedLock(prefix = "financialBizPaymentVerified",key = "#payment.id")
    public AjaxResult verified(@RequestBody BizPayment payment) {
        try {
            payment.setVerifyDate(payment.getVerifyDate() == null ? DateTime.now().toTimestamp() : payment.getVerifyDate());
            if(!CollectionUtils.isEmpty(payment.getEvidenceFiles())){
                List<SysFileStorage> fileStorageList = payment.getEvidenceFiles();
                fileStorageList.forEach(l -> {
                    l.setId(l.getId() == null || l.getId().equals(0L) ? snowflakeIdWorker.nextId() : l.getId());
                    l.setMasterId(payment.getId());
                    l.setMasterTableName("biz_payment");
                });
                fileStorageService.saveBatch(fileStorageList);
            }
            return paymentService.saveOrUpdate(payment) ? success(payment) : error();
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

    /**
     * 导出支出管理
     */
    @PreAuthorize("@ss.hasPermi('business:payment:export')")
    @Log(title = "支出管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizPayment payment) throws NoSuchFieldException, IllegalAccessException {
        setTenantId(payment);
        startOrderBy();
        List<BizPayment> list = paymentService.getListByBean(payment);
        list.forEach(l -> {
            switch (l.getVerifyStatus()) {
                case 0:
                    l.setVerifyStatusStr("未审核");
                    break;
                case 1:
                    l.setVerifyStatusStr("财务审核通过");
                    break;
                case 2:
                    l.setVerifyStatusStr("财务审核不通过");
                    break;
                case 3:
                    l.setVerifyStatusStr("出纳审核通过");
                    break;
                case 4:
                    l.setVerifyStatusStr("出纳审核不通过");
                    break;
            }

            switch (l.getPaymentStatus()) {
                case 0:
                    l.setPaymentStatusStr("未支付");
                    break;
                case 1:
                    l.setPaymentStatusStr("已支付");
                    break;
                case 2:
                    l.setPaymentStatusStr("部分支付");
                    break;
            }
        });
        ExcelUtil<BizPayment> util = new ExcelUtil<BizPayment>(BizPayment.class);
        util.exportExcel(response, list, "收款信息");

    }


}
