package com.smppw.common.pojo.enums;

import com.smppw.common.pojo.IStrategy;
import com.smppw.common.pojo.enums.strategy.Strategy;

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

/**
 * @author zhengsongliang
 */
public enum CurveType {
	PrivateComprehension(1), PrivateSubstratgy(2), PrivateRights(3), PublicComprehension(4), PublicSubstrategy(
			5), PublicRights(6), BothComprehension(7), BothSubstratgy(8), BothRights(9);

	private int id;

	private CurveType(int id) {
		this.id = id;
	}

	public int getId() {
		return id;
	}

	public static CurveType getCurveType(int id) {
		return Stream.of(CurveType.values()).filter(e -> e.id == id).findFirst().orElse(null);
	}

	public static final List<CurveType> SUBSTRATEGY = Arrays.asList(PrivateSubstratgy, PublicSubstrategy, BothSubstratgy);

	//		Equity2(101, "股票","IN0000001C", "IN00000008"),
//		OverseeFund(108, "海外","IN0000001C", "IN00000008"),
//		Hybrid(102,"混合", "IN0000001J", "IN00000008"),
//		Bond2(103, "债券","IN0000001H", "IN000002C0"),
//		Cash(104,"货币", "IN0000001H", "IN000002C0"),
//		Commodity(105, "商品","IN0000001E", "IN0000001A"),
//		MarketNeutral(106, "市场中性","IN0000001G", "IN00000008"),
//		FOF(107, "FOF","IN0000001G", "IN00000008"),
//		Others2(-100, "其他","", "");
	private static final List<Strategy> mutualFundStrategy = Arrays.asList(Strategy.Equity2, Strategy.OverseeFund, Strategy.Hybrid, Strategy.Bond2,
			Strategy.Cash, Strategy.Commodity, Strategy.MarketNeutral, Strategy.FOF, Strategy.Others2);

	public static CurveType getCurveType(RaiseType raiseType, IStrategy strategy) {
		if (strategy instanceof Strategy) {
			if (mutualFundStrategy.contains(strategy))
				return PublicSubstrategy;

			if (strategy == Strategy.All) {
				if (raiseType == RaiseType.Private)
					return PrivateComprehension;
				else if (raiseType == RaiseType.Public)
					return PublicComprehension;
				else
					return BothComprehension;
			}
			if (strategy == Strategy.Rights) {
				// 原本权益类策略
				if (raiseType == RaiseType.Private)
					return PrivateRights;
				else if (raiseType == RaiseType.Public)
					return PublicRights;
				else
					return BothRights;
			}else {
				if (raiseType == RaiseType.Private)
					return PrivateSubstratgy;
				else if (raiseType == RaiseType.Public)
					return PublicSubstrategy;
				else
					return BothSubstratgy;
			}
		}else {
			if (raiseType == RaiseType.Private)
				return PrivateSubstratgy;
			else if (raiseType == RaiseType.Public)
				return PublicSubstrategy;
			else
				return BothSubstratgy;
		}
	}
}
