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

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hzs.common.core.enums.EYesNo;
import com.hzs.common.core.utils.DateUtils;
import com.hzs.common.domain.member.base.CuMemberShare;
import com.hzs.member.base.mapper.CuMemberShareMapper;
import com.hzs.member.base.service.ICuMemberShareService;
import com.hzs.member.marketnews.param.SeaFlourParam;
import com.hzs.member.marketnews.vo.SeaFlourVo;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 分享注册记录会员 服务实现类
 */
@Service
public class CuMemberShareServiceImpl extends ServiceImpl<CuMemberShareMapper, CuMemberShare> implements ICuMemberShareService {

    @Override
    public CuMemberShare queryCuMemberShare(Long pkMember) {
        QueryWrapper<CuMemberShare> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("PK_ID,MEMBER_CODE,MEMBER_NAME,PHONE,PK_PARENT");
        return baseMapper.selectById(pkMember);
    }

    @Override
    public Boolean updateCuMemberShare(Long pkMember) {
        CuMemberShare cuMemberShare = queryCuMemberShare(pkMember);
        cuMemberShare.setPayFlag(EYesNo.YES.getIntValue());
        cuMemberShare.setPkModified(pkMember);
        cuMemberShare.setModifiedTime(DateUtils.currentDateTime());
        return baseMapper.updateById(cuMemberShare) > 0 ? Boolean.TRUE : Boolean.FALSE;
    }

    @Override
    public List<SeaFlourVo> seaFlourList(SeaFlourParam seaFlourParam) {
        return baseMapper.seaFlourList(seaFlourParam);
    }
}
