package com.bonus.canteen.core.cook.service.impl;

import java.util.List;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.bonus.canteen.core.cook.mapper.CookDishesSaleRecordMapper;
import com.bonus.canteen.core.cook.domain.CookDishesSaleRecord;
import com.bonus.canteen.core.cook.service.ICookDishesSaleRecordService;

/**
 * 菜品销售记录Service业务层处理
 * 
 * @author xsheng
 * @date 2025-05-25
 */
@Service
public class CookDishesSaleRecordServiceImpl implements ICookDishesSaleRecordService {
    @Autowired
    private CookDishesSaleRecordMapper cookDishesSaleRecordMapper;

    /**
     * 查询菜品销售记录
     * 
     * @param id 菜品销售记录主键
     * @return 菜品销售记录
     */
    @Override
    public CookDishesSaleRecord selectCookDishesSaleRecordById(Long id) {
        return cookDishesSaleRecordMapper.selectCookDishesSaleRecordById(id);
    }

    /**
     * 查询菜品销售记录列表
     * 
     * @param cookDishesSaleRecord 菜品销售记录
     * @return 菜品销售记录
     */
    @Override
    public List<CookDishesSaleRecord> selectCookDishesSaleRecordList(CookDishesSaleRecord cookDishesSaleRecord) {
        return cookDishesSaleRecordMapper.selectCookDishesSaleRecordList(cookDishesSaleRecord);
    }

    /**
     * 新增菜品销售记录
     * 
     * @param cookDishesSaleRecord 菜品销售记录
     * @return 结果
     */
    @Override
    public int insertCookDishesSaleRecord(CookDishesSaleRecord cookDishesSaleRecord) {
        cookDishesSaleRecord.setCreateTime(DateUtils.getNowDate());
        try {
            return cookDishesSaleRecordMapper.insertCookDishesSaleRecord(cookDishesSaleRecord);
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

    /**
     * 修改菜品销售记录
     * 
     * @param cookDishesSaleRecord 菜品销售记录
     * @return 结果
     */
    @Override
    public int updateCookDishesSaleRecord(CookDishesSaleRecord cookDishesSaleRecord) {
        cookDishesSaleRecord.setUpdateTime(DateUtils.getNowDate());
        try {
            return cookDishesSaleRecordMapper.updateCookDishesSaleRecord(cookDishesSaleRecord);
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

    /**
     * 批量删除菜品销售记录
     * 
     * @param ids 需要删除的菜品销售记录主键
     * @return 结果
     */
    @Override
    public int deleteCookDishesSaleRecordByIds(Long[] ids) {
        return cookDishesSaleRecordMapper.deleteCookDishesSaleRecordByIds(ids);
    }

    /**
     * 删除菜品销售记录信息
     * 
     * @param id 菜品销售记录主键
     * @return 结果
     */
    @Override
    public int deleteCookDishesSaleRecordById(Long id) {
        return cookDishesSaleRecordMapper.deleteCookDishesSaleRecordById(id);
    }
}
