package com.copy.trade.service;

import com.copy.trade.dao.PositionMapper;
import com.copy.trade.entity.dto.ContractOrderEntrust;
import com.copy.trade.entity.dto.EntrustDeal;
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.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;

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

/**
 * <p>
 * 跟单持仓表 服务类
 * </p>
 *
 * @author wz
 * @since 2022-11-17
 */
public interface IPositionService extends IService<Position> {

    public Boolean entrustDeal(EntrustDeal entrustDeal);
    
    public Boolean entrustOrderSuccess(Long posionId,ContractOrderEntrust entrustDeal,Long customerId,Long traderId,Long traderPositionId);

    public Position getByPositionId(Long positionId);

    public Boolean updateAvailablePosition(BigDecimal volume, Long positionId);

    public Boolean updateCurrentPosition(BigDecimal volume, Long positionId, Integer status, Long transactionTime);

    public List<Position> followPosition(String contractOrderEntrustId);

    public List<Position> followPositionByTraderPositionId(Long traderPositionId);

    public Position getByContractOrderEntrustId(String contractOrderEntrustId);
    
    public Position getTraderPosition(Long customerId,String contractOrderEntrustId);

    BigDecimal sumPrincipalAmount(Long customerId, Long traderId);

    public Map<String,BigDecimal> earningsCalculationByDay(Long traderId, Long startTime, Long endTime);
    
    public List<Position> updatePositionList(Long traderId, Date startTime, Date endTime);

    BigDecimal sumFollowAmount(Long traderId);
    
    BigDecimal sumFollowAmountToday(Long traderId, Long startTime);
    
    public List<Position> sumPositionList(Long customerId, Long traderId);
    
    public List<PositionDto> selectPositionStatusNot30All();
    
    public Position getStudentPositionByTraderPositionId(Long traderPositionId,Long customerId);
    
    public Integer getPositionCount(Long traderId);
    
    public Integer getStudentPositionCount(Long customerId,Long traderId,String symbol);
    
    Page<PositionVo> list(PositionForm positionForm);
    
    BigDecimal selectDividendFee(Position position);

    BigDecimal selectCommission(Position position);
    
	BigDecimal selectStudentProfit(Long customerId, Long traderId);
	
	PositionStatisticsVo getPositionStatistics();
	
    Integer getPositionCountForTeacherOrStudent(Long traderId,Long customerId);

	Integer getStudentPositionCount(Long customerId, Long traderPositionId);


}
