package com.kym.service.impl;


import com.github.pagehelper.PageHelper;
import com.github.yulichang.base.MPJBaseServiceImpl;
import com.kym.entity.queryParams.CommonQueryParam;
import com.kym.entity.common.PageBean;
import com.kym.entity.RefundLog;
import com.kym.entity.vo.RefundVo;
import com.kym.mapper.RefundLogMapper;
import com.kym.service.RefundLogService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 退款日志 服务实现类
 * </p>
 *
 * @author skyline
 * @since 2023-09-11
 */
@Service
public class RefundLogServiceImpl extends MPJBaseServiceImpl<RefundLogMapper, RefundLog> implements RefundLogService {

    @Override
    public PageBean<RefundVo> listRefundLog(CommonQueryParam params) {
        PageHelper.startPage(params.getPageNum(), params.getPageSize());
        var list = baseMapper.listRefundLog(params);
        return new PageBean<>(list);
    }

    @Override
    public PageBean<RefundLog> listRefundLogForApp(CommonQueryParam params) {
        PageHelper.startPage(params.getPageNum(), params.getPageSize());
        var list = lambdaQuery().eq(RefundLog::getUserId, params.getUserId()).orderByDesc(RefundLog::getCreateTime).list();
        return new PageBean<>(list);
    }

    @Override
    public RefundLog detail(String outRefundNo) {
        return lambdaQuery().eq(RefundLog::getOutRefundNo, outRefundNo).one();
    }
}
