package com.hzs.bonus.bonus.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.hzs.bonus.bonus.dto.BonusStageData;
import com.hzs.common.core.enums.EBonusStage;
import com.hzs.common.domain.member.achieve.CuMemberRetailDetail;
import com.hzs.common.domain.member.achieve.ext.CuMemberRetailRangeExt;
import com.hzs.common.domain.member.bonus.CuMemberBonus;
import com.hzs.common.domain.member.bonus.CuMemberBonusStage;
import com.hzs.common.domain.sale.ext.SaOrderExt;

import java.util.*;

/**
 * 会员奖金-阶段收益明细表 服务类
 */
public interface ICuMemberBonusStageService extends IService<CuMemberBonusStage> {

    /**
     * 删除会员阶段奖金表
     */
    void deleteCuMemberBonusStage(Integer period);

    /**
     * 批量插入会员阶段奖
     */
    void batchInsertCuMemberBonusStage(List<CuMemberBonusStage> cuMemberBonusStageList, Set<Long> memberIdSet);

    /**
     * 获取阶段收益信息
     */
    CuMemberBonusStage getCuMemberBonusStage(SaOrderExt saOrderExt, CuMemberRetailRangeExt cuMemberRetailRange,
                                             CuMemberBonus cuMemberBonus, Integer pkBonusItems);

    /**
     * 填充会员点位
     */
    String fillChildNode(CuMemberRetailDetail cuMemberRetailDetail, CuMemberRetailDetail newRetailDetail);

    /**
     * 填充指定点位
     */
    void fillRetailDetail(CuMemberRetailDetail targetRetailDetail, String point,
                             CuMemberRetailDetail sourceRetailDetail, Date settleDate, EBonusStage eBonusStage,
                             List<BonusStageData> bonusStageDataList);

    /**
     * 处理新点位是推荐第一层
     */
    void handlePointFirst(Map<Long, CuMemberRetailRangeExt> memberRangeExtMap,
                          CuMemberRetailDetail newRetailDetail, CuMemberRetailDetail newParentRetailDetail,
                          String rangeTableName, String rangeDetailTableName, String newNode,
                          Date settleDate, EBonusStage eBonusStage, List<BonusStageData> bonusStageDataList);

    /**
     * 处理新点位是推荐第二层
     */
    void handlePointSecond(Map<Long, CuMemberRetailRangeExt> memberRangeExtMap,
                           CuMemberRetailDetail newRetailDetail, CuMemberRetailDetail newParentRetailDetail,
                           String rangeTableName, String rangeDetailTableName, String newNode,
                           Date settleDate, EBonusStage eBonusStage, List<BonusStageData> bonusStageDataList);

    /**
     * 处理新点位是推荐第三层
     */
    void handlePointThird(Map<Long, CuMemberRetailRangeExt> memberRangeExtMap,
                          CuMemberRetailDetail newRetailDetail, CuMemberRetailDetail newParentRetailDetail,
                          String rangeTableName, String rangeDetailTableName, String newNode,
                          Date settleDate, EBonusStage eBonusStage, List<BonusStageData> bonusStageDataList);

    /**
     * 处理填充第一层
     */
    boolean firstLevelhandle(LinkedHashMap<Integer, CuMemberRetailDetail> parentDetailList, CuMemberRetailDetail newRetailDetail,
                             String rangeTableName, String rangeDetailTableName,
                             Map<Long, CuMemberRetailRangeExt> memberRangeExtMap, Date settleDate, EBonusStage eBonusStage,
                             List<BonusStageData> bonusStageDataList);

    /**
     * 处理填充第二层
     */
    boolean secondLevelhandle(LinkedHashMap<Integer, CuMemberRetailDetail> parentDetailList, CuMemberRetailDetail newRetailDetail,
                              String rangeTableName, String rangeDetailTableName,
                              Map<Long, CuMemberRetailRangeExt> memberRangeExtMap, Date settleDate, EBonusStage eBonusStage,
                              List<BonusStageData> bonusStageDataList);

    /**
     * 处理填充第三层
     */
    boolean thirdLevelhandle(LinkedHashMap<Integer, CuMemberRetailDetail> parentDetailList, CuMemberRetailDetail newRetailDetail,
                             String rangeTableName, String rangeDetailTableName,
                             Map<Long, CuMemberRetailRangeExt> memberRangeExtMap, Date settleDate, EBonusStage eBonusStage,
                             List<BonusStageData> bonusStageDataList);


}
