# 16:37 2021/9/16
ALTER TABLE `products`
	ADD COLUMN `service_persons` INT NOT NULL DEFAULT '1' COMMENT '单库存服务用户数' AFTER `content`;

# 17:49 2021/9/17
ALTER TABLE `suppliers`
	CHANGE COLUMN `balance` `balance` DECIMAL(20,2) NOT NULL DEFAULT '0.00' COMMENT '余额' AFTER `area_id`,
	CHANGE COLUMN `deposit_used` `deposit_used` DECIMAL(20,2) NOT NULL DEFAULT '0.00' COMMENT '交易金已消费' AFTER `balance`,
	CHANGE COLUMN `deposit_frozen` `deposit_frozen` DECIMAL(20,2) NOT NULL DEFAULT '0.00' COMMENT '交易金冻结' AFTER `deposit_used`,
	CHANGE COLUMN `deposit_normal` `deposit_normal` DECIMAL(20,2) NOT NULL DEFAULT '0.00' COMMENT '交易金正常' AFTER `deposit_frozen`;

# 10:26 2021/9/18 增加industry_orders、industry_products两个表
CREATE TABLE `industry_orders` (
	`id` INT(10) NOT NULL AUTO_INCREMENT,
	`agent_id` INT(10) NOT NULL COMMENT '代理商ID',
	`supplier_id` INT(10) NOT NULL COMMENT '供应商ID',
	`order_no` CHAR(22) NOT NULL COMMENT '订单号' COLLATE 'utf8_general_ci',
	`industry_product_id` INT(10) NOT NULL COMMENT '行业产品ID',
	`num` INT(10) NOT NULL COMMENT '购买数量',
	`price` DECIMAL(20,2) NOT NULL COMMENT '订单总价格',
	`name` VARCHAR(20) NOT NULL COMMENT '客户姓名' COLLATE 'utf8_general_ci',
	`mobile` CHAR(11) NOT NULL COMMENT '手机号' COLLATE 'utf8_general_ci',
	`title` VARCHAR(255) NOT NULL COMMENT '产品名称' COLLATE 'utf8_general_ci',
	`picture` VARCHAR(255) NOT NULL COMMENT '产品图片' COLLATE 'utf8_general_ci',
	`status` TINYINT(3) NOT NULL DEFAULT '0' COMMENT '订单状态，-1:已取消；0:待付款；1:已付订金/定金/首付款；2:已付全款；3:已付尾款；4:线下未支付；5:线下已支付；6:退款中；7:已退款；8:拒绝退款；16:已完成；',
	`pay_type` TINYINT(3) NOT NULL DEFAULT '0' COMMENT '支付方式，0:在线支付，1:线下支付，2:订金支付，3:定金支付，4:首款支付；5:追加/尾款支付；【注：订单生成后不应该再修改此项的值】',
	`paid_at` TIMESTAMP NULL DEFAULT NULL COMMENT '付款时间',
	`verify_code` CHAR(13) NOT NULL DEFAULT '' COMMENT '核销码' COLLATE 'utf8_general_ci',
	`timeout` TIMESTAMP NULL DEFAULT NULL COMMENT '订单超时时间，超过这个时间，订单将变为“已取消”',
	`created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
	`updated_at` TIMESTAMP NULL DEFAULT NULL,
	`deleted_at` TIMESTAMP NULL DEFAULT NULL,
	PRIMARY KEY (`id`) USING BTREE,
	UNIQUE INDEX `order_no` (`order_no`) USING BTREE,
	INDEX `agent_id` (`agent_id`) USING BTREE,
	INDEX `mobile` (`mobile`) USING BTREE,
	INDEX `user_id` (`supplier_id`) USING BTREE
)
COMMENT='行业产品订单表'
COLLATE='utf8_general_ci'
ENGINE=InnoDB;

CREATE TABLE `industry_products` (
	`id` INT(10) NOT NULL AUTO_INCREMENT,
	`supplier_id` INT(10) NOT NULL COMMENT '供应商ID',
	`category_id` INT(10) NOT NULL COMMENT '分类ID',
	`type` TINYINT(3) NOT NULL DEFAULT '0' COMMENT '0:旅游线路、1:酒店、2:景区、3:餐厅、4:车队、5:单项',
	`title` VARCHAR(255) NOT NULL COMMENT '标题' COLLATE 'utf8_general_ci',
	`price` DECIMAL(20,2) NOT NULL COMMENT '售价',
	`original_price` DECIMAL(20,2) NOT NULL DEFAULT '0.00' COMMENT '原价',
	`pictures` TEXT NOT NULL COMMENT '产品图片，可能有多张，JSON格式' COLLATE 'utf8_general_ci',
	`stock` INT(10) NOT NULL DEFAULT '0' COMMENT '库存量',
	`sale` INT(10) NOT NULL DEFAULT '0' COMMENT '销量',
	`status` TINYINT(3) NOT NULL DEFAULT '0' COMMENT '-2:下架，-1:审核拒绝，0:未审核，1:上架',
	`know` TEXT NULL DEFAULT NULL COMMENT '旅客须知' COLLATE 'utf8_general_ci',
	`content` MEDIUMTEXT NULL DEFAULT NULL COMMENT '产品详情' COLLATE 'utf8_general_ci',
	`service_persons` INT(10) NOT NULL DEFAULT '1' COMMENT '单库存服务用户数',
	`min_sale` INT(10) NOT NULL DEFAULT '0' COMMENT '起售数',
	`verify_mobile` VARCHAR(15) NOT NULL DEFAULT '' COMMENT '核销人员手机号' COLLATE 'utf8mb4_unicode_ci',
	`extends` JSON NULL DEFAULT NULL,
	`created_at` TIMESTAMP NULL DEFAULT NULL,
	`updated_at` TIMESTAMP NULL DEFAULT NULL,
	`deleted_at` TIMESTAMP NULL DEFAULT NULL,
	PRIMARY KEY (`id`) USING BTREE,
	INDEX `supplier_id` (`supplier_id`) USING BTREE
)
COMMENT='行业产品表'
COLLATE='utf8_general_ci'
ENGINE=InnoDB;

# 13:28 2021/9/18
ALTER TABLE `industry_orders`
	ADD COLUMN `deposit` DECIMAL(20,2) NOT NULL DEFAULT 0 COMMENT '需要扣除的交易金数量' AFTER `verify_code`;

# 15:59 2021/9/18 修改注释
ALTER TABLE `agent_products`
	CHANGE COLUMN `guide_id` `guide_id` INT(10) NOT NULL DEFAULT '0' COMMENT '绑定地接（计调版旅行社才能绑定）' AFTER `category_id`,
	CHANGE COLUMN `type` `type` TINYINT(3) NOT NULL DEFAULT '0' COMMENT '0:单品销售；1:组合销售；2:计调旅行社的云产品；' AFTER `is_rec`,
	CHANGE COLUMN `is_cloud` `is_cloud` TINYINT(3) NOT NULL DEFAULT '0' COMMENT '是否是（计调旅行社特有）云产品，。0:否；1:是；' AFTER `earnest_timeout`,
	CHANGE COLUMN `agent_cloud_pid` `agent_cloud_pid` INT(10) NOT NULL DEFAULT '0' COMMENT '计调版旅行社的云产品ID' AFTER `is_cloud`;
ALTER TABLE `orders`
	CHANGE COLUMN `agent_cloud_pid` `agent_cloud_pid` INT(10) NOT NULL DEFAULT '0' COMMENT '计调云产品ID' AFTER `verify_code`,
	CHANGE COLUMN `agent_cloud_price` `agent_cloud_price` DECIMAL(20,2) NOT NULL DEFAULT '0.00' COMMENT '计调云产品销售价格' AFTER `agent_cloud_pid`;



# 11:33 2021/9/22
ALTER TABLE `products`
	CHANGE COLUMN `status` `status` TINYINT(3) NOT NULL DEFAULT '0' COMMENT '-2:下架，-1:审核拒绝，0:未审核，1:上架' AFTER `sale`;

# 12:00 2021/9/22
ALTER TABLE `orders`
	ADD COLUMN `info` JSON NULL DEFAULT NULL COMMENT '订单信息' AFTER `single_price`;

# 16:09 2021/9/22
ALTER TABLE `order_product_items`
	ADD COLUMN `product_spec_id` INT NOT NULL DEFAULT 0 COMMENT '产品规格ID' AFTER `price`;

CREATE TABLE `product_specs` (
	`id` INT(10) NOT NULL AUTO_INCREMENT,
	`product_id` INT(10) NOT NULL COMMENT '所属供应商产品ID',
	`name` VARCHAR(255) NOT NULL COMMENT '规格名称' COLLATE 'utf8_general_ci',
	`stock` INT(10) NOT NULL COMMENT '库存',
	`price` DECIMAL(20,2) NOT NULL COMMENT '价格',
	PRIMARY KEY (`id`) USING BTREE,
	INDEX `product_id` (`product_id`) USING BTREE
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB;



# 13:00 2021/9/23
ALTER TABLE `product_specs`
	ADD COLUMN `original_price` DECIMAL(20,2) NOT NULL COMMENT '原价' AFTER `stock`,
	CHANGE COLUMN `price` `price` DECIMAL(20,2) NOT NULL COMMENT '售价' AFTER `original_price`;

# 9:25 2021/9/24
ALTER TABLE `product_specs`
	CHANGE COLUMN `id` `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT FIRST,
	ADD COLUMN `date` DATE NULL COMMENT '日期' AFTER `name`,
	CHANGE COLUMN `original_price` `original_price` DECIMAL(20,2) NOT NULL DEFAULT 0 COMMENT '原价' AFTER `stock`;
UPDATE `product_specs` SET `date` = NOW();
ALTER TABLE `product_specs`
	CHANGE COLUMN `date` `date` DATE NOT NULL COMMENT '日期' AFTER `name`;



# 10:39 2021/9/26
ALTER TABLE `agent_product_specs`
	DROP COLUMN `name`,
	DROP COLUMN `date`;
ALTER TABLE `product_specs`
	ADD COLUMN `deleted_at` TIMESTAMP NULL DEFAULT NULL AFTER `price`;
ALTER TABLE `agent_product_specs`
	ADD COLUMN `deleted_at` TIMESTAMP NULL DEFAULT NULL AFTER `price`;

ALTER TABLE `order_product_items`
	ADD COLUMN `agent_product_spec_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '代理商产品规格ID' AFTER `price`,
	ADD COLUMN `product_type` TINYINT NOT NULL DEFAULT 0 COMMENT '供应商产品的type' AFTER `agent_product_spec_id`,
	CHANGE COLUMN `product_spec_id` `product_spec_id` BIGINT NOT NULL DEFAULT 0 COMMENT '供应商产品规格ID' AFTER `product_type`;

# 17:03 2021/9/26
ALTER TABLE `order_product_items`
	CHANGE COLUMN `agent_product_spec_id` `agent_product_spec_id` JSON NOT NULL COMMENT '代理商产品规格ID' AFTER `price`,
	CHANGE COLUMN `product_spec_id` `product_spec_id` JSON NOT NULL COMMENT '供应商产品规格ID' AFTER `product_type`;

# 17:55 2021/9/26
ALTER TABLE `mini_program_drafts`
	ADD COLUMN `category_list` JSON NULL AFTER `developer`;
