package com.gxwebsoft.shop.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.shop.mapper.DealerCapitalMapper;
import com.gxwebsoft.shop.service.DealerCapitalService;
import com.gxwebsoft.shop.entity.DealerCapital;
import com.gxwebsoft.shop.param.DealerCapitalParam;
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-07-28 11:57:41
 */
@Service
public class DealerCapitalServiceImpl extends ServiceImpl<DealerCapitalMapper, DealerCapital> implements DealerCapitalService {

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

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

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

}
