/**Begin D:\pdm\PDM_UPGRADE\pdm_new\SIM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SIM_BILL_LOG') 
 CREATE TABLE T_SIM_BILL_LOG (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(10) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,
FINNER_PARAM NVARCHAR(100) DEFAULT ' ' NOT NULL,
FINNER_PARAM_TAG NCLOB,
FOUTTER_PARAM NVARCHAR(100) DEFAULT ' ' NOT NULL,
FOUTTER_PARAM_TAG NCLOB,
FDEAL_TYPE NVARCHAR(20) DEFAULT ' ' NOT NULL,
FMSG_DESC NVARCHAR(512) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SIM_FRONT_SYSTEM_CFG') 
 CREATE TABLE T_SIM_FRONT_SYSTEM_CFG (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSTATUS NVARCHAR(10) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE NVARCHAR(10) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FSYSTEM_URL NVARCHAR(255) DEFAULT ' ' NOT NULL,
FCALLBACK_URL NVARCHAR(255) DEFAULT ' ' NOT NULL,
FGET_DATA_TYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FINVOKE_PROTOCOL_CLASS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FABUTMENT_METHOD NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDB_ADDRESS NVARCHAR(255) DEFAULT ' ' NOT NULL,
FDB_USERNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDB_PASSWORD NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDRIVER_NAME NVARCHAR(80) DEFAULT ' ' NOT NULL,
FCLIENT_ID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCLIENT_SECRET NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCLIENT_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCLIENT_ENC_KEY NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SIM_FRONT_SYSTEM_CFG_L') 
 CREATE TABLE T_SIM_FRONT_SYSTEM_CFG_L (
FPKID NVARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID NVARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SIM_PAY_TYPE') 
 CREATE TABLE T_SIM_PAY_TYPE (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
FPAYNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE NVARCHAR(10) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FGROUPID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FCREATEORGID BIGINT DEFAULT 0 NOT NULL,
FCTRLSTRATEGY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSOURCEDATAID BIGINT DEFAULT 0 NOT NULL,
FBITINDEX BIGINT DEFAULT 0 NOT NULL,
FSOURCEBITINDEX BIGINT DEFAULT 0 NOT NULL,
FINVOICABLE NVARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(10) DEFAULT ' ' NOT NULL,
FCREATE_ORG BIGINT DEFAULT 0 NOT NULL,
FSYSTEM_CODE NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SIM_PAY_TYPE_L') 
 CREATE TABLE T_SIM_PAY_TYPE_L (
FPKID NVARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID NVARCHAR(10) DEFAULT ' ' NOT NULL,
FPAYNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SIM_RECEIVE_BILL') 
 CREATE TABLE T_SIM_RECEIVE_BILL (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(10) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,
FORGID BIGINT DEFAULT 0 NOT NULL,
FBILL_TYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FORG_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FORG_CODE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBILL_CREATE_TIME DATETIME,
FBILL_END_TIME DATETIME,
FCUSTOM_NAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FPRODUCT_NAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FPRODUCT_CODE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPRODUCT_TYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FNUM BIGINT DEFAULT 0 NOT NULL,
FTOTAL_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FINVOICABLE_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPAYMENT_METHOD NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPAYMENT_STATUS NVARCHAR(10) DEFAULT ' ' NOT NULL,
FBILL_JSON_DATA NVARCHAR(255) DEFAULT ' ' NOT NULL,
FBILL_JSON_DATA_TAG NCLOB,
FREMARK NVARCHAR(512) DEFAULT ' ' NOT NULL,
FUSER_PHONE NVARCHAR(20) DEFAULT ' ' NOT NULL,
FUSER_EMAIL NVARCHAR(70) DEFAULT ' ' NOT NULL,
FWX_OPEN_ID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTEXTFIELD1 NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTEXTFIELD2 NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTEXTFIELD3 NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTEXTFIELD4 NVARCHAR(50) DEFAULT ' ' NOT NULL,
FOP_USER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPRODUCT_ID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSYSTEM_CODE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSYSTEM_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FACTUAL_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FINVOICE_STATUS NVARCHAR(10) DEFAULT ' ' NOT NULL,
FINVOICE_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREMAIN_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FINVOICE_SERIAL_NOS NVARCHAR(512) DEFAULT ' ' NOT NULL,
FTENANT_NO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPROJECT_START_TIME DATETIME,
FPROJECT_END_TIME DATETIME,
FDATA_STATUS NVARCHAR(10) DEFAULT ' ' NOT NULL,
FINVOICABLE_SWITCH NVARCHAR(10) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SIM_SYSTEM_ORG_REL') 
 CREATE TABLE T_SIM_SYSTEM_ORG_REL (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FTARGET_ORG_ID BIGINT DEFAULT 0 NOT NULL,
FSYSTEM_CODE NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SIM_SYSTEM_ORG_REL_L') 
 CREATE TABLE T_SIM_SYSTEM_ORG_REL_L (
FPKID NVARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID NVARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SIM_SYSTEM_SOURCE_ORG') 
 CREATE TABLE T_SIM_SYSTEM_SOURCE_ORG (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSOURCE_ORG_CODE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSOURCE_ORG_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDETAIL_CREATE_DATE DATETIME,
FDETAIL_CREATER BIGINT DEFAULT 0 NOT NULL,
FDETAIL_MODIFY_DATE DATETIME,
FDETAIL_MODIFIER BIGINT DEFAULT 0 NOT NULL,
FSYSTEM_CODE NVARCHAR(50) DEFAULT ' ' NOT NULL
);



/**End D:\pdm\PDM_UPGRADE\pdm_new\SIM_table.sql **/
