package com.hzs.activity.recommend.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hzs.activity.recommend.mapper.AcRepurSharOrderTypeMapper;
import com.hzs.activity.recommend.service.IAcRepurSharOrderTypeService;
import com.hzs.common.core.enums.EDelFlag;
import com.hzs.common.domain.activity.recommend.AcRepurSharOrderType;
import org.springframework.stereotype.Service;

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

/**
 * 复购券均分-订单类型 服务实现类
 *
 * @author hzs
 * @since 2023-05-04
 */
@Service
public class AcRepurSharOrderTypeServiceImpl extends ServiceImpl<AcRepurSharOrderTypeMapper, AcRepurSharOrderType> implements IAcRepurSharOrderTypeService {


    @Override
    public List<AcRepurSharOrderType> selectSharOrderByRuleId(Long pkRuleId) {
        LambdaQueryWrapper<AcRepurSharOrderType> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(AcRepurSharOrderType::getPkRuleId, pkRuleId);
        return baseMapper.selectList(queryWrapper);
    }


    @Override
    public Boolean deleteSharOrderTypeByRuleId(Long pkRuleId, Long pkModifyId) {
        LambdaUpdateWrapper<AcRepurSharOrderType> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.set(AcRepurSharOrderType::getDelFlag, EDelFlag.DELETE.getValue());
        updateWrapper.set(AcRepurSharOrderType::getPkModified, pkModifyId);
        updateWrapper.set(AcRepurSharOrderType::getModifiedTime, new Date());
        updateWrapper.eq(AcRepurSharOrderType::getPkRuleId, pkRuleId);
        return update(updateWrapper);
    }
}
