package com.gxwebsoft.shop.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.shop.mapper.DealerWithdrawMapper;
import com.gxwebsoft.shop.service.DealerWithdrawService;
import com.gxwebsoft.shop.entity.DealerWithdraw;
import com.gxwebsoft.shop.param.DealerWithdrawParam;
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 DealerWithdrawServiceImpl extends ServiceImpl<DealerWithdrawMapper, DealerWithdraw> implements DealerWithdrawService {

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

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

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

}
