/**Begin D:\PDM_UPGRADE\PDM1\CAS_table.sql **/
EXEC p_AlterColumn 'T_CAS_RECEIVINGBILL_E', 'FREFUNDTYPE', 'NVARCHAR(30)', 'NOT NULL', '0011', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_CAS_PAYMENTBILL_REV')
CREATE TABLE T_CAS_PAYMENTBILL_REV (
   FENTRYID BIGINT DEFAULT 0 NOT NULL,
   FID BIGINT DEFAULT 0 NOT NULL,
   FSEQ INT DEFAULT 0 NOT NULL,
   FREVID BIGINT DEFAULT 0 NOT NULL,
   FPENTRYID BIGINT DEFAULT 0 NOT NULL,
   FREFUNDAMT DECIMAL(23,10) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_CAS_AGENTPAYBILL_REV')
CREATE TABLE T_CAS_AGENTPAYBILL_REV (
    FENTRYID BIGINT DEFAULT 0 NOT NULL,
    FID BIGINT DEFAULT 0 NOT NULL,
    FSEQ INT DEFAULT 0 NOT NULL,
    FREVID BIGINT DEFAULT 0 NOT NULL,
    FPENTRYID BIGINT DEFAULT 0 NOT NULL,
    FREFUNDAMT DECIMAL(23,10) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_CAS_REFUND_OPLOG')
CREATE TABLE T_CAS_REFUND_OPLOG (
    FID BIGINT DEFAULT 0 NOT NULL,
    FBILLENTITY VARCHAR(48),
    FORGID BIGINT DEFAULT 0 NOT NULL,
    FREFUNDBILLNO VARCHAR(128),
    FREFUNDBILLID BIGINT DEFAULT 0 NOT NULL,
    FREVBILLNO VARCHAR(128),
    FREVID BIGINT DEFAULT 0 NOT NULL,
    FOPERATETYPE VARCHAR(48),
    FOPRESULT CHAR(1) DEFAULT '0' NOT NULL,
    FERRORLOG VARCHAR(2048),
    FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
    FOPDATETIME DATETIME DEFAULT GETDATE() NOT NULL,
    FCREATERID BIGINT DEFAULT 0 NOT NULL,
    TRACEID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_CAS_REFUND_OPLOG_ENTRY')
CREATE TABLE T_CAS_REFUND_OPLOG_ENTRY (
  FENTRYID BIGINT DEFAULT 0 NOT NULL,
  FID BIGINT DEFAULT 0 NOT NULL,
  FSEQ INT DEFAULT 0 NOT NULL,
  FLINENO INT DEFAULT 0 NOT NULL,
  FRENTRYID BIGINT DEFAULT 0 NOT NULL,
  FAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
  FBEFOREREFUNDAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
  FAFTERREFUNDAMT DECIMAL(23,10) DEFAULT 0 NOT NULL
);

/**End D:\PDM_UPGRADE\PDM1\CAS_table.sql **/
