package com.gic.haoban.manage.web.utils.target;

import com.alibaba.fastjson.JSONObject;

import java.util.*;

/**
 * 目标达成分析处理
 * @Author guojx
 * @Date 2023/1/18 9:12
 */
public class TargetAnalysisUtils {
    /**
     * 实际会员销售额
     */
    private static List<String> mbrPayAmt = Arrays.asList("mbrPayAmt", "mbrPayAmtLast", "mbrPayAmtRollTarget", "mbrPayAmtActualRate");

    /**
     * 实际新增会员数
     */
    private static List<String> newMbrNum = Arrays.asList("newMbrNum", "newMbrNumLast", "newMbrNumRollTarget", "newMbrNumActualRate");
    /**
     * 会员消费总次数
     */
    private static List<String> mbrCsmeTimes = Arrays.asList("mbrCsmeTimes", "mbrCsmeTimesLast", "mbrCsmeTimesRollTarget", "mbrCsmeTimesActualRate");
    /**
     * 客单价
     */
    private static List<String> perCusTrans = Arrays.asList("perCusTrans", "perCusTransLast", "perCusTransTarget", "perCusTransActualRate");
    /**
     * 存量会员消费总次数
     */
    private static List<String> stockMbrCsmeCnt = Arrays.asList("stockMbrCsmeCnt", "yearStockMbrCsmeCnt", "stockMbrCsmeTimesTarget", "stockMbrCsmeCntRate");
    /**
     * 新增会员消费总次数
     */
    private static List<String> newMbrCsmeCnt = Arrays.asList("newMbrCsmeCnt", "yearNewMbrCsmeCnt", "newMbrCsmeTimesTarget", "newMbrCsmeCntRate");
    /**
     * 存量会员仅消费一次总次数
     */
    private static List<String> stockMbrCsmeFristCnt = Arrays.asList("stockMbrCsmeFristCnt", "yearStockMbrCsmeFristCnt", "stockMbrOneCsmeTimesTarget", "stockMbrCsmeFristCntRate");
    /**
     * 存量会员消费多次总次数
     */
    private static List<String> stockMbrCsmeRepchCnt = Arrays.asList("stockMbrCsmeRepchCnt", "yearStockMbrCsmeRepchCnt", "stockMbrRepchCsmeTimesTarget", "stockMbrCsmeRepchCntRate");
    /**
     * 存量会员仅消费一次总人数
     */
    private static List<String> stockMbrCsmeFristNum = Arrays.asList("stockMbrCsmeFristNum", "yearStockMbrCsmeFristNum", "stockMbrOneCsmeNumTarget", "stockMbrCsmeFristNumRate");
    /**
     * 存量会员消费多次总人数
     */
    private static List<String> stockMbrCsmeRepchNum = Arrays.asList("stockMbrCsmeRepchNum", "yearStockMbrCsmeRepchNum", "stockMbrRepchCsmeNumTarget", "stockMbrCsmeRepchNumRate");
    /**
     * 存量会员消费多次人均消费次数  存量会员复购总人数待定
     */
    private static List<String> stockMbrCsmeRepchAvg = Arrays.asList("stockMbrCsmeRepchAvg", "yearStockMbrCsmeRepchAvg", "stockMbrRepchAvgCsmeTimesTarget", "stockMbrCsmeRepchAvgRate");
    /**
     * 新增会员仅消费一次总次数
     */
    private static List<String> newMbrCsmeFristCnt = Arrays.asList("newMbrCsmeFristCnt", "yearNewMbrCsmeFristCnt", "newMbrOneCsmeTimesTarget", "newMbrCsmeFristCntRate");
    /**
     * 新增会员消费多次总次数
     */
    private static List<String> newMbrCsmeRepchCnt = Arrays.asList("newMbrCsmeRepchCnt", "yearNewMbrCsmeRepchCnt", "newMbrRepchCsmeTimesTarget", "newMbrCsmeRepchCntRate");
    /**
     * 新增会员仅消费一次总人数
     */
    private static List<String> newMbrCsmeFristnum = Arrays.asList("newMbrCsmeFristnum", "yearNewMbrCsmeFristNum", "newMbrOneCsmeNumTarget", "newMbrCsmeFristnumRate");
    /**
     * 新增会员消费多次总人数
     */
    private static List<String> newMbrCsmeRepchNum = Arrays.asList("newMbrCsmeRepchNum", "yearNewMbrCsmeRepchNum", "newMbrRepchCsmeNumTarget", "newMbrCsmeRepchNumRate");
    /**
     * 新增会员消费多次人均消费次数
     */
    private static List<String> newMbrCsmeRepchAvg = Arrays.asList("newMbrCsmeRepchAvg", "yearNewMbrCsmeRepchAvg", "newMbrRepchAvgCsmeTimesTarget", "newMbrCsmeRepchAvgRate");

    public static Map<String, List<String>> map = new HashMap<>(24);

    static {
        map.put("0", newMbrNum);
        map.put("1", mbrPayAmt);
        map.put("2", mbrCsmeTimes);
        map.put("3", perCusTrans);
        map.put("4", stockMbrCsmeCnt);
        map.put("5", newMbrCsmeCnt);
        map.put("6", stockMbrCsmeFristCnt);
        map.put("7", stockMbrCsmeRepchCnt);
        map.put("8", newMbrCsmeFristCnt);
        map.put("9", newMbrCsmeRepchCnt);
        map.put("10", stockMbrCsmeFristNum);
        map.put("11", stockMbrCsmeRepchNum);
        map.put("12", stockMbrCsmeRepchAvg);
        map.put("13", newMbrCsmeFristnum);
        map.put("14", newMbrCsmeRepchNum);
        map.put("15", newMbrCsmeRepchAvg);
    }

    public static List<JSONObject> getData(String type, List<JSONObject> list) {
        List<String> keyList = map.get(type);
        List<JSONObject> result = new ArrayList<>();
        for (JSONObject json : list) {
            JSONObject vo = new JSONObject();
            for (String key : keyList) {
                vo.put(key, json.get(key));
            }
            result.add(vo);
        }
        return result;
    }
}
