
CREATE TABLE `wx_bill_settle` (
  `id` bigint(20) NOT NULL COMMENT '主键ID',
  `tenant_id` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `settle_number` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '结算单号',
  `merchant_id` bigint(20) DEFAULT NULL COMMENT '商户ID',
  `status` smallint(1) DEFAULT '0' COMMENT '7待清算3结算完成',
  `apply_status` smallint(1) DEFAULT '0' COMMENT '审核状态0未审核1审核中2审核完成3驳回4异常终止5撤回',
  `receive_money` bigint(12) DEFAULT '0' COMMENT '收款',
  `pay_money` bigint(12) DEFAULT '0' COMMENT '承付',
  `settletime` datetime DEFAULT NULL COMMENT '结算时间',
  `createtime` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updatetime` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='结算单';


CREATE TABLE `wx_bill_settle_bill` (
  `id` bigint(20) NOT NULL COMMENT '主键ID',
  `tenant_id` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `settle_id` bigint(20) DEFAULT NULL COMMENT '结算单id',
  `type` smallint(1) DEFAULT '0' COMMENT '类型: 0收款1承付',
  `bill_id` bigint(20) DEFAULT NULL COMMENT '账单id',
  `bill_type` smallint(1) DEFAULT '0' COMMENT '账单类型: 1租金2押金3物业4日常费用6其他8补贴',
  `createtime` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updatetime` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='结算单-账单表';


CREATE TABLE `wx_bill_settle_record` (
  `id` bigint(20) NOT NULL COMMENT '主键ID',
  `settle_id` bigint(20) NOT NULL COMMENT '主表id',
  `tenant_id` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '租户id',
  `userid` bigint(20) DEFAULT NULL COMMENT '操作人id',
  `user_name` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '操作人姓名',
  `settle_money` bigint(12) DEFAULT '0' COMMENT '清算金额',
  `settle_time` datetime DEFAULT NULL COMMENT '清算时间',
  `settle_way` smallint(1) DEFAULT '1' COMMENT '清算方式1现金2支付宝3微信4银行卡转账5其他',
  `balance` bigint(12) DEFAULT '0' COMMENT '结余',
  `detail` varchar(300) COLLATE utf8mb4_unicode_ci DEFAULT '0' COMMENT '明细',
  `createtime` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updatetime` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
  `desc` varchar(800) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '描述',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='结算记录表';