package com.fs.crm.service.impl;

import java.util.List;
import com.fs.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.fs.crm.mapper.CrmCustomerHisOrderMapper;
import com.fs.crm.domain.CrmCustomerHisOrder;
import com.fs.crm.service.ICrmCustomerHisOrderService;

/**
 * 客户历史订单Service业务层处理
 * 
 * @author fs
 * @date 2023-04-07
 */
@Service
public class CrmCustomerHisOrderServiceImpl implements ICrmCustomerHisOrderService 
{
    @Autowired
    private CrmCustomerHisOrderMapper crmCustomerHisOrderMapper;

    /**
     * 查询客户历史订单
     * 
     * @param orderId 客户历史订单ID
     * @return 客户历史订单
     */
    @Override
    public CrmCustomerHisOrder selectCrmCustomerHisOrderById(Long orderId)
    {
        return crmCustomerHisOrderMapper.selectCrmCustomerHisOrderById(orderId);
    }

    /**
     * 查询客户历史订单列表
     * 
     * @param crmCustomerHisOrder 客户历史订单
     * @return 客户历史订单
     */
    @Override
    public List<CrmCustomerHisOrder> selectCrmCustomerHisOrderList(CrmCustomerHisOrder crmCustomerHisOrder)
    {
        return crmCustomerHisOrderMapper.selectCrmCustomerHisOrderList(crmCustomerHisOrder);
    }

    /**
     * 新增客户历史订单
     * 
     * @param crmCustomerHisOrder 客户历史订单
     * @return 结果
     */
    @Override
    public int insertCrmCustomerHisOrder(CrmCustomerHisOrder crmCustomerHisOrder)
    {
        if(crmCustomerHisOrder.getCreateTime()==null){
            crmCustomerHisOrder.setCreateTime(DateUtils.getNowDate());
        }
        return crmCustomerHisOrderMapper.insertCrmCustomerHisOrder(crmCustomerHisOrder);
    }

    /**
     * 修改客户历史订单
     * 
     * @param crmCustomerHisOrder 客户历史订单
     * @return 结果
     */
    @Override
    public int updateCrmCustomerHisOrder(CrmCustomerHisOrder crmCustomerHisOrder)
    {
        return crmCustomerHisOrderMapper.updateCrmCustomerHisOrder(crmCustomerHisOrder);
    }

    /**
     * 批量删除客户历史订单
     * 
     * @param orderIds 需要删除的客户历史订单ID
     * @return 结果
     */
    @Override
    public int deleteCrmCustomerHisOrderByIds(Long[] orderIds)
    {
        return crmCustomerHisOrderMapper.deleteCrmCustomerHisOrderByIds(orderIds);
    }

    /**
     * 删除客户历史订单信息
     * 
     * @param orderId 客户历史订单ID
     * @return 结果
     */
    @Override
    public int deleteCrmCustomerHisOrderById(Long orderId)
    {
        return crmCustomerHisOrderMapper.deleteCrmCustomerHisOrderById(orderId);
    }
}
