package com.gxwebsoft.shop.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.shop.mapper.OrderRefundMapper;
import com.gxwebsoft.shop.service.OrderRefundService;
import com.gxwebsoft.shop.entity.OrderRefund;
import com.gxwebsoft.shop.param.OrderRefundParam;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 售后单记录表Service实现
 *
 * @author 科技小王子
 * @since 2023-05-18 13:09:51
 */
@Service
public class OrderRefundServiceImpl extends ServiceImpl<OrderRefundMapper, OrderRefund> implements OrderRefundService {

    @Override
    public PageResult<OrderRefund> pageRel(OrderRefundParam param) {
        PageParam<OrderRefund, OrderRefundParam> page = new PageParam<>(param);
        page.setDefaultOrder("create_time desc");
        List<OrderRefund> list = baseMapper.selectPageRel(page, param);
        return new PageResult<>(list, page.getTotal());
    }

    @Override
    public List<OrderRefund> listRel(OrderRefundParam param) {
        List<OrderRefund> list = baseMapper.selectListRel(param);
        // 排序
        PageParam<OrderRefund, OrderRefundParam> page = new PageParam<>();
        page.setDefaultOrder("create_time desc");
        return page.sortRecords(list);
    }

    @Override
    public OrderRefund getByIdRel(Integer orderRefundId) {
        OrderRefundParam param = new OrderRefundParam();
        param.setOrderRefundId(orderRefundId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
