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

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
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.constant.SystemFieldConstants;
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;

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


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


    @Override
    public Boolean deleteSharOrderTypeByRuleId(Long pkRuleId, Long pkModifyId) {
        UpdateWrapper<AcRepurSharOrderType> updateWrapper = new UpdateWrapper<>();
        updateWrapper.set(SystemFieldConstants.DEL_FLAG, EDelFlag.DELETE.getValue());
        updateWrapper.set(SystemFieldConstants.PK_MODIFIED, pkModifyId);
        updateWrapper.set(SystemFieldConstants.MODIFIED_TIME, new Date());
        updateWrapper.eq("PK_RULE_ID", pkRuleId);
        return update(updateWrapper);
    }
}
