package com.ruoyi.frequency.orderevaluate.service.impl;

import java.math.BigDecimal;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.vo.UserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.code.PublicCommon;
import com.ruoyi.frequency.orderevaluate.mapper.OrderEvaluateMapper;
import com.ruoyi.frequency.orderevaluate.entity.OrderEvaluate;
import com.ruoyi.frequency.orderevaluate.service.OrderEvaluateService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 订单评价Service业务层处理
 *
 * @author zj
 * @date 2023-10-13
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class OrderEvaluateServiceImpl extends ServiceImpl<OrderEvaluateMapper, OrderEvaluate>  implements OrderEvaluateService
{
    @Autowired
    private OrderEvaluateMapper orderEvaluateMapper;

    /**
     * 查询订单评价
     *
     * @param id 订单评价主键
     * @return 订单评价
     */
    @Override
    public OrderEvaluate selectOrderEvaluateById(Long id)
    {
        return orderEvaluateMapper.selectOrderEvaluateById(id);
    }

    /**
     * 查询订单评价列表
     *
     * @param orderEvaluate 订单评价
     * @return 订单评价
     */
    @Override
    public List<OrderEvaluate> selectOrderEvaluateList(OrderEvaluate orderEvaluate)
    {
        return orderEvaluateMapper.selectOrderEvaluateList(orderEvaluate);
    }

    /**
     * 新增订单评价
     *
     * @param orderEvaluate 订单评价
     * @return 结果
     */
    @Override
    public int insertOrderEvaluate(OrderEvaluate orderEvaluate)
    {
        return orderEvaluateMapper.insertOrderEvaluate(orderEvaluate);
    }

    /**
     * 修改订单评价
     *
     * @param orderEvaluate 订单评价
     * @return 结果
     */
    @Override
    public int updateOrderEvaluate(OrderEvaluate orderEvaluate)
    {
        orderEvaluate.setUpdateTime(DateUtils.getNowDate());
        return orderEvaluateMapper.updateOrderEvaluate(orderEvaluate);
    }

    /**
     * 批量删除订单评价
     *
     * @param ids 需要删除的订单评价主键
     * @return 结果
     */
    @Override
    public int deleteOrderEvaluateByIds(Long[] ids)
    {
        this.lambdaUpdate().set(OrderEvaluate::getDelFlag,PublicCommon.删除).in(OrderEvaluate::getId,ids).update();
        return ids.length;
    }

    /**
     * 删除订单评价信息
     *
     * @param id 订单评价主键
     * @return 结果
     */
    @Override
    public int deleteOrderEvaluateById(Long id)
    {
        this.lambdaUpdate().set(OrderEvaluate::getDelFlag,PublicCommon.删除).eq(OrderEvaluate::getId,id).update();
        return 1;
    }

    @Override
    public BigDecimal getUserStar(UserVo evaluateUserVo) {
        return orderEvaluateMapper.getUserStar(evaluateUserVo);
    }
}
