IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_CHECKINGINVOICE')
CREATE TABLE T_ER_CHECKINGINVOICE
(

    FID                      BIGINT          DEFAULT 0   NOT NULL,
    FENTRYID                 BIGINT          DEFAULT 0   NOT NULL,
    FSEQ                     BIGINT          DEFAULT 0   NOT NULL,
    FINVOICETYPE             VARCHAR(50)     DEFAULT ' ' NOT NULL,
    FINVOICECODE             VARCHAR(129)    DEFAULT ' ' NOT NULL,
    FINVOICENO               VARCHAR(129)    DEFAULT ' ' NOT NULL,
    FTOTALAMOUNT             NUMERIC(23, 10) DEFAULT 0   NOT NULL,
    FTAXAMOUNT               NUMERIC(23, 10) DEFAULT 0   NOT NULL,
    FPASSENGERNAME           VARCHAR(255)    DEFAULT ' ' NOT NULL,
    FFROMCITY                VARCHAR(500)     DEFAULT ' ' NOT NULL,
    FTOCITY                  VARCHAR(500)     DEFAULT ' ' NOT NULL,
    FBUYERNAME               VARCHAR(250)    DEFAULT ' ' NOT NULL,
    FMAKEOUTCOMPNAME         VARCHAR(250)    DEFAULT ' ' NOT NULL,
    FBUYERORGID              BIGINT          DEFAULT 0   NOT NULL,
    FFLIGHTITINERARYANDTRAIN CHAR(1)     DEFAULT '0' NOT NULL,
    FCHECKINGBILLNO          VARCHAR(50)     DEFAULT ' ' NOT NULL,
    FDOWNLOADURL             VARCHAR(1500)    DEFAULT ' ' NOT NULL,
    FINNERDOWNLOADURL        VARCHAR(1500)    DEFAULT ' ' NOT NULL
);



EXEC P_ALTERPK 'PK_ER_CHECKINGINVOICE', 'T_ER_CHECKINGINVOICE', 'FENTRYID', '0';

-- 创建发票代码索引
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_INVOICE_FINVOICECODE') CREATE INDEX IDX_INVOICE_FINVOICECODE ON T_ER_CHECKINGINVOICE ( FINVOICECODE,FCHECKINGBILLNO );

-- 创建发票号码索引
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_INVOICE_FINVOICENO') CREATE INDEX IDX_INVOICE_FINVOICENO ON T_ER_CHECKINGINVOICE ( FINVOICENO,FCHECKINGBILLNO );

-- 创建月结账单索引
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_INVOICE_FCHECKINGNO') CREATE INDEX IDX_INVOICE_FCHECKINGNO ON T_ER_CHECKINGINVOICE ( FCHECKINGBILLNO );






