package com.hzs.bonus.detail.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hzs.bonus.detail.mapper.CuMemberGradeMapper;
import com.hzs.bonus.detail.service.ICuMemberGradeService;
import com.hzs.common.core.enums.EUpgradeType;
import com.hzs.common.domain.member.detail.CuMemberGrade;
import com.hzs.common.domain.member.detail.CuMemberLevel;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 会员信息-等级升级记录 服务实现类
 */
@Service
public class CuMemberGradeServiceImpl extends ServiceImpl<CuMemberGradeMapper, CuMemberGrade> implements ICuMemberGradeService {

    @Override
    public List<CuMemberLevel> calculateCuMemberRetailGradeInit(Integer period, Date startDate, Date endDate, String rangeTableName) {
        // 根据手动升级记录，更新日结表
        baseMapper.updateCuMemberGrade(rangeTableName, period);
        // 购买升级记录列表
        return baseMapper.queryCuMemberLevel(startDate, endDate, EUpgradeType.BUY_UPGRADE.getValue());
    }

    @Override
    public List<CuMemberLevel> listAutoLevel(Date startDate, Date endDate) {
        // 自动升级记录列表
        return baseMapper.queryCuMemberLevel(startDate, endDate, EUpgradeType.AUTO_UPGRADE.getValue());
    }
}
