package com.cf.imes.module.system.service.funds.purchase;

import com.cf.imes.framework.common.pojo.PageResult;
import com.cf.imes.module.system.controller.admin.funds.organamount.vo.TotalSalesAmountRespVO;
import com.cf.imes.module.system.controller.admin.funds.products.vo.productDetails.ProductDetailsRespVO;
import com.cf.imes.module.system.controller.admin.funds.purchase.vo.OrgEarliestPurchaseProductRespVO;
import com.cf.imes.module.system.controller.admin.funds.purchase.vo.PurchaseRecordPageReqVO;
import com.cf.imes.module.system.controller.admin.funds.purchase.vo.PurchaseRecordRespVO;
import com.cf.imes.module.system.controller.admin.funds.purchase.vo.SalesDetailRespVO;
import com.cf.imes.module.system.controller.admin.funds.purchase.vo.SalesDetailsPageReqVO;
import com.cf.imes.module.system.controller.admin.organ.vo.organ.OrganCreateProductPurchaseReqVO;
import com.cf.imes.module.system.controller.admin.statistics.vo.ManageSalesTotalStatisticRespVO;
import com.cf.imes.module.system.dal.dataobject.funds.purchase.PurchaseRecordDO;

import java.math.BigDecimal;
import java.util.List;
import java.util.Set;

/**
 * @author 软件购买接口
 */
public interface PurchaseService {
    /**
     * 查询购买记录
     *
     * @param id
     * @return
     */
    PurchaseRecordDO getRecord(Long id);

    /**
     * 删除购买记录
     *
     * @param id
     */
    void deleteRecord(Long id);

    /**
     * 查询购买记录分页
     *
     * @param pageReqVO
     * @return
     */
    PageResult<PurchaseRecordRespVO> getPurchaseRecord(PurchaseRecordPageReqVO pageReqVO);

    /**
     * 创建购买记录
     *
     * @param purchaseRecordDO
     */
    void createRecord(PurchaseRecordDO purchaseRecordDO);

    /**
     * 更新购买记录为可开票
     *
     * @param purchaseRecordId
     * @param organId
     */
    void updateRecordInvoicable(Long purchaseRecordId, Long organId);

    /**
     * 查询组织下最早购买产品定价规则
     *
     * @param organId
     * @return
     */
    OrgEarliestPurchaseProductRespVO getOrgEarliestProductDetail(Long organId);

    /**
     * 查询可开票金额
     *
     * @param organId
     * @return
     */
    BigDecimal getInvoicingAmount(Long organId);

    /**
     * 创建组织初始化（创建）时的购买记录
     *
     * @param organId
     * @param productPurchaseReqVOS
     */
    void createOrgInitProductPurchaseRecord(Long organId, List<OrganCreateProductPurchaseReqVO> productPurchaseReqVOS);

    /**
     * 更新组织首购记录
     *
     * @param organId
     * @param productPurchaseReqVOS
     */
    void updateOrgInitProductPurchaseRecord(Long organId, List<OrganCreateProductPurchaseReqVO> productPurchaseReqVOS);

    /**
     * 查询组织下产品购买记录
     *
     * @param organIds
     * @return
     */
    List<PurchaseRecordDO> getOrgPurchaseList(Set<Long> organIds);

    /**
     * 查询销售总额
     */
    TotalSalesAmountRespVO getTotalSales();

    /**
     * 查询管理端销售明细分页
     *
     * @return
     */
    PageResult<SalesDetailRespVO> getManageSalesDetailsPage(SalesDetailsPageReqVO pageReqVO);

    /**
     * 获取组织初始产品购买记录
     *
     * @param organId
     * @return
     */
    PurchaseRecordDO getOrgInitialPurchaseRecord(Long organId, Long productId);

    /**
     * 获取组织产品待支付的购买记录
     *
     * @param organId
     * @param productId
     * @return
     */
    List<PurchaseRecordDO> getOrgProductPendingPurchaseList(Long organId, Long productId);

    /**
     * 获取组织续费定价规则列表
     *
     * @param organId
     * @return
     */
    List<ProductDetailsRespVO> getOrgProductDetailList(Long organId, Long productId);

    /**
     * 作废历史组织产品购买记录
     *
     * @param organId
     * @param purchaseRecordId
     */
    void invalidHistoryOrganProductPurchaseRecord(Long organId, Long purchaseRecordId);

    /**
     * 激活历史组织产品购买记录
     *
     * @param organId
     * @param purchaseRecordId
     */
    void activateHistoryOrganProductPurchaseRecord(Long organId, Long purchaseRecordId);

    /**
     * 管理端获取销售总额统计
     * @return
     */
    ManageSalesTotalStatisticRespVO getSalesTotalStatistics();
}
