package com.fs.oms.service.impl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import com.fs.common.utils.DateUtils;
import com.fs.oms.vo.OmsPurchaseOrderVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.fs.oms.mapper.OmsPurchaseOrderMapper;
import com.fs.oms.domain.OmsPurchaseOrder;
import com.fs.oms.service.IOmsPurchaseOrderService;

/**
 * oms采购单Service业务层处理
 *
 * @author oms
 * @date 2023-07-03
 */
@Service
public class OmsPurchaseOrderServiceImpl implements IOmsPurchaseOrderService
{
    @Autowired
    private OmsPurchaseOrderMapper omsPurchaseOrderMapper;

    /**
     * 查询oms采购单
     *
     * @param id oms采购单ID
     * @return oms采购单
     */
    @Override
    public OmsPurchaseOrder selectOmsPurchaseOrderById(Long id)
    {
        return omsPurchaseOrderMapper.selectOmsPurchaseOrderById(id);
    }

    /**
     * 查询oms采购单列表
     * @return oms采购单
     */
    @Override
    public List<OmsPurchaseOrderVO> selectOmsPurchaseOrderList(OmsPurchaseOrderVO omsPurchaseOrderVO)
    {
        return omsPurchaseOrderMapper.selectOmsPurchaseOrderList(omsPurchaseOrderVO);
    }

    /**
     * 新增oms采购单
     *
     * @param omsPurchaseOrder oms采购单
     * @return 结果
     */
    @Override
    public int insertOmsPurchaseOrder(OmsPurchaseOrder omsPurchaseOrder)
    {

        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
        String timeStr = sdf.format(new Date());
        String prefix = "ORD";
        omsPurchaseOrder.setCode(prefix + timeStr);
        omsPurchaseOrder.setCreateTime(DateUtils.getNowDate());
        return omsPurchaseOrderMapper.insertOmsPurchaseOrder(omsPurchaseOrder);
    }

    /**
     * 修改oms采购单
     *
     * @param omsPurchaseOrder oms采购单
     * @return 结果
     */
    @Override
    public int updateOmsPurchaseOrder(OmsPurchaseOrder omsPurchaseOrder)
    {
        omsPurchaseOrder.setUpdateTime(DateUtils.getNowDate());
        return omsPurchaseOrderMapper.updateOmsPurchaseOrder(omsPurchaseOrder);
    }

    /**
     * 批量删除oms采购单
     *
     * @param ids 需要删除的oms采购单ID
     * @return 结果
     */
    @Override
    public int deleteOmsPurchaseOrderByIds(Long[] ids)
    {
        return omsPurchaseOrderMapper.deleteOmsPurchaseOrderByIds(ids);
    }

    /**
     * 删除oms采购单信息
     *
     * @param id oms采购单ID
     * @return 结果
     */
    @Override
    public int deleteOmsPurchaseOrderById(Long id)
    {
        return omsPurchaseOrderMapper.deleteOmsPurchaseOrderById(id);
    }
}
