package com.gxwebsoft.glt.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.glt.mapper.GltUserTicketLogMapper;
import com.gxwebsoft.glt.service.GltUserTicketLogService;
import com.gxwebsoft.glt.entity.GltUserTicketLog;
import com.gxwebsoft.glt.param.GltUserTicketLogParam;
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 2026-02-03 18:55:55
 */
@Service
public class GltUserTicketLogServiceImpl extends ServiceImpl<GltUserTicketLogMapper, GltUserTicketLog> implements GltUserTicketLogService {

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

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

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

}
