package com.tzld.piaoquan.ad.engine.service.predict.v2;

import com.alibaba.fastjson.JSONObject;
import com.tzld.piaoquan.ad.engine.commons.param.MachineInfoParam;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PredictContext {

    private String mid;

    private String videoId;

    private String appType;

    /**
     * 用户在广告层所属的实验组
     */
    private String adAbCode;

    /**
     * 用户命中的广告层所有实验
     */
    private Set<String> expCodeSet = new HashSet<>();

    private Map<String, JSONObject> expConfigMap = new HashMap<>();

    /**
     * 省份
     */
    private String region;

    /**
     * 城市
     */
    private String city;

    private String pqtId;

    /**
     * 设备信息
     */
    MachineInfoParam machineInfo = new MachineInfoParam();

    private String userExternalSource;

    /**
     * 分享所属层
     * <br />
     * 1. firstLayer: 首层
     * <br />
     * 2. otherLayer: 裂变层
     */
    private String shareLayer;

    /**
     * 用户分享和回流的分组
     */
    private String shareType;

    private String rootSessionId;

    private String adPlatformType;

    private String userLayer;

    private PredictLogParam logParam = new PredictLogParam();

    public String getHandleAfterShareType() {
        if (StringUtils.isEmpty(shareType)) {
            return "";
        }
        return shareType
                .replace("return", "")
                .replace("mids", "");
    }
}
