# 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 DEFAULT NULL AFTER `developer`;
ALTER TABLE `mini_program_templates`
	ADD COLUMN `category_list` JSON NULL DEFAULT NULL AFTER `developer`,
	ADD COLUMN `audit_scene` INT NOT NULL DEFAULT 0 AFTER `category_list`,
	ADD COLUMN `audit_status` INT NOT NULL DEFAULT 0 AFTER `audit_scene`;


# 11:15 2021/9/27
ALTER TABLE `mini_program_upload_logs`
	ADD COLUMN `to_user_name` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '小程序的原始 ID' AFTER `id`;



# 15:25 2021/9/27
ALTER TABLE `agent_product_specs`
	DROP INDEX `product_id`,
	ADD INDEX `agent_product_id_deleted_at` (`agent_product_id`, `deleted_at`);
ALTER TABLE `product_specs`
	DROP INDEX `product_id`,
	ADD INDEX `product_id_deleted_at` (`product_id`, `deleted_at`);

# 17:36 2021/9/27
ALTER TABLE `products`
	ADD COLUMN `diy_form_id` INT NOT NULL DEFAULT 0 COMMENT '信息收集表单ID' AFTER `extends`;

# 19:03 2021/9/27
CREATE TABLE `diy_forms` (
	`id` INT(10) NOT NULL AUTO_INCREMENT,
	`supplier_id` INT(10) NOT NULL COMMENT '供应商ID',
	`name` VARCHAR(255) NOT NULL COMMENT '表单名' COLLATE 'utf8_general_ci',
	`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;

CREATE TABLE `diy_form_fields` (
	`id` INT(10) NOT NULL AUTO_INCREMENT,
	`diy_form_id` INT(10) NOT NULL COMMENT '所属表单ID',
	`field` VARCHAR(50) NOT NULL COMMENT '字段名' COLLATE 'utf8_general_ci',
	`type` VARCHAR(50) NOT NULL COMMENT '字段类型，有text，textarea，select，checkbox，image等类型' COLLATE 'utf8_general_ci',
	`options` JSON NULL DEFAULT NULL COMMENT '选项值，当为select和checkbox时用到',
	`required` TINYINT(3) NOT NULL DEFAULT '0' COMMENT '是否必填',
	`sort` SMALLINT(5) NOT NULL DEFAULT '255' COMMENT '排序，越小越靠前',
	PRIMARY KEY (`id`) USING BTREE,
	INDEX `diy_form_id` (`diy_form_id`) USING BTREE
)
COMMENT='自定义表单字段'
COLLATE='utf8_general_ci'
ENGINE=InnoDB;

# 15:24 2021/10/9
ALTER TABLE `categories`
	DROP COLUMN `template`;



# 11:10 2021/10/11
ALTER TABLE `product_specs`
	CHANGE COLUMN `original_price` `original_price` DECIMAL(20,2) NOT NULL DEFAULT 0 COMMENT '市场价' AFTER `stock`,
	CHANGE COLUMN `price` `price` DECIMAL(20,2) NOT NULL COMMENT '销售价' AFTER `original_price`,
	ADD COLUMN `cost_price` DECIMAL(20,2) NOT NULL DEFAULT 0 COMMENT '成本价' AFTER `price`;

# 11:11 2021/10/11 修改注释
ALTER TABLE `products`
	CHANGE COLUMN `price` `price` DECIMAL(20,2) NOT NULL COMMENT '销售价' AFTER `title`,
	CHANGE COLUMN `original_price` `original_price` DECIMAL(20,2) NOT NULL DEFAULT '0.00' COMMENT '市场价' AFTER `price`;
ALTER TABLE `agent_products`
	CHANGE COLUMN `price` `price` DECIMAL(20,2) NOT NULL COMMENT '销售价' AFTER `product_ids`,
	CHANGE COLUMN `original_price` `original_price` DECIMAL(20,2) NOT NULL DEFAULT '0.00' COMMENT '市场价' AFTER `price`;

# 11:52 2021/10/11
ALTER TABLE `agents`
	CHANGE COLUMN `license_pic` `business_license` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '营业执照' COLLATE 'utf8_general_ci' AFTER `address`;
ALTER TABLE `suppliers`
	CHANGE COLUMN `license_pic` `business_license` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '营业执照' COLLATE 'utf8_general_ci' AFTER `address`,
	ADD COLUMN `license` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '许可证' AFTER `business_license`,
	ADD COLUMN `credit_codes` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '统一社会信用代码' COLLATE 'utf8_general_ci' AFTER `license`,
	ADD COLUMN `corporate_account` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '对公账号' AFTER `credit_codes`,
	ADD COLUMN `deposit_bank` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '开户行' AFTER `corporate_account`,
	ADD COLUMN `contract` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '入驻合同' AFTER `deposit_bank`;



# 17:35 2021/10/11
ALTER TABLE `industry_products`
	ADD COLUMN `single_deposit` DECIMAL(20,2) NOT NULL DEFAULT 0 COMMENT '交易金单价' AFTER `content`,
	DROP COLUMN `service_persons`;



# 11:03 ‎2021/‎10/‎15
ALTER TABLE `industry_products`
	CHANGE COLUMN `extends` `extends` JSON NULL DEFAULT NULL COMMENT '扩展字段，根据type不同，字段名不同' AFTER `verify_mobile`,
	ADD COLUMN `diy_form_id` INT NOT NULL DEFAULT 0 COMMENT '信息收集表单ID' AFTER `extends`;

CREATE TABLE `industry_product_specs` (
	`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
	`industry_product_id` INT(10) NOT NULL COMMENT '所属供应商行业产品ID',
	`name` VARCHAR(255) NOT NULL COMMENT '规格名称' COLLATE 'utf8_general_ci',
	`date` DATE NOT NULL COMMENT '日期',
	`stock` INT(10) NOT NULL COMMENT '库存',
	`original_price` DECIMAL(20,2) NOT NULL DEFAULT '0.00' COMMENT '市场价',
	`price` DECIMAL(20,2) NOT NULL COMMENT '销售价',
	`deleted_at` TIMESTAMP NULL DEFAULT NULL,
	PRIMARY KEY (`id`) USING BTREE,
	INDEX `industry_product_id_deleted_at` (`industry_product_id`, `deleted_at`) USING BTREE
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB
ROW_FORMAT=DYNAMIC
;

# 12:47 ‎2021/‎10/‎15
ALTER TABLE `industry_orders`
	ADD COLUMN `industry_product_spec_id` BIGINT UNSIGNED NOT NULL COMMENT '行业产品规格ID' AFTER `industry_product_id`;

# 16:43 ‎2021/‎10/‎15
ALTER TABLE `products`
	ADD COLUMN `single_deposit` DECIMAL(20,2) NOT NULL DEFAULT '0.00' COMMENT '交易金单价' AFTER `content`,
	DROP COLUMN `service_persons`;

# 10:12 ‎2021/‎10/‎16
ALTER TABLE `order_product_items`
	CHANGE COLUMN `service_persons` `single_deposit` DECIMAL(20,2) NOT NULL DEFAULT 0 COMMENT '交易金单价' AFTER `deleted_at`;

# 10:30 ‎2021/‎10/‎16
ALTER TABLE `suppliers`
	ADD COLUMN `trade_balance` DECIMAL(20,2) NOT NULL DEFAULT '0.00' COMMENT '交易金' AFTER `balance`,
	DROP COLUMN `deposit_used`,
	DROP COLUMN `deposit_frozen`,
	DROP COLUMN `deposit_normal`;
ALTER TABLE `industry_orders`
	CHANGE COLUMN `deposit` `trade_deposit` DECIMAL(20,2) NOT NULL DEFAULT '0.00' COMMENT '需要扣除的交易金' AFTER `verify_code`;



# 19:48 ‎2021/‎10/‎16
ALTER TABLE `industry_products`
	ADD COLUMN `deposit` DECIMAL(20,2) NOT NULL DEFAULT '0.00' COMMENT '订金' AFTER `diy_form_id`,
	ADD COLUMN `earnest` DECIMAL(20,2) NOT NULL DEFAULT '0.00' COMMENT '定金' AFTER `deposit`;



# 14:40 ‎2021/‎10/‎17
ALTER TABLE `user_money_logs`
	CHANGE COLUMN `desc` `desc` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '描述' COLLATE 'utf8mb4_general_ci' AFTER `type`;

# 15:04 ‎2021/‎10/‎17
ALTER TABLE `industry_orders`
	ADD COLUMN `paid_money` DECIMAL(20,2) NOT NULL DEFAULT '0.00' COMMENT '已付款金额' AFTER `pay_type`,
	ADD COLUMN `prepay_price` DECIMAL(8,2) NOT NULL DEFAULT '0.00' COMMENT '下单时产品的订金/定金' AFTER `deleted_at`,
	ADD COLUMN `prepay_timeout` INT(11) NOT NULL DEFAULT '0' COMMENT '订金/定金支付超时时间，单位：分钟' AFTER `prepay_price`,
	ADD COLUMN `single_price` DECIMAL(8,2) NOT NULL DEFAULT '0.00' COMMENT '下单时的单人头交易费' AFTER `prepay_timeout`,
	ADD COLUMN `info` JSON NULL DEFAULT NULL COMMENT '客户信息收集' AFTER `single_price`;


# 17:46 ‎2021/‎10/‎17
ALTER TABLE `products`
	ADD COLUMN `logitude` DECIMAL(20,14) NOT NULL DEFAULT 0 COMMENT '经度' AFTER `diy_form_id`,
	ADD COLUMN `latitude` DECIMAL(20,14) NOT NULL DEFAULT 0 COMMENT '纬度' AFTER `logitude`,
	ADD COLUMN `address` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '地址' AFTER `latitude`;



# 10:43 ‎2021/‎10/‎18
ALTER TABLE `industry_orders`
	CHANGE COLUMN `trade_deposit` `trade_deposit` DECIMAL(20,2) NOT NULL DEFAULT '0.00' COMMENT '需要扣除的交易金' AFTER `prepay_timeout`;

# 15:15 ‎2021/‎10/‎18
ALTER TABLE `agent_product_specs`
	CHANGE COLUMN `product_spec_id` `product_spec_id` BIGINT(19) UNSIGNED NOT NULL COMMENT '供应商产品规格ID' AFTER `agent_product_id`;

# 16:20 ‎2021/‎10/‎18
ALTER TABLE `order_product_items`
	CHANGE COLUMN `price` `price` DECIMAL(20,2) NOT NULL COMMENT '供应商成本价（成本单价*数量）' AFTER `num`;

# 11:53 ‎2021/‎10/‎19
CREATE TABLE `settled_orders` (
	`id` INT(11) NOT NULL AUTO_INCREMENT,
	`order_no` CHAR(22) NOT NULL COMMENT '订单号' COLLATE 'utf8_general_ci',
	`username` VARCHAR(120) NOT NULL COMMENT '用户名' COLLATE 'utf8_general_ci',
	`user_type` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '用户类型，1供应商，2代理商，3地接',
	`transaction_id` VARCHAR(32) NOT NULL DEFAULT '' COMMENT '微信支付订单号' COLLATE 'utf8mb4_general_ci',
	`money` DECIMAL(20,2) NOT NULL DEFAULT '0.00' COMMENT '应付入驻费',
	`paid_money` DECIMAL(20,2) NOT NULL DEFAULT '0.00' COMMENT '实际支付费用（微信回调后存入）',
	`paid_at` TIMESTAMP NULL DEFAULT NULL COMMENT '支付时间',
	`status` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '状态，0未支付，1已支付',
	`created_at` TIMESTAMP NULL DEFAULT NULL,
	`updated_at` TIMESTAMP NULL DEFAULT NULL,
	PRIMARY KEY (`id`) USING BTREE,
	UNIQUE INDEX `username_user_type` (`username`, `user_type`) USING BTREE,
	UNIQUE INDEX `order_no` (`order_no`) USING BTREE
)
COMMENT='商家入驻支付记录'
COLLATE='utf8_general_ci'
ENGINE=InnoDB;



# 11:21 ‎2021/‎10/‎20 修改DECIMAL长度
ALTER TABLE `statement`
	CHANGE COLUMN `price` `price` DECIMAL(20,2) NOT NULL DEFAULT '0.00' COMMENT '金额' AFTER `id`;



# 0:22 ‎2021/‎10/‎22 修改长度
ALTER TABLE `suppliers`
	CHANGE COLUMN `license` `license` VARCHAR(1024) NOT NULL DEFAULT '' COMMENT '许可证' COLLATE 'utf8mb4_general_ci' AFTER `business_license`;

# 0:35 ‎2021/‎10/‎22 代理商增加字段
ALTER TABLE `agents`
	ADD COLUMN `license` VARCHAR(1024) NOT NULL DEFAULT '' COMMENT '许可证' COLLATE 'utf8mb4_general_ci' AFTER `business_license`,
	ADD COLUMN `corporate_account` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '对公账号' COLLATE 'utf8mb4_general_ci' AFTER `license`,
	ADD COLUMN `deposit_bank` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '开户行' COLLATE 'utf8mb4_general_ci' AFTER `corporate_account`,
	ADD COLUMN `contract` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '入驻合同' COLLATE 'utf8mb4_general_ci' AFTER `deposit_bank`;

# 12:25 ‎2021/‎10/‎22 增加字段
ALTER TABLE `guides`
	ADD COLUMN `company_name` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '公司名称' COLLATE 'utf8mb4_general_ci' AFTER `remember_token`,
	ADD COLUMN `address` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '公司地址' COLLATE 'utf8mb4_general_ci' AFTER `company_name`,
	ADD COLUMN `business_license` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '营业执照' COLLATE 'utf8_general_ci' AFTER `photo`,
	ADD COLUMN `license` VARCHAR(1024) NOT NULL DEFAULT '' COMMENT '许可证' COLLATE 'utf8mb4_general_ci' AFTER `business_license`,
	ADD COLUMN `credit_codes` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '统一社会信用代码' COLLATE 'utf8_general_ci' AFTER `license`,
	ADD COLUMN `corporate_account` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '对公账号' COLLATE 'utf8mb4_general_ci' AFTER `credit_codes`,
	ADD COLUMN `deposit_bank` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '开户行' COLLATE 'utf8mb4_general_ci' AFTER `corporate_account`,
	ADD COLUMN `contract` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '入驻合同' COLLATE 'utf8mb4_general_ci' AFTER `deposit_bank`,
	ADD COLUMN `director` VARCHAR(20) NOT NULL DEFAULT '' COMMENT '负责人' COLLATE 'utf8mb4_general_ci' AFTER `contract`,
	DROP COLUMN `license_pic`;



# 21:06 ‎2021/‎10/‎25
ALTER TABLE `orders`
	CHANGE COLUMN `price` `price` DECIMAL(20,2) NOT NULL COMMENT '订单总价（单价*数量）' AFTER `num`;



# 10:31 ‎2021/‎10/‎26
ALTER TABLE `industry_orders`
	ADD COLUMN `audit_status` TINYINT NOT NULL DEFAULT 0 COMMENT '审核状态，-1拒绝，0待审核，1通过' AFTER `info`,
	ADD COLUMN `audit_opinion` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '审核不通过原因' AFTER `audit_status`;



# 23:45 ‎2021/‎10/‎28
ALTER TABLE `products`
	CHANGE COLUMN `logitude` `longitude` DECIMAL(20,14) NOT NULL DEFAULT '0.00000000000000' COMMENT '经度' AFTER `diy_form_id`;
ALTER TABLE `collect_products`
	CHANGE COLUMN `logitude` `longitude` DECIMAL(20,14) NOT NULL DEFAULT '0.00000000000000' COMMENT '经度' AFTER `diy_form_id`;

ALTER ALGORITHM = UNDEFINED SQL SECURITY DEFINER VIEW `view_agent_products` AS select `agent_products`.`id` AS `id`,`agent_products`.`agent_id` AS `agent_id`,`agent_products`.`product_id` AS `product_id`,`agent_products`.`product_ids` AS `product_ids`,`agent_products`.`price` AS `price`,`agent_products`.`original_price` AS `original_price`,`agent_products`.`sale` AS `sale`,`agent_products`.`stock` AS `stock`,`agent_products`.`channel_id` AS `channel_id`,`agent_products`.`category_id` AS `category_id`,`agent_products`.`guide_id` AS `guide_id`,`agent_products`.`guide_price` AS `guide_price`,`agent_products`.`status` AS `status`,`agent_products`.`verifier` AS `verifier`,`agent_products`.`is_rec` AS `is_rec`,`agent_products`.`type` AS `type`,`agent_products`.`title` AS `title`,`agent_products`.`pictures` AS `pictures`,`agent_products`.`know` AS `know`,`agent_products`.`content` AS `content`,`agent_products`.`deposit` AS `deposit`,`agent_products`.`deposit_timeout` AS `deposit_timeout`,`agent_products`.`earnest` AS `earnest`,`agent_products`.`earnest_timeout` AS `earnest_timeout`,`agent_products`.`is_cloud` AS `is_cloud`,`agent_products`.`agent_cloud_pid` AS `agent_cloud_pid`,`agent_products`.`created_at` AS `created_at`,`agent_products`.`updated_at` AS `updated_at`,`agent_products`.`deleted_at` AS `deleted_at`,`products`.`latitude` AS `latitude`,`products`.`longitude` AS `longitude`,`products`.`address` AS `address` from (`agent_products` join `products` on((`agent_products`.`product_id` = `products`.`id`))) ;





# 14:45 ‎2021/‎10/‎29
ALTER TABLE `diy_forms`
	CHANGE COLUMN `supplier_id` `merchant_id` INT(10) NOT NULL COMMENT '供应商ID或代理ID' AFTER `id`,
	ADD COLUMN `type` TINYINT NOT NULL DEFAULT 1 COMMENT '1供应商，2代理商' AFTER `merchant_id`,
	DROP INDEX `supplier_id`,
	ADD INDEX `merchant_id_type` (`merchant_id`, `type`);
UPDATE `hainan`.`diy_forms` SET `type`=1;

ALTER TABLE `agent_products`
	CHANGE COLUMN `type` `type` TINYINT(3) NOT NULL DEFAULT '0' COMMENT '0:单品销售；1:组合销售；2:计调旅行社的云产品；3:代理商自有产品；' AFTER `is_rec`;

# 0:46 ‎2021/‎10/‎30
ALTER TABLE `agent_product_specs`
	ADD COLUMN `name` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '规格名称（代理商发布自营产品时才有效）' COLLATE 'utf8_general_ci' AFTER `product_spec_id`,
	ADD COLUMN `date` DATE NULL DEFAULT NULL COMMENT '日期（代理商发布自营产品时才有效）' AFTER `name`;

# 0:36 ‎2021/‎10/‎31
ALTER TABLE `agent_products`
	ADD COLUMN `diy_form_id` INT NOT NULL DEFAULT 0 COMMENT '信息收集表单ID' AFTER `type`,
	ADD COLUMN `tpl_type` TINYINT NOT NULL DEFAULT 0 COMMENT '0:旅游线路、1:酒店、2:景区、3:餐厅、4:车队、5:单项' AFTER `agent_cloud_pid`,
	ADD COLUMN `extends` JSON NULL DEFAULT NULL COMMENT '扩展字段，根据tpl_type不同，字段名不同' AFTER `tpl_type`,
	ADD COLUMN `longitude` DECIMAL(20,14) NOT NULL DEFAULT '0.00000000000000' COMMENT '经度' AFTER `extends`,
	ADD COLUMN `latitude` DECIMAL(20,14) NOT NULL DEFAULT '0.00000000000000' COMMENT '纬度' AFTER `longitude`,
	ADD COLUMN `address` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '地址' COLLATE 'utf8mb4_general_ci' AFTER `latitude`;




