package com.gxwebsoft.shop.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.shop.mapper.RechargeOrderPlanMapper;
import com.gxwebsoft.shop.service.RechargeOrderPlanService;
import com.gxwebsoft.shop.entity.RechargeOrderPlan;
import com.gxwebsoft.shop.param.RechargeOrderPlanParam;
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-20 20:36:24
 */
@Service
public class RechargeOrderPlanServiceImpl extends ServiceImpl<RechargeOrderPlanMapper, RechargeOrderPlan> implements RechargeOrderPlanService {

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

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

    @Override
    public RechargeOrderPlan getByIdRel(Integer orderPlanId) {
        RechargeOrderPlanParam param = new RechargeOrderPlanParam();
        param.setOrderPlanId(orderPlanId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
