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.CuMemberAwards;
import com.hzs.common.domain.member.detail.ext.CuMemberAwardsExt;
import com.hzs.member.detail.mapper.CuMemberAwardsMapper;
import com.hzs.member.detail.service.ICuMemberAwardsService;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * 会员信息-奖衔升级记录 服务实现类
 *
 * @author hzs
 * @since 2022-08-31
 */
@Service
public class CuMemberAwardsServiceImpl extends ServiceImpl<CuMemberAwardsMapper, CuMemberAwards> implements ICuMemberAwardsService {

    @Override
    public void deleteCuMemberAwards(Long pkOrder, Long pkApprove, Date currentDateTime) {
        UpdateWrapper<CuMemberAwards> 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 CuMemberAwardsExt queryLastManualAwards(Long pkMember, Integer pkCountry) {
        return baseMapper.queryLastManualAwards(pkMember, pkCountry);
    }

}
