package com.kym.service.miniapp.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.github.pagehelper.PageHelper;
import com.github.yulichang.base.MPJBaseServiceImpl;
import com.kym.entity.admin.queryParams.CommonQueryParam;
import com.kym.entity.common.PageBean;
import com.kym.entity.miniapp.RefundLog;
import com.kym.entity.miniapp.vo.RefundVo;
import com.kym.mapper.miniapp.RefundLogMapper;
import com.kym.service.miniapp.RefundLogService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 退款日志 服务实现类
 * </p>
 *
 * @author skyline
 * @since 2023-09-11
 */
@Service
@DS("db-miniapp")
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);
    }
}
