package com.yiqi.activity.service.impl;

import java.util.List;

import com.yiqi.activity.domain.dto.ChangeActivityCouponItemStockDTO;
import com.yiqi.activity.domain.vo.ActivityCouponItemVO;
import com.yiqi.common.utils.DateUtils;
import com.yiqi.common.utils.SecurityUtils;
import com.yiqi.order.domain.OrderActivityItem;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yiqi.activity.mapper.ActivityCouponItemMapper;
import com.yiqi.activity.domain.ActivityCouponItem;
import com.yiqi.activity.service.IActivityCouponItemService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * 注册送券活动优惠券明细Service业务层处理
 *
 * @author xiaohei
 * @date 2023-09-09
 */
@Service
public class ActivityCouponItemServiceImpl extends ServiceImpl<ActivityCouponItemMapper,ActivityCouponItem> implements IActivityCouponItemService {

    /**
     * 查询注册送券活动优惠券明细
     *
     * @param id 注册送券活动优惠券明细主键
     * @return 注册送券活动优惠券明细
     */
    @Override
    public ActivityCouponItem selectActivityCouponItemById(Long id) {
        return baseMapper.selectActivityCouponItemById(id);
    }

    /**
     * 查询注册送券活动优惠券明细列表
     *
     * @param activityCouponItem 注册送券活动优惠券明细
     * @return 注册送券活动优惠券明细
     */
    @Override
    public List<ActivityCouponItemVO> selectActivityCouponItemList(ActivityCouponItem activityCouponItem) {
        return baseMapper.selectActivityCouponItemList(activityCouponItem);
    }

    /**
     * 查询指定送券活动优惠券明细列表
     *
     * @param activityId 指定送券活动id
     * @return 查询指定送券活动优惠券明细列表
     */
    @Override
    public List<ActivityCouponItemVO> selectActivityCouponItemListByActivityId(Long activityId) {
        return baseMapper.selectActivityCouponItemListByActivityId(activityId);
    }

    /**
     * 新增注册送券活动优惠券明细
     *
     * @param activityCouponItem 注册送券活动优惠券明细
     * @return 结果
     */
    @Override
    public int insertActivityCouponItem(ActivityCouponItem activityCouponItem) {
        activityCouponItem.setCreateTime(DateUtils.getNowDate());
        return baseMapper.insertActivityCouponItem(activityCouponItem);
    }

    @Override
    public int minusActivityCouponStockByOrder(List<OrderActivityItem> orderActivityItemList) {
        return baseMapper.minusActivityCouponStockByOrder(orderActivityItemList);
    }

    @Override
    public int addActivityCouponStockByOrder(List<OrderActivityItem> orderActivityItemList) {
        return baseMapper.addActivityCouponStockByOrder(orderActivityItemList);
    }

    /**
     * 修改注册送券活动优惠券明细
     *
     * @param activityCouponItem 注册送券活动优惠券明细
     * @return 结果
     */
    @Override
    public int updateActivityCouponItem(ActivityCouponItem activityCouponItem) {
        activityCouponItem.setUpdateTime(DateUtils.getNowDate());
        return baseMapper.updateActivityCouponItem(activityCouponItem);
    }

    @Override
    public int editStock(ChangeActivityCouponItemStockDTO changeActivityCouponItemStockDTO){
        changeActivityCouponItemStockDTO.setUpdateBy(SecurityUtils.getUsername());
        changeActivityCouponItemStockDTO.setUpdateById(SecurityUtils.getUserId());
        changeActivityCouponItemStockDTO.setUpdateTime(DateUtils.getNowDate());
        return baseMapper.editStock(changeActivityCouponItemStockDTO);
    }

    /**
     * 批量删除注册送券活动优惠券明细
     *
     * @param ids 需要删除的注册送券活动优惠券明细主键
     * @return 结果
     */
    @Override
    public int deleteActivityCouponItemByIds(Long[] ids) {
        return baseMapper.deleteActivityCouponItemByIds(ids);
    }

    /**
     * 删除注册送券活动优惠券明细信息
     *
     * @param id 注册送券活动优惠券明细主键
     * @return 结果
     */
    @Override
    public int deleteActivityCouponItemById(Long id) {
        return baseMapper.deleteActivityCouponItemById(id);
    }



}
