package com.ruoyi.web.v2.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.web.v2.entity.PayInvoice;
import com.ruoyi.web.v2.entity.request.PayInvoiceRequest;
import com.ruoyi.web.v2.mapper.PayInvoiceMapper;
import com.ruoyi.web.v2.service.IPayInvoiceService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author author
 * @since 2025-12-25
 */
@Service
public class PayInvoiceServiceImpl extends ServiceImpl<PayInvoiceMapper, PayInvoice> implements IPayInvoiceService {

    @Override
    public AjaxResult getListByPage(PayInvoiceRequest payInvoice) {
        return AjaxResult.success(this.page(new Page<PayInvoice>( payInvoice.getPageNum(),payInvoice.getPageSize()),
                new QueryWrapper<PayInvoice>()
                        .ge(StringUtils.isNotEmpty(payInvoice.getStartTime()), "create_time", payInvoice.getStartTime())
                        .le(StringUtils.isNotEmpty(payInvoice.getEndTime()),"create_time",payInvoice.getEndTime())
                .eq(StringUtils.isNotEmpty(payInvoice.getUserId()),"user_id",payInvoice.getUserId())));
    }

    @Override
    public AjaxResult getList(PayInvoiceRequest payInvoice) {
        return AjaxResult.success(this.list(  new QueryWrapper<PayInvoice>()
                .ge(StringUtils.isNotEmpty(payInvoice.getStartTime()), "create_time", payInvoice.getStartTime())
                .le(StringUtils.isNotEmpty(payInvoice.getEndTime()),"create_time",payInvoice.getEndTime())
                .eq(StringUtils.isNotEmpty(payInvoice.getUserId()),"user_id",payInvoice.getUserId())));
    }
}
