package com.sonic.lion.service.impl;

import com.sonic.lion.dao.IapUploadReceiptDao;
import com.sonic.lion.domain.entity.IapUploadReceipt;
import com.sonic.lion.service.IapUploadReceiptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @author: code
 * @date: 2025/07/15
 * @Description:
 * @version: 1.0.0
 */
@Service
public class IapUploadReceiptServiceImpl implements IapUploadReceiptService {

    @Autowired
    private IapUploadReceiptDao iapUploadReceiptDao;

    @Override
    public IapUploadReceipt getById(Long id) {
        return iapUploadReceiptDao.selectById(id);
    }

    @Override
    public Long save(@NonNull IapUploadReceipt iapUploadReceipt) {
        iapUploadReceiptDao.insert(iapUploadReceipt);
        return  iapUploadReceipt.getId();
    }

    @Override
    public int updateProcessed(@NonNull Long id, @NonNull Boolean processed) {
        IapUploadReceipt updater = IapUploadReceipt.builder()
                .id(id)
                .processed(processed)
                .build();
        return iapUploadReceiptDao.updateById(updater);
    }

    @Override
    public List<IapUploadReceipt> list(Boolean processed, LocalDateTime startCreateTime, Integer num) {
        return iapUploadReceiptDao.list(processed, startCreateTime, num);
    }
}
