package com.sqx.modules.common.enums;

import com.sqx.modules.common.utils.CommonConfigUtil;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
public enum CommonEnum {

	NONE(null,null,null,null),

	/**距离服务开始n个小时以上免费取消*/
	V3_ORDER_FORM_CANCEL_NOT_START_01(436, "v3_order_form", "距离服务开始n分钟以上免费取消", "240"),
	/**距离服务开始前取消n-n个小时内，收取n元*/
	V3_ORDER_FORM_CANCEL_NOT_START_02(437, "v3_order_form", "距离服务开始前取消n-n分钟内，收取n元", "90,240,10"),
	/**距离服务开始前取消少于n个小时内，收取n元*/
	V3_ORDER_FORM_CANCEL_NOT_START_03(438, "v3_order_form", "距离服务开始前取消少于n分钟内，收取n元", "90,30"),

	/**服务开始n分钟内取消订单，扣项目费用n%，车费全扣n%；*/
	V3_ORDER_FORM_CANCEL_START_01(439, "v3_order_form", "服务开始n分钟内取消订单，扣项目费用n%，车费全扣n%；", "15,50,100"),
	/**服务开始n分钟后不可以取消订单*/
	V3_ORDER_FORM_CANCEL_START_02(440, "v3_order_form", "服务开始n分钟后不可以取消订单", "15"),

	/**距离服务开始前n分钟可修改*/
	V3_ORDER_FORM_EDIT_NOT_START_01(441, "v3_order_form", "距离服务开始前n分钟可修改", "120"),
	/**距离服务开始n分钟内不可修改*/
	V3_ORDER_FORM_EDIT_NOT_START_02(442, "v3_order_form", "距离服务开始n分钟内不可修改", "120"),

	/**夏令时开始时间~结束时间*/
	V3_TRAVEL_CONF_DAYLIGHT_SAVING_TIME(443, "v3_travel_conf", "夏令时开始时间~结束时间", "0521,0823"),
	/**冬令时开始时间~结束时间(留空自动计算)*/
	V3_TRAVEL_CONF_WINTER_TIME(444, "v3_travel_conf", "冬令时开始时间~结束时间(留空自动计算)", ","),
	/**白天时段从n开始~n结束*/
	V3_TRAVEL_CONF_DAY(445, "v3_travel_conf", "白天时段从n开始~n结束", "2"),
	/**夜间时段从n开始~n结束(留空自动计算)*/
	V3_TRAVEL_CONF_NIGHT(446, "v3_travel_conf", "夜间时段从n开始~n结束(留空自动计算)", ","),

	V3_TRAVEL_CONF_IS_PRICING(447, "v3_travel_conf", "出行配置使用动态价格", "true"),

	V3_TRAVEL_CONF_IS_FIXED(450, "v3_travel_conf", "出行配置固定价格是否往返", "false");

	private final Integer key;

	private final String defCondition;

	private final String defName;

	private final String defValue;

//	private boolean defValueIsEmpty() {
//		return CommonConfigUtil.defValueIsEmpty(this.defValue);
//	}


	public Integer getIntValue() {
		return CommonConfigUtil.getIntValue(this.defValue);
	}

	public Long getLongValue() {
		return CommonConfigUtil.getLongValue(this.defValue);
	}

	public Double getDoubleValue() {
		return CommonConfigUtil.getDoubleValue(this.defValue);
	}

	/**
	 * 获取数组，默认按,分隔
	 * @return 数组
	 */
	public String[] getArrayValue() {
		return CommonConfigUtil.getArrayValue(this.defValue);
	}

	/**
	 * 获取数组，默认按,分隔
	 * @param splitStr 自定义分隔符
	 * @return 数组
	 */
	public String[] getArrayValue(String splitStr) {
		return CommonConfigUtil.getArrayValue(this.defValue, splitStr);
	}

	@Getter
	@RequiredArgsConstructor
	public enum GroupKeyEnum {

		/**
		 * v3服务订单相关
		 */
		V3_ORDER_FORM(new Integer[]{
				V3_ORDER_FORM_CANCEL_NOT_START_01.getKey(),
				V3_ORDER_FORM_CANCEL_NOT_START_02.getKey(),
				V3_ORDER_FORM_CANCEL_NOT_START_03.getKey(),
				V3_ORDER_FORM_CANCEL_START_01.getKey(),
				V3_ORDER_FORM_CANCEL_START_02.getKey(),
				V3_ORDER_FORM_EDIT_NOT_START_01.getKey(),
				V3_ORDER_FORM_EDIT_NOT_START_02.getKey()
		}),

		/**
		 * v3服务订单开始前（取消）
		 */
		V3_ORDER_FORM_CANCEL_NOT_START(new Integer[]{
				V3_ORDER_FORM_CANCEL_NOT_START_01.getKey(),
				V3_ORDER_FORM_CANCEL_NOT_START_02.getKey(),
				V3_ORDER_FORM_CANCEL_NOT_START_03.getKey(),
		}),

		/**
		 * v3服务订单开始后（取消）
		 */
		V3_ORDER_FORM_CANCEL_START(new Integer[]{
				V3_ORDER_FORM_CANCEL_START_01.getKey(),
				V3_ORDER_FORM_CANCEL_START_02.getKey(),
		}),

		/**
		 * 服务开始前，后（修改）
		 */
		V3_ORDER_FORM_EDIT_NOT_START(new Integer[]{
				V3_ORDER_FORM_EDIT_NOT_START_01.getKey(),
				V3_ORDER_FORM_EDIT_NOT_START_02.getKey()
		}),

		/**
		 * 时令和白天黑夜配置
		 */
		V3_TRAVEL_CONF(new Integer[]{
			V3_TRAVEL_CONF_DAYLIGHT_SAVING_TIME.getKey(),
			V3_TRAVEL_CONF_WINTER_TIME.getKey(),
			V3_TRAVEL_CONF_DAY.getKey(),
			V3_TRAVEL_CONF_NIGHT.getKey(),
			V3_TRAVEL_CONF_IS_PRICING.getKey(),
			V3_TRAVEL_CONF_IS_FIXED.getKey()
		});

		private final Integer[] values;
	}

	@Getter
	@RequiredArgsConstructor
	public enum GroupConditionEnum {

		V3_ORDER_FORM("v3_order_form"),

		V3_TRAVEL_CONF("v3_travel_conf");

		private final String value;
	}
	}
