package com.kym.service.impl;

import com.github.pagehelper.PageHelper;
import com.kym.common.utils.CommUtil;
import com.kym.entity.ParkingCouponRecord;
import com.kym.entity.common.PageBean;
import com.kym.mapper.ParkingCouponRecordMapper;
import com.kym.service.ParkingCouponRecordService;
import com.kym.service.mybatisplus.MyBaseServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 停车券发放记录表 服务实现类
 * </p>
 *
 * @author skyline
 * @since 2026-06-12
 */
@Service
public class ParkingCouponRecordServiceImpl extends MyBaseServiceImpl<ParkingCouponRecordMapper, ParkingCouponRecord> implements ParkingCouponRecordService {

    @Override
    public PageBean<ParkingCouponRecord> page(Integer pageNum, Integer pageSize, Long userId, String stationId, Integer status) {
        PageHelper.startPage(pageNum, pageSize);
        var list = lambdaQuery()
                .eq(userId != null, ParkingCouponRecord::getUserId, userId)
                .eq(CommUtil.isNotEmptyAndNull(stationId), ParkingCouponRecord::getStationId, stationId)
                .eq(status != null, ParkingCouponRecord::getStatus, status)
                .orderByDesc(ParkingCouponRecord::getCreateTime)
                .list();
        return new PageBean<>(list);
    }
}
