CREATE TABLE hrsa_tax_agent_emp
(
    id            bigint NOT NULL ,
    create_time   timestamp NULL DEFAULT NULL ,
    update_time   timestamp NULL DEFAULT NULL ,
    creator       bigint NULL DEFAULT NULL ,
    delete_type   int NULL DEFAULT 0,
    tenant_key    varchar(10)   NULL DEFAULT NULL ,
    tax_agent_id  bigint NULL DEFAULT NULL ,
    employee_id   bigint NULL DEFAULT NULL ,
    employee_name varchar(255)   NULL DEFAULT NULL,
    PRIMARY KEY (id) 
) ;


CREATE TABLE hrsa_tax_agent_emp_change
(
    id            bigint NOT NULL ,
    create_time   timestamp NULL DEFAULT NULL ,
    update_time   timestamp NULL DEFAULT NULL ,
    creator       bigint NULL DEFAULT NULL ,
    delete_type   int NULL DEFAULT 0 ,
    tenant_key    varchar(10)   NULL DEFAULT NULL ,
    tax_agent_id  bigint NOT NULL ,
    employee_id   bigint NOT NULL ,
    change_type   int NOT NULL DEFAULT 0 ,
    employee_name varchar(255)   NULL DEFAULT NULL,
    module_type   int NOT NULL DEFAULT 0,
    PRIMARY KEY (id) 
) ;



CREATE TABLE hrsa_tax_agent_admin
(
    id           bigint NOT NULL ,
    tax_agent_id bigint NOT NULL ,
    employee_id  bigint NOT NULL ,
    create_time  timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP (0) ,
    update_time  timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP (0) ,
    creator      bigint NOT NULL DEFAULT 0 ,
    delete_type  int NOT NULL DEFAULT 0 ,
    tenant_key   varchar(10)  NOT NULL DEFAULT '' ,
    PRIMARY KEY (id) 
) ;


CREATE TABLE hrsa_tax_agent_manage_range
(
    id                     bigint NOT NULL ,
    tax_agent_id           bigint NOT NULL DEFAULT 0 ,
    employee_id            bigint NOT NULL DEFAULT 0 ,
    tax_agent_sub_admin_id bigint NOT NULL DEFAULT 0 ,
    target_type            smallint NOT NULL DEFAULT 1 ,
    target_id              bigint NOT NULL DEFAULT 0 ,
    employee_status        varchar(100)  NOT NULL,
    include_type           int NOT NULL DEFAULT 1,
    creator                bigint NOT NULL DEFAULT 0 ,
    create_time            timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP (0) ,
    update_time            timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP (0) ,
    delete_type            int NOT NULL DEFAULT 0 ,
    tenant_key             varchar(10)  NOT NULL DEFAULT '' ,
    range_type             int NOT NULL DEFAULT 0,
    PRIMARY KEY (id) 
) ;


CREATE TABLE hrsa_tax_agent_base
(
    id                bigint NOT NULL ,
    devolution_status int NOT NULL DEFAULT 0 ,
    create_time       timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP (0) ,
    update_time       timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP (0) ,
    creator           bigint NOT NULL DEFAULT 0 ,
    delete_type       int NOT NULL DEFAULT 0 ,
    tenant_key        varchar(10)  NOT NULL DEFAULT '' ,
    PRIMARY KEY (id) 
) ;


CREATE TABLE hrsa_tax_agent_sub_admin
(
    id           bigint NOT NULL ,
    tax_agent_id bigint NOT NULL ,
    employee_id  bigint NOT NULL ,
    description  varchar(100)  NULL DEFAULT NULL ,
    create_time  timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ,
    update_time  timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ,
    creator      bigint NOT NULL DEFAULT 0 ,
    delete_type  int NOT NULL DEFAULT 0 ,
    tenant_key   varchar(10) NOT NULL DEFAULT '' ,
    remark       text  NULL,
    PRIMARY KEY (id) 
) ;


CREATE TABLE hrsa_tax_agent_sub_admin_emp
(
    id                     bigint NOT NULL ,
    create_time            timestamp NULL DEFAULT NULL ,
    update_time            timestamp NULL DEFAULT NULL ,
    creator                bigint NULL DEFAULT NULL ,
    delete_type            int NULL DEFAULT 0 ,
    tenant_key             varchar(10)   NULL DEFAULT NULL ,
    tax_agent_id           bigint NOT NULL DEFAULT 0 ,
    tax_agent_sub_admin_id bigint NOT NULL DEFAULT 0 ,
    employee_id            bigint NOT NULL DEFAULT 0 ,
    employee_name          varchar(255)   NULL DEFAULT NULL ,
    PRIMARY KEY (id) 
) ;


ALTER TABLE hrsa_tax_agent ADD COLUMN payment_agency varchar(255) NULL ;


ALTER TABLE hrsa_salary_sob ADD COLUMN tax_agent_id bigint NULL ;


INSERT INTO hrsa_tax_agent_base(id, devolution_status, create_time, update_time, creator, delete_type, tenant_key) VALUES (1653303537239, 1, '2022-05-23 18:58:53', '2022-05-23 19:12:12', 1, 0, 'all_teams');

ALTER TABLE hrsa_bill_detail_temp ADD COLUMN payment_organization bigint NULL ;

ALTER TABLE hrsa_bill_detail ADD COLUMN payment_organization bigint NULL ;

ALTER TABLE hrsa_bill_batch ADD COLUMN payment_organization bigint NULL ;