package com.hzs.bonus.constant;

import cn.hutool.core.util.ReflectUtil;
import com.hzs.common.core.constant.RetailConstants;
import com.hzs.common.core.utils.DateUtils;
import com.hzs.common.domain.member.achieve.CuMemberRetailDetail;

import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.util.*;

public class BonusConstants {

    /**
     * 领导平级奖金为3个3%的10%
     * 2025.10.27需求调整，平级收益拿3个3%的10%
     */
    public static final BigDecimal SAME_LEVEL_RATIO = new BigDecimal("0.03");

    /**
     * 领导奖处理时，满350PV以上按350算 -- 2025.10.13改为500
     */
    public static final BigDecimal RANGE_BONUS_ACHIEVE = RetailConstants.SPECIAL_AREA_41_MAX_ORDER_DIVIDEND_PV_VALUE;

    /**
     * 赠送2个点位订单业绩（2025.10.13精品专区改为按业绩处理）
     */
    public static final BigDecimal GIFT_TWO_AMOUNT = new BigDecimal("20000");
    /**
     * 赠送1个点位订单业绩（2025.10.13精品专区改为按业绩处理）
     */
    public static final BigDecimal GIFT_ONE_AMOUNT = new BigDecimal("10000");

    /**
     * 2万业绩赠送积分
     */
    public static final BigDecimal GIFT_TWO_POINT = new BigDecimal("7000");
    /**
     * 1万业绩赠送积分
     */
    public static final BigDecimal GIFT_ONE_POINT = new BigDecimal("2000");

    /**
     * 推荐2万业绩会员赠送积分
     */
    public static final BigDecimal TARGET_GIFT_TWO_POINT = new BigDecimal("2000");
    /**
     * 推荐1万业绩会员赠送积分
     */
    public static final BigDecimal TARGET_GIFT_ONE_POINT = new BigDecimal("1000");

    /**
     * 一阶段奖金 -- 满14，发35
     */
    public static final BigDecimal ONE_BONUS = new BigDecimal("35");
    /**
     * 二阶段奖金 -- 满14，发220
     */
    public static final BigDecimal TWO_BONUS = new BigDecimal("220");
    /**
     * 三阶段一层奖金 -- 第一层满2，发160
     */
    public static final BigDecimal THREE_BONUS_1 = new BigDecimal("160");
    /**
     * 三阶段二层奖金 -- 第二层满4，发320
     */
    public static final BigDecimal THREE_BONUS_2 = new BigDecimal("320");
    /**
     * 三阶段三层前7点奖金 -- 发130
     */
    public static final BigDecimal THREE_BONUS_3 = new BigDecimal("130");
    /**
     * 三阶段三层前最后一点奖金 -- 发155
     */
    public static final BigDecimal THREE_BONUS_38 = new BigDecimal("155");

    /**
     * 赠点初始时间
     */
    public static final Date GIFT_PAY_TIME = DateUtils.parseStringToDateTime("2025-09-01 00:00:00");

    public static final String POINT_11 = "11";
    public static final String POINT_12 = "12";
    public static final String POINT_21 = "21";
    public static final String POINT_22 = "22";
    public static final String POINT_23 = "23";
    public static final String POINT_24 = "24";
    public static final String POINT_31 = "31";
    public static final String POINT_32 = "32";
    public static final String POINT_33 = "33";
    public static final String POINT_34 = "34";
    public static final String POINT_35 = "35";
    public static final String POINT_36 = "36";
    public static final String POINT_37 = "37";
    public static final String POINT_38 = "38";

    // 全部字段
    public static final List<String> FIELD_LIST = Arrays.asList(POINT_11, POINT_12, POINT_21, POINT_22, POINT_23, POINT_24,
            POINT_31, POINT_32, POINT_33, POINT_34, POINT_35, POINT_36, POINT_37, POINT_38);
    // 第三层字段
    public static final List<String> THREE_FIELD_LIST = Arrays.asList(POINT_31, POINT_32, POINT_33, POINT_34, POINT_35, POINT_36, POINT_37, POINT_38);

    // 会员ID字段
    public static final String POINT_MEMBER_FIELD_NAME = "pointMember";
    // 会员子点位字段
    public static final String POINT_FIELD_NAME = "point";
    // 入库标记字段
    public static final String UPDATE_FLAG = "updateBool";

    public static Map<String, Field> FIELD_MAP = null;

    static {
        BonusConstants.FIELD_MAP = new HashMap<>();
        for (String suffix : BonusConstants.FIELD_LIST) {
            BonusConstants.FIELD_MAP.put(BonusConstants.POINT_MEMBER_FIELD_NAME + suffix, ReflectUtil.getField(CuMemberRetailDetail.class, BonusConstants.POINT_MEMBER_FIELD_NAME + suffix));
            BonusConstants.FIELD_MAP.put(BonusConstants.POINT_FIELD_NAME + suffix, ReflectUtil.getField(CuMemberRetailDetail.class, BonusConstants.POINT_FIELD_NAME + suffix));
        }
    }

}
