package com.jeesharp.business.modules.marketing.couponVerifyLog.service.impl;

import cn.hutool.core.util.StrUtil;
import com.jeesharp.business.modules.marketing.couponVerifyLog.entity.MemberCouponVerifyLog;
import com.jeesharp.business.modules.marketing.couponVerifyLog.mapper.MemberCouponVerifyLogMapper;
import com.jeesharp.business.modules.marketing.couponVerifyLog.service.MemberCouponVerifyLogService;
import com.jeesharp.business.modules.marketing.couponVerifyLog.vo.MemberCouponVerifyLogQueryVO;
import com.jeesharp.framework.exception.BizErrorException;
import com.jeesharp.framework.mybatis.core.service.CrudService;
import org.springframework.stereotype.Service;

/**
 * 会员券核销流水领域服务实现。
 *
 * @author jeesharp
 * @since 2026-06-25
 */
@Service
public class MemberCouponVerifyLogServiceImpl
        extends CrudService<MemberCouponVerifyLogMapper, MemberCouponVerifyLog, MemberCouponVerifyLogQueryVO>
        implements MemberCouponVerifyLogService {

    @Override
    public MemberCouponVerifyLog createVerifyLog(MemberCouponVerifyLog entity) {
        if (StrUtil.isNotBlank(entity.getId())) {
            throw new BizErrorException("新增核销流水不应预置主键");
        }
        entity.preInsert();
        getBaseMapper().insert(entity);
        return entity;
    }

    @Override
    public MemberCouponVerifyLog getByVerifyToken(String verifyToken) {
        if (StrUtil.isBlank(verifyToken)) {
            return null;
        }
        return getBaseMapper().getByVerifyToken(verifyToken.trim());
    }
}
