package com.jeequan.jeepay.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ArrayUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jeequan.jeepay.db.entity.RedPacketAccountDetail;
import com.jeequan.jeepay.service.mapper.RedPacketAccountDetailMapper;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 * 账户变动明细表 服务实现类
 * </p>
 *
 * @author [mybatis plus generator]
 * @since 2024-01-18
 */
@Service
public class RedPacketAccountDetailService extends ServiceImpl<RedPacketAccountDetailMapper, RedPacketAccountDetail>{

    /**
     *
     * @param flowNo
     * @param types
     * @return
     */
    public List<RedPacketAccountDetail> getByFlowNoType(String flowNo, Byte... types) {
        LambdaQueryWrapper<RedPacketAccountDetail> queryWrapper = new LambdaQueryWrapper<RedPacketAccountDetail>();
        queryWrapper.eq(RedPacketAccountDetail::getFlowNo,flowNo);
        if (ArrayUtils.isNotEmpty(types)) {
            queryWrapper.in(RedPacketAccountDetail::getType,types);
        }
        return baseMapper.selectList(queryWrapper);
    }
}
