package com.yd.csf.service.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yd.csf.service.dto.CommissionExpectedAddRequest;
import com.yd.csf.service.dto.CommissionExpectedChangeStatusRequest;
import com.yd.csf.service.dto.CommissionExpectedQueryRequest;
import com.yd.csf.service.dto.CommissionExpectedUpdateRequest;
import com.yd.csf.service.model.Commission;
import com.yd.csf.service.model.CommissionExpected;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yd.csf.service.model.Policy;
import com.yd.csf.service.vo.*;
import com.yd.product.feign.response.expectedspecies.ApiExpectedSpeciesListResponse;

import java.io.IOException;
import java.util.List;

/**
* @author Zhang Jianan
* @description 针对表【commission_expected(预计来佣表)】的数据库操作Service
* @createDate 2025-10-08 19:47:40
*/
public interface CommissionExpectedService extends IService<CommissionExpected> {

    Page<CommissionExpectedVO> getCommissionExpectedVOPage(Page<CommissionExpected> commissionExpectedPage);

    Page<CommissionExpectedNewVO> getCommissionExpectedVONewPage(CommissionExpectedQueryRequest request,List<CommissionExpected> allExpectedList);

    /**
     * 校验数据
     *
     * @param commissionExpected
     * @param add 对创建的数据进行校验
     */
    void validCommissionExpected(CommissionExpected commissionExpected, boolean add);

    /**
     * 获取查询条件
     *
     * @param commissionExpectedQueryRequest
     * @return
     */
    QueryWrapper<CommissionExpected> getQueryWrapper(CommissionExpectedQueryRequest commissionExpectedQueryRequest);

    /**
     * 获取预计来佣封装
     *
     * @param commissionExpected
     * @return
     */
    CommissionExpectedVO getCommissionExpectedVO(CommissionExpected commissionExpected);

    Boolean addCommissionExpected(CommissionExpectedAddRequest commissionExpectedAddRequest);

    Boolean deleteCommissionExpected(String commissionExpectedBizId);

    Boolean updateCommissionExpected(CommissionExpectedUpdateRequest commissionExpectedUpdateRequest);

    CommissionExpectedStatisticsVO getExpectedStatistics(List<Long> expectedIds);

    CommissionExpectedStatisticsVO getExpectedStatisticsNew(List<CommissionExpected> allExpectedList);

    CommissionExpected getByBizId(String commissionExpectedBizId);

    void getExpectedCommissionByProductlaunchId(Policy policy, String productLaunchBizId, String insuranceCompanyBizId, String reconciliationCompany, String reconciliationCompanyCode, String reconciliationCompanyBizId, String professionalInvestor);

    List<ApiExpectedSpeciesListResponse> queryExpectedSpeciesByFeign(String productLaunchBizId);

    /**
     * 检查产品是否维护发佣信息
     *
     * @param productLaunchBizId 产品计划业务ID
     * @return true-已维护发佣信息，false-未维护发佣信息
     */
    Boolean checkProductExpectedFortune(String productLaunchBizId);

    /**
     * 应收款报表 - 按保单号和期数维度统计（分页）
     * @param page 分页参数
     * @param expectedIds 预计来佣ID列表
     * @return 应收款报表VO分页列表
     */
    IPage<ReceivableReportVO> receivableReportPage(Page<ReceivableReportVO> page, List<Long> expectedIds);

//    IPage<ReceivableReportVO> receivableReportPage(Page<ReceivableReportVO> page,
//                                                   CommissionExpectedQueryRequest query);

    void testExpectedCommission(String policyNo, String effectiveDate, String coolingOffEndDate) throws IOException;

    Boolean changeStatus(CommissionExpectedChangeStatusRequest commissionExpectedChangeStatusRequest);

    CommissionExpected queryOne(String commissionExpectedBizId);

    CommissionExpected queryOne(String policyNo, Integer commissionPeriod, String commissionType);
}
