package com.m2pool.lease.mapper;

import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.m2pool.common.datasource.annotation.Pool2DB;
import com.m2pool.lease.dto.HourIncomeDto;
import com.m2pool.lease.dto.UserMinerDto;
import com.m2pool.lease.dto.UserMinerPowerDto;
import com.m2pool.lease.entity.LeaseUserOwnedProduct;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

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

/**
 * <p>
 * 用户拥有商品详情表 Mapper 接口
 * </p>
 *
 * @author yyb
 * @since 2025-07-23
 */
@Mapper
public interface LeaseUserOwnedProductMapper extends BaseMapper<LeaseUserOwnedProduct> {
    /**
     * 获取已生效商品机器id集合
     * @param beginOfDay
     * @return
     */
    List<Long> getProductMachineIds(@Param("beginOfDay") DateTime beginOfDay);


    /**
     * 获取小时收益列表
     * @param coin
     * @param start
     * @param end
     * @return
     */
    @Pool2DB
    List<HourIncomeDto> getHourIncomeList(@Param("list") List<LeaseUserOwnedProduct> list,@Param("coin") String coin, @Param("start") LocalDateTime start, @Param("end") LocalDateTime end);


    /**
     * 批量更新收益
     * @param list
     * @return
     */
    int updateBatchIncome(@Param("list") List<LeaseUserOwnedProduct> list);


    /**
     * 获取矿机实时算力（30m）
     * @param list
     * @param coin
     * @return
     */
    @Pool2DB
    List<UserMinerPowerDto> getUserMinerPower(@Param("list")List<UserMinerDto>  list,@Param("coin") String coin);
}
