package com.sonic.lion.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.sonic.lion.dao.IapRecordDao;
import com.sonic.lion.domain.entity.IapRecord;
import com.sonic.lion.service.IapRecordService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Service;

/**
 * @author: code
 * @date: 2025/06/24
 * @Description:
 * @version: 1.0.0
 */
@Service
public class IapRecordServiceImpl implements IapRecordService {

    @Autowired
    private IapRecordDao iapRecordDao;

    @Override
    public void save(@NonNull IapRecord iapRecord) {
        iapRecordDao.insert(iapRecord);
    }

    @Override
    public IapRecord getByTransactionId(String transactionId) {
        if (StringUtils.isBlank(transactionId)) {
            return null;
        }
        LambdaQueryWrapper<IapRecord> queryWrapper = Wrappers.<IapRecord>lambdaQuery()
                .eq(IapRecord::getTransactionId, transactionId);
        return iapRecordDao.selectOne(queryWrapper);
    }
}
