package com.hzs.sale.ticket.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hzs.common.core.constant.SystemFieldConstants;
import com.hzs.common.core.enums.EDelFlag;
import com.hzs.common.core.utils.DateUtils;
import com.hzs.common.domain.member.address.CuMemberReceiving;
import com.hzs.common.domain.sale.ticket.SaBuyTicket;
import com.hzs.sale.ticket.mapper.SaBuyTicketMapper;
import com.hzs.sale.ticket.param.BuyTicketParam;
import com.hzs.sale.ticket.service.ISaBuyTicketService;
import org.springframework.stereotype.Service;

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

/**
 * <p>
 * 订单表 服务实现类
 * </p>
 *
 * @author hzs
 * @since 2025-01-09
 */
@Service
public class SaBuyTicketServiceImpl extends ServiceImpl<SaBuyTicketMapper, SaBuyTicket> implements ISaBuyTicketService {

    @Override
    public void mergeSaBuyTicketService(Long pkMember, List<BuyTicketParam> ticketParamList) {
        baseMapper.mergeSaBuyTicketService(pkMember, ticketParamList);
    }

    @Override
    public SaBuyTicket querySaBuyTicket(Long pkMember, Long pkId) {
        QueryWrapper<SaBuyTicket> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(SystemFieldConstants.PK_ID, pkId);
        queryWrapper.eq(SystemFieldConstants.PK_CREATOR, pkMember);
        return baseMapper.selectOne(queryWrapper);
    }

    @Override
    public void deleteSaBuyTicketByPkId(Long pkId, Long pkMember) {
        LambdaUpdateWrapper<SaBuyTicket> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.eq(SaBuyTicket::getPkSaTicket, pkId);
        updateWrapper.set(SaBuyTicket::getDelFlag, EDelFlag.DELETE.getValue());
        updateWrapper.set(SaBuyTicket::getPkModified, pkMember);
        updateWrapper.set(SaBuyTicket::getModifiedTime, DateUtils.currentDateTime());
        update(updateWrapper);
    }
}
