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.DeductionRecord;
import com.ruoyi.web.v2.entity.request.DeductionRecordRequest;
import com.ruoyi.web.v2.mapper.DeductionRecordMapper;
import com.ruoyi.web.v2.service.IDeductionRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author author
 * @since 2025-12-25
 */
@Service
public class DeductionRecordServiceImpl extends ServiceImpl<DeductionRecordMapper, DeductionRecord> implements IDeductionRecordService {

    @Override
    public AjaxResult getListPayRecordPage(DeductionRecordRequest deductionRecordRequest) {
        return AjaxResult.success(this.page(new Page<DeductionRecord>( deductionRecordRequest.getPageNum(),deductionRecordRequest.getPageSize()),new QueryWrapper<DeductionRecord>()
                .ge(StringUtils.isNotEmpty(deductionRecordRequest.getStartDate()), "create_time", deductionRecordRequest.getStartDate())
                .le(StringUtils.isNotEmpty(deductionRecordRequest.getEndDate()),"create_time",deductionRecordRequest.getEndDate())
                .like(StringUtils.isNotEmpty(deductionRecordRequest.getUserId()),"user_id",deductionRecordRequest.getUserId())
        ));
    }

    @Override
    public AjaxResult getList(DeductionRecordRequest deductionRecordRequest) {
        return AjaxResult.success(this.list( new QueryWrapper<DeductionRecord>()
                .ge(StringUtils.isNotEmpty(deductionRecordRequest.getStartDate()), "create_time", deductionRecordRequest.getStartDate())
                .le(StringUtils.isNotEmpty(deductionRecordRequest.getEndDate()),"create_time",deductionRecordRequest.getEndDate())
                .like(StringUtils.isNotEmpty(deductionRecordRequest.getUserId()),"user_id",deductionRecordRequest.getUserId())
        ));
    }
}
