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

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hzs.common.core.constant.SaOrderFieldConstants;
import com.hzs.common.core.constant.SystemFieldConstants;
import com.hzs.common.core.enums.EYesNo;
import com.hzs.common.domain.member.detail.CuMemberLevel;
import com.hzs.common.domain.member.detail.ext.CuMemberLevelExt;
import com.hzs.member.detail.mapper.CuMemberLevelMapper;
import com.hzs.member.detail.param.CuMemberLevelParam;
import com.hzs.member.detail.service.ICuMemberLevelService;
import org.springframework.stereotype.Service;

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

/**
 * 会员信息-等级升级记录 服务实现类
 */
@Service
public class CuMemberLevelServiceImpl extends ServiceImpl<CuMemberLevelMapper, CuMemberLevel> implements ICuMemberLevelService {

    @Override
    public List<CuMemberLevelExt> listMemberLevelList(CuMemberLevelParam param) {
        return baseMapper.listMemberLevelList(param);
    }

    @Override
    public void deleteCuMemberLevelRecord(Long pkOrder, Long pkApprove, Date currentDateTime) {
        UpdateWrapper<CuMemberLevel> updateWrapper = new UpdateWrapper<>();
        updateWrapper.set(SystemFieldConstants.DEL_FLAG, EYesNo.NO.getIntValue());
        updateWrapper.set(SystemFieldConstants.PK_MODIFIED, pkApprove);
        updateWrapper.set(SystemFieldConstants.MODIFIED_TIME, currentDateTime);
        updateWrapper.eq(SaOrderFieldConstants.PK_ORDER, pkOrder);
        update(updateWrapper);
    }

    @Override
    public CuMemberLevel queryLastManualUpgrade(Long pkMember) {
        return baseMapper.queryLastManualUpgrade(pkMember);
    }

}
