CREATE TABLE xhItem(
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`name` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '花材名称',
unitNum tinyint not null default 0 comment '每扎多少支',
unitWeight decimal(9,2) NOT NULL DEFAULT '0.00' COMMENT '每扎多少公斤',
unitCost decimal(9,2) NOT NULL DEFAULT '0.00' COMMENT '每扎成本价，采购价',
unitAddPrice decimal(9,2) NOT NULL DEFAULT '0.00' COMMENT '每扎加价',
unit int not null default 0 comment '单位名称ID',
addTime int not null default 0 comment '添加时间',
updateTime int not null default 0 comment '修改时间'
)comment='花材，资材';

create table if not exists xhItemClass(
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`name` varchar(50) not null default '' comment '名称',
inTurn int not null default 0 comment '排序，越大越靠前',
addTime int not null default 0 comment '添加时间',
updateTime int not null default 0 comment '修改时间'
)comment='花材分类';

CREATE TABLE xhUnit(
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`name` VARCHAR(10) NOT NULL DEFAULT '' COMMENT '单位名称',
addTime int not null default 0 comment '添加时间',
updateTime int not null default 0 comment '修改时间'
)COMMENT='花材单位';

create table xhMerchantItemClass(
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
merchantId int not null default 0 comment '商家id',
`name` varchar(50) not null default '' comment '名称',
inTurn int not null default 0 comment '排序，越大越靠前',
addTime int not null default 0 comment '添加时间',
updateTime int not null default 0 comment '修改时间'
)comment='商家花材分类';
create table xhMerchantItem(
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
merchantId int not null default 0 comment '商家id',
classId int not null default 0 comment '商家花材分类id',
itemId int not null default 0 comment '花材id',
unitCost decimal(9,2) NOT NULL DEFAULT '0.00' COMMENT '每扎成本价，采购价',
unitAddPrice decimal(9,2) NOT NULL DEFAULT '0.00' COMMENT '每扎加价',
addTime int not null default 0 comment '添加时间',
updateTime int not null default 0 comment '修改时间'
)comment='商家花材';

CREATE TABLE `xhGhsOrder` (
  `id` int(11) NOT NULL AUTO_INCREMENT primary key COMMENT '自增id',
  `orderSn` char(40) NOT NULL DEFAULT '' COMMENT '订单编号',
  `goodsNum` tinyint(4) NOT NULL DEFAULT '0' COMMENT '商品数量',
  `payWay` tinyint(4) NOT NULL DEFAULT '0' COMMENT '支付方式 0微信 1支付宝 2余额',
  `wxPayType` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0 H5支付 1 小程序支付',
  `payCode` varchar(1000) NOT NULL DEFAULT '' COMMENT '支付返回号',
  `fromType` tinyint(4) NOT NULL DEFAULT '0' COMMENT '来源：0门店 1商城 2朋友圈',
  `store` tinyint(4) NOT NULL DEFAULT '0' COMMENT '门店订单 0不是 1是',
  `capitalId` int(11) NOT NULL DEFAULT '0' COMMENT '流水id',
  `prePrice` decimal(9,2) NOT NULL DEFAULT '0.00' COMMENT '应付款，原价，未修改价格，打折前',
  `actPrice` decimal(9,2) NOT NULL DEFAULT '0.00' COMMENT '实际付款，实价，修改后价格，打折后',
  `userId` int(11) NOT NULL DEFAULT '0' COMMENT '用户id',
  `merchantId` int(11) NOT NULL DEFAULT '0' COMMENT '商户id',
  `shopId` int(11) NOT NULL DEFAULT '0' COMMENT '门店id',
  `sendType` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0未确认配送方式 1免配送 2自己送 3别人送；快递送',
  `sendSide` tinyint(4) NOT NULL DEFAULT '0' COMMENT '配送方 0没有 1达达',
  `sendStatus` tinyint(4) NOT NULL DEFAULT '0' COMMENT '配送状态：0未发货，待接单 1已发货，已接单 2已送达',
  `refund` tinyint(4) NOT NULL DEFAULT '0' COMMENT '1已退款 0正常订单',
  `payStatus` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0待付款 1已付款',
  `printStatus` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0未打印 1已打印',
  `remark` varchar(1000) NOT NULL DEFAULT '' COMMENT '备注',
  `status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '订单状态 0待付款 1待配送 2配送中 3待通知 4已取消 5已完成',
  `deadline` int(11) NOT NULL DEFAULT '0' COMMENT '订单有效期',
  `payTime` int(11) NOT NULL DEFAULT '0' COMMENT '付款时间',
  addTime int not null default 0 comment '添加时间',
  `updateTime` int not null default 0 comment '修改时间'
) COMMENT='供货商订单';
create table xhGhsOrderItem(
`id` int(11) unsigned NOT NULL AUTO_INCREMENT primary key COMMENT 'id',
`orderId` int(11) NOT NULL DEFAULT '0' COMMENT '订单id',
`userId` int(11) NOT NULL DEFAULT '0' COMMENT '用户id',
`merchantId` int(11) NOT NULL DEFAULT '0' COMMENT '商户id',
itemId int not null default 0 comment '商家花材id',
`unitPrice` decimal(9,2) NOT NULL DEFAULT '0.00' COMMENT '每扎价格',
unitNum int not null default 0 comment '每扎多少支',
`num` decimal(9,2) NOT NULL DEFAULT '0.00' COMMENT '多少扎'
)comment='供货商订单商品';

ALTER TABLE xhItem ADD cover VARCHAR(500) NOT NULL DEFAULT '' COMMENT '封面图片' AFTER `name`;

ALTER TABLE xhMerchantAccount RENAME TO xhMerchantApply


== shish 2021-1-3

DROP TABLE IF EXISTS `xhItemRank`;
CREATE TABLE IF NOT EXISTS `xhItemRank` (
  `id` INT(11) NOT NULL AUTO_INCREMENT,
  `itemId` INT NOT NULL DEFAULT 0 COMMENT '花材id',
  `rank` CHAR(5) NOT NULL DEFAULT 'A' COMMENT '等级 A B C D E',
  `unitCost` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '每扎成本价，采购价',
  `unitAddPrice` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '每扎加价',
  `addTime` INT(11) NOT NULL DEFAULT '0' COMMENT '添加时间',
  `updateTime` INT(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
  PRIMARY KEY (`id`)
) COMMENT='花材等级价格';
ALTER TABLE xhMerchantItem ADD rank CHAR(5) NOT NULL DEFAULT 'A' COMMENT '花材级别' AFTER `itemId`;
ALTER TABLE xhGhsOrderItem ADD rank CHAR(5) NOT NULL DEFAULT 'A' COMMENT '花材级别' AFTER `itemId`;
ALTER TABLE xhItemRank RENAME TO xhMerchantItemRank;
alter table xhMerchantItemRank add merchantId int not null default 0 comment '' after `id`;
ALTER TABLE xhAdmin ADD identity TINYINT NOT NULL DEFAULT 0 COMMENT '身份 0未知 1花粉 2花店员工' AFTER `mobile`;
ALTER TABLE xhMerchant ADD `style` TINYINT NOT NULL DEFAULT 0 COMMENT '商家类型 0普通 1零售商使用 2供货商使用' AFTER `id`;

==在开发环境 找到 花美玲 将style设置为1 找到 花掌柜 将style设置为2 如果找不到 则去走流程创建
==在线上环境 找到 花卉宝 将style设置为1 找到 销花宝 将style设置为2 如果找不到 则去走流程创建
===注意 xhWxOpen wxMiniBaseId wxBaseId wxGhsBaseId wxGhsMiniBaseId 相关字段的修改
===注意 BaseId GhsBaseId GhsMiniBaseId 表记录的增加

==shish 20201-1-6

ALTER TABLE xhWxOpen MODIFY wxMiniBaseId INT(11) NOT NULL DEFAULT '0' COMMENT '平台零售商小程序';
ALTER TABLE xhWxOpen MODIFY wx_base_id INT(11) NOT NULL DEFAULT '0' COMMENT '平台零售商公众号';
ALTER TABLE xhWxOpen ADD wxGhsMiniBaseId INT(11) NOT NULL DEFAULT '0' COMMENT '平台供货商小程序' AFTER wx_base_id;
ALTER TABLE xhWxOpen ADD wxGhsBaseId INT(11) NOT NULL DEFAULT '0' COMMENT '平台供货商公众号' AFTER wxGhsMiniBaseId;
DROP TABLE IF EXISTS `xhGhsAdmin`;
CREATE TABLE IF NOT EXISTS `xhGhsAdmin` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `mobile` varchar(15) DEFAULT NULL COMMENT '手机号',
  `identity` tinyint(4) NOT NULL DEFAULT '0' COMMENT '身份 0未知 1花粉 2花店员工',
  `adminName` varchar(50) NOT NULL DEFAULT '' COMMENT '管理员姓名',
  `nickName` varchar(50) NOT NULL DEFAULT '' COMMENT '昵称',
  `avatar` varchar(500) NOT NULL DEFAULT '' COMMENT '头像',
  `password` varchar(500) NOT NULL DEFAULT '' COMMENT '密码',
  `confirmPassword` varchar(500) NOT NULL DEFAULT '' COMMENT '确认密码',
  `sourceType` tinyint(4) NOT NULL DEFAULT '0' COMMENT '来源 0微信 1支付宝 2小程序 3朋友圈 4美团',
  `subscribeTime` int(11) NOT NULL DEFAULT '0' COMMENT '关注时间',
  `hasSubscribe` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否关注过 0没有 1是的',
  `subscribe` tinyint(4) NOT NULL DEFAULT '0' COMMENT '关注平台 0未关注 1关注',
  `unionId` varchar(100) NOT NULL DEFAULT '' COMMENT '微信平台唯一id',
  `miniOpenId` varchar(100) NOT NULL DEFAULT '' COMMENT '小程序openid',
  `openId` varchar(100) NOT NULL DEFAULT '' COMMENT '微信openid',
  `remark` varchar(500) NOT NULL DEFAULT '' COMMENT '员工备注',
  `sex` tinyint(4) NOT NULL DEFAULT '0' COMMENT '性别 0未知 1男性 2女性',
  `super` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否超级管理员 0不是 1是，超级员工不可删除',
  `delStatus` tinyint(4) NOT NULL DEFAULT '0' COMMENT '软删除标识 0未删除 1已删除',
  `accountStatus` tinyint(4) NOT NULL DEFAULT '1' COMMENT '帐号状态 0禁用 1正常',
  `loginTime` int(11) NOT NULL DEFAULT '0' COMMENT '最后登陆时间',
  `addTime` int(11) NOT NULL DEFAULT '0' COMMENT '添加时间',
  PRIMARY KEY (`id`)
)COMMENT='供货商管理员表';
drop table if exists `xhGhsShop`;
CREATE TABLE `xhGhsShop` (
  `id` bigint(11) NOT NULL AUTO_INCREMENT,
  `avatar` varchar(500) NOT NULL DEFAULT '' COMMENT '门店照片；门店头像',
  `shopName` varchar(100) NOT NULL DEFAULT '' COMMENT '门店名称',
  `merchantName` varchar(100) NOT NULL DEFAULT '' COMMENT '商家名称',
  `merchantId` int(11) NOT NULL DEFAULT '0' COMMENT '商户id',
  `lat` varchar(20) NOT NULL DEFAULT '' COMMENT '纬度',
  `long` varchar(20) NOT NULL DEFAULT '' COMMENT '经度',
  `province` varchar(100) NOT NULL DEFAULT '' COMMENT '省',
  `city` varchar(100) NOT NULL DEFAULT '' COMMENT '市',
  `dist` varchar(100) NOT NULL DEFAULT '' COMMENT '区县',
  `address` varchar(500) NOT NULL DEFAULT '' COMMENT '街道地址',
  `floor` varchar(50) NOT NULL DEFAULT '' COMMENT '楼号门牌号',
  `fullAddress` varchar(500) NOT NULL DEFAULT '' COMMENT '完整地址',
  `telephone` varchar(20) NOT NULL DEFAULT '' COMMENT '电话',
  `openTime` varchar(30) NOT NULL DEFAULT '' COMMENT '营业时间',
  `introduction` varchar(800) DEFAULT '' COMMENT '简介',
  `gatheringCode` varchar(500) NOT NULL DEFAULT '' COMMENT '收款的二维码',
  `applyMemberCode` varchar(500) NOT NULL DEFAULT '' COMMENT '注册会员码',
  `totalIncome` decimal(9,2) NOT NULL DEFAULT '0.00' COMMENT '累计收入',
  `default` tinyint(4) NOT NULL DEFAULT '0' COMMENT '默认门店 0不是 1是，默认门店不能删除',
  `delStatus` tinyint(4) NOT NULL DEFAULT '0' COMMENT '删除状态 0没有删除 1已删除',
  `status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '门店状态 0停用 1正常',
  `addTime` int(11) NOT NULL DEFAULT '0' COMMENT '添加时间，时间戳格式',
  `createTime` datetime NOT NULL COMMENT '创建时间',
  `updateTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) comment='供货商门店';
drop table if exists `xhGhsShopAdmin`;
CREATE TABLE if not exists `xhGhsShopAdmin` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `adminId` int(11) NOT NULL DEFAULT '0' COMMENT '管理员id',
  `merchantId` int(11) NOT NULL DEFAULT '0' COMMENT '商家id',
  `shopId` int(11) NOT NULL DEFAULT '0' COMMENT '门店id',
  `remind` tinyint(4) NOT NULL DEFAULT '0' COMMENT '动态提醒 0不需要 1需要',
  `roleId` int(11) NOT NULL DEFAULT '0' COMMENT '角色id',
  `default` tinyint(4) NOT NULL DEFAULT '0' COMMENT '默认管理的门店 1是 0否',
  `delStatus` tinyint(4) NOT NULL DEFAULT '0' COMMENT '删除状态 0正常 1已删除',
  `status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '状态 0停用 1正常',
  `addTime` int(11) NOT NULL DEFAULT '0' COMMENT '添加时间',
  PRIMARY KEY (`id`)
) COMMENT='供货商员工';
ALTER TABLE xhGhsAdmin MODIFY `identity` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '身份 0未知 1花店员工 2供货商员工';
ALTER TABLE xhGhsShop CHANGE createTime `addTime` INT NOT NULL DEFAULT 0 COMMENT '添加时间';
ALTER TABLE xhGhsShop MODIFY updateTime INT NOT NULL DEFAULT 0 COMMENT '修改时间';
ALTER TABLE xhGhsShopAdmin ADD updateTime INT NOT NULL DEFAULT 0 COMMENT '修改时间';
ALTER TABLE xhGhsShop DROP COLUMN `createTime`;
CREATE TABLE IF NOT EXISTS `xhGhsCustom`(
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
ghsId INT NOT NULL DEFAULT 0 COMMENT '供货商id merchantId',
shopId INT NOT NULL DEFAULT 0 COMMENT '零售门店id',
shopName VARCHAR(100) NOT NULL DEFAULT '' COMMENT '门店名称',
`mobile` VARCHAR(15) NOT NULL DEFAULT '0' COMMENT '店长手机号',
isOpen TINYINT NOT NULL DEFAULT 0 COMMENT '是否开店 0没有 1已开',
`addTime` INT NOT NULL DEFAULT 0 COMMENT '添加时间',
`updateTime` INT NOT NULL DEFAULT 0 COMMENT '修改时间'
)COMMENT='供货商客户';

ALTER TABLE xhGhsShop CHANGE `merchantId` ghsId INT NOT NULL DEFAULT 0 COMMENT '供货商id';
ALTER TABLE xhGhsShop CHANGE `merchantName` ghsName VARCHAR(100) NOT NULL DEFAULT '' COMMENT '供货商名称';
ALTER TABLE `xhGhsCustom` ADD debt TINYINT NOT NULL DEFAULT 0 COMMENT '是否允许欠款买花 0不允许 1允许' AFTER `isOpen`;
ALTER TABLE `xhGhsCustom` ADD debtAmount DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '欠款金额' AFTER `debt`;
ALTER TABLE `xhGhsCustom` ADD buyNum INT NOT NULL DEFAULT 0 COMMENT '消费次数' AFTER `debtAmount`;
ALTER TABLE `xhGhsCustom` ADD buyAmount DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '消费总金额' AFTER `buyNum`;
ALTER TABLE xhGhsShopAdmin CHANGE merchantId `ghsId` INT NOT NULL DEFAULT 0 COMMENT '供货商id merchantId';
ALTER TABLE xhApply ADD updateTime INT NOT NULL DEFAULT 0 COMMENT '修改时间' AFTER `addTime`;
ALTER TABLE xhApply ADD `from` TINYINT NOT NULL DEFAULT 0 COMMENT '来源 0花店自己申请 1供货商发起' AFTER `introMerchantId`;

==shish 2021-1-12
ALTER TABLE `xhApply` ADD introStyle TINYINT NOT NULL DEFAULT 0 COMMENT '介绍的商家类型 同 xhMerchant style' AFTER `introMerchantId`;
ALTER TABLE `xhMerchant` MODIFY `style` TINYINT NOT NULL DEFAULT 0 COMMENT '商家类型 0零售 1 供货';
ALTER TABLE `xhMerchant` ADD `property` TINYINT NOT NULL DEFAULT 0 COMMENT '商家属性 0零售 1 供货' AFTER `style`;
ALTER TABLE `xhMerchant` MODIFY `property` TINYINT NOT NULL DEFAULT 0 COMMENT '平台微信取用类型 0普通 1零售商使用 2供货商使用';
ALTER TABLE `xhApply` ADD adminName VARCHAR(100) NOT NULL DEFAULT '' COMMENT '店长姓名' AFTER adminId;
ALTER TABLE `xhApply` MODIFY `mobile` VARCHAR(20) NOT NULL DEFAULT '' COMMENT '店长手机号' AFTER `adminName`;
=======
===linqhai 2021-01-11

ALTER TABLE `xhItem` ADD COLUMN `pyName`  varchar(50) NOT NULL DEFAULT '' COMMENT '花材名称的拼音首字母' AFTER `name`;
ALTER TABLE `xhMerchantItemClass`
ADD COLUMN `adminId`  int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '操作人ID' AFTER `inTurn`,
ADD INDEX `idx_merchantId` (`merchantId`) USING BTREE ;
RENAME  TABLE xhMerchantItemClass to xhGhsItemClass;
RENAME  TABLE xhMerchantItem to xhGhsItem;
RENAME  TABLE xhMerchantItemRank to xhGhsItemRank;

ALTER TABLE `xhGhsItemClass`
CHANGE COLUMN `merchantId` `ghsId`  int(11) NOT NULL DEFAULT 0 COMMENT '商家id' AFTER `id`,
DROP INDEX `idx_merchantId` ,
ADD INDEX `idx_ghsId` (`ghsId`) USING BTREE ;

ALTER TABLE `xhGhsItem`
CHANGE COLUMN `merchantId` `ghsId`  int(11) NOT NULL DEFAULT 0 COMMENT '商家id' AFTER `id`,
ADD INDEX `idx_ghsId` (`ghsId`) USING BTREE ;

ALTER TABLE `xhGhsItem`
ADD INDEX `idx_itemId` (`itemId`) USING BTREE ,
ADD INDEX `idx_classId` (`classId`) USING BTREE ;

CREATE TABLE `xhGhsItemInfo` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `ghsId` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '供货商ID',
  `shopId` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '门店ID',
  `itemId` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '花材ID',
  `stock` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '库存，多少扎,可以出现负库存',
  `rank` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'B' COMMENT '花材等级 A、B、C、D',
  `price` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '每扎的价格(对应等级价格)',
  `actualSold` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '实际销售量',
  `viewNum` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '浏览量',
  `delStatus` tinyint(2) unsigned NOT NULL DEFAULT '0' COMMENT '删除标识 0未删除 1删除',
  `adminId` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '最后操作人',
  `addTime` int(11) NOT NULL DEFAULT '0' COMMENT '添加时间',
  `updateTime` int(11) NOT NULL DEFAULT '0' COMMENT '最后修改时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='供货商的商品表，对应各个门店';


CREATE TABLE `xhGhsCheckOrder` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `ghsId` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '供货商ID',
  `shopId` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '门店ID',
  `orderSn` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '订单号',
  `orderStatus` tinyint(2) unsigned NOT NULL DEFAULT '0' COMMENT '盘点订单状态： 1草稿，2完成',
  `adminId` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '操作人ID',
  `itemNumBundle` int(11) NOT NULL DEFAULT '0' COMMENT '合计多少商品(扎)(盈亏）',
  `itemNumPiece` int(11) NOT NULL DEFAULT '0' COMMENT '合计多少商品(支)(盈亏）',
  `totalItemPrice` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '商品总价格(盈亏）',
  `remark` varchar(1000) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '备注信息',
  `addTime` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
  `updateTime` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '最后修改时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uni_orderNum` (`orderSn`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='盘点订单表';

CREATE TABLE `xhGhsCheckOrderItem` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `orderSn` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '订单号',
  `itemId` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '花材ID',
  `itemNum` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '盘点花材数量',
  `itemStock` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '当时的库存',
  `profitLossNum` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '盈亏数，正数盈，负数亏',
  `itemInfo` text COLLATE utf8mb4_unicode_ci COMMENT '花材信息json{"itemName":"","itemCover":"","itemRank":""}',
  `itemPrice` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '价格',
  PRIMARY KEY (`id`),
  KEY `idx_orderNum` (`orderSn`) USING BTREE,
  KEY `idx_goodsItemId` (`itemId`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='盘点订单详情表';

CREATE TABLE `xhGhsPurchaseOrder` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `ghsId` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '供货商ID',
  `shopId` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '门店ID',
  `orderSn` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '订单号',
  `orderStatus` tinyint(2) NOT NULL DEFAULT '0' COMMENT '订单状态：1待确认，2待配送，3配送中，4已完成',
  `adminId` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '采购人ID',
  `gysId` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '供应商ID',
  `itemNumBundle` int(11) NOT NULL DEFAULT '0' COMMENT '合计多少商品(扎)',
  `itemNumPiece` int(11) DEFAULT NULL COMMENT '合计多少商品(支)',
  `totalGoodsPrice` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '商品总价格',
  `packingCharge` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '打包费',
  `shortHaulCharge` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '短途运费',
  `lineHaulCharge` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '长途运费',
  `pickCharge` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '提货费',
  `localHaulCharge` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '本地运费',
  `orderPrice` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '订单总价',
  `entryTime` int(11) NOT NULL DEFAULT '0' COMMENT '入库时间',
  `addTime` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
  `updateTime` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '最后修改时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uni_orderNum` (`orderSn`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='采购订单表';


CREATE TABLE `xhGhsPurchaseOrderItem` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `orderSn` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '采购订单号',
  `itemId` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '花材ID',
  `itemNum` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '花材数量',
  `itemInfo` text COLLATE utf8mb4_unicode_ci COMMENT '花材信息json{"itemName":"","itemCover":"","itemRank":""}   ',
  `itemPrice` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '采购价',
  PRIMARY KEY (`id`),
  KEY `idx_orderNum` (`orderSn`) USING BTREE,
  KEY `idx_goodsItemId` (`itemId`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='采购订单详情表';

CREATE TABLE `xhGhsSellOrder` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `ghsId` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '供货商ID',
  `shopId` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '门店ID',
  `orderSn` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '订单号',
  `orderStatus` tinyint(2) unsigned NOT NULL DEFAULT '0' COMMENT '订单状态： 1待确认，2下单成功，2出库中，3已完成，4取消下单',
  `distributionMode` tinyint(2) NOT NULL DEFAULT '0' COMMENT '配送方式: 1 门店自取，2本地送，3快递',
  `shipStatus` tinyint(2) NOT NULL DEFAULT '0' COMMENT '订单物流状态：1待确认，2待配送，3发货，4配送中，5配送中-已接单，6配送中-骑手送货中，7配送中-配送完成',
  `shipType` tinyint(2) NOT NULL COMMENT '快递公司: 1达达，2顺丰同城3闪送，4美团',
  `shipSn` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '快递单号',
  `payMethod` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '支付方式： alipay,wxpay,defer(延期)，cash(现金收款)，',
  `payNo` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '支付订单号',
  `payStatus` tinyint(2) unsigned NOT NULL DEFAULT '0' COMMENT '支付状态：1待支付，2支付成功,3支付失败',
  `payTime` int(11) NOT NULL DEFAULT '0' COMMENT '支付时间',
  `adminId` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '采购人ID',
  `retailShopId` int(11) NOT NULL DEFAULT '0' COMMENT '零售门店ID',
  `userId` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '客户D',
  `itemNumBundle` int(11) NOT NULL DEFAULT '0' COMMENT '合计多少商品(扎)',
  `itemNumPiece` int(11) NOT NULL DEFAULT '0' COMMENT '合计多少商品(支)',
  `totalItemPrice` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '商品总价格',
  `orderPrice` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '订单总价',
  `shipPrice` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '运费',
  `address` text COLLATE utf8mb4_unicode_ci COMMENT '收货地址 json',
  `addTime` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
  `updateTime` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '最后修改时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uni_orderNum` (`orderSn`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='销售订单表';


CREATE TABLE `xhGhsSellOrderItem` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `orderSn` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '订单号',
  `itemId` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '花材ID',
  `itemNum` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '花材数量',
  `itemInfo` text COLLATE utf8mb4_unicode_ci COMMENT '花材信息json{"itemName":"","itemCover":"","itemRank":""}',
  `itemPrice` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '价格',
  PRIMARY KEY (`id`),
  KEY `idx_orderNum` (`orderSn`) USING BTREE,
  KEY `idx_goodsItemId` (`itemId`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='销售订单详情表';

CREATE TABLE `xhGhsStockOrder` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `ghsId` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '出库的供货商ID',
  `outShopId` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '出库的门店ID',
  `inShopId` int(11) NOT NULL DEFAULT '0' COMMENT '入库的门店ID',
  `orderSn` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '订单号',
  `orderStatus` tinyint(2) unsigned NOT NULL DEFAULT '0' COMMENT '订单状态： 1待出库，2已出库（待入库） 3已入库, 4取消出库，5取消入库',
  `adminId` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '操作人ID',
  `itemNumBundle` int(11) NOT NULL DEFAULT '0' COMMENT '合计多少商品(扎)',
  `itemNumPiece` int(11) NOT NULL DEFAULT '0' COMMENT '合计多少商品(支)',
  `totalItemPrice` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '商品总价格',
  `remark` varchar(1000) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '备注信息',
  `addTime` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
  `updateTime` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '最后修改时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uni_orderNum` (`orderSn`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='出库入库订单表';

CREATE TABLE `xhGhsStockOrderItem` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `orderSn` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '订单号',
  `itemId` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '花材ID',
  `itemNum` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '出库花材数量',
  `itemStock` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '当时的库存',
  `itemInfo` text COLLATE utf8mb4_unicode_ci COMMENT '花材信息json{"itemName":"","itemCover":"","itemRank":""}',
  `itemPrice` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '价格',
  PRIMARY KEY (`id`),
  KEY `idx_orderNum` (`orderSn`) USING BTREE,
  KEY `idx_goodsItemId` (`itemId`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='出库入库订单详情表';

===员工相关 shish 2021-1-13

CREATE TABLE `xhGhsAdminLog` (
  `id` INT(11) NOT NULL AUTO_INCREMENT,
  `ip` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'ip地址',
  `ghsId` INT(11) NOT NULL DEFAULT '0' COMMENT '商家id',
  `content` VARCHAR(1000) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '操作内容',
  `adminId` INT(11) NOT NULL DEFAULT '0' COMMENT '员工id；管理员id',
  `addTime` INT(11) NOT NULL DEFAULT '0' COMMENT '添加时间',
  PRIMARY KEY (`id`)
) COMMENT='员工操作日志';
CREATE TABLE `xhGhsAdminRole` (
  `id` INT(11) NOT NULL AUTO_INCREMENT,
  `roleName` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '角色名称',
  `ghsId` INT(11) NOT NULL DEFAULT '0' COMMENT '商家id',
  `num` INT(11) NOT NULL DEFAULT '0' COMMENT '成员数',
  `addTime` INT(11) NOT NULL DEFAULT '0' COMMENT '添加时间',
  `delStatus` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '删除状态 0未删除 1已删除',
  `auth` VARCHAR(500) NOT NULL DEFAULT '' COMMENT '权限id列表，存在*表示有所有权限',
  PRIMARY KEY (`id`)
) COMMENT='管理员角色';
CREATE TABLE `xhGhsAdminRoleAuth` (
  `id` INT(11) NOT NULL AUTO_INCREMENT,
  `roleId` INT(11) NOT NULL DEFAULT '0' COMMENT '角色id',
  `endId` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '业务端id',
  `ghsId` INT(11) NOT NULL DEFAULT '0' COMMENT '商家id',
  `auth` VARCHAR(1000) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '权限',
  `addTime` INT(11) NOT NULL DEFAULT '0' COMMENT '添加时间',
  PRIMARY KEY (`id`)
) COMMENT='员工角色权限';
ALTER TABLE `xhWxOpen` CHANGE `wx_mini_base_id` `wxMiniBaseId` INT(11) NOT NULL DEFAULT '0' COMMENT '平台零售商小程序';
ALTER TABLE `xhWxOpen` CHANGE `wx_base_id` `wxBaseId` INT(11) NOT NULL DEFAULT '0' COMMENT '平台零售商公众号';

== 平台 shish 2021-1-13

ALTER TABLE `xhWxBase` ADD `openAppId` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '开放平台帐号' AFTER merchantId;
ALTER TABLE `xhWxMiniBase` ADD `openAppId` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '开放平台帐号' AFTER merchantId;
ALTER TABLE `xhWxBase` DROP COLUMN `merchantId`;
ALTER TABLE `xhWxMiniBase` DROP COLUMN `merchantId`;
=======
== linqh 2021-01-13
ALTER TABLE `xhGhsItem`
ADD COLUMN `unitWeight`  float(10,2) NOT NULL DEFAULT 0 COMMENT '每扎重量(斤)' AFTER `rank`,
ADD COLUMN `stockWarning`  decimal(10,2) NOT NULL DEFAULT 0 COMMENT '库存预警' AFTER `unitWeight`;

========
== shish 2021-1-13 删掉二个表
DROP TABLE IF EXISTS `xhGhsOrder`;
DROP TABLE IF EXISTS `xhGhsOrderItem`;
drop table if exists `xhGhsSellOrder`;
drop table if exists `xhGhsSellOrderItem`;
CREATE TABLE `xhGhsOrder` (
  `id` int(11) NOT NULL AUTO_INCREMENT primary key COMMENT '自增id',
  `orderSn` char(40) NOT NULL DEFAULT '' COMMENT '订单编号',
  `goodsNum` tinyint(4) NOT NULL DEFAULT '0' COMMENT '商品数量',
  `payWay` tinyint(4) NOT NULL DEFAULT '0' COMMENT '支付方式 0微信 1支付宝 2余额',
  `wxPayType` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0 H5支付 1 小程序支付',
  `payCode` varchar(1000) NOT NULL DEFAULT '' COMMENT '支付返回号',
  `fromType` tinyint(4) NOT NULL DEFAULT '0' COMMENT '来源：0门店 1商城 2朋友圈',
  `store` tinyint(4) NOT NULL DEFAULT '0' COMMENT '门店订单 0不是 1是',
  `capitalId` int(11) NOT NULL DEFAULT '0' COMMENT '流水id',
  `prePrice` decimal(9,2) NOT NULL DEFAULT '0.00' COMMENT '应付款，原价，未修改价格，打折前',
  `actPrice` decimal(9,2) NOT NULL DEFAULT '0.00' COMMENT '实际付款，实价，修改后价格，打折后',
  `adminId` int(11) NOT NULL DEFAULT '0' COMMENT '用户id',
  `ghsId` int(11) NOT NULL DEFAULT '0' COMMENT '商家id',
  `shopId` int(11) NOT NULL DEFAULT '0' COMMENT '门店id',
  `sendType` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0未确认配送方式 1免配送 2自己送 3别人送；快递送',
  `sendSide` tinyint(4) NOT NULL DEFAULT '0' COMMENT '配送方 0没有 1达达',
  `sendStatus` tinyint(4) NOT NULL DEFAULT '0' COMMENT '配送状态：0未发货，待接单 1已发货，已接单 2已送达',
  `refund` tinyint(4) NOT NULL DEFAULT '0' COMMENT '1已退款 0正常订单',
  `payStatus` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0待付款 1已付款',
  `printStatus` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0未打印 1已打印',
  `remark` varchar(1000) NOT NULL DEFAULT '' COMMENT '备注',
  `status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '订单状态 0待付款 1待配送 2配送中 3待通知 4已取消 5已完成',
  `deadline` int(11) NOT NULL DEFAULT '0' COMMENT '订单有效期',
  `payTime` int(11) NOT NULL DEFAULT '0' COMMENT '付款时间',
  addTime int not null default 0 comment '添加时间',
  `updateTime` int not null default 0 comment '修改时间'
) COMMENT='供货商订单';
create table xhGhsOrderItem(
`id` int(11) unsigned NOT NULL AUTO_INCREMENT primary key COMMENT 'id',
`orderId` int(11) NOT NULL DEFAULT '0' COMMENT '订单id',
`adminId` int(11) NOT NULL DEFAULT '0' COMMENT '用户id',
`ghsId` int(11) NOT NULL DEFAULT '0' COMMENT '商家id',
itemId int not null default 0 comment '商家花材id',
`unitPrice` decimal(9,2) NOT NULL DEFAULT '0.00' COMMENT '每扎价格',
unitNum int not null default 0 comment '每扎多少支',
`num` decimal(9,2) NOT NULL DEFAULT '0.00' COMMENT '多少扎'
)comment='供货商订单商品';
CREATE TABLE `xhGhsOrderExpress` (
  `id` INT(11) NOT NULL AUTO_INCREMENT,
  `orderId` INT(11) NOT NULL DEFAULT '0' COMMENT '订单id',
  `ghsId` INT(11) NOT NULL DEFAULT '0' COMMENT '商家id',
  `sideId` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '配送方id',
  `distance` DECIMAL(6,1) NOT NULL DEFAULT '0.0' COMMENT '距离',
  `cost` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '运费',
  `tip` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '小费',
  `sendTime` INT(11) NOT NULL DEFAULT '0' COMMENT '要求配送时间',
  `status` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '0待接单 1已接单 2已完成 3已取消',
  `addTime` INT(11) NOT NULL DEFAULT '0' COMMENT '添加时间',
  PRIMARY KEY (`id`)
) COMMENT='第三方配送';
CREATE TABLE `xhGhsStatOrderCount` (
  `id` INT(11) NOT NULL AUTO_INCREMENT,
  `time` INT(11) NOT NULL DEFAULT '0' COMMENT '月份',
  `riseNum` INT(11) NOT NULL DEFAULT '0' COMMENT '增加数量',
  `totalNum` INT(11) NOT NULL DEFAULT '0' COMMENT '总数量',
  `ghsId` INT(11) NOT NULL DEFAULT '0' COMMENT '商家id',
  `shopId` INT(11) NOT NULL DEFAULT '0' COMMENT '门店id',
  PRIMARY KEY (`id`),
  KEY `ghs` (`ghsId`,`time`)
) COMMENT='供货商月订单量，包括未付款';
ALTER TABLE xhGhsAdmin ADD currentShopId INT NOT NULL DEFAULT 0 COMMENT '当前管理的门店' AFTER `openId`;
ALTER TABLE xhAdmin ADD currentShopId INT NOT NULL DEFAULT 0 COMMENT '当前管理的门店' AFTER `openId`;

====
==linqh 2021-01-16
ALTER TABLE `xhGhsPurchaseOrder`
CHANGE COLUMN `totalGoodsPrice` `totalItemPrice`  decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '商品总价格' AFTER `itemNumPiece`;


====
==shish 2021-01-17
ALTER TABLE xhGhsShop AUTO_INCREMENT=35816;
ALTER TABLE xhGhsCustom CHANGE `shopId` `retailShopId` INT(11) NOT NULL DEFAULT '0' COMMENT '零售门店id';
ALTER TABLE xhItem MODIFY unitNum TINYINT(4) NOT NULL DEFAULT '0' COMMENT '每扎多少支，每包多少支，每箱多少块，每扎多少条';
ALTER TABLE `xhGhsShopAdmin` ADD `super` TINYINT NOT NULL DEFAULT 0 COMMENT '是否店长或超级管理员0不是1是' AFTER `roleId`;
ALTER TABLE `xhShopAdmin` ADD `super` TINYINT NOT NULL DEFAULT 0 COMMENT '是否店长或超级管理员0不是1是' AFTER `roleId`;
ALTER TABLE `xhGhsShop` ADD adminId INT NOT NULL DEFAULT 0 COMMENT '店长id' AFTER `ghsId`;
ALTER TABLE `xhShop` ADD adminId INT NOT NULL DEFAULT 0 COMMENT '店长id' AFTER `merchantId`;
ALTER TABLE xhGhsOrder MODIFY `sendSide` TINYINT NOT NULL DEFAULT 0 COMMENT '配送方 0未选择 1达达2顺丰同城3闪送4美团';
ALTER TABLE xhOrder MODIFY `sendSide` TINYINT NOT NULL DEFAULT 0 COMMENT '配送方 0未选择 1达达2顺丰同城3闪送4美团';
ALTER TABLE xhGhsOrder ADD `receiveProvince` VARCHAR(20) NOT NULL DEFAULT '' COMMENT '收货地址 省' AFTER `shopId`;
ALTER TABLE xhGhsOrder ADD `receiveCity` VARCHAR(20) NOT NULL DEFAULT '' COMMENT '收货地址 市' AFTER `receiveProvince`;
ALTER TABLE xhGhsOrder ADD `receiveDist` VARCHAR(20) NOT NULL DEFAULT '' COMMENT '收货地址 区县市' AFTER `receiveCity`;
ALTER TABLE xhGhsOrder ADD `receiveAddress` VARCHAR(300) NOT NULL DEFAULT '' COMMENT '收货地址 详细街道地址' AFTER `receiveDist`;
ALTER TABLE xhGhsOrder ADD `receiveFloor` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '收货地址 楼号门牌号' AFTER `receiveAddress`;
ALTER TABLE xhGhsOrder ADD `receiveFullAddress` VARCHAR(400) NOT NULL DEFAULT '' COMMENT '完整收货地址' AFTER `receiveFloor`;
ALTER TABLE xhGhsOrder ADD `receiveLong` VARCHAR(20) NOT NULL DEFAULT '' COMMENT '收货的经度' AFTER `receiveFullAddress`;
ALTER TABLE xhGhsOrder ADD `receiveLat` VARCHAR(20) NOT NULL DEFAULT '' COMMENT '收货的纬度' AFTER `receiveLong`;
ALTER TABLE `xhGhsOrder` ADD sendTime INT NOT NULL DEFAULT 0 COMMENT '配送时间' AFTER `sendSide`;
ALTER TABLE `xhGhsOrder` ADD `sendCost` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '运费' AFTER `sendTime`;
ALTER TABLE `xhGhsOrder` ADD `sendTip` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '运费里增加的小费' AFTER `sendCost`;
ALTER TABLE `xhGhsOrder` ADD `sendNum` VARCHAR(20) NOT NULL DEFAULT '' COMMENT '配送编号，方便寻找订单对应的花束' AFTER `sendTip`;
ALTER TABLE xhGhsOrderItem ADD itemInfoId INT NOT NULL DEFAULT 0 COMMENT '商家商品id' AFTER `itemId`;
INSERT INTO xhUnit VALUES(NULL,'扎',1610881951,1610881951);
INSERT INTO xhUnit VALUES(NULL,'支',1610881951,1610881951);
ALTER TABLE xhGhsOrderItem ADD smallUnit SMALLINT NOT NULL DEFAULT 2 COMMENT '小单位，支，个，条' AFTER `itemInfoId`;
ALTER TABLE xhGhsOrderItem ADD bigUnit SMALLINT NOT NULL DEFAULT 1 COMMENT '大单位，扎，箱，包' AFTER `smallUnit`;
ALTER TABLE xhGhsOrderItem ADD smallUnitName CHAR(5) NOT NULL DEFAULT '支' COMMENT '小单位中文名' AFTER `smallUnit`;
ALTER TABLE xhGhsOrderItem ADD bigUnitName CHAR(5) NOT NULL DEFAULT '扎' COMMENT '大单位中文名' AFTER `bigUnit`;
ALTER TABLE `xhGhsOrderItem` DROP COLUMN `smallUnitName`;
ALTER TABLE `xhGhsOrderItem` DROP COLUMN `bigUnitName`;
ALTER TABLE xhGhsOrderItem DROP COLUMN `ghsId`;
ALTER TABLE xhGhsOrderItem DROP COLUMN `adminId`;
CREATE TABLE `xhPurchase` (
  `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  `ghsId` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '供货商ID',
  `ghsShopId` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '供货商门店ID',
  `shopId` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '门店ID',
  `status` TINYINT(2) NOT NULL DEFAULT '0' COMMENT '订单状态 1待付款，待确认，2待配送，3配送中，4已完成',
  `debt` TINYINT NOT NULL DEFAULT 0 COMMENT '欠款 1是 0没有，已结清',
  `addTime` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '创建时间',
  `updateTime` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '最后修改时间',
  PRIMARY KEY (`id`)
) COMMENT='采购单';
CREATE TABLE `xhPurchaseItem` (
  `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  `orderId` INT NOT NULL DEFAULT 0 COMMENT '采购单id',
  `itemId` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '花材ID',
  `num` DECIMAL(10,2) NOT NULL DEFAULT '0.00' COMMENT '花材数量',
  `unitPrice` DECIMAL(10,2) NOT NULL DEFAULT '0.00' COMMENT '采购总价',
  `price` DECIMAL(10,2) NOT NULL DEFAULT '0.00' COMMENT '采购总价',
  PRIMARY KEY (`id`)
) COMMENT='采购单详情';
ALTER TABLE `xhPurchase` ADD getType TINYINT NOT NULL DEFAULT 1 COMMENT '取货方式 1配送 2自取' AFTER `shopId`;
ALTER TABLE `xhPurchase` ADD sendTime INT NOT NULL DEFAULT 0 COMMENT '配送时间' AFTER `getType`;
ALTER TABLE `xhPurchase` ADD sendCost DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '运费' AFTER `sendTime`;
ALTER TABLE `xhPurchase` ADD `itemPrice` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '花材总金额' AFTER `shopId`;
ALTER TABLE `xhPurchase` ADD `prePrice` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '应付款，原价，未修改价格，打折前' AFTER `itemPrice`;
ALTER TABLE `xhPurchase` ADD `actPrice` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '实际付款，实价，修改后价格，打折后' AFTER `prePrice`;
ALTER TABLE `xhPurchase` ADD remark VARCHAR(1000) NOT NULL DEFAULT '' COMMENT '备注' AFTER `debt`;


=======
== lqh 2021-1-17
CREATE TABLE `xhGhsStockRecord` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `ghsId` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '供货商ID',
  `shopId` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '门店ID',
  `recordType` tinyint(2) unsigned NOT NULL DEFAULT '0' COMMENT '1 采购，2出库，3入库，4盘点 5销售（开单）',
  `orderSn` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '订单号',
  `itemId` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '花材ID',
  `itemNum` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '花材数量',
  `oldStock` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '原库存',
  `newStock` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '新库存',
  `addTime` int(11) unsigned NOT NULL DEFAULT '0',
  `updateTime` int(11) unsigned NOT NULL DEFAULT '0',
  `extend` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '扩展字段',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='供货商库存流水记录表';

ALTER TABLE `xhItem`
ADD COLUMN `bigUnit`  smallint(6) NOT NULL DEFAULT 0 COMMENT '大单位' AFTER `unit`,
ADD COLUMN `smallUnit`  smallint(6) NOT NULL DEFAULT 0 COMMENT '小单位' AFTER `bigUnit`;

=====
== shish 2021-1-18
ALTER TABLE xhGhsOrder MODIFY `adminId` INT(11) NOT NULL DEFAULT '0' COMMENT '客户id，对应表xhGhsAdmin id字段';
ALTER TABLE xhGhsOrder ADD staffId INT NOT NULL DEFAULT 0 COMMENT '员工id，对应表xhGhsAdmin id字段' AFTER adminId;
ALTER TABLE xhGhsOrder MODIFY `adminId` INT NOT NULL DEFAULT 0 COMMENT '员工id，对应xhGhsAdmin id字段';
ALTER TABLE xhGhsOrder CHANGE `staffId` `userId` INT NOT NULL DEFAULT 0 COMMENT '客户id，对应xhGhsAdmin id字段';
ALTER TABLE xhGhsOrder ADD `customId` INT NOT NULL DEFAULT 0 COMMENT '客户id 对应xhCustom id字段' AFTER `userId`;
ALTER TABLE xhGhsOrder ADD customAdminId INT NOT NULL DEFAULT 0 COMMENT '客户员工id' AFTER customId;
ALTER TABLE `xhGhsOrderItem` CHANGE `itemInfoId` `productId` INT(11) NOT NULL DEFAULT '0' COMMENT '商家商品id';
CREATE TABLE xhSupplier(
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
upId INT NOT NULL DEFAULT 0 COMMENT '上游商家id，供应商id，merchantId',
merchantId INT NOT NULL DEFAULT 0 COMMENT '商家id',
`addTime` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '创建时间',
`updateTime` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '最后修改时间'
)COMMENT='供应商关系';
ALTER TABLE `xhSupplier` ADD upName VARCHAR(30) NOT NULL DEFAULT '' COMMENT '上游供应商名称' AFTER `upId`,ADD debtAmount DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '欠款金额' AFTER `upName`,
ADD expendAmount DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '消费金额' AFTER `debtAmount`,ADD expendNum INT NOT NULL DEFAULT 0 COMMENT '消费次数' AFTER `expendAmount`;
ALTER TABLE `xhSupplier` ADD py VARCHAR(20) NOT NULL DEFAULT '' COMMENT '' AFTER `upName`;
ALTER TABLE `xhItem` CHANGE `pyName` `py` VARCHAR(20) NOT NULL DEFAULT '' COMMENT '花材名称的拼音首字母';
ALTER TABLE `xhGhsOrderItem` ADD orderSn CHAR(40) NOT NULL DEFAULT '' COMMENT '订单编号' AFTER `orderId`;
ALTER TABLE xhSupplier MODIFY `py` VARCHAR(20) NOT NULL DEFAULT '' COMMENT '名称拼音首字母';
ALTER TABLE xhSupplier ADD upShopId INT NOT NULL DEFAULT 0 COMMENT '上游供货商门店id' AFTER `py`;
ALTER TABLE `xhPurchaseItem` ADD orderSn CHAR(40) NOT NULL DEFAULT '' COMMENT '订单编号' AFTER orderId;
=======
===
==linqh 21-01-18
ALTER TABLE `xhGhsPurchaseOrder`
CHANGE COLUMN `orderStatus` `status`  tinyint(2) NOT NULL DEFAULT 0 COMMENT '订单状态：1待确认，2待配送，3配送中，4已完成' AFTER `orderSn`,
CHANGE COLUMN `itemNumBundle` `bigNum`  int(11) NOT NULL DEFAULT 0 COMMENT '合计多少商品(大单位 -扎)' AFTER `gysId`,
CHANGE COLUMN `itemNumPiece` `smallNum`  int(11) NULL DEFAULT 0 COMMENT '合计多少商品(小单位-支)' AFTER `bigNum`,
CHANGE COLUMN `totalItemPrice` `totalPrice`  decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '商品总价格' AFTER `smallNum`,
CHANGE COLUMN `shortHaulCharge` `shortCharge`  decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '短途运费' AFTER `packingCharge`,
CHANGE COLUMN `lineHaulCharge` `longCharge`  decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '长途运费' AFTER `shortCharge`,
CHANGE COLUMN `localHaulCharge` `localCharge`  decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '本地运费' AFTER `pickCharge`;

ALTER TABLE `xhGhsPurchaseOrder`
CHANGE COLUMN `gysId` `supplierId`  int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '供应商ID' AFTER `adminId`;
ALTER TABLE `xhGhsPurchaseOrder`
CHANGE COLUMN `ghsId` `merchantId`  int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '供货商ID' AFTER `id`;

RENAME  TABLE xhGhsItemInfo to xhGhsProduct;
ALTER TABLE `xhGhsPurchaseOrderItem`
ADD COLUMN `productId`  int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '门店的产品ID' AFTER `orderSn`;

ALTER TABLE `xhGhsItem`
CHANGE COLUMN `ghsId` `merchantId`  int(11) NOT NULL DEFAULT 0 COMMENT '商家id' AFTER `id`,
DROP INDEX `idx_ghsId` ,
ADD INDEX `idx_merchantId` (`merchantId`) USING BTREE ;

ALTER TABLE `xhGhsItemClass`
CHANGE COLUMN `ghsId` `merchantId`  int(11) NOT NULL DEFAULT 0 COMMENT '商家id' AFTER `id`,
DROP INDEX `idx_ghsId` ,
ADD INDEX `idx_merchantId` (`merchantId`) USING BTREE ;

ALTER TABLE `xhGhsStockRecord`
CHANGE COLUMN `ghsId` `merchantId`  int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '供货商ID' AFTER `id`;

ALTER TABLE `xhGhsProduct`
CHANGE COLUMN `ghsId` `merchantId`  int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '供货商ID' AFTER `id`;

======
== shish 2021-1-19
drop table if exists `xhGhsOrderSn`;
CREATE TABLE if not exists  xhGhsOrderSn(
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY
)AUTO_INCREMENT=26316718 COMMENT='供货商订单号';
DROP TABLE IF EXISTS `xhGhsPurchaseSn`;
CREATE TABLE IF NOT EXISTS  xhGhsPurchaseSn(
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY
)AUTO_INCREMENT=26316718 COMMENT='供货商采购单号';
DROP TABLE IF EXISTS `xhPurchaseSn`;
CREATE TABLE IF NOT EXISTS  xhPurchaseSn(
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY
)AUTO_INCREMENT=26316718 COMMENT='零售商采购单号';
DROP TABLE IF EXISTS `xhGhsCheckSn`;
CREATE TABLE IF NOT EXISTS  xhGhsCheckSn(
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY
)AUTO_INCREMENT=26316718 COMMENT='供货商盘点单号';
DROP TABLE IF EXISTS `xhOrderSn`;
CREATE TABLE IF NOT EXISTS  xhOrderSn(
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY
)AUTO_INCREMENT=26315618 COMMENT='零售商订单号';
ALTER TABLE `xhPurchase` ADD orderSn CHAR(40) NOT NULL DEFAULT '' COMMENT '订单号' AFTER `id`;
ALTER TABLE `xhPurchaseItem` DROP COLUMN `orderId`;
ALTER TABLE `xhGhsShop` CHANGE `ghsName` `merchantName` VARCHAR(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '供货商名称';
ALTER TABLE `xhGhsShop` CHANGE `ghsId` `merchantId` INT(11) NOT NULL DEFAULT '0' COMMENT '供货商id';
ALTER TABLE `xhGhsShopAdmin` CHANGE `ghsId` `merchantId` INT(11) NOT NULL DEFAULT '0' COMMENT '供货商id';
ALTER TABLE `xhGhsAdminLog`  CHANGE `ghsId` `merchantId` INT(11) NOT NULL DEFAULT '0' COMMENT '供货商id';
ALTER TABLE `xhGhsAdminRole`  CHANGE `ghsId` `merchantId` INT(11) NOT NULL DEFAULT '0' COMMENT '供货商id';
ALTER TABLE `xhGhsAdminRoleAuth`  CHANGE `ghsId` `merchantId` INT(11) NOT NULL DEFAULT '0' COMMENT '供货商id';
ALTER TABLE `xhGhsCustom`  CHANGE `ghsId` `merchantId` INT(11) NOT NULL DEFAULT '0' COMMENT '供货商id';
ALTER TABLE `xhGhsCheckOrder`  CHANGE `ghsId` `merchantId` INT(11) NOT NULL DEFAULT '0' COMMENT '供货商id';
ALTER TABLE `xhGhsOrderExpress`  CHANGE `ghsId` `merchantId` INT(11) NOT NULL DEFAULT '0' COMMENT '供货商id';
ALTER TABLE `xhGhsStatOrderCount`  CHANGE `ghsId` `merchantId` INT(11) NOT NULL DEFAULT '0' COMMENT '供货商id';
ALTER TABLE `xhGhsStockOrder`  CHANGE `ghsId` `merchantId` INT(11) NOT NULL DEFAULT '0' COMMENT '供货商id';
ALTER TABLE `xhPurchaseItem` CHANGE `itemId` `productId` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '产品ID';
ALTER TABLE `xhPurchaseItem` CHANGE `unitPrice` `bigPrice` DECIMAL(10,2) NOT NULL DEFAULT '0.00' COMMENT '采购大单位价，每扎每包价';
ALTER TABLE `xhPurchaseItem` ADD `ratio` TINYINT NOT NULL DEFAULT 0 COMMENT '大小单位转换比例，1扎多少支，1包多少支，1箱多少块 0表示只有一个单位' AFTER `num`;
ALTER TABLE xhPurchaseItem MODIFY `num` DECIMAL(10,2) NOT NULL DEFAULT '0.00' COMMENT '花材数量，支持小数点';
ALTER TABLE xhPurchaseItem MODIFY `bigPrice` DECIMAL(10,2) NOT NULL DEFAULT '0.00' COMMENT '大单位价，每扎价、每包价、每箱价';
ALTER TABLE xhPurchaseItem MODIFY `num` DECIMAL(10,2) NOT NULL DEFAULT '0.00' COMMENT '大单位数量，支持小数点';
ALTER TABLE `xhGhsOrderItem` CHANGE `unitPrice` `bigPrice` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '大单位价格，每扎价格，每包价格，每箱价格';
ALTER TABLE `xhGhsOrderItem` CHANGE `unitNum` `ratio` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '大小单位转换比例，1扎多少支，1包多少支，1箱多少块 0表示只有一个单位';
ALTER TABLE `xhGhsOrderItem` MODIFY `num` DECIMAL(10,2) NOT NULL DEFAULT '0.00' COMMENT '大单位数量，支持小数点';
ALTER TABLE `xhGhsOrderItem` CHANGE `bigPrice` `price` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '大单位价格，每扎价格，每包价格，每箱价格'
ALTER TABLE `xhGhsOrderItem` CHANGE `bigUnit` `unit` SMALLINT(6) NOT NULL DEFAULT '1' COMMENT '大单位，扎，箱，包';
ALTER TABLE `xhPurchaseItem` CHANGE `price` `totalPrice` DECIMAL(10,2) NOT NULL DEFAULT '0.00' COMMENT '采购总价';
ALTER TABLE `xhPurchaseItem` CHANGE `bigPrice` `price` DECIMAL(10,2) NOT NULL DEFAULT '0.00' COMMENT '大单位价，每扎价、每包价、每箱价';
ALTER  TABLE xhPurchaseItem MODIFY `totalPrice` DECIMAL(10,2) NOT NULL DEFAULT '0.00' COMMENT '总价';
ALTER TABLE xhGhsOrderItem ADD totalPrice DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '总价' AFTER `price`;
ALTER TABLE xhGhsOrderItem DROP COLUMN `orderId`;
ALTER TABLE `xhGhsOrder` CHANGE `goodsNum` `num` SMALLINT(4) NOT NULL DEFAULT '0' COMMENT '数量，大单位数量，多少扎，多少箱';
ALTER TABLE `xhGhsOrder` ADD smallNum SMALLINT NOT NULL DEFAULT 0 COMMENT '小单位数量，多少支，多少块' AFTER `num`;

===
==linqh  21-01-19
ALTER TABLE `xhGhsPurchaseOrder`
CHANGE COLUMN `bigNum` `num`  int(11) NOT NULL DEFAULT 0 COMMENT '合计多少商品(大单位 -扎)' AFTER `supplierId`,
CHANGE COLUMN `totalPrice` `price`  decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '商品总价格' AFTER `smallNum`;

=====
== shish 2021-01-20
ALTER TABLE `xhGhsOrder` MODIFY `status` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '订单状态 1待付款 2待配送 3配送中 4待通知 5已取消 6已完成';
ALTER TABLE xhGhsOrder MODIFY `sendType` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '1未确认 2免配送，自取 3自己送 4别人送，快递送';
ALTER TABLE `xhGhsOrder` DROP COLUMN `userId`;
ALTER TABLE xhGhsOrder CHANGE `ghsId` `merchantId` INT NOT NULL DEFAULT 0 COMMENT '商家id';
ALTER TABLE `xhGhsCustom` CHANGE `retailId` `downId` INT(11) NOT NULL DEFAULT '0' COMMENT '客户商id，下游商家id';
ALTER TABLE `xhGhsCustom` CHANGE `retailShopId` `downShopId` INT(11) NOT NULL DEFAULT '0' COMMENT '客户门店id，下游门店id';
ALTER TABLE `xhGhsCustom` CHANGE `shopName` `name` VARCHAR(30) NOT NULL DEFAULT '' COMMENT '客户名称，纯彩花艺 集美店';
ALTER TABLE `xhGhsOrder` MODIFY `sendStatus` TINYINT(4) NOT NULL DEFAULT '1' COMMENT '配送状态 1未发货，待接单 2已发货，已接单 3已送达';
ALTER TABLE `xhGhsOrder` MODIFY `sendSide` TINYINT(4) NOT NULL DEFAULT '1' COMMENT '配送方 1未选择 2达达 3顺丰同城 4闪送 5美团';
ALTER TABLE `xhGhsOrder` MODIFY `refund` TINYINT(4) NOT NULL DEFAULT '1' COMMENT '1正常订单 2已退款';
ALTER TABLE `xhGhsOrder` MODIFY `payStatus` TINYINT(4) NOT NULL DEFAULT '1' COMMENT '1待付款 2已付款';
ALTER TABLE `xhGhsOrder` MODIFY `printStatus` TINYINT(4) NOT NULL DEFAULT '1' COMMENT '1未打印 2已打印';
ALTER TABLE xhGhsOrder MODIFY `status` TINYINT(4) NOT NULL DEFAULT '1' COMMENT '订单状态 1待付款 2待配送 3配送中 4待通知 5已取消 6已完成';
ALTER TABLE xhGhsOrderItem MODIFY `num` DECIMAL(10,2) NOT NULL DEFAULT '0.00' COMMENT '总数量';
ALTER TABLE xhGhsOrderItem ADD `smallNum` SMALLINT NOT NULL DEFAULT '0' COMMENT '小单位，支，个，条' AFTER `num`;
ALTER TABLE xhGhsOrderItem ADD `bigNum` SMALLINT NOT NULL DEFAULT '0' COMMENT '大单位，扎，包，箱' AFTER `num`;
ALTER TABLE `xhGhsOrderItem` DROP COLUMN `totalPrice`;
ALTER TABLE `xhGhsOrderItem` MODIFY `price` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '总价格';
ALTER TABLE `xhGhsOrderItem` CHANGE `unit` `bigUnit` SMALLINT(6) NOT NULL DEFAULT '1' COMMENT '大单位，扎，箱，包';
ALTER TABLE xhGhsOrderItem MODIFY `ratio` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '大小单位转换比例，1扎多少支，1包多少支' AFTER `smallNum`;
ALTER TABLE xhGhsCustom ADD address VARCHAR(800) NOT NULL DEFAULT '' COMMENT '客户地址' AFTER `mobile`;
ALTER TABLE `xhGhsOrder` DROP COLUMN `addTime`;
ALTER TABLE `xhGhsOrder` DROP COLUMN `updateTime`;
ALTER TABLE `xhGhsOrder` ADD `addTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间' AFTER `payTime`;
ALTER TABLE `xhGhsOrder` ADD `updateTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间' AFTER `addTime`;
=======

=====
==linqh
ALTER TABLE `xhGhsPurchaseOrder`
CHANGE COLUMN `num` `bigNum`  int(11) NOT NULL DEFAULT 0 COMMENT '合计多少商品(大单位 -扎)' AFTER `supplierId`;

ALTER TABLE `xhGhsPurchaseOrder`
MODIFY COLUMN `addTime`  timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间' AFTER `entryTime`,
MODIFY COLUMN `updateTime`  timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间' AFTER `addTime`,
AUTO_INCREMENT=30;

ALTER TABLE `xhGhsPurchaseOrder`
MODIFY COLUMN `entryTime`  timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '入库时间' AFTER `orderPrice`;

=====
== shish 2021-1-21
ALTER TABLE xhGhsOrder DROP COLUMN `payTime`;
ALTER TABLE xhGhsOrder ADD `payTime` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '付款时间' AFTER `deadline`;
ALTER TABLE xhGhsOrder DROP COLUMN `deadline`;
ALTER TABLE xhGhsOrder ADD `deadline` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '订单有效时间' AFTER `status`;
ALTER TABLE xhGhsOrder DROP COLUMN `sendTime`;
ALTER TABLE xhGhsOrder ADD `sendTime` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '配送时间' AFTER `sendSide`;
ALTER TABLE xhGhsOrder MODIFY `orderSn` CHAR(20) NOT NULL DEFAULT '' COMMENT '订单编号';
ALTER TABLE xhGhsOrderItem MODIFY `orderSn` CHAR(20) NOT NULL DEFAULT '' COMMENT '订单编号';
ALTER TABLE xhGhsPurchaseOrder MODIFY `orderSn` CHAR(20) NOT NULL DEFAULT '' COMMENT '订单编号';
ALTER TABLE xhGhsPurchaseOrderItem MODIFY `orderSn` CHAR(20) NOT NULL DEFAULT '' COMMENT '订单编号';
ALTER TABLE xhGhsCheckOrder MODIFY `orderSn` CHAR(20) NOT NULL DEFAULT '' COMMENT '订单编号';
ALTER TABLE xhGhsCheckOrderItem MODIFY `orderSn` CHAR(20) NOT NULL DEFAULT '' COMMENT '订单编号';
ALTER TABLE xhPurchase MODIFY `orderSn` CHAR(20) NOT NULL DEFAULT '' COMMENT '订单编号';
ALTER TABLE xhGhsStockOrder MODIFY `orderSn` CHAR(20) NOT NULL DEFAULT '' COMMENT '订单编号';
ALTER TABLE xhGhsStockOrderItem MODIFY `orderSn` CHAR(20) NOT NULL DEFAULT '' COMMENT '订单编号';
ALTER TABLE `xhGhsOrder` ADD outTime DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '出库时间' AFTER `payTime`;
CREATE TABLE `xhGhsOrderSend` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`orderSn` CHAR(20) NOT NULL DEFAULT '' COMMENT '订单编号',
`actionId` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '动作id',
`option` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '动作的选项',
`finishTime` INT(11) NOT NULL DEFAULT '0' COMMENT '完成时间',
`inTurn` INT(11) NOT NULL DEFAULT '0' COMMENT '排序',
`addTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间',
`updateTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
PRIMARY KEY (`id`)
) COMMENT='供货商发货管理';
ALTER TABLE xhGhsOrder ADD `totalFlow` TINYINT(4) NOT NULL DEFAULT '5' COMMENT '总流程数' AFTER `printStatus`;
ALTER TABLE xhGhsOrder ADD `currentFlow` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '完成流程数，当前流程数' AFTER `totalFlow`;

=====
==linqh 20210122

ALTER TABLE `xhGhsCheckOrder`
CHANGE COLUMN `orderStatus` `status`  tinyint(2) UNSIGNED NOT NULL DEFAULT 0 COMMENT '盘点订单状态： 1草稿，2完成' AFTER `orderSn`,
CHANGE COLUMN `itemNumBundle` `bigNum`  int(11) NOT NULL DEFAULT 0 COMMENT '合计多少商品(扎)(盈亏）' AFTER `adminId`,
CHANGE COLUMN `itemNumPiece` `smallNum`  int(11) NOT NULL DEFAULT 0 COMMENT '合计多少商品(支)(盈亏）' AFTER `bigNum`,
CHANGE COLUMN `totalItemPrice` `price`  decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '商品总价格(盈亏）' AFTER `smallNum`,
MODIFY COLUMN `addTime`  timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间' AFTER `remark`,
MODIFY COLUMN `updateTime`  timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间' AFTER `addTime`;

ALTER TABLE `xhGhsCheckOrderItem`
ADD COLUMN `productId`  int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '商品id' AFTER `orderSn`;

ALTER TABLE `xhGhsStockRecord`
MODIFY COLUMN `addTime`  timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP AFTER `newStock`,
MODIFY COLUMN `updateTime`  timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP AFTER `addTime`;

====
==linqh 20210123
RENAME TABLE  xhGhsStockOrder TO  xhGhsStockOutOrder
ALTER TABLE `xhGhsStockOutOrder`
CHANGE COLUMN `orderStatus` `status`  tinyint(2) UNSIGNED NOT NULL DEFAULT 0 COMMENT '订单状态： 1待出库，2已出库  3取消出库' AFTER `orderSn`,
CHANGE COLUMN `itemNumBundle` `bigNum`  int(11) NOT NULL DEFAULT 0 COMMENT '合计多少商品(扎)' AFTER `adminId`,
CHANGE COLUMN `itemNumPiece` `smallNum`  int(11) NOT NULL DEFAULT 0 COMMENT '合计多少商品(支)' AFTER `bigNum`,
CHANGE COLUMN `totalItemPrice` `price`  decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '商品总价格' AFTER `smallNum`,
MODIFY COLUMN `addTime`  timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间' AFTER `remark`,
MODIFY COLUMN `updateTime`  timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间' AFTER `addTime`,
COMMENT='出库订单表';

RENAME TABLE  xhGhsStockOrderItem TO  xhGhsStockOutOrderItem

ALTER TABLE `xhGhsStockOutOrder`
ADD COLUMN `inOrderSn`  char(20) NOT NULL DEFAULT '' COMMENT '对应的入库订单号，订单完成的时候写入' AFTER `orderSn`;

CREATE TABLE `xhGhsStockInOrder` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `merchantId` int(11) NOT NULL DEFAULT '0' COMMENT '供货商id',
  `outShopId` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '出库的门店ID',
  `inShopId` int(11) NOT NULL DEFAULT '0' COMMENT '入库的门店ID',
  `orderSn` char(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '入库订单编号',
  `outOrderSn` char(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '对应的出库订单号',
  `status` tinyint(2) unsigned NOT NULL DEFAULT '0' COMMENT '订单状态： 1待入库，2已入库  3取消入库',
  `adminId` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '操作人ID',
  `bigNum` int(11) NOT NULL DEFAULT '0' COMMENT '合计多少商品(扎)',
  `smallNum` int(11) NOT NULL DEFAULT '0' COMMENT '合计多少商品(支)',
  `price` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '商品总价格',
  `remark` varchar(1000) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '备注信息',
  `addTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updateTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uni_orderNum` (`orderSn`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='入库订单表';

CREATE TABLE `xhGhsStockInOrderItem` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `orderSn` char(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '订单编号',
  `itemId` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '花材ID',
  `itemNum` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '出库花材数量',
  `itemStock` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '当时的库存',
  `itemInfo` text COLLATE utf8mb4_unicode_ci COMMENT '花材信息json{"itemName":"","itemCover":"","itemRank":""}',
  `itemPrice` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '价格',
  PRIMARY KEY (`id`),
  KEY `idx_orderNum` (`orderSn`) USING BTREE,
  KEY `idx_goodsItemId` (`itemId`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='出库入库订单详情表';


CREATE TABLE `xhGhsStockInSn` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=26316726 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='入库订单号';

CREATE TABLE `xhGhsStockOutSn` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=26316726 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='出库订单号';

ALTER TABLE `xhGhsStockInOrderItem`
ADD COLUMN `productId`  int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '商品ID' AFTER `orderSn`;

ALTER TABLE `xhGhsStockOutOrderItem`
ADD COLUMN `productId`  int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '商品ID' AFTER `orderSn`;

ALTER TABLE `xhGhsStockOutOrder`
ADD COLUMN `outTime`  timestamp NULL DEFAULT NULL COMMENT '出库时间' AFTER `remark`;


=====
== shish 2021-1-24
ALTER TABLE `xhGhsOrderSend` MODIFY `finishTime` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '完成时间';
ALTER TABLE xhGhsOrderSend ADD `status` TINYINT NOT NULL DEFAULT 0 COMMENT '0待完成 1已完成' AFTER `finishTime`;
ALTER TABLE `xhGhsOrderSend` ADD actionName VARCHAR(50) NOT NULL DEFAULT '' COMMENT '动作名称' AFTER `actionId`;
ALTER TABLE `xhAdmin` ADD payPassword VARCHAR(500) NOT NULL DEFAULT '' COMMENT '支付密码' AFTER `confirmPassword`;
ALTER TABLE `xhSupplier` DROP COLUMN `addTime`;
ALTER TABLE `xhSupplier` DROP COLUMN `updateTime`;
ALTER TABLE `xhSupplier` ADD `addTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间' AFTER `merchantId`;
ALTER TABLE `xhSupplier` ADD `updateTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间' AFTER `addTime`;
ALTER TABLE xhPurchase ADD merchantId INT NOT NULL DEFAULT 0 COMMENT '商家id' AFTER `shopId`;
ALTER TABLE `xhPurchase` CHANGE `ghsId` `upId` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '供货商id，上游id';
ALTER TABLE `xhPurchase` CHANGE `ghsShopId` `upShopId` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '供货商门店id，上游门店id';

=====
== linqh 2021-01-24
ALTER TABLE `xhGhsProduct`
MODIFY COLUMN `addTime`  timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间' AFTER `adminId`,
MODIFY COLUMN `updateTime`  timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间' AFTER `addTime`;


====
==linqh 2021-01-25
ALTER TABLE `xhGhsPurchaseOrderItem`
ADD COLUMN `itemStock`  decimal(10,2) NOT NULL DEFAULT 0 COMMENT '当时的库存' AFTER `itemId`;

=====
== shish 2021-01-25
ALTER TABLE `xhPurchase` ADD `supplierId` INT NOT NULL DEFAULT 0 COMMENT '供货商id' AFTER `shopId`;
ALTER TABLE `xhPurchase` DROP COLUMN `addTime`;
ALTER TABLE `xhPurchase` DROP COLUMN `updateTime`;
ALTER TABLE `xhPurchase` ADD `addTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间' AFTER `remark`;
ALTER TABLE `xhPurchase` ADD `updateTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间' AFTER `addTime`;
ALTER TABLE `xhPurchase` ADD bigNum SMALLINT NOT NULL DEFAULT 0 COMMENT '大单位数量' AFTER `sendCost`;
ALTER TABLE `xhPurchase` ADD smallNum SMALLINT NOT NULL DEFAULT 0 COMMENT '小单位数量' AFTER `bigNum`;
ALTER TABLE `xhPurchase` ADD adminId INT NOT NULL DEFAULT 0 COMMENT '采购员' AFTER `smallNum`;
ALTER TABLE xhPurchase ADD kindNum SMALLINT NOT NULL DEFAULT 0 COMMENT '多少种' AFTER `sendCost`;
ALTER TABLE xhSupplier ADD debt TINYINT NOT NULL DEFAULT 1 COMMENT '1没有欠款 2有欠款' AFTER `upShopId`;
ALTER TABLE `xhSupplier` ADD debtNum SMALLINT NOT NULL DEFAULT 0 COMMENT '欠款订单数，欠款笔数' AFTER `debt`;
ALTER TABLE xhSupplier CHANGE `upName` `name` VARCHAR(30) NOT NULL DEFAULT '' COMMENT '供货商名称';
ALTER TABLE xhPurchase MODIFY `debt` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '欠款 0未知 1是 2没有';
DROP TABLE IF EXISTS `xhPurchaseClear`;
CREATE TABLE IF NOT EXISTS xhPurchaseClear(
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  `prePrice` decimal(9,2) NOT NULL DEFAULT '0.00' COMMENT '应付款，原价，未修改价格，打折前',
  `actPrice` decimal(9,2) NOT NULL DEFAULT '0.00' COMMENT '实际付款，实价，修改后价格，打折后',
orderSn CHAR(20) NOT NULL DEFAULT '' COMMENT '订单号',
merchantId INT NOT NULL DEFAULT 0 COMMENT '商家id',
purchaseIds TEXT NOT NULL COMMENT '结算的采购单id，json串',
`addTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间',
`updateTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间'
)COMMENT='采购单结算';
CREATE TABLE IF EXISTS `xhPurchaseClearSn`;
CREATE TABLE IF NOT EXISTS `xhPurchaseClearSn` (
  `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`id`)
) AUTO_INCREMENT=28356251 COMMENT='结算订单号';
ALTER TABLE xhGhsOrder MODIFY `fromType` TINYINT(4) NOT NULL DEFAULT '1' COMMENT '来源：1门店 2商城 3朋友圈';


========
== shish 20210126
ALTER TABLE `xhWxBase` ADD `wxPayMerchantId` VARCHAR(20) NOT NULL DEFAULT '' COMMENT '微信支付商户id' AFTER `wxRefreshToken`;
ALTER TABLE `xhWxBase` ADD `wxPayKey` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '微信支付密钥' AFTER `wxPayMerchantId`;

相应的值需要补充

=========
==shsish 20210127
ALTER TABLE `xhApply` ADD `style` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '商家类型 1零售 2供货' AFTER `merchantId`;
ALTER TABLE `xhMerchant` MODIFY `style` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '商家类型 1零售 2供货';
ALTER TABLE `xhMerchantApply` RENAME TO `xhApplyInfo`;
ALTER TABLE `xhApplyInfo` rename to `xhApplyExtend`;
ALTER TABLE `xhApplyExtend` CHANGE `subjectTitles` `subject` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '商事主体名称';
ALTER TABLE `xhApplyExtend` CHANGE `businessLicense` `license` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '营业执照';
ALTER TABLE `xhApplyExtend` ADD `licenseNo` VARCHAR(30) NOT NULL DEFAULT '' COMMENT '营业执照号码' AFTER `license`;
ALTER TABLE `xhApplyExtend` DROP INDEX `businessLicense`;
ALTER TABLE `xhApplyExtend` DROP INDEX `bankCardNo`;
ALTER TABLE `xhApplyExtend` DROP INDEX `email`;
ALTER TABLE `xhApplyExtend` COMMENT '申请拓展信息';
ALTER TABLE `xhApply` COMMENT '申请表';
ALTER TABLE `xhApply` CHANGE `introMerchantId` `introSjId` INT(11) NOT NULL DEFAULT '0' COMMENT '引荐商家';
ALTER TABLE `xhApply` CHANGE `merchantId` `sjId` INT(11) NOT NULL DEFAULT '0' COMMENT '新商家id，0表示还没审核通过';
ALTER TABLE `xhApply` DROP COLUMN `addTime`;
ALTER TABLE `xhApply` DROP COLUMN `updateTime`;
ALTER TABLE `xhApply` ADD `addTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间' AFTER `status`;
ALTER TABLE `xhApply` ADD `updateTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间' AFTER `addTime`;
ALTER TABLE `xhApply` DROP INDEX `mobile`;
ALTER TABLE `xhGhsOrder` ADD `modPrice` TINYINT(4) NOT NULL DEFAULT '1' COMMENT '0不能修改价格 1可以修改' AFTER `capitalId`;
ALTER TABLE `xhApplyExtend` DROP COLUMN `createTime`;
ALTER TABLE `xhApplyExtend` DROP COLUMN `updateTime`;
ALTER TABLE `xhApplyExtend` ADD `addTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间' AFTER `email`;
ALTER TABLE `xhApplyExtend` ADD `updateTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间' AFTER `addTime`;

=============
==shish 20210128
还有余额的客户要导给国兰
等级和积分需要同步

===================
== shish 20210128
ALTER TABLE `xhMerchant` MODIFY `manageStyle` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '经营类型，0零售 1花艺培训学校 2批发商（此字段应弃用）';
ALTER TABLE `xhApply` ADD main TINYINT NOT NULL DEFAULT 1 COMMENT '零售店的主营业务 1零售 2花艺培训' AFTER `style`;
ALTER TABLE `xhApply` ADD nickName VARCHAR(30) NOT NULL DEFAULT '' COMMENT '店长昵称' AFTER `adminName`;
ALTER TABLE `xhUnionUser` DROP COLUMN `createTime`;
ALTER TABLE `xhUnionUser` DROP COLUMN `updateTime`;
ALTER TABLE `xhUnionUser` ADD `addTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间' AFTER `mobile`;
ALTER TABLE `xhUnionUser` ADD `updateTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间' AFTER `addTime`;

将 销花宝 花卉宝 花掌柜 花美玲 的公众号和小程序 绑定到同一个开放平台下

ALTER TABLE `xhApply` MODIFY `from` TINYINT NOT NULL DEFAULT 1 COMMENT '来源平台 1零售平台 2供货商平台';
ALTER TABLE `xhApplyExtend` ADD applyId INT NOT NULL DEFAULT 0 COMMENT '申请id' AFTER `id`;
ALTER TABLE `xhApply` MODIFY `status` TINYINT(4) NOT NULL DEFAULT '1' COMMENT '1审核中 2审核通过，试用中 3审核未通过 4已付费，使用中 5试用到期失效';
UPDATE `xhApply` SET `status`=1;
ALTER TABLE `xhMerchant` DROP COLUMN `setDeadline`;
ALTER TABLE `xhMerchant` DROP COLUMN `deadline`;
ALTER TABLE `xhMerchant` ADD `deadline` DATETIME NOT NULL DEFAULT '00000-00-00 00:00:00' COMMENT '帐号过期时间' AFTER setId;
UPDATE `xhMerchant` SET deadline='2022-07-09 12:00:00';

nginx增加
"~^http://ghs.huahb.com" http://ghs.huahb.com;
"~^https://ghs.huahb.com" https://ghs.huahb.com;
增加ghs.huahb.com的nginx配置 增加api.ghs.huahb.com的nginx配置 增加二者的https访问


======
==linqh 2021-1-28
ALTER TABLE `xhGhsItem`
MODIFY COLUMN `addTime`  timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间' AFTER `unitAddPrice`,
MODIFY COLUMN `updateTime`  timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间' AFTER `addTime`;

==========
== shish 20210129
ALTER TABLE `xhOrder` CHANGE `userId` `adminId` INT(11) NOT NULL DEFAULT '0' COMMENT '客户id，员工id';
UPDATE `xhOrder` SET adminId=0;
ALTER TABLE `xhOrder` CHANGE `adminId` `customId` INT(11) NOT NULL DEFAULT '0' COMMENT '客户id';
ALTER TABLE xhOrderGoods CHANGE `userId` `customId` INT NOT NULL DEFAULT 0 COMMENT '客户id';
DROP TABLE IF EXISTS `xhCustom`;
CREATE TABLE IF NOT EXISTS `xhCustom`(
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`name` VARCHAR(30) NOT NULL DEFAULT '' COMMENT '客户名称',
adminId INT NOT NULL DEFAULT 0 COMMENT 'adminId',
merchantId INT NOT NULL DEFAULT 0 COMMENT '商家id',
`addTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间',
`updateTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间'
) AUTO_INCREMENT=12563516 COMMENT='零售客户表';
DROP TABLE IF EXISTS `xhCustom`;
CREATE TABLE `xhCustom` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '客户名称',
  `adminId` int(11) NOT NULL DEFAULT '0' COMMENT 'adminId',
  `sjId` int(11) NOT NULL DEFAULT '0' COMMENT '商家id',
  `totalExpend` decimal(9,2) NOT NULL DEFAULT '0.00' COMMENT '累计消费',
  `totalIncome` decimal(9,2) NOT NULL DEFAULT '0.00' COMMENT '累计收入',
  `totalRecharge` decimal(9,2) NOT NULL DEFAULT '0.00' COMMENT '累计充值',
  `totalBuyNum` int(11) NOT NULL DEFAULT '0' COMMENT '消费次数',
  `getCouponNum` int(11) NOT NULL DEFAULT '0' COMMENT '已领卷次数',
  `balance` decimal(9,2) NOT NULL DEFAULT '0.00' COMMENT '余额',
  `integral` int(11) NOT NULL DEFAULT '0' COMMENT '积分',
  `growth` int(11) NOT NULL DEFAULT '0' COMMENT '成长值',
  `discount` float(3,2) NOT NULL DEFAULT '1.00' COMMENT '折扣',
  `inviteNum` int(11) NOT NULL DEFAULT '0' COMMENT '邀请新人数量',
  `member` smallint(6) NOT NULL DEFAULT '0' COMMENT '会员等级 0普遍客户 大于等于1 会员',
  `addTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间',
  `updateTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
  PRIMARY KEY (`id`)
) COMMENT='客户表';
ALTER TABLE `xhCustom` ADD `mobile` VARCHAR(15) NOT NULL DEFAULT '0' COMMENT '手机号' AFTER `name`;
ALTER TABLE xhCustom ADD `visitTime` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '最后一次访问时间' AFTER `member`;

======
==linqh 2021.1.31

ALTER TABLE `xhGhsProduct`
ADD COLUMN `priceLabel`  tinyint(2) UNSIGNED NOT NULL DEFAULT 1 COMMENT '价格标识（price）: 1 自动调价，2改价' AFTER `price`;

======
==linqh 2021.2.2
ALTER TABLE `xhGhsStockRecord`
MODIFY COLUMN `itemNum`  decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '花材数量' AFTER `itemId`;

CREATE TABLE `xhExpressLocal` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `deliveryId` varchar(20) NOT NULL DEFAULT '' COMMENT '快递ID',
  `deliveryName` varchar(50) NOT NULL DEFAULT '' COMMENT '快递名称',
  `appKey` varchar(100) NOT NULL DEFAULT '' COMMENT 'app key',
  `appSecret` varchar(200) NOT NULL DEFAULT '' COMMENT 'appSecret',
  `status` tinyint(2) unsigned NOT NULL DEFAULT '1' COMMENT '状态：1启用，2关闭',
  `addTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updateTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uni_deliveryId` (`deliveryId`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COMMENT='即时配送快递公司信息';

=========
== shish 2021-2-2

将供货商和零售店绑定到自己的开放平台下 并且更新 xhWxBase 和 xhWxMiniBase 下的openAppId值

===========
== shish 20201-2-4
ALTER TABLE `xhGhsCustom` ADD isDebt TINYINT NOT NULL DEFAULT 0 COMMENT '是否有欠款 0没有 1有' AFTER debt;
ALTER TABLE xhGhsOrder ADD debt TINYINT NOT NULL DEFAULT 0 COMMENT '0没有欠款 1有欠款' AFTER `refund`;
CREATE TABLE `xhGhsOrderClear` (
  `id` INT(11) NOT NULL AUTO_INCREMENT,
  `prePrice` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '应付款，原价，未修改价格，打折前',
  `actPrice` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '实际付款，实价，修改后价格，打折后',
  `orderSn` CHAR(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '订单号',
  `sjId` INT(11) NOT NULL DEFAULT '0' COMMENT '商家id',
  `orderIds` TEXT COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'id的json串',
  `addTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间',
  `updateTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
  PRIMARY KEY (`id`)
) COMMENT='清算订单';
CREATE TABLE `xhGhsOrderClearSn` (
  `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`id`)
) AUTO_INCREMENT=12358276 COMMENT='清算订单号';
DROP TABLE IF EXISTS `xhExpress`;
ALTER TABLE xhExpressLocal RENAME TO xhExpress;
ALTER TABLE xhOrderExpress CHANGE `merchantId` `sjId` INT(11) NOT NULL DEFAULT '0' COMMENT '商家id';
ALTER TABLE xhGhsOrderExpress CHANGE `merchantId` `sjId` INT(11) NOT NULL DEFAULT '0' COMMENT '商家id';
ALTER TABLE xhOrderExpress CHANGE `sideId` `expressId` INT(11) NOT NULL DEFAULT '0' COMMENT '配送方id';
ALTER TABLE xhGhsOrderExpress CHANGE `sideId` `expressId` INT(11) NOT NULL DEFAULT '0' COMMENT '配送方id';

===============
== shish 2021-2-18
ALTER TABLE `xhItem` MODIFY `unitNum` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '大小单位转换比例，每扎多少支';
ALTER TABLE `xhItem` MODIFY `unitWeight` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '大单位重量，每扎多少公斤';
ALTER TABLE `xhItem` MODIFY `unitCost` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '大单位采购价，每扎成本价，采购价';
ALTER TABLE `xhItem` MODIFY `unitAddPrice` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '大单位加价，每扎加价';
ALTER TABLE `xhGhsItem` MODIFY `unitWeight` FLOAT(10,2) NOT NULL DEFAULT '0.00' COMMENT '大单位重量，每扎重量(斤)';
ALTER TABLE `xhGhsItem` MODIFY `unitCost` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '大单位采购价，每扎成本价，采购价';
ALTER TABLE `xhGhsItem` MODIFY `unitAddPrice` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '大单位加价，每扎加价';
ALTER TABLE xhItem ADD alias VARCHAR(50) NOT NULL DEFAULT '' COMMENT '花材别名' AFTER `name`;

TRUNCATE `xhItem`;
ALTER TABLE xhItem AUTO_INCREMENT=1000;

请直接将xhItem xhItemClass xhUnit 表和数据迁移到线上

ALTER TABLE xhItemClass ADD `group` TINYINT NOT NULL DEFAULT 0 COMMENT ' 所属分组，0默认平台的分类' AFTER `name`;
ALTER TABLE xhItem ADD classId INT NOT NULL DEFAULT 0 COMMENT '平台分类id' AFTER `cover`;
ALTER TABLE `xhItem`
MODIFY COLUMN `addTime`  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间',
MODIFY COLUMN `updateTime`  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间';
ALTER TABLE xhOrderGoods ADD orderSn CHAR(20) NOT NULL DEFAULT '' COMMENT '' AFTER `orderId`;
ALTER TABLE xhOrder ADD packingFee DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '包装费' AFTER `anonymity`;
ALTER TABLE xhOrder ADD orderType TINYINT NOT NULL DEFAULT 1 COMMENT '1成品订单 2花材订单' AFTER `goodsNum`;
DROP TABLE IF EXISTS `xhOrderItem`;
CREATE TABLE IF NOT EXISTS `xhOrderItem`(
  id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  `orderSn` CHAR(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '订单编号',
  `itemId` INT(11) NOT NULL DEFAULT '0' COMMENT '商家花材id',
  `productId` INT(11) NOT NULL DEFAULT '0' COMMENT '商家商品id',
  `smallUnit` SMALLINT(6) NOT NULL DEFAULT '2' COMMENT '小单位，支，个，条',
  `bigUnit` SMALLINT(6) NOT NULL DEFAULT '1' COMMENT '大单位，扎，箱，包',
  `price` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '总价格',
  `num` DECIMAL(10,2) NOT NULL DEFAULT '0.00' COMMENT '总数量',
  `bigNum` SMALLINT(6) NOT NULL DEFAULT '0' COMMENT '大单位数量，扎，包，箱',
  `smallNum` SMALLINT(6) NOT NULL DEFAULT '0' COMMENT '小单位数量，支，个，条',
  `ratio` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '大小单位转换比例，1扎多少支，1包多少支'
)COMMENT='零售订单的花材';
DROP TABLE IF EXISTS `xhRecharge`;
CREATE TABLE IF NOT EXISTS `xhRecharge`(
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`payWay` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '支付方式 0微信 1支付宝 2余额',
`payCode` VARCHAR(1000) NOT NULL DEFAULT '' COMMENT '支付返回号',
sjId INT NOT NULL DEFAULT 0 COMMENT '商家id',
sjStyle TINYINT NOT NULL DEFAULT 1 COMMENT '商家类型 1零售 2供货',
shopId INT NOT NULL DEFAULT 0 COMMENT '门店id',
`amount` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '金额',
`balance` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '余额',
`totalRecharge` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '门店累计充值'
)COMMENT='门店充值记录';
DROP TABLE IF EXISTS `xhRechargeSn`;
CREATE TABLE IF NOT EXISTS `xhRechargeSn` (
  `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`id`)
) AUTO_INCREMENT=18213721 COMMENT='充值订单号';
ALTER TABLE xhRecharge ADD orderSn CHAR(20) NOT NULL DEFAULT '' COMMENT '订单编号' AFTER `id`;
ALTER TABLE `xhRecharge` ADD `modPrice` TINYINT(4) NOT NULL DEFAULT '1' COMMENT '0不能修改价格 1可以修改' AFTER `orderSn`;
ALTER TABLE `xhRecharge` ADD `deadline` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '订单有效时间' AFTER `modPrice`;
ALTER TABLE xhRecharge ADD payStatus TINYINT NOT NULL DEFAULT 1 COMMENT '1待付款 2已付款' AFTER `totalRecharge`;
DROP TABLE `xhGhsShopAdmin`;
DROP TABLE `xhGhsShop`;
ALTER TABLE `xhShop` MODIFY `createTime` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '创建时间';
ALTER TABLE xhShop ADD balance DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '余额' AFTER `adminId`;
ALTER TABLE xhShop ADD fixBalance DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '只能向推荐人消费的余额，指定余额' AFTER `balance`;
ALTER TABLE xhMerchant ADD parentId INT NOT NULL DEFAULT 0 COMMENT '父id' AFTER `adminId`;
ALTER TABLE `xhRecharge` ADD INDEX `orderSn` (`orderSn`);
DROP TABLE IF EXISTS `xhRechargeRecord`;
CREATE TABLE IF NOT EXISTS `xhRechargeRecord`(
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
sjId INT NOT NULL DEFAULT 0 COMMENT '商家id',
shopId INT NOT NULL DEFAULT 0 COMMENT '门店id',
`amount` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '充值金额',
`totalRecharge` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '充值金额',
`remark` VARCHAR(1000) NOT NULL DEFAULT '' COMMENT '备注',
`addTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间',
`updateTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间'
)COMMENT='充值记录';
ALTER TABLE `xhShop` DROP COLUMN `createTime`;
ALTER TABLE `xhShop` DROP COLUMN `addTime`;
ALTER TABLE `xhShop` ADD `addTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间' AFTER `status`;
ALTER TABLE xhRechargeRecord RENAME TO xhRechargeLog;
ALTER TABLE xhShop ADD totalRecharge DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '累计充值' AFTER `fixBalance`;