package com.gxwebsoft.shop.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.shop.mapper.PaymentTradeMapper;
import com.gxwebsoft.shop.service.PaymentTradeService;
import com.gxwebsoft.shop.entity.PaymentTrade;
import com.gxwebsoft.shop.param.PaymentTradeParam;
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-09 13:59:38
 */
@Service
public class PaymentTradeServiceImpl extends ServiceImpl<PaymentTradeMapper, PaymentTrade> implements PaymentTradeService {

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

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

    @Override
    public PaymentTrade getByIdRel(Integer tradeId) {
        PaymentTradeParam param = new PaymentTradeParam();
        param.setTradeId(tradeId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
