/**
 * 数据脚本
 */

import moment = require("moment");
import { addManyData, addOneData } from "./data/add";
import { TABLEENUM } from "./data/models/model";
import { generateOrderId, generateUserId } from "./tools/system";
import { createOrder } from "./biz/member/order";

/**
 * 注册账号
 */
export async function test1() {
    let i = parseInt(`${moment().hour()}${moment().minute()}${moment().second()}`);
    let maxi = i + 20;
    let dataList = [];
    for (i; i < maxi; i++) {
        let nowMs = new Date().valueOf();
        let randomNum = parseInt(`${moment().hour()}${moment().minute()}${moment().second()}${Math.ceil(Math.random() * 100)}`);
        let userId = generateUserId();
        let endTime = new Date(moment().add(1, 'd').format("YYYY-MM-DD")+' 00:00:00').valueOf();
        dataList.push({
            "token" : "",
            "tokenMs" : 0,
            "adminLv" : [],
            "registerFlow" : 2,
            "isAdmin" : 0,
            "isFirstPay" : false,
            "userRegisterState" : 1,
            "memberState" : 1,
            "memberLevel" : 1,
            "isGracePeriod" : 0,
            "cardUrlJust" : "http://192.168.0.105:40012/whb/files/12/vue2024-03-22_16-11-873169.png",
            "cardUrlBack" : "http://192.168.0.105:40012/whb/files/12/vue2024-03-22_16-11-873169.png",
            "auxiliaryMaterial" : [],
            "userId" : userId,
            "memberType" : 1,
            "askForTime" : nowMs,
            "loginId" : randomNum,
            "mail" : "18120935727@163.com",
            "pwd" : "123456",
            "phone" : `1812093${Math.ceil(Math.random() * 10)}${Math.ceil(Math.random() * 10)}${Math.ceil(Math.random() * 10)}${Math.ceil(Math.random() * 10)}`,
            "__v" : 0,
            "academicCERTUrl" : "http://192.168.0.105:40012/whb/files/12/vue2024-03-22_16-11-356620.png",
            "addres" : "才能实现但是",
            "birth" : 1711036800000.0,
            "documentId" : "340822199901012333",
            "documentType" : 1,
            "duties" : "吃的蔬菜生产",
            "education" : 2,
            "name" : `V${randomNum}`,
            "nation" : 1,
            "otherEMP" : "23年前注册",
            "otherPROF" : "23年前注册",
            "photoUrl" : "http://192.168.0.105:40012/whb/files/12/vue2024-03-22_16-11-624049.png",
            "profAchievement" : "23年前注册",
            "profCategory" : 1,
            "professionalCERTUrl" : "http://192.168.0.105:40012/whb/files/12/vue2024-03-22_16-11-603763.png",
            "qu" : "130524",
            "sex" : 2,
            "sheng" : "130000",
            "shi" : "130500",
            "studyResume" : "23年前注册",
            "unitName" : "23年前注册",
            "workResume" : "23年前注册",
            "workTitle" : "23年前注册",
            "auditTime" : nowMs+1,
            "individualMemberType" : 1,
            "joinTime" : nowMs+1,
            "lifespanEndTime" : endTime,
            "lifespanStartTime" : nowMs,
            "paymentStatus" : 2,
            "session" : 200907
        });
    }
    await addManyData(TABLEENUM.用户表, dataList);
    console.log("初始化成功");
}

export async function test2() {
    let i = parseInt(`${moment().hour()}${moment().minute()}${moment().second()}`);
    let maxi = i + 20;
    let dataList = [];
    for (i; i < maxi; i++) {
        let nowMs = new Date().valueOf();
        let randomNum = parseInt(`${moment().hour()}${moment().minute()}${moment().second()}${Math.ceil(Math.random() * 100)}`);
        let userId = generateUserId();
        let endTime = new Date(moment().add(1, 'd').format("YYYY-MM-DD")+' 00:00:00').valueOf();
        dataList.push({
            "token" : "",
            "tokenMs" : 0,
            "isInput" : false,
            "inputUserChangePwd" : false,
            "adminLv" : [],
            "registerFlow" : 3,
            "isAdmin" : 0,
            "userRegisterState" : 1,
            "memberState" : 1,
            "memberLevel" : 1,
            "isFirstPay" : false,
            "isGracePeriod" : 0,
            "profCategory" : [],
            "auxiliaryMaterial" : [],
            "userId" : userId,
            "memberType" : 2,
            "askForTime" : nowMs,
            "loginId" : randomNum,
            "mail" : "16621071125@163.com",
            "pwd" : "123456",
            "phone" : `1812093${Math.ceil(Math.random() * 10)}${Math.ceil(Math.random() * 10)}${Math.ceil(Math.random() * 10)}${Math.ceil(Math.random() * 10)}`,
            "__v" : 0,
            "ZhuYaoFuZeRenYouXiang" : "16621071125@163.com",
            "addres" : "asfasfsda",
            "contactPerson" : "16621071125",
            "contactPersonDuties" : "16621071125",
            "contactPersonPhone" : "16621071125",
            "danWeiJianJie" : "吃成都成都成都成都成都",
            "jiaoXueFuZeRenDianHua" : "16621071125",
            "jiaoXueFuZeRenXinMing" : "sdfs",
            "kaishezhuanYe" : "测试",
            "legalPerson" : "12312321",
            "legalPersonMail" : "16621071125@163.com",
            "legalPersonPhone" : "16621071125",
            "qu" : "350102",
            "sheng" : "350000",
            "shi" : "350100",
            "unitMemberType" : 9,
            "unitName" : `V${randomNum}`,
            "uscc" : "1111111111111111",
            "uusinessLicenseUrl" : "http://wenhuabu-files.oss-cn-beijing.aliyuncs.com/aae42fa7664b8c43945694c561d6cba7/undefined/1713925918987/Snipaste_2024-02-27_15-21-46.png",
            "yuanXiaoBanGongFuZeRen" : "sdfs",
            "yuanXiaoBanGongFuZeRenDianHua" : "16621071125",
            "yuanXiaoBanXueLeiXing" : 1,
            "yuanXiaoFuZeRen" : "sdfs",
            "yuanXiaoFuZeRenDianHua" : "16621071125",
            "yuanXiaoFuZeRenZhiWu" : "fdsfs",
            "yuanXiaoJiaoZhiGongZongRenShu" : "12312",
            "yuanXiaoKeYanFuZeRen" : "sdfasf",
            "yuanXiaoKeYanFuZeRenDianHua" : "16621071125",
            "yuanXiaoXueShengZongRenShu" : "123",
            "yuanXiaoZhuGuanBuMen" : "sdfsd",
            "applicationForm" : "http://wenhuabu-files.oss-cn-beijing.aliyuncs.com/aae42fa7664b8c43945694c561d6cba7/undefined/1713926286655/功能清单.png"
        });
    }
    await addManyData(TABLEENUM.用户表, dataList);
    console.log("初始化成功");
}


export async function initOrderData() {
    let randomNum = parseInt(`${moment().hour()}${moment().minute()}${moment().second()}${Math.ceil(Math.random() * 100)}`);
    let userId = generateUserId();

    let userInfo = {
        "token" : "",
        "tokenMs" : 0,
        "adminLv" : [],
        "registerFlow" : 2,
        "isAdmin" : 0,
        "userRegisterState" : 4,
        "memberState" : 1,
        "memberLevel" : 1,
        "isGracePeriod" : 0,
        "cardUrlJust" : "http://192.168.0.105:40012/whb/files/12/vue2024-03-22_16-11-873169.png",
        "cardUrlBack" : "http://192.168.0.105:40012/whb/files/12/vue2024-03-22_16-11-873169.png",
        "auxiliaryMaterial" : [],
        "userId" : userId,
        "memberType" : 1,
        "askForTime" : 1679327000000.0,
        "loginId" : randomNum,
        "mail" : "18120935727@163.com",
        "pwd" : "123456",
        "phone" : `1812093${Math.ceil(Math.random() * 10)}${Math.ceil(Math.random() * 10)}${Math.ceil(Math.random() * 10)}${Math.ceil(Math.random() * 10)}`,
        "__v" : 0,
        "academicCERTUrl" : "http://192.168.0.105:40012/whb/files/12/vue2024-03-22_16-11-356620.png",
        "addres" : "才能实现但是",
        "birth" : 1711036800000.0,
        "documentId" : "340822199901012333",
        "documentType" : 1,
        "duties" : "吃的蔬菜生产",
        "education" : 2,
        "name" : `V${randomNum}`,
        "nation" : 1,
        "otherEMP" : "23年前注册",
        "otherPROF" : "23年前注册",
        "photoUrl" : "http://192.168.0.105:40012/whb/files/12/vue2024-03-22_16-11-624049.png",
        "profAchievement" : "23年前注册",
        "profCategory" : 1,
        "professionalCERTUrl" : "http://192.168.0.105:40012/whb/files/12/vue2024-03-22_16-11-603763.png",
        "qu" : "130524",
        "sex" : 2,
        "sheng" : "130000",
        "shi" : "130500",
        "studyResume" : "23年前注册",
        "unitName" : "23年前注册",
        "workResume" : "23年前注册",
        "workTitle" : "23年前注册",
        "auditTime" : 1679328000000.0,
        "individualMemberType" : 1,
        "joinTime" : 1679328000000.0,
        "lifespanEndTime" : 1710864000000.0,
        "lifespanStartTime" : 1679328000000.0,
        "paymentStatus" : 2,
        "session" : 200907
    };

    await addOneData(TABLEENUM.用户表, userInfo);
    let dataList = [{
        "paymentNum" : "",
        "offlinePaymentUrl" : "",
        "weChartPR" : "",
        "weChartState" : 0,
        "isFirst" : true,
        "firstPayExamine" : false,
        "confirmReceipt" : 0,
        "invoiceStatus" : 1,
        "advanceInvoice" : false,
        "id" : generateOrderId(userId),
        "orderCycleStart" : 1679328000000.0,
        "orderCycleEnd" : 1710864000000.0,
        "unitName" : "23年注册",
        "money" : 100,
        "paymentMethod" : 0,
        "userId" : `${userId}`,
        "loginId" : `${randomNum}`,
        "memberCategory" : 1,
        "invoiceAdd" : "",
        "state" : 1,
        "phone" : "181209323310",
        "ct" : 1711103141897.0,
    },{
        "paymentNum" : "",
        "offlinePaymentUrl" : "",
        "weChartPR" : "",
        "weChartState" : 0,
        "isFirst" : false,
        "firstPayExamine" : false,
        "confirmReceipt" : 0,
        "invoiceStatus" : 1,
        "advanceInvoice" : false,
        "id" : generateOrderId(userId),
        "orderCycleStart" : 1710864000000.0,
        "orderCycleEnd" : 1742400000000.0,
        "unitName" : "23年注册",
        "money" : 100,
        "paymentMethod" : 0,
        "userId" : `${userId}`,
        "loginId" : `${randomNum}`,
        "memberCategory" : 1,
        "invoiceAdd" : "",
        "state" : 1,
        "phone" : "181209323310",
        "ct" : 1711103141897.0,
    }];

    await addManyData(TABLEENUM.订单表, dataList);
    console.log("订单数据模拟成功");
}