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

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hzs.bonus.account.service.ICuMemberAccountService;
import com.hzs.common.core.constant.MemberFieldConstants;
import com.hzs.common.domain.member.account.CuMemberAccount;
import com.hzs.bonus.account.mapper.CuMemberAccountMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * <p>
 * 会员账户信息 服务实现类
 * </p>
 *
 * @author hzs
 * @since 2022-08-11
 */
@Service
@Slf4j
public class CuMemberAccountServiceImpl extends ServiceImpl<CuMemberAccountMapper, CuMemberAccount> implements ICuMemberAccountService {

    @Override
    public Boolean updateMemberAccount(CuMemberAccount cuMemberAccount, Long pkModified) {
        cuMemberAccount.setPkModified(pkModified);
        return baseMapper.updateMemberAccount(cuMemberAccount) > 0;
    }

    @Override
    public CuMemberAccount queryCuMemberAccountByPkMember(Long pkMember) {
        QueryWrapper<CuMemberAccount> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(MemberFieldConstants.PK_MEMBER, pkMember);
        return baseMapper.selectOne(queryWrapper);
    }

    @Override
    public void updateMemberAccountGrantByPeriod(Integer pkCountry, Integer startPeriod, Integer endPeriod) {
        baseMapper.updateMemberAccountGrantByPeriod(pkCountry, startPeriod, endPeriod);
    }

    @Override
    public void updateMemberAccountByDate(Date settleDate) {
        baseMapper.updateMemberAccountByDate(settleDate);
    }

    @Override
    public void updateMemberAccountWithdrawalByPeriod(Integer startPeriod, Integer endPeriod, Integer pkCountry) {
        baseMapper.updateMemberAccountWithdrawalByPeriod(startPeriod, endPeriod, pkCountry);
    }

}

