package com.ruixuan.salesLeads.pojo;


import com.ruixuan.common.utils.DateUtils;
import com.ruixuan.salesLeads.utils.CsvImportUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.codec.binary.Base64;

import javax.crypto.Cipher;
import java.security.Key;
import java.security.KeyFactory;
import java.security.KeyStore;
import java.security.PrivateKey;
import java.security.spec.PKCS8EncodedKeySpec;
import java.util.Date;
import java.util.List;

/**
 * ***************************************************
 *
 * @Auther: zianY
 * @Descipion: 销售线索通话记录
 * @CreateDate: 2022-05-19
 * ****************************************************
 */

@Data
@ApiModel(value = "saleClueCallResultPojo", description = "销售线索通话记录")
public class SaleClueCallResultPojo {

    private int id;

    @ApiModelProperty("企业ID")
    private Long organizationId;

    @ApiModelProperty("企业名称")
    private String organizationName;

    @ApiModelProperty("用户id")
    private Long userId;

    @ApiModelProperty("用户姓名")
    private String userName;

   @ApiModelProperty("客户ID")
    private Long customerId;

    @ApiModelProperty("客户姓名")
    private String customerName;

    @ApiModelProperty("客户电话")
    private String customerPhone;

    @ApiModelProperty("客户公司名称")
    private String customerCompanyName;

    @ApiModelProperty("标签")
    private String labelType;

    @ApiModelProperty("开始拨打时间")
    private String startedAt;

    @ApiModelProperty("通话时长")
    private Long duration;

    @ApiModelProperty("录音地址")
    private String recordUrl;

    @ApiModelProperty("话术名称id")
    private Long surveyId;

    @ApiModelProperty("话术名称")
    private String surveyName;

    @ApiModelProperty("外呼计划id")
    private Long groupId;

    @ApiModelProperty("外呼计划名称")
    private String groupName;

    @ApiModelProperty("通话唯一标示")
    private Long jobId;

    @ApiModelProperty("客户关注点")
    private String focus;

    @ApiModelProperty("对话内容-原数据")
    private String content;

    @ApiModelProperty("机器人对话内容")
    private List robotContent;
    @ApiModelProperty("客户对话内容")
    private List speakerContent;

    @ApiModelProperty("创建时间")
    private Date createTime;


    @ApiModelProperty("卖家id")
    private String seller_id;

    @ApiModelProperty("卖家昵称")
    private String seller_name;

    @ApiModelProperty("行业")
    private String industryName;

    @ApiModelProperty("销售姓名")
    private String saleName;

    @ApiModelProperty("销售线索状态 1-未开始 2-进行中 3-已结束")
    private String state;







    //电话号码 解密
    public static String decryptPhone(String phone){
        //String phone = "c9Xk2jegP5sH54hMJRIumWIWTUnXKsiUHJuX3LZTuWhua7ZU+5Xse8KEPKWqjadHH73a/TT/hi0NmObyHTJjVvvx0VcSCDCnXSUZJxW4wK5kUrwo9btHU8gLf7OhOdfYG99OxNzwfogk/1PShmgVls6wZMybtu3PDTGvAwFeuWo=";
        String privateKeyPerm =
                "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAL6ZRBim0vwPsOCq\n" +
                        "Z/3zV8a+f26j4w1P6vZyobNuR91k9NZYCDyLljZ9mIaT9GDqbwFZeZwcXOJ4QJRI\n" +
                        "3wN04drsj1/3N8itchT5DkmG3RhWqMdLkBxW5YXSFe/NWtkp2zfTNRhSzsA7D8l6\n" +
                        "nXrum96QZw2SlGhzROz2fvx7QJD1AgMBAAECgYBYl2jdhH1BCBIQ+2QG2BsOl/En\n" +
                        "finFQEZYcwPSIQpqT8i18IkzizYw8cP5mb/XZGBgYjRyaYSLB5YM1qpCMwvfJqSt\n" +
                        "yP9t7U0rxHOmTDYxEwduQnMXqJLH/eQsGiA1Vj7zO0cfXhAmPCQBN0wqFJv9FjMN\n" +
                        "h3k9MFhOKGXVEHk/AQJBAOrz7mNBgvp8OVYerYuD8LnapSPfgpXiTc19Z/ox0QAd\n" +
                        "isI3MgI2Qadg+xL13KQ+AW6sknuAJO1XRo+FaLPgRNUCQQDPrC4/oH6A3SQ3QM02\n" +
                        "juDolmNJT5oK4RgcbY2SE+ix6l9YVonpiL41eRO56t8lOIT00Rbx1+a7C5jqnSfR\n" +
                        "z6uhAkEA0GYBIsTu+mLJMJwRbthe41sOc11DJNMQE56SZZdePG33sADpOJELdv1M\n" +
                        "dirhxETDXHlxjF3DY0mwaoj4r+PS6QJAPgDrYgXaH0FnYbPQUVzBW9Ai3q2MkXj5\n" +
                        "SOuQnC+jhxMx2l8kF/zCxZZbxGOSsjs4vxt6XUSX1/qzckDvtZ3qYQJASJa1t4zg\n" +
                        "PcEapVMbOoV1IFUgkL3GY6eqwS3MtZOwYeZ3pioisc738MYPor4WyS3orGOfhhTC\n" +
                        "pi5AWGavBZaH7A==";
        PrivateKey privateKey = str2PrivateKey(privateKeyPerm);
        return decrypt(phone,privateKey);
    }


    public static PrivateKey str2PrivateKey(String privateKeyPerm) {
        try {
            PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(Base64.decodeBase64(privateKeyPerm));
            KeyFactory keyFactory = KeyFactory.getInstance("RSA");
            return keyFactory.generatePrivate(keySpec);
        } catch (Exception var3) {
            return null;
        }
    }
    public static String decrypt(String enText, Key privateKey) {
        try {

            Cipher cipher = Cipher.getInstance("RSA");
            cipher.init(Cipher.DECRYPT_MODE, privateKey);
            byte[] data = cipher.doFinal(Base64.decodeBase64(enText));
            return new String(data);
        } catch (Exception e) {
            return null;
        }
    }



    public static void main(String[] args) {
        //System.out.println(decryptPhone(null));
        String currentDate = DateUtils.formatDate(new Date(), DateUtils.YYMMDD);
        String a = "220722004";
        System.out.println(Integer.valueOf(a));
        System.out.println(currentDate);

    }

}
