package com.gxwebsoft.shop.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.shop.mapper.OrderRenewMapper;
import com.gxwebsoft.shop.service.OrderRenewService;
import com.gxwebsoft.shop.entity.OrderRenew;
import com.gxwebsoft.shop.param.OrderRenewParam;
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-04-13 10:34:35
 */
@Service
public class OrderRenewServiceImpl extends ServiceImpl<OrderRenewMapper, OrderRenew> implements OrderRenewService {

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

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

    @Override
    public OrderRenew getByIdRel(Integer orderRenewId) {
        OrderRenewParam param = new OrderRenewParam();
        param.setOrderRenewId(orderRenewId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
