package com.jeesharp.business.modules.member.service;

import com.jeesharp.business.modules.member.entity.MemberPointsLog;
import com.jeesharp.business.modules.member.enums.MemberPointsTypeEnum;
import com.jeesharp.business.modules.member.vo.MemberPointsLogQueryVO;
import com.jeesharp.framework.mybatis.core.service.BaseInterface;

import java.util.List;

/**
 * 会员积分流水领域服务，负责流水落库、查询与按会员查询。
 *
 * @author jeesharp
 * @since 2026-06-09
 */
public interface MemberPointsLogService extends BaseInterface<MemberPointsLog, MemberPointsLogQueryVO> {

    /**
     * 写入一条积分流水。
     */
    void appendLog(MemberPointsLog log);

    /**
     * 记录积分变动（封装 before/after 与正负号）。
     */
    void recordChange(String memberId, MemberPointsTypeEnum pointsType, int delta,
                      int beforePoints, int afterPoints,
                      String bizType, String bizId, String bizDesc);

    /**
     * 记录积分变动并关联规则与过期时间，返回流水主键。
     */
    String recordChangeWithRule(String memberId, MemberPointsTypeEnum pointsType, int delta,
                                int beforePoints, int afterPoints,
                                String bizType, String bizId, String bizDesc,
                                String ruleId, String ruleName,
                                java.time.LocalDateTime expireDate, String operateSource);

    /**
     * 会员最近积分流水（按创建时间倒序）。
     */
    List<MemberPointsLog> listRecentByMember(String memberId, int limit);
}
