CREATE TABLE if not exists `bsl_doc_header` (
    `id` varchar(64) NOT NULL COMMENT 'id',
    `doc_no` varchar(255) DEFAULT NULL COMMENT '单据号',
    `doc_type` varchar(255) DEFAULT NULL COMMENT '单据类型',
    `doc_creator` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '制单人',
    `business_type` varchar(255) DEFAULT NULL COMMENT '业务类型',
    `vendor_code` varchar(255) DEFAULT NULL COMMENT '供应商编码',
    `vendor_name` varchar(255) DEFAULT NULL COMMENT '供应商全称',
    `custom_name` varchar(255) DEFAULT NULL COMMENT '客户名称',
    `purchaser` varchar(255) DEFAULT NULL COMMENT '采购人',
    `tax_rate` varchar(255) DEFAULT NULL COMMENT '税率',
    `dept` varchar(255) DEFAULT NULL COMMENT '部门名称',
    `sale_return_unit` varchar(255) DEFAULT NULL COMMENT '销售退货单位',
    `sale_returner` varchar(255) DEFAULT NULL COMMENT '销售退货人',
    `sale_contract` varchar(255) DEFAULT NULL COMMENT '销售合同',
    `shipper` varchar(255) DEFAULT NULL COMMENT '发货人',
    `receiver` varchar(255) DEFAULT NULL COMMENT '接收人',
    `receive_address` varchar(255) DEFAULT NULL COMMENT '收货地址',
    `receive_phone` varchar(255) DEFAULT NULL COMMENT '收货人电话',
    `reviewer` varchar(255) DEFAULT NULL COMMENT '审核人',
    `reviewer_next` varchar(255) DEFAULT NULL COMMENT '复审人',
    `warehouse_type` varchar(255) DEFAULT NULL COMMENT '仓库类别',
    `remark` varchar(255) DEFAULT NULL COMMENT '备注',
    `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '创建者',
    `create_date` datetime DEFAULT NULL COMMENT '创建时间',
    `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '更新者',
    `update_date` datetime DEFAULT NULL COMMENT '更新时间',
    PRIMARY KEY (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='佰穗莱单据单头表';

CREATE TABLE if not exists `bsl_doc_details` (
    `id` varchar(64) NOT NULL COMMENT 'id',
    `doc_header_id` varchar(64) DEFAULT NULL COMMENT '单据头id',
    `doc_line_no` int(64) DEFAULT NULL COMMENT '明细行号',
    `sku_code` varchar(255) DEFAULT NULL COMMENT '物料编码',
    `sku_name` varchar(255) DEFAULT NULL COMMENT '物料名称',
    `sku_qty` varchar(255) DEFAULT NULL COMMENT '物料数量',
    `original_lot_number` varchar(255) DEFAULT NULL COMMENT '原厂批号',
    `income_lot_number` varchar(255) DEFAULT NULL COMMENT '进厂批号',
    `product_name` varchar(255) DEFAULT NULL COMMENT '产品名称',
    `product_lot_number` varchar(255) DEFAULT NULL COMMENT '产品批号',
    `measure_unit` varchar(255) DEFAULT NULL COMMENT '计量单位',
    `manufacture_date` datetime DEFAULT NULL COMMENT '生产日期',
    `receiver` varchar(255) DEFAULT NULL COMMENT '收货人',
    `specification` varchar(255) DEFAULT NULL COMMENT '规格',
    `quality_inspection_doc` varchar(255) DEFAULT NULL COMMENT '质检单号/检验单号',
    `returner` varchar(255) DEFAULT NULL COMMENT '退库人',
    `price_include_tax` varchar(255) DEFAULT NULL COMMENT '含税价',
    `warehouse_person` varchar(255) DEFAULT NULL COMMENT '入库人',
    `reviewer_next` varchar(255) DEFAULT NULL COMMENT '复审人',
    `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '备注',
    `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '创建者',
    `create_date` datetime DEFAULT NULL COMMENT '创建时间',
    `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '更新者',
    `update_date` datetime DEFAULT NULL COMMENT '更新时间',
    PRIMARY KEY (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='佰穗莱单据明细表';

-- ----------------------------
-- 物料信息表
-- ----------------------------
DROP TABLE IF EXISTS `base_sku`;
CREATE TABLE `base_sku`  (
  `sku_customer_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '货主编号',
  `sku` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '物料编号',
  `sku_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '物料名称',
  `sku_specs` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '规格',
  `sku_packaging_specs` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '包装规格',
  `sku_allergen_information` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '过敏原信息',
  `sku_uom` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '计量单位',
  `sku_shelflife` int(11) NULL DEFAULT NULL COMMENT '有效期(天)',
  `sku_qc_time` double(4, 1) NULL DEFAULT NULL COMMENT '质检周期（复验期）',
  `sku_qc_check` varchar(1) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '0' COMMENT '是否质检 Y:质检 N:不质检',
  `sku_type` int(10) UNSIGNED ZEROFILL NULL DEFAULT NULL COMMENT '产品类型',
  `sku_desc` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '描述',
  `sku_tare` decimal(18, 8) NULL DEFAULT NULL COMMENT '皮重',
  `sku_grossweight` decimal(18, 8) NULL DEFAULT NULL COMMENT '毛重',
  `sku_netweight` decimal(18, 8) NULL DEFAULT NULL COMMENT '净重',
  `sku_status` varchar(1) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'Y' COMMENT '物料状态 Y:启用 N:禁用',
  `sku_putaway_zone` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '上架区域',
  `sku_high` decimal(18, 8) NULL DEFAULT NULL COMMENT '高',
  `sku_length` decimal(18, 8) NULL DEFAULT NULL COMMENT '长',
  `sku_width` decimal(18, 8) NULL DEFAULT NULL COMMENT '宽',
  `sku_qc_rule` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '质检规则',
  `sku_manufacturer` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '生产企业',
  `creator` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '创建者',
  `create_date` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `updater` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '更新者',
  `update_date` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  `remark` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`sku_customer_id`, `sku`) USING BTREE,
  INDEX `base_sku_index1`(`sku_customer_id`, `sku`) USING BTREE,
  INDEX `base_sku_index2`(`sku_type`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '物料信息' ROW_FORMAT = Dynamic;

-- ----------------------------
-- 客户/供应商表
-- ----------------------------
DROP TABLE IF EXISTS `base_org`;
CREATE TABLE `base_org`  (
  `id` bigint(32) NOT NULL COMMENT '主键',
  `org_code` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '客户/供应商编码',
  `org_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '客户/供应商全称',
  `org_status` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '客户/供应商状态 1:合格且启用 2:不合格且启用 0:禁用',
  `org_address` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '通信地址',
  `org_contacts` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '联系人',
  `org_phone_num` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '联系电话',
  `org_accounts_bank` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '开户行',
  `org_credit_code` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '企业统一代码',
  `org_business_license` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '营业执照',
  `org_production_license` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '生产许可证',
  `org_business_certificate` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '经营许可证',
  `org_type` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '业务类型 10:客户，00:供应商',
  `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者',
  `create_date` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新者',
  `update_date` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

CREATE TABLE `sys_config` (
  `config_id` int(5) NOT NULL AUTO_INCREMENT COMMENT '参数主键',
  `config_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '参数名称',
  `config_key` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '参数键名',
  `config_value` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '参数键值',
  `config_type` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT 'N' COMMENT '系统内置（Y是 N否）',
  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '创建者',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '更新者',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`config_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='参数配置表';
