package com.gxwebsoft.shop.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.shop.mapper.ProfitLogMapper;
import com.gxwebsoft.shop.service.ProfitLogService;
import com.gxwebsoft.shop.entity.ProfitLog;
import com.gxwebsoft.shop.param.ProfitLogParam;
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-08-10 11:24:02
 */
@Service
public class ProfitLogServiceImpl extends ServiceImpl<ProfitLogMapper, ProfitLog> implements ProfitLogService {

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

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

    @Override
    public ProfitLog getByIdRel(Integer profitId) {
        ProfitLogParam param = new ProfitLogParam();
        param.setProfitId(profitId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
