package com.ruoyi.ss.orderOper.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.ss.orderOper.domain.OrderOper;
import com.ruoyi.ss.orderOper.mapper.OrderOperMapper;
import com.ruoyi.ss.orderOper.service.IOrderOperService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;

/**
 * 操作操作履历Service业务层处理
 *
 * @author qzz
 * @date 2024-10-10
 */
@Service
public class OrderOperServiceImpl implements IOrderOperService
{
    @Resource
    private OrderOperMapper rlOrderOperMapper;

    /**
     * 查询操作操作履历
     *
     * @param operId 操作操作履历主键
     * @return 操作操作履历
     */
    @Override
    public OrderOper selectRlOrderOperByOperId(Long operId)
    {
        return rlOrderOperMapper.selectRlOrderOperByOperId(operId);
    }

    /**
     * 查询操作操作履历列表
     *
     * @param rlOrderOper 操作操作履历
     * @return 操作操作履历
     */
    @Override
    public List<OrderOper> selectRlOrderOperList(OrderOper rlOrderOper)
    {
        return rlOrderOperMapper.selectRlOrderOperList(rlOrderOper);
    }

    /**
     * 新增操作操作履历
     *
     * @param rlOrderOper 操作操作履历
     * @return 结果
     */
    @Override
    public int insertRlOrderOper(OrderOper rlOrderOper)
    {
        rlOrderOper.setCreateTime(DateUtils.getNowDate());
        return rlOrderOperMapper.insertRlOrderOper(rlOrderOper);
    }

    /**
     * 修改操作操作履历
     *
     * @param rlOrderOper 操作操作履历
     * @return 结果
     */
    @Override
    public int updateRlOrderOper(OrderOper rlOrderOper)
    {
        return rlOrderOperMapper.updateRlOrderOper(rlOrderOper);
    }

    /**
     * 批量删除操作操作履历
     *
     * @param operIds 需要删除的操作操作履历主键
     * @return 结果
     */
    @Override
    public int deleteRlOrderOperByOperIds(Long[] operIds)
    {
        return rlOrderOperMapper.deleteRlOrderOperByOperIds(operIds);
    }

    /**
     * 删除操作操作履历信息
     *
     * @param operId 操作操作履历主键
     * @return 结果
     */
    @Override
    public int deleteRlOrderOperByOperId(Long operId)
    {
        return rlOrderOperMapper.deleteRlOrderOperByOperId(operId);
    }

    @Override
    public boolean recordOrderHistory(String orderNo, String type, String beforeStatus,String afterStatus, BigDecimal beforeAmount,BigDecimal afterAmount,Long userId,String phone,String detail) {
        OrderOper rlOrderOper = new OrderOper();
        rlOrderOper.setOrderNo(orderNo);
        rlOrderOper.setOperType(type);
        rlOrderOper.setBeforeAmount(beforeAmount.toString());
        rlOrderOper.setAfterAmount(afterAmount.toString());
        rlOrderOper.setBeforeStatus(beforeStatus);
        rlOrderOper.setAfterStatus(afterStatus);
        rlOrderOper.setOperUserId(userId);
        rlOrderOper.setOperPhone(phone);
        rlOrderOper.setCreateTime(DateUtils.getNowDate());
        rlOrderOper.setDetails(detail);
        return rlOrderOperMapper.insertRlOrderOper(rlOrderOper) > 0;
    }


}
