package com.gxwebsoft.common.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.system.entity.RechargeOrder;
import com.gxwebsoft.common.system.mapper.RechargeOrderMapper;
import com.gxwebsoft.common.system.param.RechargeOrderParam;
import com.gxwebsoft.common.system.service.RechargeOrderService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 会员充值订单表Service实现
 *
 * @author 科技小王子
 * @since 2024-07-26 23:18:48
 */
@Service
public class RechargeOrderServiceImpl extends ServiceImpl<RechargeOrderMapper, RechargeOrder> implements RechargeOrderService {

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

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

    @Override
    public RechargeOrder getByIdRel(Integer orderId) {
        RechargeOrderParam param = new RechargeOrderParam();
        param.setOrderId(orderId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
