-- 门店服务区域表结构设计 -- 基于腾讯地图实现手绘多边形服务区域功能 -- ---------------------------- -- Table structure for ls_store_service_area -- ---------------------------- DROP TABLE IF EXISTS `ls_store_service_area`; CREATE TABLE `ls_store_service_area` ( `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键ID', `store_id` int(11) NOT NULL COMMENT '门店ID,关联ls_retail_store表', `merchant_id` int(11) NOT NULL COMMENT '商户ID', `area_name` varchar(100) NOT NULL DEFAULT '' COMMENT '服务区域名称', `polygon_data` text NOT NULL COMMENT '多边形坐标数据,JSON格式存储经纬度数组', `center_lat` decimal(10,7) DEFAULT NULL COMMENT '区域中心点纬度', `center_lng` decimal(10,7) DEFAULT NULL COMMENT '区域中心点经度', `area_size` decimal(15,2) DEFAULT '0.00' COMMENT '服务区域面积(平方公里)', `delivery_fee` decimal(8,2) DEFAULT '0.00' COMMENT '该区域配送费用', `min_order_amount` decimal(8,2) DEFAULT '0.00' COMMENT '该区域最低起送金额', `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态:1=启用,0=禁用', `priority` int(3) NOT NULL DEFAULT '0' COMMENT '优先级,数字越大优先级越高', `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', `update_time` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间', `operator_id` int(11) DEFAULT '0' COMMENT '操作员ID', `remarks` varchar(500) DEFAULT '' COMMENT '备注说明', PRIMARY KEY (`id`), KEY `idx_store_id` (`store_id`), KEY `idx_merchant_id` (`merchant_id`), KEY `idx_status` (`status`), KEY `idx_priority` (`priority`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='门店服务区域表'; -- ---------------------------- -- Table structure for ls_store_service_area_log -- ---------------------------- DROP TABLE IF EXISTS `ls_store_service_area_log`; CREATE TABLE `ls_store_service_area_log` ( `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键ID', `area_id` int(11) NOT NULL COMMENT '服务区域ID', `store_id` int(11) NOT NULL COMMENT '门店ID', `action_type` tinyint(2) NOT NULL COMMENT '操作类型:1=创建,2=修改,3=删除,4=启用,5=禁用', `old_data` text COMMENT '修改前数据(JSON格式)', `new_data` text COMMENT '修改后数据(JSON格式)', `operator_id` int(11) DEFAULT '0' COMMENT '操作员ID', `operator_name` varchar(50) DEFAULT '' COMMENT '操作员姓名', `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '操作时间', `ip_address` varchar(45) DEFAULT '' COMMENT '操作IP地址', `user_agent` varchar(500) DEFAULT '' COMMENT '用户代理信息', PRIMARY KEY (`id`), KEY `idx_area_id` (`area_id`), KEY `idx_store_id` (`store_id`), KEY `idx_action_type` (`action_type`), KEY `idx_create_time` (`create_time`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='门店服务区域操作日志表'; -- 为现有门店表添加服务区域相关字段(如果需要) -- ALTER TABLE `ls_retail_store` ADD COLUMN `service_area_enabled` tinyint(1) DEFAULT '0' COMMENT '是否启用自定义服务区域:0=使用默认半径,1=使用自定义区域'; -- ALTER TABLE `ls_retail_store` ADD COLUMN `default_service_radius` decimal(8,2) DEFAULT '3.00' COMMENT '默认服务半径(公里)'; -- 示例数据插入 -- INSERT INTO `ls_store_service_area` (`store_id`, `merchant_id`, `area_name`, `polygon_data`, `center_lat`, `center_lng`, `area_size`, `delivery_fee`, `min_order_amount`, `status`, `priority`, `create_time`, `operator_id`, `remarks`) -- VALUES (1, 1, '主要配送区域', '[{"lat":39.908823,"lng":116.397470},{"lat":39.908823,"lng":116.407470},{"lat":39.918823,"lng":116.407470},{"lat":39.918823,"lng":116.397470}]', 39.913823, 116.402470, 1.25, 5.00, 30.00, 1, 1, UNIX_TIMESTAMP(), 1, '门店主要服务区域');