package com.gxwebsoft.shop.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.shop.mapper.MerchantWithdrawMapper;
import com.gxwebsoft.shop.service.MerchantWithdrawService;
import com.gxwebsoft.shop.entity.MerchantWithdraw;
import com.gxwebsoft.shop.param.MerchantWithdrawParam;
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 2022-12-02 00:41:09
 */
@Service
public class MerchantWithdrawServiceImpl extends ServiceImpl<MerchantWithdrawMapper, MerchantWithdraw> implements MerchantWithdrawService {

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

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

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

}
