CREATE TABLE `qimall_addons_store` (
       `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
      `mall_id` int(11) NOT NULL DEFAULT '0',
       `user_id` int(11) NOT NULL DEFAULT '0' COMMENT '绑定会员id',
       `shop_owner` varchar(255) NOT NULL DEFAULT '' COMMENT '店长姓名',
      `shop_mobile` varchar(11) NOT NULL DEFAULT '' COMMENT '店长手机号',
       `store_name` varchar(255) NOT NULL DEFAULT '' COMMENT '门店名称',
       `c_id` int(11) NOT NULL DEFAULT '0' COMMENT '门店分类',
       `store_desc` varchar(255) NOT NULL DEFAULT '' COMMENT '门店简介',
       `logo_img` varchar(255) NOT NULL DEFAULT '' COMMENT '门店logo',
       `license_img` varchar(255) NOT NULL DEFAULT '' COMMENT '营业执照',
       `province_id` int(11) DEFAULT '0' COMMENT '省',
       `city_id` int(11) DEFAULT '0' COMMENT '市',
       `district_id` int(11) DEFAULT '0' COMMENT '区',
       `address` varchar(255) NOT NULL DEFAULT '' COMMENT '详细地址',
       `expire_time` bigint(20) NOT NULL DEFAULT '0' COMMENT '失效时间，0代表无限期',
       `total_money` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '累计收入',
       `balance` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '当前余额',
       `total_expenses` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '累计支出',
       `user_nums` int(11) DEFAULT '0' COMMENT '会员总数',
       `longitude` varchar(255) NOT NULL DEFAULT '' COMMENT '经度',
       `latitude` varchar(255) NOT NULL DEFAULT '' COMMENT '维度',
       `check_status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '审核状态：0：待审核；1：已通过；2：未通过',
       `check_remark` varchar(255) NOT NULL DEFAULT '' COMMENT '审核备注',
       `business_time_start` varchar(255) NOT NULL DEFAULT '' COMMENT '营业时间开始',
       `business_time_end` varchar(255) NOT NULL DEFAULT '' COMMENT '营业时间结束',
       `store_style` tinyint(1) NOT NULL DEFAULT '1' COMMENT '门店样式 1：样式1；2：样式2',
       `store_background` varchar(255) NOT NULL DEFAULT '' COMMENT '门店背景',
       `commission_authority` varchar(255) NOT NULL DEFAULT '' COMMENT '分佣/营销权限',
       `share_title` varchar(255) NOT NULL DEFAULT '' COMMENT '分享标题',
       `share_desc` varchar(255) NOT NULL DEFAULT '' COMMENT '分享描述',
       `share_pic` varchar(255) NOT NULL DEFAULT '' COMMENT '分享图片',
       `freight_type` varchar(255) NOT NULL DEFAULT '' COMMENT '配送设置',
       `intra_city_distribution` varchar(500) NOT NULL DEFAULT '' COMMENT '同城配送',
       `total_order_money` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '订单总金额',
       `total_num` int(11) NOT NULL DEFAULT '0' COMMENT '总数',
       `total_settled_amount` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '已结算总金额',
      `unsettled_amount` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '未结算金额',
       `sales_volume` int(11) NOT NULL DEFAULT '0' COMMENT '销量',
       `praise` decimal(3,1) NOT NULL DEFAULT '5.0' COMMENT '评分',
       `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态[0禁用 1启用 -1删除]',
       `shop_status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '门店营业状态，1：正在营业；0：休息中',
       `scan_code_bind` tinyint(1) NOT NULL DEFAULT '0' COMMENT '门店收款码-扫码绑定开关：0：否；1：是',
       `created_at` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
       `updated_at` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
       PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB  DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='门店';

CREATE TABLE `qimall_addons_store_admin` (
   `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
   `username` varchar(50) NOT NULL DEFAULT '' COMMENT '登录账号',
   `account` varchar(50) NOT NULL DEFAULT '' COMMENT '账号名称',
   `password` varchar(255) NOT NULL DEFAULT '' COMMENT '密码',
   `mall_id` int(11) NOT NULL DEFAULT '0' COMMENT '商城id',
   `store_id` int(11) NOT NULL DEFAULT '0' COMMENT '门店id',
   `auth_key` varchar(128) NOT NULL DEFAULT '',
   `access_token` varchar(128) NOT NULL DEFAULT '',
   `admin_type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '管理员类型1超级管理员2管理员3操作员',
   `created_at` int(11) NOT NULL DEFAULT '0',
   `updated_at` int(11) NOT NULL DEFAULT '0',
  `status` tinyint(1) DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
   PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB  DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='门店后台管理员表';

CREATE TABLE `qimall_addons_store_bank` (
   `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `mall_id` int(11) NOT NULL DEFAULT '0' COMMENT '商城id',
   `store_id` int(11) NOT NULL DEFAULT '0' COMMENT '门店id',
   `username` varchar(50) NOT NULL DEFAULT '' COMMENT '开户名',
   `bank` varchar(255) NOT NULL DEFAULT '' COMMENT '开户银行',
   `card_no` varchar(255) NOT NULL DEFAULT '' COMMENT '银行卡号',
   `created_at` int(11) NOT NULL DEFAULT '0',
   `updated_at` int(11) NOT NULL DEFAULT '0',
   `status` tinyint(1) DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
   PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB  DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='门店提现银行卡';

CREATE TABLE `qimall_addons_store_cashier_order` (
     `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
     `mall_id` int(11) NOT NULL DEFAULT '0',
     `store_id` int(11) NOT NULL DEFAULT '0' COMMENT '门店id',
     `user_id` int(11) NOT NULL DEFAULT '0' COMMENT '会员id',
     `order_no` varchar(100) NOT NULL DEFAULT '' COMMENT '订单编号',
     `pay_status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '支付状态：0：否；1：是',
     `pay_time` int(11) NOT NULL DEFAULT '0' COMMENT '付款时间',
     `money` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '应付金额',
     `pay_money` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '实付金额',
     `payment_type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '支付类型',
     `amount_received` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '实收金额',
     `service_money` decimal(12,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '服务费',
     `remark` varchar(255) NOT NULL DEFAULT '' COMMENT '备注',
     `extra` varchar(255) NOT NULL DEFAULT '' COMMENT '额外信息：例如优惠信息，渠道分红，经销分红',
     `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态[0禁用 1启用 -1删除]',
     `created_at` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
     `updated_at` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
     PRIMARY KEY (`id`) USING BTREE,
     KEY `idx_order_no` (`order_no`) USING BTREE
) ENGINE=InnoDB  DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='门店收银订单';

CREATE TABLE `qimall_addons_store_cate`  (
  `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  `mall_id` int(11) NOT NULL DEFAULT 0,
  `parent_id` int(11) NOT NULL DEFAULT 0 COMMENT '父级ID',
  `name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '分类名称',
  `pic` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
  `big_pic` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
  `advert_pic` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '广告图片',
  `advert_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '广告链接',
  `advert_open_type` varchar(65) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '打开方式',
  `advert_params` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '导航参数',
  `is_show` tinyint(1) NOT NULL DEFAULT 1 COMMENT '是否显示',
  `status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '状态[0禁用 1启用 -1删除]',
  `sort` int(11) NOT NULL DEFAULT 999 COMMENT '排序',
  `created_at` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
  `updated_at` int(11) NOT NULL DEFAULT 0 COMMENT '修改时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB  CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '门店分类' ROW_FORMAT = COMPACT;

CREATE TABLE `qimall_addons_store_census` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `mall_id` int(11) NOT NULL DEFAULT '0',
  `store_id` int(11) NOT NULL DEFAULT '0' COMMENT '门店id',
  `add_user_nums` int(11) NOT NULL DEFAULT '0' COMMENT '新增会员',
  `order_nums` int(11) NOT NULL DEFAULT '0' COMMENT '订单数',
  `settlement_commission` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '结算佣金',
  `sales_money` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '门店销售额',
  `cashier_sales_money` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '收银台销售额',
  `date_time` varchar(50) NOT NULL DEFAULT '' COMMENT '日期时间',
  `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态[0禁用 1启用 -1删除]',
  `created_at` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
  `updated_at` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB  DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='门店每日统计';

CREATE TABLE `qimall_addons_store_clerk`  (
  `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  `mall_id` int(11) NOT NULL DEFAULT 0,
  `store_id` int(11) NOT NULL DEFAULT 0 COMMENT '门店id',
  `user_id` int(11) NOT NULL DEFAULT 0 COMMENT '会员id',
  `goods_id` int(11) NOT NULL DEFAULT 0 COMMENT 'o2o商品id',
  `nums` int(11) NOT NULL DEFAULT 0 COMMENT '累计核销订单数',
  `total_money` decimal(12, 2) NOT NULL DEFAULT 0.00 COMMENT '累计核销金额',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '备注',
  `status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '状态[0禁用 1启用 -1删除]',
  `created_at` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
  `updated_at` int(11) NOT NULL DEFAULT 0 COMMENT '修改时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB  CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '门店核销员' ROW_FORMAT = COMPACT;

CREATE TABLE `qimall_addons_store_clerk_log`  (
  `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  `mall_id` int(11) NOT NULL DEFAULT 0,
  `store_id` int(11) NOT NULL DEFAULT 0 COMMENT '门店id',
  `user_id` int(11) NOT NULL DEFAULT 0 COMMENT '会员id',
  `clerk_id` int(11) NOT NULL DEFAULT 0 COMMENT '核销员id',
  `mobile` varchar(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '电话',
  `order_no` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '订单编号',
  `status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '状态[0禁用 1启用 -1删除]',
  `created_at` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
  `updated_at` int(11) NOT NULL DEFAULT 0 COMMENT '修改时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB  CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '门店核销明细' ROW_FORMAT = COMPACT;

CREATE TABLE `qimall_addons_store_commission` (
    `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
    `mall_id` int(11) NOT NULL DEFAULT '0' COMMENT '商城id',
    `store_id` int(11) NOT NULL DEFAULT '0' COMMENT '门店id',
    `user_id` int(11) NOT NULL DEFAULT '0' COMMENT '会员id',
    `order_no` varchar(100) NOT NULL DEFAULT '' COMMENT '订单编号',
    `order_money` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '订单金额',
    `pay_money` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '支付金额',
    `discount_money` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '优惠金额',
    `addons_bonus` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '插件分红',
    `service_charge` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '服务费',
    `amount_received` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '到账金额',
    `is_settlement` tinyint(1) NOT NULL DEFAULT '0' COMMENT '结算状态 0：待结算；1：已结算',
    `type` tinyint(1) NOT NULL DEFAULT '1' COMMENT '类型：1：o2o订单；2：o2o收银台订单',
    `created_at` int(11) NOT NULL DEFAULT '0',
   `updated_at` int(11) NOT NULL DEFAULT '0',
    `status` tinyint(1) DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
    PRIMARY KEY (`id`) USING BTREE,
    KEY `idx_order_no` (`order_no`) USING BTREE
) ENGINE=InnoDB  DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='门店提成明细';

CREATE TABLE `qimall_addons_store_freight_rules` (
    `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
    `mall_id` int(11) NOT NULL DEFAULT '0' COMMENT '商城ID',
    `store_id` int(11) NOT NULL DEFAULT '0' COMMENT '门店id',
    `name` varchar(65) NOT NULL DEFAULT '' COMMENT '规则名称',
    `rule` longtext NOT NULL COMMENT '规则详情',
    `is_default` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否默认',
    `status` int(11) NOT NULL DEFAULT '1' COMMENT '状态【1启用 0禁用 -1删除】',
    `type` tinyint(4) NOT NULL DEFAULT '1' COMMENT '计费方式【1=>按重计费、2=>按件计费】',
    `created_at` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
    `updated_at` int(11) NOT NULL DEFAULT '0',
   PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB  DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='门店运费规则';

CREATE TABLE `qimall_addons_store_goods` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `mall_id` int(11) NOT NULL DEFAULT '0' COMMENT '商城id',
    `mall_goods_id` int(11) NOT NULL DEFAULT '0' COMMENT '主商城goods_id',
    `store_id` int(11) NOT NULL DEFAULT '0' COMMENT '门店id',
    `goods_name` varchar(120) NOT NULL DEFAULT '' COMMENT '商品名称',
    `subtitle` varchar(150) NOT NULL DEFAULT '' COMMENT '商品副标题',
   `price` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '售价',
    `original_price` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '原价（划线价仅展示）',
    `cost_price` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '成本价',
    `unit` varchar(255) NOT NULL DEFAULT '件' COMMENT '单位',
    `cover_pic` varchar(255) NOT NULL DEFAULT '' COMMENT '商品缩略图',
    `bannar_pic` varchar(1500) NOT NULL DEFAULT '' COMMENT '商品展示bannar图',    `video_url` varchar(255) NOT NULL DEFAULT '' COMMENT '商品视频',
    `video_cover_pic` varchar(500) NOT NULL DEFAULT '' COMMENT '商品视频封面',
    `is_on_sale` smallint(1) NOT NULL DEFAULT '0' COMMENT '上架状态【1是 0否】',
    `is_attr` smallint(1) NOT NULL DEFAULT '0' COMMENT '是否有规格【1是 0否】',
    `attr_groups` text COMMENT '规格组',
    `attr_groups_format` longtext COMMENT '格式化规格组',
    `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态[1正常 -1删除]',
    `stock` int(11) NOT NULL DEFAULT '0' COMMENT '商品库存',
    `stock_warning` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '商品库存预警',
    `is_show_stock` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否显示库存',
    `is_show_sales` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否显示销量【1是 0否】',
    `virtual_sales` int(11) NOT NULL DEFAULT '0' COMMENT '虚拟销量',
    `sales_num` int(11) NOT NULL DEFAULT '0' COMMENT '累计销量',
    `buy_num_limit` int(11) NOT NULL DEFAULT '-1' COMMENT '购买数量限制',
    `freight_type` varchar(255) NOT NULL DEFAULT '' COMMENT '物流方式【1快递发货 2上门自提 3商家配送】逗号分隔',
    `freight_rules_type` tinyint(4) NOT NULL DEFAULT '0' COMMENT '运费规则 【1运费模板 2自定义运费】',
    `freight_id` int(11) NOT NULL DEFAULT '0' COMMENT '运费模板ID',
    `shipping_fee` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '自定义运费金额',
    `free_shipping_num` int(11) NOT NULL DEFAULT '0' COMMENT '商品满件包邮',
    `free_shipping_money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '商品满额包邮',
    `goods_type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '商品类型',
    `detail` longtext COMMENT '商品详情，图文',
    `is_area_limit` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否开启限购区域',
    `area_limit` longtext COMMENT '限购区域',
    `services` varchar(500) NOT NULL DEFAULT '' COMMENT '商品服务',
    `labels` varchar(500) NOT NULL DEFAULT '' COMMENT '商品标签',
    `goods_source` varchar(32) DEFAULT NULL COMMENT '商品来源',
    `supplier_type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '供应者类型：0:自身；1：商城；2：o2o；3：多商户',
    `supplier_id` int(11) NOT NULL DEFAULT '0' COMMENT '供应者id',
    `supplier_goods_id` int(11) NOT NULL DEFAULT '0' COMMENT '供应品id',
    `sort` int(11) NOT NULL DEFAULT '100' COMMENT '排序',
    `check_status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '审核状态 0：待审核；1；：已通过；2：未通过',
    `check_remark` varchar(255) NOT NULL DEFAULT '' COMMENT '审核备注',
    `created_at` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
    `updated_at` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
    PRIMARY KEY (`id`) USING BTREE,
    KEY `mall_id_store_id_goods_name_index` (`mall_id`,`store_id`,`goods_name`) USING BTREE
) ENGINE=InnoDB  DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='商品表';

CREATE TABLE `qimall_addons_store_goods_attr`  (
  `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  `goods_id` int(11) NOT NULL DEFAULT 0 COMMENT '商品ID',
  `name` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '规格名称',
  `sign_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '规格ID标识',
  `stock` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '库存',
  `price` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '价格',
  `original_price` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '原价',
  `cost_price` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '成本价',
  `goods_no` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '货号',
  `weight` int(11) NOT NULL DEFAULT 0 COMMENT '重量（克）',
  `pic_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '规格图片',
  `status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '状态[1正常 -1删除]',
  `version` bigint(11) NOT NULL DEFAULT 0 COMMENT '版本',
  `sort` int(11) NOT NULL DEFAULT 999 COMMENT '排序',
  `created_at` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
  `updated_at` int(11) NOT NULL DEFAULT 0 COMMENT '修改时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `goods_id`(`goods_id`) USING BTREE,
  INDEX `attr_name_goods_id_index`(`goods_id`) USING BTREE
) ENGINE = InnoDB  CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '商品规格表' ROW_FORMAT = COMPACT;

CREATE TABLE `qimall_addons_store_goods_cate`  (
  `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  `mall_id` int(11) NOT NULL DEFAULT 0,
  `store_id` int(11) NOT NULL DEFAULT 0,
  `cate_id` int(11) NOT NULL DEFAULT 0 COMMENT '主商城分类id',
  `parent_id` int(11) NOT NULL DEFAULT 0 COMMENT '父级ID',
  `name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '分类名称',
  `pic` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
  `big_pic` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
  `advert_pic` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '广告图片',
  `advert_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '广告链接',
  `advert_open_type` varchar(65) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '打开方式',
  `advert_params` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '导航参数',
  `is_show` tinyint(1) NOT NULL DEFAULT 1 COMMENT '是否显示',
  `status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '状态[0禁用 1启用 -1删除]',
  `sort` int(11) NOT NULL DEFAULT 999 COMMENT '排序',
  `created_at` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
  `updated_at` int(11) NOT NULL DEFAULT 0 COMMENT '修改时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `mall_id_mch_id_index`(`mall_id`) USING BTREE,
  INDEX `parent_id`(`parent_id`) USING BTREE
) ENGINE = InnoDB  CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '商品分类表' ROW_FORMAT = COMPACT;

CREATE TABLE `qimall_addons_store_goods_cate_relate`  (
  `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  `cate_id` int(10) NULL DEFAULT 0 COMMENT '分类id',
  `goods_id` int(10) NULL DEFAULT 0 COMMENT '产品id',
  `created_at` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
  `updated_at` int(11) NOT NULL DEFAULT 0 COMMENT '修改时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `tag_id`(`cate_id`) USING BTREE,
  INDEX `article_id`(`goods_id`) USING BTREE
) ENGINE = InnoDB  CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '商品分类关联表' ROW_FORMAT = DYNAMIC;

CREATE TABLE `qimall_addons_store_goods_extra` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `mall_id` int(11) NOT NULL DEFAULT '0' COMMENT '商城id',
    `store_id` int(11) NOT NULL DEFAULT '0' COMMENT '门店id',
    `goods_id` int(11) NOT NULL DEFAULT '0' COMMENT '商品ID',
    `full_reduce_money` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '单品满额减免金额',
    `full_reduce_price_limit` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '单品满额金额阈值',
    `score_give_setting` longtext COMMENT '积分赠送设置',
    `score_deduct_setting` longtext COMMENT '积分抵扣设置',
    `currency_deduct_setting` longtext COMMENT '货币营销设置',
    `is_member_price` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否参与会员价 [1是 0 否]',
    `member_price_setting` longtext COMMENT '会员价格设置',
    `member_buy_limit_setting` longtext COMMENT '会员限购设置',
    `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态[1正常 -1删除]',
    `created_at` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
    `updated_at` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
    PRIMARY KEY (`id`) USING BTREE,
    KEY `goods_id` (`goods_id`) USING BTREE,
    KEY `mall_id_goods_id` (`mall_id`,`goods_id`) USING BTREE,
    KEY `mall_id_store_id_goods_id` (`mall_id`,`store_id`,`goods_id`) USING BTREE
) ENGINE=InnoDB  DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='商品额外信息表';

CREATE TABLE `qimall_addons_store_goods_model`  (
  `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  `mall_id` int(11) NOT NULL DEFAULT 0,
  `store_id` int(11) NOT NULL DEFAULT 0,
  `goods_id` int(11) NOT NULL DEFAULT 0 COMMENT '商品id',
  `content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '内容',
  `status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '状态[0禁用 1启用 -1删除]',
  `created_at` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
  `updated_at` int(11) NOT NULL DEFAULT 0 COMMENT '修改时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB  CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '模式' ROW_FORMAT = COMPACT;

CREATE TABLE `qimall_addons_store_goods_ranking` (
   `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
   `mall_id` int(11) NOT NULL DEFAULT '0',
   `store_id` int(11) NOT NULL DEFAULT '0' COMMENT '门店id',
   `goods_id` int(11) NOT NULL DEFAULT '0' COMMENT '商品id',
   `sales_money` int(11) NOT NULL DEFAULT '0' COMMENT '销售额',
   `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态[0禁用 1启用 -1删除]',
   `created_at` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
   `updated_at` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
   PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='门店商品排行榜';

CREATE TABLE `qimall_addons_store_menu`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '标题',
  `app_id` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '0' COMMENT '应用id',
  `pid` int(50) UNSIGNED NULL DEFAULT 0 COMMENT '上级id',
  `url` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '路由',
  `icon` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '样式',
  `level` tinyint(1) UNSIGNED NULL DEFAULT 1 COMMENT '级别',
  `dev` tinyint(4) UNSIGNED NULL DEFAULT 0 COMMENT '开发者[0:都可见;开发模式可见]',
  `sort` int(5) NULL DEFAULT 999 COMMENT '排序',
  `params` json NULL COMMENT '参数',
  `tree` varchar(300) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '树',
  `status` tinyint(4) NULL DEFAULT 1 COMMENT '状态[-1:删除;0:禁用;1启用]',
  `created_at` int(10) UNSIGNED NULL DEFAULT 0 COMMENT '添加时间',
  `updated_at` int(10) UNSIGNED NULL DEFAULT 0 COMMENT '修改时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `url`(`url`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = 'o2o菜单' ROW_FORMAT = DYNAMIC;

CREATE TABLE `qimall_addons_store_model` (
      `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
      `mall_id` int(11) NOT NULL DEFAULT '0',
      `store_id` int(11) NOT NULL DEFAULT '0',
      `content` longtext COMMENT '内容',
      `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态[0禁用 1启用 -1删除]',
      `created_at` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
      `updated_at` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
      PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB  DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='门店分佣模式';


CREATE TABLE `qimall_addons_store_notice`  (
  `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  `mall_id` int(11) NOT NULL DEFAULT 0,
  `store_id` int(11) NOT NULL DEFAULT 0 COMMENT '门店id',
  `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '标题',
  `content` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '内容',
  `status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '状态[0禁用 1启用 -1删除]',
  `created_at` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
  `updated_at` int(11) NOT NULL DEFAULT 0 COMMENT '修改时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB  CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '店铺公告' ROW_FORMAT = COMPACT;

CREATE TABLE `qimall_addons_store_order` (
      `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '订单id',
      `mch_id` int(11) NOT NULL DEFAULT '0' COMMENT '多商户id，0表示商城订单',
      `store_id` int(11) NOT NULL DEFAULT '0' COMMENT '门店id，0表示商城订单',
      `mall_id` int(11) NOT NULL DEFAULT '0' COMMENT '商城ID',
      `user_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '用户id',
      `order_no` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '订单编号',
      `out_trade_no` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '系统支付流水号',
      `mobile` varchar(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '收货人的手机号码',
      `province` int(11) DEFAULT '0' COMMENT '收货人所在省',
      `city` int(11) DEFAULT '0' COMMENT '收货人所在城市',
      `area` int(11) DEFAULT '0' COMMENT '收货人所在街道',
      `town` int(11) NOT NULL DEFAULT '0' COMMENT '镇id',
      `address` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '详细地址',
      `region_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '地区名称（省市区[乡/镇]）',
      `zip` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '收货人邮编',
      `receiver_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '收货人姓名',
      `remark` varchar(255) NOT NULL DEFAULT '' COMMENT '用户订单备注',
      `seller_remark` varchar(255) NOT NULL DEFAULT '' COMMENT '商家订单备注',
      `shipping_type` tinyint(4) DEFAULT '1' COMMENT '订单配送方式【1物流配送 2买家自提 3商家配送】',
      `shipping_money` decimal(10,2) DEFAULT '0.00' COMMENT '订单运费',
      `refund_money` decimal(10,2) DEFAULT '0.00' COMMENT '订单退款金额',
      `pay_money` decimal(10,2) DEFAULT '0.00' COMMENT '订单实付金额',
      `goods_price` decimal(19,2) DEFAULT '0.00' COMMENT '商品优惠后总价',
      `original_goods_price` decimal(10,2) DEFAULT '0.00' COMMENT '商品原本总价',
      `ip` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '买家ip',
      `coupon_id` int(11) DEFAULT '0' COMMENT '优惠券券id',
      `coupon_money` decimal(10,2) DEFAULT '0.00' COMMENT '优惠券券支付金额',
      `score` decimal(10,2) DEFAULT '0.00' COMMENT '订单消耗积分',
      `score_money` decimal(10,2) DEFAULT '0.00' COMMENT '订单消耗积分抵多少钱',
      `order_status` int(6) DEFAULT '0' COMMENT '订单状态',
      `pay_status` tinyint(4) DEFAULT '0' COMMENT '订单付款状态',
     `shipping_status` tinyint(4) DEFAULT '0' COMMENT '订单配送状态',
      `review_status` tinyint(4) DEFAULT '0' COMMENT '订单评价状态',
      `is_feedback` tinyint(4) DEFAULT '0' COMMENT '订单售后状态:0:未售后；1：售后中；2：售后完成',
      `payment_type` tinyint(4) DEFAULT '0' COMMENT '支付类型',
      `marketing_id` int(11) NOT NULL DEFAULT '0' COMMENT '营销活动id',
      `marketing_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '营销活动类型',
      `invoice_id` int(11) DEFAULT NULL COMMENT '发票id',
      `status` tinyint(4) DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
      `is_comment` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否评价 0为未评价 1为已评价 2为已追评',
      `is_recycle` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否加入回收站【1是 0否】',
      `is_virtual` tinyint(1) DEFAULT '0' COMMENT '是否包含虚拟商品【1是 0否】',
      `is_new_user` tinyint(4) DEFAULT '0' COMMENT '是否新顾客',
      `pay_time` int(11) DEFAULT '0' COMMENT '订单付款时间',
      `shipping_time` int(11) DEFAULT '0' COMMENT '买家要求配送时间',
      `sign_time` int(11) DEFAULT '0' COMMENT '买家签收时间',
      `consign_time` int(11) DEFAULT '0' COMMENT '卖家发货时间',
      `finish_time` int(11) DEFAULT '0' COMMENT '订单完成时间',
      `close_time` int(11) DEFAULT '0' COMMENT '关闭的时间',
      `extra_info` text COMMENT '额外信息',
      `created_at` int(10) DEFAULT '0' COMMENT '创建时间',
      `updated_at` int(10) unsigned DEFAULT '0' COMMENT '更新时间',
      `order_source` varchar(255) DEFAULT '' COMMENT '订单来源：juhe_shop=>聚合供应链',
      `supplier_type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '供应者类型：0:自身；1：商城；2：o2o；3：多商户',
      PRIMARY KEY (`id`) USING BTREE,
      KEY `order_user_id` (`user_id`) USING BTREE,
      KEY `order_order_no` (`order_no`) USING BTREE,
      KEY `order_pay_status` (`pay_status`) USING BTREE,
      KEY `order_status` (`order_status`) USING BTREE
) ENGINE=InnoDB  DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='门店订单表';

CREATE TABLE `qimall_addons_store_order_detail` (
      `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '订单项ID',
      `order_id` int(11) NOT NULL DEFAULT '0' COMMENT '订单ID',
      `main_order_detail_id` int(11) NOT NULL DEFAULT '0' COMMENT '主商城订单id',
      `user_id` int(11) NOT NULL DEFAULT '0' COMMENT '用户id',
      `mall_id` int(11) NOT NULL DEFAULT '0' COMMENT '商城ID',
      `mch_id` int(11) NOT NULL DEFAULT '0' COMMENT '多商户id',
      `goods_id` int(11) NOT NULL DEFAULT '0' COMMENT '商品ID',
      `goods_name` varchar(200) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '商品名称',
      `goods_attr_id` int(11) NOT NULL DEFAULT '0' COMMENT '规格ID',
      `goods_attr_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '规格名称',
      `sign_id` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '规格ID标识',
      `attr_groups_format` longtext COLLATE utf8mb4_unicode_ci COMMENT '格式化规格组',
      `price` decimal(19,2) NOT NULL DEFAULT '0.00' COMMENT '商品价格',
      `cost_price` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '商品成本价',
      `original_goods_price` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '商品原本总价',
      `goods_price` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '商品优惠后总价',
      `num` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '购买数量',
      `adjust_money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '调整金额',
      `pic_url` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '商品图片',
      `marketing_id` int(11) NOT NULL DEFAULT '0' COMMENT '促销ID',
      `marketing_type` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0' COMMENT '促销类型',
      `order_type` int(11) NOT NULL DEFAULT '1' COMMENT '订单类型',
      `give_score` int(11) NOT NULL DEFAULT '0' COMMENT '赠送积分数量',
      `order_status` int(11) NOT NULL DEFAULT '0' COMMENT '订单状态【0待付款 1待发货 2 已发货 3已收货 4已完成 -1申请售后 -2售后中 -3售后完成 -4 已关闭 -5撤销售后】',
      `shipping_status` int(11) NOT NULL DEFAULT '0' COMMENT '物流状态【1已发货 0待发货】',
      `is_feedback` int(1) NOT NULL DEFAULT '0' COMMENT '订单售后状态【0未售后 1售后中 2售后完成】',
      `remark` varchar(200) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '备注',
      `is_evaluate` smallint(6) NOT NULL DEFAULT '0' COMMENT '是否评价 【0未评价 1已评价 2已追评】',
      `refund_balance_money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '订单退款余额',
      `is_virtual` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否包含 虚拟商品   0 不包含  1  包含',
      `status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
      `extra_info` text CHARACTER SET utf8mb4 COMMENT '额外信息',
      `created_at` int(10) NOT NULL DEFAULT '0',
      `updated_at` int(10) NOT NULL DEFAULT '0',
      PRIMARY KEY (`id`) USING BTREE,
      KEY `order_detail_goods_buyer_id` (`user_id`) USING BTREE,
      KEY `order_detail_goods_goods_id` (`goods_id`) USING BTREE,
      KEY `order_detail_goods_order_id` (`order_id`) USING BTREE,
      KEY `order_detail_goods_marketing_id` (`marketing_id`) USING BTREE,
      KEY `order_detail_goods_attr_id` (`goods_attr_id`) USING BTREE
) ENGINE=InnoDB  DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='门店订单商品详情表';

CREATE TABLE `qimall_addons_store_order_marketing` (
   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
   `mall_id` int(11) NOT NULL DEFAULT '0' COMMENT 'mall_id',
   `store_id` int(11) NOT NULL DEFAULT '0' COMMENT '门店id',
   `order_detail_id` int(11) NOT NULL DEFAULT '0' COMMENT '订单详情id',
   `give_score` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '赠送积分',
   `give_balance` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '赠送余额',
   `give_currency` text COMMENT '赠送货币(json字符串保存)',
   `deduct_score` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '减扣积分',
   `deduct_currency` text COMMENT '减扣货币(json字符串保存)',
   `pay_money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '商品实际付款金额，单位：元',
   `full_reduce_money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '满减金额，单位：元',
   `coupon_discount_money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '优惠券优惠金额，单位：元',
   `member_price_deduct` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '会员价优惠',
   `user_coupon_id` varchar(1000) NOT NULL DEFAULT '' COMMENT '用户优惠券id map',
   `agent_deduct` decimal(10,2) NOT NULL DEFAULT '0.00',
   `agent_extra` varchar(255) NOT NULL DEFAULT '' COMMENT '经销商内购商品抵扣额外信息',
  `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
   `created_at` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
   `updated_at` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '修改时间',
   PRIMARY KEY (`id`) USING BTREE,
   KEY `order_detail_id` (`order_detail_id`) USING BTREE
) ENGINE=InnoDB  DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='订单营销赠扣表';

CREATE TABLE `qimall_addons_store_refund_address`  (
  `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  `mall_id` int(11) NOT NULL DEFAULT 0,
  `store_id` int(11) NOT NULL DEFAULT 0 COMMENT '门店id',
  `refund_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '退货名称',
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '联系人',
  `mobile` varchar(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '退换货手机号',
  `address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '退换货地址',
  `status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '状态[0禁用 1启用 -1删除]',
  `created_at` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
  `updated_at` int(11) NOT NULL DEFAULT 0 COMMENT '修改时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB  CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '门店退货地址' ROW_FORMAT = COMPACT;

CREATE TABLE `qimall_addons_store_settings` (
       `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
       `mall_id` int(10) unsigned NOT NULL,
       `store_id` int(10) unsigned NOT NULL,
      `store_service_fee` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否收取服务费，1：收取；0：不收取',
       `store_service_ratio` decimal(5,3) NOT NULL DEFAULT '0.000' COMMENT '门店服务费比例',
       `store_settle_type` tinyint(4) NOT NULL DEFAULT '1' COMMENT '服务费计算方式，1：门店商品售价（分佣平台承担）；2：订单实际支付金额（分佣平台承担）；3：商品成本+运费（不包含服务费）；4：订单实际支付减去（分销商提成、经销商提成、区域代理、股东分红）',
       `store_settle_scene` tinyint(4) NOT NULL DEFAULT '1' COMMENT '服务费计算触发场景，1：订单支付；2：订单完成',
       `store_commission_authority` text COMMENT '分销/营销权限，存 json，key 区别各个不同应用',
       `cachier_service_ratio` decimal(5,3) NOT NULL DEFAULT '0.000' COMMENT '收银台服务费比例',
       `cashier_member_status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否启用会员价，1：启用；0：不启用',
       `cashier_member_settings` text COMMENT '会员各个等级比例设置，存 json',
       `cashier_distribution_is_enable` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否开启分销设置，1：是；0：否',
       `cashier_distribution_settings` text COMMENT '分销各个等级佣金比例设置，存 json',
        `cashier_agent_is_enable` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否开启经销设置，1：是；0：否',
       `cashier_agent_settings` text COMMENT '经销各个等级佣金比例设置，存 json',
       `status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '状态，-1：已删除；0：禁用；1：正常',
       `created_at` int(10) unsigned NOT NULL DEFAULT '0',
        `updated_at` int(10) unsigned NOT NULL DEFAULT '0',
       PRIMARY KEY (`id`),
       KEY `idx_mall_store` (`mall_id`,`store_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COMMENT='门店配置记录表';

CREATE TABLE `qimall_addons_store_statistics` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `mall_id` int(11) NOT NULL DEFAULT '0' COMMENT '商城id',
  `store_id` int(11) NOT NULL DEFAULT '0' COMMENT '门店id',
  `date_time` varchar(50) NOT NULL DEFAULT '' COMMENT '月份',
  `income_money` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '收入',
  `created_at` int(11) NOT NULL DEFAULT '0',
  `updated_at` int(11) NOT NULL DEFAULT '0',
  `status` tinyint(1) DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB  DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='门店月份统计';

CREATE TABLE `qimall_addons_store_user`  (
  `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  `mall_id` int(11) NOT NULL DEFAULT 0,
  `store_id` int(11) NOT NULL DEFAULT 0 COMMENT '门店id',
  `user_id` int(11) NOT NULL DEFAULT 0 COMMENT '会员id',
  `last_time` int(11) NOT NULL DEFAULT 0 COMMENT '最近下单时间',
  `order_nums` int(11) NOT NULL DEFAULT 0 COMMENT '店内下单数',
  `pay_nums` int(11) NOT NULL DEFAULT 0 COMMENT '店内消费订单数',
  `pay_money` decimal(12, 2) NOT NULL DEFAULT 0.00 COMMENT '店内消费金额',
  `refund_nums` int(11) NOT NULL DEFAULT 0 COMMENT '累计退款订单数',
  `refund_money` decimal(12, 2) NOT NULL DEFAULT 0.00 COMMENT '累计退款金额',
  `status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '状态[0禁用 1启用 -1删除]',
  `created_at` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
  `updated_at` int(11) NOT NULL DEFAULT 0 COMMENT '修改时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB  CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '门店会员' ROW_FORMAT = COMPACT;

CREATE TABLE `qimall_addons_store_user_buy`  (
  `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  `mall_id` int(11) NOT NULL DEFAULT 0,
  `store_id` int(11) NOT NULL DEFAULT 0 COMMENT '门店id',
  `user_id` int(11) NOT NULL DEFAULT 0 COMMENT '会员id',
  `goods_id` int(11) NOT NULL DEFAULT 0 COMMENT 'o2o商品id',
  `nums` int(11) NOT NULL DEFAULT 0 COMMENT '付款件数',
  `pay_money` decimal(12, 2) NOT NULL DEFAULT 0.00 COMMENT '付款金额',
  `status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '状态[0禁用 1启用 -1删除]',
  `created_at` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
  `updated_at` int(11) NOT NULL DEFAULT 0 COMMENT '修改时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB  CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '门店会员购买记录' ROW_FORMAT = COMPACT;


CREATE TABLE `qimall_addons_store_user_enter_qualification` (
      `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
      `mall_id` int(10) unsigned NOT NULL,
      `user_id` int(10) unsigned NOT NULL,
      `enter_mode` tinyint(4) NOT NULL DEFAULT '1' COMMENT '入驻模式，1：免费入驻，2：购买指定商品入驻',
      `goods_id` int(11) NOT NULL DEFAULT '0' COMMENT '已经购买的商品 id',
      `status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '状态，-1：已删除；0：禁用；1：正常',
      `created_at` int(10) unsigned NOT NULL DEFAULT '0',
      `updated_at` int(10) unsigned NOT NULL DEFAULT '0',
      PRIMARY KEY (`id`),
      KEY `idx_mu_id` (`mall_id`,`user_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COMMENT='会员入驻资格记录（监听支付事件写入数据）';

CREATE TABLE `qimall_addons_store_withdraw_log` (
   `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
   `mall_id` int(11) NOT NULL DEFAULT '0' COMMENT '商城id',
   `store_id` int(11) NOT NULL DEFAULT '0' COMMENT '门店id',
   `user_id` int(11) NOT NULL DEFAULT '0' COMMENT '会员id',
   `order_no` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '提现订单号',
   `num` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '提现金额',
   `actual_num` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '实际到账金额',
   `poundage_num` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '手续费扣除金额',
   `poundage_ratio` float NOT NULL DEFAULT '0' COMMENT '手续费比例',
   `type` varchar(45) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '提现方式 bank--银行转账 balance--打款到余额',
   `extra` longtext COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '额外信息',
   `withdraw_status` int(11) NOT NULL DEFAULT '0' COMMENT '提现状态 0--待打款 --已打款 2--驳回 ',
   `status` int(11) NOT NULL DEFAULT '0' COMMENT '状态[0禁用 1启用 -1删除]',
   `remark` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '备注',
   `created_at` int(11) DEFAULT '0' COMMENT '添加时间戳',
   `updated_at` int(11) DEFAULT '0' COMMENT '更新时间戳',
   PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='门店提现记录表';


CREATE TABLE `qimall_addons_store_cashier_extra` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `mall_id` int(11) NOT NULL DEFAULT '0' COMMENT '商城id',
  `store_id` int(11) NOT NULL DEFAULT '0' COMMENT '门店id',
  `full_reduce_money` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '单品满额减免金额',
  `full_reduce_price_limit` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '单品满额金额阈值',
  `score_give_setting` longtext COMMENT '积分赠送设置',
  `score_deduct_setting` longtext COMMENT '积分抵扣设置',
  `currency_deduct_setting` longtext COMMENT '货币营销设置',
  `is_member_price` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否参与会员价 [1是 0 否]',
  `member_price_setting` longtext COMMENT '会员价格设置',
 `member_buy_limit_setting` longtext COMMENT '会员限购设置',
  `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态[1正常 -1删除]',
  `created_at` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
  `updated_at` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='收银额外信息表';

INSERT INTO `qimall_addons_store_menu`(`id`, `title`, `app_id`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`) VALUES (1, '概况', '0', 0, 'store/client/index/index', 'el-icon-s-platform', 1, 0, 999, NULL, '', 1, 0, 0);
INSERT INTO `qimall_addons_store_menu`(`id`, `title`, `app_id`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`) VALUES (2, '商品', '0', 0, 'store/client/goods/index', 'el-icon-s-goods', 1, 0, 999, NULL, '', 1, 0, 0);
INSERT INTO `qimall_addons_store_menu`(`id`, `title`, `app_id`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`) VALUES (3, '订单', '0', 0, 'store/client/order/index', 'el-icon-s-order', 1, 0, 999, NULL, '', 1, 0, 0);
INSERT INTO `qimall_addons_store_menu`(`id`, `title`, `app_id`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`) VALUES (4, '会员', '0', 0, 'store/client/user/index', 'el-icon-user', 1, 0, 999, NULL, '', 1, 0, 0);
INSERT INTO `qimall_addons_store_menu`(`id`, `title`, `app_id`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`) VALUES (5, '核销', '0', 0, 'store/client/clerk/index', 'el-icon-s-ticket', 1, 0, 999, NULL, '', 1, 0, 0);
INSERT INTO `qimall_addons_store_menu`(`id`, `title`, `app_id`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`) VALUES (6, '收银', '0', 0, 'store/client/cash/index', 'el-icon-money', 1, 0, 999, NULL, '', 1, 0, 0);
INSERT INTO `qimall_addons_store_menu`(`id`, `title`, `app_id`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`) VALUES (7, '资产', '0', 0, 'store/client/finance/index', 'el-icon-coin', 1, 0, 999, NULL, '', 1, 0, 0);
INSERT INTO `qimall_addons_store_menu`(`id`, `title`, `app_id`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`) VALUES (8, '设置', '0', 0, 'store/client/setting/index', 'el-icon-setting', 1, 0, 999, NULL, '', 1, 0, 0);
INSERT INTO `qimall_addons_store_menu`(`id`, `title`, `app_id`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`) VALUES (9, '商品管理', '0', 2, 'store/client/goods/index', '', 2, 0, 999, NULL, '', 1, 0, 0);
INSERT INTO `qimall_addons_store_menu`(`id`, `title`, `app_id`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`) VALUES (10, '商品分类', '0', 2, 'store/client/cate/index', '', 2, 0, 999, NULL, '', 1, 0, 0);
INSERT INTO `qimall_addons_store_menu`(`id`, `title`, `app_id`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`) VALUES (11, '选品中心', '0', 2, 'store/client/goods/supply', '', 2, 0, 999, NULL, '', -1, 0, 0);
INSERT INTO `qimall_addons_store_menu`(`id`, `title`, `app_id`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`) VALUES (12, '订单管理', '0', 3, 'store/client/order/index', '', 2, 0, 999, NULL, '', 1, 0, 0);
INSERT INTO `qimall_addons_store_menu`(`id`, `title`, `app_id`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`) VALUES (13, '售后订单', '0', 3, 'store/client/order/refund', '', 2, 0, 999, NULL, '', 1, 0, 0);
INSERT INTO `qimall_addons_store_menu`(`id`, `title`, `app_id`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`) VALUES (14, '外部订单', '0', 3, 'store/client/order/platform-order', '', 2, 0, 999, NULL, '', -1, 0, 0);
INSERT INTO `qimall_addons_store_menu`(`id`, `title`, `app_id`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`) VALUES (15, '资产概况', '0', 7, 'store/client/finance/index', '', 2, 0, 999, NULL, '', 1, 0, 0);
INSERT INTO `qimall_addons_store_menu`(`id`, `title`, `app_id`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`) VALUES (16, '收入明细', '0', 7, 'store/client/finance/income-log', '', 2, 0, 999, NULL, '', 1, 0, 0);
INSERT INTO `qimall_addons_store_menu`(`id`, `title`, `app_id`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`) VALUES (17, '资金提现', '0', 7, 'store/client/finance/withdrawal', '', 2, 0, 999, NULL, '', 1, 0, 0);
INSERT INTO `qimall_addons_store_menu`(`id`, `title`, `app_id`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`) VALUES (18, '运费模板', '0', 2, 'store/client/setting/freight-rules', '', 2, 0, 999, NULL, '', 1, 0, 0);
INSERT INTO `qimall_addons_store_menu`(`id`, `title`, `app_id`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`) VALUES (19, '店铺信息', '0', 8, 'store/client/setting/index', '', 2, 0, 999, NULL, '', 1, 0, 0);
INSERT INTO `qimall_addons_store_menu`(`id`, `title`, `app_id`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`) VALUES (20, '退货地址', '0', 8, 'store/client/refund-address/index', '', 2, 0, 999, NULL, '', 1, 0, 0);
INSERT INTO `qimall_addons_store_menu`(`id`, `title`, `app_id`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`) VALUES (21, '店铺公告', '0', 8, 'store/client/notice/index', '', 2, 0, 999, NULL, '', 1, 0, 0);
INSERT INTO `qimall_addons_store_menu`(`id`, `title`, `app_id`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`) VALUES (22, '模式设置', '0', 8, 'store/client/setting/goods-model', '', 2, 0, 999, NULL, '', 1, 0, 0);
INSERT INTO `qimall_addons_store_menu`(`id`, `title`, `app_id`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`) VALUES (23, '运费模板', '0', 8, 'store/client/setting/freight-rules', '', 2, 0, 999, NULL, '', 1, 0, 0);
INSERT INTO `qimall_addons_store_menu`(`id`, `title`, `app_id`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`) VALUES (24, '核销员', '0', 5, 'store/client/clerk/index', '', 3, 0, 999, NULL, '', 1, 0, 0);
INSERT INTO `qimall_addons_store_menu`(`id`, `title`, `app_id`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`) VALUES (25, '核销明细', '0', 5, 'store/client/clerk/clerk-log', '', 3, 0, 999, NULL, '', 1, 0, 0);



ALTER table qimall_addons_store_cashier_extra add `preferential_deduction` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '优惠抵扣开关按钮';
ALTER table qimall_addons_store_cashier_extra add `preferential_gift` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '优惠赠送开关按钮';


ALTER table qimall_addons_store_order_detail add `store_id` int(11) NOT NULL DEFAULT '0' COMMENT '门店id';

INSERT INTO `qimall_addons_store_menu`(`id`,`title`, `app_id`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`) VALUES ('29','预约订单', '0', 3, 'store/client/subscribe/index', '', 2, 0, 999, NULL, '', 1, 0, 0);


ALTER TABLE qimall_addons_store_settings add   `cashier_distribution_settings_score` text COMMENT '分销各个等级积分比例设置，存 json';
ALTER TABLE qimall_addons_store_settings add     `cashier_distribution_is_enable_score` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否开启分销设置，1：是；0：否';


CREATE TABLE `qimall_addons_store_order_give` (
    `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
    `mall_id` int(11) NOT NULL DEFAULT '0' COMMENT 'mall_id',
    `store_id` int(11) NOT NULL DEFAULT '0' COMMENT '门店id',
    `order_id` int(11) NOT NULL DEFAULT '0' COMMENT '订单id',
    `give_score` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '赠送积分',
    `give_coupon` text COMMENT '赠送优惠券(json字符串保存)',
    `give_currency` text COMMENT '赠送货币(json字符串保存)',
    `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
    `created_at` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
    `updated_at` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '修改时间',
    PRIMARY KEY (`id`) USING BTREE,
    KEY `order_id` (`order_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='订单赠送表';


ALTER TABLE qimall_addons_store add   `store_img` varchar(255) NOT NULL DEFAULT '' COMMENT '门店图片';

