package com.gxwebsoft.shop.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.shop.mapper.OrderInfoLogMapper;
import com.gxwebsoft.shop.service.OrderInfoLogService;
import com.gxwebsoft.shop.entity.OrderInfoLog;
import com.gxwebsoft.shop.param.OrderInfoLogParam;
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 2024-05-14 13:20:04
 */
@Service
public class OrderInfoLogServiceImpl extends ServiceImpl<OrderInfoLogMapper, OrderInfoLog> implements OrderInfoLogService {

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

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

    @Override
    public OrderInfoLog getByIdRel(Integer id) {
        OrderInfoLogParam param = new OrderInfoLogParam();
        param.setId(id);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
