package com.hzs.bonus.achieve.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.hzs.bonus.achieve.param.MemberAchieveParam;
import com.hzs.common.domain.member.achieve.CuMemberRetailRange;
import com.hzs.common.domain.member.achieve.ext.CuMemberRetailRangeExt;
import com.hzs.common.domain.member.base.CuMember;
import com.hzs.common.domain.member.ext.CuMemberExt;
import com.hzs.common.domain.sale.ext.SaOrderExt;

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

/**
 * 服务类
 */
public interface ICuMemberRetailRangeService extends IService<CuMemberRetailRange> {

    /**
     * 将昨天的业绩信息迁移到今天
     */
    void mergeMemberRetailRangeByYesterday(String rangeTableName, String yesterdayRangeTableName, Boolean isSameMonth);

    /**
     * 将昨天的结算明细迁移到今天
     */
    void mergeMemberRetailRangeDetailByYesterday(String detailTableName, String yesterdayDetailTableName, Boolean isClear);

    /**
     * 根据会员查询会员上的所有网体, 按照pkParent作为key
     */
    List<CuMemberRetailRangeExt> queryCuMemberRetailRangeParent(String tableName, List<SaOrderExt> saOrderExtList);

    /**
     * 推荐推荐人查询推荐人下的所有部门, 该订单日期之前的算他的网体
     */
    List<CuMemberRetailRangeExt> queryCuMemberRetailRangeExtByParent(String tableName, Long pkParent);

    /**
     * 根据会员查询会员上的所有网体, 按照pkParent作为key,查询极差秒接表
     */
    List<CuMemberRetailRangeExt> queryCuMemberSecondRangeParent(String rangeTableName, String secondTableName, Long pkMember);

    /**
     * 推荐推荐人查询推荐人下的所有部门, 该订单日期之前的算他的网体
     */
    List<CuMemberRetailRangeExt> queryCuMemberSecondRangeExtByParent(String rangeTableName, String secondTableName, Long pkMember);

    /**
     * 更新会员日结数据
     */
    void updateCuMemberRetailRange(String settleTableName, Map<Long, CuMemberRetailRangeExt> cuMemberTreeMap);

    /**
     * 更新会员日结明细数据
     */
    void updateCuMemberRetailDetail(String rangeDetailTableName, Map<Long, CuMemberRetailRangeExt> memberRangeExtMap);

    /**
     * 更新极差秒接表，用昨天的结算表
     */
    void mergeMemberSecondRetailRangeByRange(String rangeTableName, String secondRangeTableName, Long pkMember);

    /**
     * 更新购买订单的等级
     */
    void mergeMemberRetailGradeByMember(String rangeTableName, Long pkMember, Integer isToday);

    /**
     * 更新会员树的累计业绩
     *
     * @param secondTableName 结算日期
     * @param cuMemberTreeMap 树
     */
    void updateCuMemberSecondRange(String secondTableName, Map<Long, CuMemberRetailRangeExt> cuMemberTreeMap);

    List<CuMemberExt> findParentMemberList(Long pkMember);

    void updateMemberRetailSecondRangeSelf(String settleTableName, SaOrderExt orderExt, CuMember pkMember, Integer updateType, String symbol);

    void updateMemberRetailSecondRangeParent(String settleTableName, SaOrderExt orderExt, List<CuMemberExt> pkMemberList, Integer updateType, String symbol);

    void initMemberRetailSecondRange(String tableName, CuMemberExt member);

    /**
     * 更新会员血缘上累计数据
     */
    void updateMemberParentDate(String rangeTableName, Map<Long, MemberAchieveParam> memberAchieveHashMap);

    /**
     * 查询符合奖衔业绩条件会员
     */
    List<CuMemberRetailRangeExt> queryEnoughAwardMember(String rangeTableName, BigDecimal totalCheck, Integer awardsValue);

    /**
     * 查询符合奖衔业绩、安置条件会员
     */
    List<CuMemberRetailRangeExt> queryEnoughAwardPlaceMember(String rangeTableName, Integer awardsValue, BigDecimal totalCheck, Integer placeDeptNum,
                                                             Integer checkAwardsValue);

    /**
     * 查询会员血缘下达标奖衔会员
     */
    List<Integer> listChildAwards(String rangeTableName, Integer pkAwards, List<Long> childMemberList);

    /**
     * 更新会员奖衔
     */
    void updateCuMemberAwardsByPeriod(String rangeTableName, Integer period);


}
