package com.copy.trade.dao;

import com.copy.trade.entity.dto.PositionDto;
import com.copy.trade.entity.form.CopiedTradeForm;
import com.copy.trade.entity.form.PositionForm;
import com.copy.trade.entity.po.Position;
import com.copy.trade.entity.vo.CopiedTradeVo;
import com.copy.trade.entity.vo.PositionStatisticsVo;
import com.copy.trade.entity.vo.PositionVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 跟单持仓表 Mapper 接口
 * </p>
 *
 * @author wz
 * @since 2022-11-17
 */
public interface PositionMapper extends BaseMapper<Position> {

    BigDecimal sumPrincipalAmount(@Param("customerId") Long customerId, @Param("traderId") Long traderId);
    
    Position getStudentPositionByTraderPositionId(@Param("traderPositionId") Long traderPositionId, @Param("customerId") Long customerId);

    Boolean updateAvailablePosition(@Param("volume")BigDecimal volume,@Param("positionId") Long positionId);

    List<Position> followPosition(String contractOrderEntrustId);

    List<Position> followPositionByTraderPositionId(@Param("traderPositionId") Long traderPositionId);
  
    Position getTraderPosition(@Param("customerId")Long customerId,@Param("contractOrderEntrustId")String contractOrderEntrustId);

    Boolean updateCurrentPosition(@Param("volume")BigDecimal volume, @Param("positionId")Long positionId,@Param("status") Integer status, @Param("closeTime") Long transactionTime);

    List<Position> closedPositionList(@Param("traderId") Long traderId, @Param("startTime") Long startTime, @Param("endTime") Long endTime);
    
    List<Position> updatePositionList(@Param("traderId") Long traderId, @Param("startTime") Date startTime, @Param("endTime") Date endTime);

    BigDecimal sumFollowAmount(Long traderId);
    
    BigDecimal sumFollowAmountToday(Long traderId,Long startTime);
    
    List<Position> sumPositionList(@Param("customerId") Long customerId, @Param("traderId") Long traderId);
    
    List<PositionDto> selectPositionStatusNot30All();
    
    List<PositionVo> page(@Param("page") Page page, @Param("positionForm") PositionForm positionForm);
    
    BigDecimal selectDividendFee(@Param("position")Position position);

    BigDecimal selectCommission(@Param("position")Position position);
    
    BigDecimal selectStudentProfit(@Param("customerId") Long customerId, @Param("traderId") Long traderId);
    
    BigDecimal sumTotalFollowAmount();

}
