/**Begin C:\PDM_UPGRADE\PDM1\MAL_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MAL_ADDRESSREL_L') 
 CREATE TABLE T_MAL_ADDRESSREL_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FFULLNAME NVARCHAR(510) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MAL_ADDRESSREL') 
 CREATE TABLE T_MAL_ADDRESSREL (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(80) DEFAULT ' ' NOT NULL,
FSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE CHAR(1) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FEMALADDRESSID BIGINT DEFAULT 0 NOT NULL,
FADDRESSID BIGINT DEFAULT 0 NOT NULL,
FEMALTYPE CHAR(1) DEFAULT ' ' NOT NULL,
FMATCHSTATUS CHAR(1) DEFAULT '1' NOT NULL,
FLONGNUMBER VARCHAR(80) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MAL_EMALADDRESS') 
 CREATE TABLE T_MAL_EMALADDRESS (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(30) DEFAULT ' ' NOT NULL,
FSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE CHAR(1) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FISLEAF CHAR(1) DEFAULT '1' NOT NULL,
FLEVEL INT DEFAULT 0 NOT NULL,
FLONGNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FPARENTID BIGINT DEFAULT 0 NOT NULL,
FEMALTYPE CHAR(1) DEFAULT ' ' NOT NULL
);


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

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MAL_EMALSTATUS') 
 CREATE TABLE T_MAL_EMALSTATUS (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(30) DEFAULT ' ' NOT NULL,
FSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FSTATUSTYPENUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FSTATUSTYPE CHAR(1) DEFAULT ' ' NOT NULL,
FEMALTYPE CHAR(1) DEFAULT ' ' NOT NULL,
FEMALSTATUSNAME VARCHAR(50) DEFAULT ' ' NOT NULL,
FEMALSTATUSNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MAL_ORDER_JD') 
 CREATE TABLE T_MAL_ORDER_JD (
FID BIGINT DEFAULT 0 NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FPORDERID VARCHAR(80) DEFAULT ' ' NOT NULL,
FORDERID VARCHAR(80) DEFAULT ' ' NOT NULL,
FORDERSTATE CHAR(1) DEFAULT ' ' NOT NULL,
FSUBMITSTATE CHAR(1) DEFAULT ' ' NOT NULL,
FSTATE CHAR(1) DEFAULT ' ' NOT NULL,
FJDORDERSTATE CHAR(1) DEFAULT ' ' NOT NULL,
FFREIGHT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FORDERNAKEDAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FORDERTAXAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FPAYCODEID NVARCHAR(80) DEFAULT ' ' NOT NULL,
FINVOICERESULT NVARCHAR(255) DEFAULT ' ' NOT NULL,
FINVOICESTATE CHAR(1) DEFAULT ' ' NOT NULL,
FINVOICEID VARCHAR(50) DEFAULT ' ' NOT NULL,
FINVOICECODE VARCHAR(80) DEFAULT ' ' NOT NULL,
FINVOICEDATE DATETIME,
FINVOICETAXAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FINVOICEAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FINVOICETAX DECIMAL(19,6) DEFAULT 0 NOT NULL,
FINVOICETAXRATE DECIMAL(19,6) DEFAULT 0 NOT NULL,
FINVOICEADDRESS VARCHAR(1000) DEFAULT ' ' NOT NULL,
FMARKID NVARCHAR(255) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MAL_ORDER_JD' AND KSQL_COL_NAME IN ('FORDERAMOUNT')) 
 ALTER TABLE T_MAL_ORDER_JD ADD (FORDERAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MAL_ORDER_SN') 
 CREATE TABLE T_MAL_ORDER_SN (
FID BIGINT DEFAULT 0 NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FPORDERID VARCHAR(80) DEFAULT ' ' NOT NULL,
FORDERID VARCHAR(80) DEFAULT ' ' NOT NULL,
FSUBMITSTATE CHAR(1) DEFAULT ' ' NOT NULL,
FORDERSTATE CHAR(1) DEFAULT ' ' NOT NULL,
FSUBORDERSTATE CHAR(1) DEFAULT ' ' NOT NULL,
FFREIGHT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FORDERAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FORDERNAKEDAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FORDERTAXAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FINVOICESTATE CHAR(1) DEFAULT ' ' NOT NULL,
FINVOICEID VARCHAR(50) DEFAULT ' ' NOT NULL,
FINVOICECODE VARCHAR(80) DEFAULT ' ' NOT NULL,
FINVOICEDATE DATETIME,
FINVOICETAXAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FINVOICEAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FINVOICETAX DECIMAL(19,6) DEFAULT 0 NOT NULL,
FINVOICETAXRATE DECIMAL(19,6) DEFAULT 0 NOT NULL,
FINVOICEADDRESS VARCHAR(1000) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MAL_ORDERENTRY_JD') 
 CREATE TABLE T_MAL_ORDERENTRY_JD (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FGOODSID BIGINT DEFAULT 0 NOT NULL,
FQTY DECIMAL(19,6) DEFAULT 0 NOT NULL,
FPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FNAKEDAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAXRATE DECIMAL(19,6) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MAL_ORDERENTRY_SN') 
 CREATE TABLE T_MAL_ORDERENTRY_SN (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FGOODSID BIGINT DEFAULT 0 NOT NULL,
FQTY DECIMAL(19,6) DEFAULT 0 NOT NULL,
FPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FNAKEDAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAXRATE DECIMAL(19,6) DEFAULT 0 NOT NULL
);

/**End C:\PDM_UPGRADE\PDM1\MAL_table.sql **/
