package com.gxwebsoft.shop.service.impl;

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

import javax.annotation.Resource;
import java.util.List;

/**
 * 会员充值订单表Service实现
 *
 * @author 科技小王子
 * @since 2023-04-20 20:36:24
 */
@Service
public class RechargeOrderServiceImpl extends ServiceImpl<RechargeOrderMapper, RechargeOrder> implements RechargeOrderService {
    @Resource
    private UserService userService;

    @Override
    public PageResult<RechargeOrder> pageRel(RechargeOrderParam param) {
        PageParam<RechargeOrder, RechargeOrderParam> page = new PageParam<>(param);
        page.setDefaultOrder("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("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));
    }

}
