package com.bonus.canteen.core.account.mapper;

import com.bonus.canteen.core.account.domain.AccWalletInfo;
import com.bonus.canteen.core.account.domain.vo.AccWalletInfoVO;
import org.apache.ibatis.annotations.Param;

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

/**
 * 钱包详情信息Mapper接口
 * 
 * @author xsheng
 * @date 2025-04-05
 */
public interface AccWalletInfoMapper {
    /**
     * 查询钱包详情信息
     * 
     * @param userId 钱包详情信息主键
     * @return 钱包详情信息
     */
    public List<AccWalletInfo> selectAccWalletInfoByUserId(Long userId);
    public AccWalletInfo selectAccWalletInfoByUserIdAndWalletType(@Param("userId") Long userId, @Param("walletType") Integer walletType);

    List<AccWalletInfoVO> selectAccWalletInfoByUserIds(@Param("userIds") List<Long> userIds);

    /**
     * 查询钱包详情信息列表
     * 
     * @param accWalletInfo 钱包详情信息
     * @return 钱包详情信息集合
     */
    public List<AccWalletInfo> selectAccWalletInfoList(AccWalletInfo accWalletInfo);

    /**
     * 新增钱包详情信息
     * 
     * @param accWalletInfo 钱包详情信息
     * @return 结果
     */
    public int insertAccWalletInfo(AccWalletInfo accWalletInfo);

    public int batchInsertAccWalletInfo(@Param("list") List<AccWalletInfo> accWalletInfos);


    /**
     * 删除钱包详情信息
     * 
     * @param userId 钱包详情信息主键
     * @return 结果
     */
    public int deleteAccWalletInfoByUserId(Long userId);

    /**
     * 批量删除钱包详情信息
     * 
     * @param userIds 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteAccWalletInfoByUserIds(Long[] userIds);

    void updateMinBalanceByUserId(@Param("minBalance") BigDecimal limitBalance,
                                  @Param("walletType") Integer walletType,
                                  @Param("userIds") List<Long> userIds,
                                  @Param("updateBy") String updateBy,
                                  @Param("updateTime") LocalDateTime updateTime);

    void addAccWalletInfo(@Param("amount") BigDecimal amount,
                          @Param("userId") Long userId,
                          @Param("walletType") Integer walletType,
                          @Param("updateBy") String updateBy,
                          @Param("updateTime") LocalDateTime updateTime
                          );
    void reduceAccWalletInfo(@Param("amount") BigDecimal amount,
                             @Param("userId") Long userId,
                             @Param("walletType") Integer walletType,
                             @Param("updateBy") String updateBy,
                             @Param("updateTime") LocalDateTime updateTime
    );

    void clearAccWalletInfo(@Param("userId") Long userId,
                            @Param("walletType") Integer walletType,
                            @Param("updateBy") String updateBy,
                            @Param("updateTime") LocalDateTime updateTime
    );
}
