package com.cool.store.enums;

import com.aliyun.openservices.shade.org.apache.commons.lang3.StringUtils;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.Objects;

/**
 * @author zhangchenbiao
 * @FileName: MessageEnum
 * @Description:
 * @date 2024-03-27 10:50
 */
public enum MessageEnum {

    MESSAGE_1("您有一份加盟意向申请，请查收。", "##### 加盟商姓名：${partnerUsername}\n##### 手机号码：${partnerMobile}\n##### 意向加盟区域：${wantShopName}\n"),
    MESSAGE_2("您收到一份邀约面谈预约，请查收", "##### 加盟商姓名：${partnerUsername}\n##### 预约时间：${appointmentTime}\n"),
    MESSAGE_3("您收到一份一次面审预约，请查收", "##### 加盟商姓名：${partnerUsername}\n##### 预约时间：${appointmentTime}\n"),
    MESSAGE_3_1("您的线索已预约一次面审，请关注", "##### 加盟商姓名：${partnerUsername}\n面审官：${interviewUsername}\n##### 预约时间：${appointmentTime}\n"),
    MESSAGE_4("您有线索未通过面审，请查收", "##### 加盟商姓名：${partnerUsername}\n##### 面审时间：${interviewTime}\n##### 面审官：${interviewUsername}\n"),
    MESSAGE_5("您收到一份缴纳意向金审核，请查收", "##### 加盟商姓名：${partnerUsername}\n##### 缴费时间：${payTime}\n"),
    MESSAGE_6("您收到一份加盟意向协议信息审核，请查收", "##### 加盟商姓名：${partnerUsername}\n##### 手机号码：${partnerMobile}\n##### 信息提交时间：${submitTime}\n"),
    MESSAGE_7("您提交的一份加盟意向协议OA审核未通过，请查收", "##### 加盟商姓名：${partnerUsername}\n##### 审批提交时间：${submitTime}\n"),
    MESSAGE_8("您有一位加盟商待安排体验门店及体验时间，请查收", "##### 加盟商姓名：${partnerUsername}\n##### 手机号码：${partnerMobile}\n"),
    MESSAGE_9("您有一位加盟商已放弃门店体验，请查收", "##### 加盟商姓名：${partnerUsername}\n##### 手机号码：${partnerMobile}\n"),
    MESSAGE_10("您收到一份二次面审预约，请查收", "##### 加盟商姓名：${partnerUsername}\n##### 预约时间：${appointmentTime}\n"),
    MESSAGE_10_1("您的线索已预约二次面审，请关注", "##### 加盟商姓名：${partnerUsername}\n面审官：${interviewUsername}\n##### 预约时间：${appointmentTime}\n"),
    MESSAGE_11("您的一个铺位已审核通过，请查收", "##### 铺位名称：${pointName}\n##### 铺位地址：${pointAddress}\n"),
    MESSAGE_12("您的一个铺位审核未通过，请查收", "##### 铺位名称：${pointName}\n##### 铺位地址：${pointAddress}\n##### 未通过原因：${reason}\n"),
    MESSAGE_13("您有一个铺位需要审核，请查收", "##### 铺位名称：${pointName}\n##### 铺位地址：${pointAddress}\n"),
    MESSAGE_14("已为您分配一位加盟商，请查收", "##### 加盟商姓名：${partnerUsername}\n##### 手机号码：${partnerMobile}\n##### 意向加盟区域：${wantShopName}\n"),
    MESSAGE_15("您有一份加盟商上传的租赁合同待审核，请查收", "##### 加盟商姓名：${partnerUsername}\n##### 提交时间：${submitTime}\n"),
    MESSAGE_16("您有一家门店待提交系统建店申请，请查收", "##### 门店名称：${storeName}\n##### 加盟商姓名：${partnerName}\n##### 加盟商手机号码：${partnerMobile}\n"),
    MESSAGE_16_1("您有一家门店待提交系统建店申请，请查收", "##### 加盟商姓名：${partnerName}\n##### 加盟商手机号码：${partnerMobile}\n"),
    MESSAGE_17("您收到一份证照信息审核申请，请查收", "##### 门店名称：${storeName}\n##### 加盟商姓名：${partnerName}\n##### 加盟商手机号码：${partnerMobile}\n"),
    MESSAGE_18("您有一个门店已缴纳加盟费/保证金，请审核", "##### 门店名称：${storeName}\n##### 加盟商姓名：${partnerName}\n##### 加盟商手机号码：${partnerMobile}\n"),
    MESSAGE_19("您有一个门店待提交加盟合同审核，请查收", "##### 门店名称：${storeName}\n##### 加盟商姓名：${partnerName}\n##### 加盟商手机号码：${partnerMobile}\n"),
    MESSAGE_20("您有一个门店的加盟合同审核未通过，请查收", "##### 门店名称：${storeName}\n##### 加盟商姓名：${partnerName}\n##### 加盟商手机号码：${partnerMobile}\n"),
    MESSAGE_21("加盟商已登记一位员工，请及时安排培训", "##### 员工姓名：【${userName}】，员工手机号码：【${mobile}】，登记时间：【${registerTime}】"),
    MESSAGE_22("您收到一位员工由您带教，请查收", "##### 员工姓名：【${userName}】，员工手机号码：【${mobile}】，登记时间：【${registerTime}】"),
    MESSAGE_23("您有一个门店待发布加盟费/保证金账单，请查收", "##### 加盟商姓名：${partnerName}\n##### 加盟商手机号码：${partnerMobile}\n"),
    MESSAGE_24("您有一个门店待预约三方验收时间，请查收", "##### 门店名称：${storeName}\n##### 加盟商姓名：${partnerUsername}\n##### 加盟商手机号码：${partnerMobile}\n"),
    MESSAGE_25("您有一个门店待进行三方验收，请查收","##### 门店名称：${storeName}\n##### 加盟商姓名：${partnerUsername}\n##### 加盟商手机号码：${partnerMobile}\n"),
    MESSAGE_26("您有一个门店需要上传开业运营方案，请查收","##### 门店名称：${storeName}\n##### 加盟商姓名：${partnerUsername}\n##### 加盟商手机号码：${partnerMobile}\n"),
    MESSAGE_27("您有一个门店需要上传首批订货清单，请查收","##### 门店名称：${storeName}\n##### 加盟商姓名：${partnerUsername}\n##### 加盟商手机号码：${partnerMobile}\n"),
    MESSAGE_28("您有一个门店需要进行视觉验收，请查收","##### 门店名称：${storeName}\n##### 加盟商姓名：${partnerUsername}\n##### 加盟商手机号码：${partnerMobile}\n"),

    MESSAGE_29("您有一份加盟申请书，请查收","##### 加盟商姓名：${partnerUsername}\n##### 加盟商手机号码：${partnerMobile}\n##### 意向加盟区域：${regionName}\n"),
    MESSAGE_30("您收到一份加盟意向协议信息审核，请查收","##### 加盟商姓名：${partnerUsername}\n##### 加盟商手机号码：${partnerMobile}\n##### 信息提交时间：${submitTime}\n"),
    MESSAGE_31("您提交的一份加盟意向协议OA审核未通过，请查收","##### 加盟商姓名：${partnerUsername}\n##### 信息提交时间：${submitTime}\n"),
    MESSAGE_32("您有一位加盟商待安排体验门店及体验时间，请查收","##### 加盟商姓名：${partnerUsername}\n##### 加盟商手机号码：${partnerMobile}\n"),
    MESSAGE_33("您有一位加盟商已放弃门店体验，请查收","##### 加盟商姓名：${partnerUsername}\n##### 加盟商手机号码：${partnerMobile}\n"),




    ;

    private String title;

    private String content;

    MessageEnum(String title, String content) {
        this.title = title;
        this.content = content;
    }

    public String getTitle() {
        return title;
    }

    public String getContent() {
        return content;
    }

    public String getContent(Map<String, String> paramMap) {
        String result = this.content;
        for (String key : paramMap.keySet()) {
            result = result.replace("${" + key + "}", paramMap.get(key));
        }
        return result;
    }

    public String getImageUrl() {
        return "https://oss-store.coolcollege.cn/xfsg_notice.png";
    }


    public String getMessageUrl(String domainUrl, String appId, String corpId, Map<String, String> paramMap) {
        if (StringUtils.isAnyBlank(domainUrl, appId, corpId) || Objects.isNull(paramMap)) {
            return "";
        }
        try {
            switch (this) {
                case MESSAGE_1:
                case MESSAGE_2:
                case MESSAGE_3_1:
                case MESSAGE_4:
                case MESSAGE_5:
                case MESSAGE_6:
                case MESSAGE_7:
                case MESSAGE_8:
                case MESSAGE_9:
                case MESSAGE_29:
                case MESSAGE_30:
                    return domainUrl + "/dd-noticemsg?appId=" + appId + "&corpId=" + corpId + "&appUrl=" +
                            URLEncoder.encode("pages/common-web-view/index?noticeType=xfsg&routerUrl=notice&target=clue&timestamp=" + System.currentTimeMillis() + "&lineId=" + paramMap.get("lineId"), StandardCharsets.UTF_8.name());
                case MESSAGE_3:
                case MESSAGE_10:
                    return domainUrl + "/dd-noticemsg?appId=" + appId + "&corpId=" + corpId + "&appUrl=" +
                            URLEncoder.encode("pages/common-web-view/index?noticeType=xfsg&routerUrl=notice&target=interview&timestamp=" + System.currentTimeMillis() + "&lineId=" + paramMap.get("lineId"), StandardCharsets.UTF_8.name());
                case MESSAGE_11:
                case MESSAGE_12:
                    return domainUrl + "/dd-noticemsg?appId=" + appId + "&corpId=" + corpId + "&appUrl=" +
                            URLEncoder.encode("pages/common-web-view/index?noticeType=xfsg&routerUrl=notice&target=point&timestamp=" + System.currentTimeMillis() + "&pointId=" + paramMap.get("pointId"), StandardCharsets.UTF_8.name());
                case MESSAGE_13:
                    return "dingtalk://dingtalkclient/action/open_micro_app?appId=" + appId + "&corpId=" + corpId + "&page=" +
                            URLEncoder.encode("pages/common-web-view/index?noticeType=xfsg&routerUrl=notice&target=point&timestamp=" + System.currentTimeMillis() + "&pointId=" + paramMap.get("pointId"), StandardCharsets.UTF_8.name());
                case MESSAGE_14:
                    return "dingtalk://dingtalkclient/action/open_micro_app?appId=" + appId + "&corpId=" + corpId + "&page=" +
                            URLEncoder.encode("pages/common-web-view/index?noticeType=xfsg&routerUrl=notice&target=franchiseeDetails&timestamp=" + System.currentTimeMillis() + "&lineId=" + paramMap.get("lineId"), StandardCharsets.UTF_8.name());
                case MESSAGE_15:
                case MESSAGE_10_1:
                case MESSAGE_31:
                case MESSAGE_32:
                case MESSAGE_33:
                    //跳转我的加盟商的加盟商详情都可以使用这个
                    return domainUrl + "/dd-noticemsg?appId=" + appId + "&corpId=" + corpId + "&appUrl=" +
                            URLEncoder.encode("pages/common-web-view/index?noticeType=xfsg&routerUrl=notice&target=franchiseeDetails&timestamp=" + System.currentTimeMillis() + "&lineId=" + paramMap.get("lineId"), StandardCharsets.UTF_8.name());
                case MESSAGE_21:
                    return domainUrl + "/dd-noticemsg?appId="+appId+"&corpId="+corpId+"&page=" +
                            URLEncoder.encode("pages/common-web-view/index?noticeType=xfsg&routerUrl=notice&target=employeeTraining&timestamp="+System.currentTimeMillis()+"&userDetailId="+ paramMap.get("userDetailId"), StandardCharsets.UTF_8.name());
                case MESSAGE_22:
                    return "dingtalk://dingtalkclient/action/open_micro_app?appId="+appId+"&corpId="+corpId+"&page=" +
                            URLEncoder.encode("pages/common-web-view/index?noticeType=xfsg&routerUrl=notice&target=trainerUser&timestamp="+System.currentTimeMillis()+"&userDetailId="+ paramMap.get("userDetailId"), StandardCharsets.UTF_8.name());
                case MESSAGE_24:
                    return "dingtalk://dingtalkclient/action/open_micro_app?appId="+appId+"&corpId="+corpId+"&page=" +
                            URLEncoder.encode("pages/common-web-view/index?noticeType=xfsg&routerUrl=notice&target=threeAcceptance&timestamp="+System.currentTimeMillis(), StandardCharsets.UTF_8.name());
                case MESSAGE_25:
                    return "dingtalk://dingtalkclient/action/open_micro_app?appId="+appId+"&corpId="+corpId+"&page=" +
                            URLEncoder.encode("pages/common-web-view/index?noticeType=xfsg&routerUrl=notice&target=threeAcceptance&timestamp="+System.currentTimeMillis(), StandardCharsets.UTF_8.name());
                case MESSAGE_26:
                    return domainUrl + "/dd-noticemsg?appId=" + appId + "&corpId=" + corpId + "&appUrl=" +
                            URLEncoder.encode("pages/common-web-view/index?noticeType=xfsg&routerUrl=notice&target=openPlan&timestamp=" + System.currentTimeMillis() +"&lineId="+ paramMap.get("lineId")+"&shopId="+ paramMap.get("shopId"), StandardCharsets.UTF_8.name());
                case MESSAGE_27:
                    return domainUrl + "/dd-noticemsg?appId=" + appId + "&corpId=" + corpId + "&appUrl=" +
                            URLEncoder.encode("pages/common-web-view/index?noticeType=xfsg&routerUrl=notice&target=orderList&timestamp=" + System.currentTimeMillis() +"&lineId="+ paramMap.get("lineId"), StandardCharsets.UTF_8.name());
                case MESSAGE_28:
                    return "dingtalk://dingtalkclient/action/open_micro_app?appId="+appId+"&corpId="+corpId+"&page=" +
                            URLEncoder.encode("pages/common-web-view/index?noticeType=xfsg&routerUrl=notice&target=eyeAcceptance&timestamp="+System.currentTimeMillis()+"&shopId="+ paramMap.get("shopId"), StandardCharsets.UTF_8.name());
                case MESSAGE_16:
                    return domainUrl + "/dd-noticemsg?appId=" + appId + "&corpId=" + corpId + "&appUrl=" +
                            URLEncoder.encode("pages/common-web-view/index?noticeType=xfsg&routerUrl=notice&target=sysStoreSchedule&timestamp=" + System.currentTimeMillis() +"&lineId="+ paramMap.get("lineId")+"&shopId="+ paramMap.get("shopId"), StandardCharsets.UTF_8.name());
                case MESSAGE_17:
                    return domainUrl + "/dd-noticemsg?appId=" + appId + "&corpId=" + corpId + "&appUrl=" +
                            URLEncoder.encode("pages/common-web-view/index?noticeType=xfsg&routerUrl=notice&target=licenseSchedule&timestamp=" + System.currentTimeMillis() +"&lineId="+ paramMap.get("lineId")+"&shopId="+ paramMap.get("shopId"), StandardCharsets.UTF_8.name());
                case MESSAGE_18:
                case MESSAGE_23:
                    return domainUrl + "/dd-noticemsg?appId=" + appId + "&corpId=" + corpId + "&appUrl=" +
                            URLEncoder.encode("pages/common-web-view/index?noticeType=xfsg&routerUrl=notice&target=franchiseeSchedule&timestamp=" + System.currentTimeMillis() +"&lineId="+ paramMap.get("lineId")+"&shopId="+ paramMap.get("shopId"), StandardCharsets.UTF_8.name());
                case MESSAGE_19:
                case MESSAGE_20:
                    return domainUrl + "/dd-noticemsg?appId=" + appId + "&corpId=" + corpId + "&appUrl=" +
                            URLEncoder.encode("pages/common-web-view/index?noticeType=xfsg&routerUrl=notice&target=contractSchedule&timestamp=" + System.currentTimeMillis() +"&lineId="+ paramMap.get("lineId")+"&shopId="+ paramMap.get("shopId"), StandardCharsets.UTF_8.name());
                default:
                    return "";
            }
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return null;
    }

}
