<!-- Space: qifu -->
<!-- Parent: 后端技术&知识&规范 -->
<!-- Parent: 技术方案 -->
<!-- Parent: 基建 -->
<!-- Parent: 01-发布文档 -->
<!-- Title: 20250423-电商订单对接发布 -->

<!-- Macro: :anchor\((.*)\):
     Template: ac:anchor
     Anchor: ${1} -->
<!-- Macro: \!\[.*\]\((.+)\)\<\!\-\- width=(.*) \-\-\>
     Template: ac:image
     Url: ${1}
     Width: ${2} -->
<!-- Macro: \<\!\-\- :toc: \-\-\>
     Template: ac:toc
     Printable: 'false'
     MinLevel: 2 
     MaxLevel: 4 -->
<!-- Include: 杂项/声明文件.md -->

<!-- :toc: -->

# 电商订单对接发布

## 发布说明

### RocketMQ配置

#### RocketMQ Topic 创建

- EG_ORDER_SPI_TOPIC
- EG_WEWORK_EVENT_WEBHOOK_TOPIC

#### RocketMQ ConsumerGroup 创建

- egOrderSpiConsumerGroup
- egWeworkEventWebhookConsumerGroup

### 涉及项目

| 项目              | 分支                        | 发布顺序 | 数据库变更                 | 配置变更                    | 负责人 | 备注                         |
|-----------------|---------------------------|------|-----------------------|-------------------------|-----|----------------------------|
| yuanmeng-engine | feat/20250429-web-satrter | 1    |                       |                         | 刘晓华 | 升级 1.1.0                   |
| yuanmeng-parent | feat/20250429-web-satrter | 2    |                       |                         | 刘晓华 | 升级 1.1.0                   |
| qifu-saas-eg    | master                    | 3    | [数据库脚本DDL](#数据库脚本DDL) | [Nacos配置文件](#Nacos配置文件) | 刘晓华 | 注意配置文件中需要修改的部分需要修改为对应环境的数据 |
| pm              | master                    | 4    | [数据库脚本DDL](#数据库脚本DDL) | [Nacos配置文件](#Nacos配置文件) | 刘晓华 | 注意配置文件中需要修改的部分需要修改为对应环境的数据 |

### 附件

#### 数据库脚本DDL

##### qifu-saas-eg数据库DDL

```sql
/*
 Navicat Premium Dump SQL

 Source Server         : DEV-Mysql
 Source Server Type    : MySQL
 Source Server Version : 50743 (5.7.43-log)
 Source Host           : mysql.develop.qifu.com:30336
 Source Schema         : dev_qifu_saas_eg

 Target Server Type    : MySQL
 Target Server Version : 50743 (5.7.43-log)
 File Encoding         : 65001

 Date: 21/03/2025 11:28:05
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for eg_order_app
-- ----------------------------
DROP TABLE IF EXISTS `eg_order_app`;
CREATE TABLE `eg_order_app`
(
    `id`             bigint(20)                                                    NOT NULL AUTO_INCREMENT,
    `channel`        int(4)                                                        NOT NULL COMMENT '渠道：1=eBay',
    `app_name`       varchar(50)                                                   NOT NULL DEFAULT '' COMMENT '渠道：1=eBay',
    `client_id`      varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '客户端id',
    `client_secret`  varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '客户端secret',
    `dev_id`         varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '开发者id',
    `scopes`         text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci         NULL COMMENT '授权范围，+ 号拼接',
    `redirect_uri`   varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '回调链接',
    `attach_info`    text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci         NULL COMMENT '附加信息，Json 格式',
    `create_user_id` bigint(20)                                                    NOT NULL DEFAULT 0 COMMENT '创建人id',
    `create_by`      varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL DEFAULT '' COMMENT '创建人名称',
    `create_time`    bigint(20)                                                    NOT NULL COMMENT '创建时间',
    `update_user_id` bigint(20)                                                    NOT NULL DEFAULT 0 COMMENT '更新人ID',
    `update_by`      varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL DEFAULT '' COMMENT '更新人名称',
    `update_time`    bigint(20)                                                    NOT NULL DEFAULT 0 COMMENT '更新时间',
    `deleted`        bigint(20)                                                    NOT NULL DEFAULT 0 COMMENT '删除标识：0=未删除，id=以删除',
    PRIMARY KEY (`id`) USING BTREE,
    INDEX `idx_channel` (`channel`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 2
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '电商应用表'
  ROW_FORMAT = DYNAMIC;


-- ----------------------------
-- Table structure for eg_order_app_seller
-- ----------------------------
DROP TABLE IF EXISTS `eg_order_app_seller`;
CREATE TABLE `eg_order_app_seller`
(
    `id`                         bigint(20)                                                    NOT NULL AUTO_INCREMENT,
    `channel`                    int(4)                                                        NOT NULL COMMENT '渠道：1=eBay',
    `seller_id`                  varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '卖家id',
    `order_app_id`               bigint(20)                                                    NOT NULL COMMENT '应用id',
    `region`                     varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL DEFAULT '' COMMENT '所属区域，对照 client 包中的 xxxRegionEnum',
    `spi_server_codes`           varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '关联服务编码，spi调用使用。, 分割',
    `refresh_token`              varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '刷新token',
    `refresh_token_expires_in`   int(8)                                                        NOT NULL DEFAULT 0 COMMENT '刷新token过期时间',
    `refresh_token_expires_time` bigint(20)                                                    NOT NULL DEFAULT 0 COMMENT '过期时间',
    `attach_info`                text                                                                   DEFAULT NULL COMMENT '附加参数，json字段，参考 EgOrderAppSellerAttachInfo',
    `create_user_id`             bigint(20)                                                    NOT NULL DEFAULT 0 COMMENT '创建人id',
    `create_by`                  varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL DEFAULT '' COMMENT '创建人名称',
    `create_time`                bigint(20)                                                    NOT NULL COMMENT '创建时间',
    `update_user_id`             bigint(20)                                                    NOT NULL DEFAULT 0 COMMENT '更新人ID',
    `update_by`                  varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL DEFAULT '' COMMENT '更新人名称',
    `update_time`                bigint(20)                                                    NOT NULL DEFAULT 0 COMMENT '更新时间',
    `deleted`                    bigint(20)                                                    NOT NULL DEFAULT 0 COMMENT '删除标识：0=未删除，id=以删除',
    PRIMARY KEY (`id`) USING BTREE,
    INDEX `idx_channel_seller_id_update_time` (`channel`, `seller_id`, `update_time`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 2
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '卖家电商应用表'
  ROW_FORMAT = DYNAMIC;


-- ----------------------------
-- Table structure for eg_order_order
-- ----------------------------
DROP TABLE IF EXISTS `eg_order_order`;
CREATE TABLE `eg_order_order`
(
    `id`                       bigint(20)                                                    NOT NULL AUTO_INCREMENT,
    `channel`                  int(4)                                                        NOT NULL COMMENT '渠道：1=eBay',
    `order_app_seller_id`      varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '卖家id',
    `order_id`                 varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '电商订单id',
    `status`                   varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL DEFAULT '' COMMENT '订单状态，参考 OrderStatusEnum',
    `buyer_id`                 varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '买家ID',
    `buyer_remark`             varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '买家备注',
    `buyer_name`               varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '买家全名',
    `buyer_phone`              varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL DEFAULT '' COMMENT '发货收件人的主要电话号码',
    `buyer_email`              varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '买家邮箱',
    `buyer_tax_id`             varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '买家税号',
    `buyer_tax_type`           varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL DEFAULT '' COMMENT '买家税号类型',
    `buyer_company_name`       varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '买家公司名称',
    `receiver_address_line1`   varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '街道地址的第一行',
    `receiver_address_line2`   varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '街道地址的第二行',
    `receiver_address_detail`  varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '完整的收件人详细地址',
    `receiver_city`            varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL DEFAULT '' COMMENT '配送目的地所在的城市',
    `receiver_country_code`    varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL DEFAULT '' COMMENT '配送目的地所在的国家/地区',
    `receiver_province`        varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '配送目的地的州或省',
    `receiver_postal_code`     varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL DEFAULT '' COMMENT '配送目的地的邮政编码',
    `cancel_state`             varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL DEFAULT '' COMMENT '订单取消状态，NONE_REQUESTED 表示尚未针对该订单提出取消请求',
    `cancelled_date`           varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL DEFAULT '' COMMENT '订单取消时间',
    `creation_date`            varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL DEFAULT '' COMMENT '订单创建时间',
    `creation_date_time`       bigint(20)                                                    NOT NULL DEFAULT 0 COMMENT '订单创建时间的时间戳',
    `last_modified_date`       varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL DEFAULT '' COMMENT '订单修改时间',
    `last_modified_date_time`  bigint(20)                                                    NOT NULL DEFAULT 0 COMMENT '订单修改时间的时间戳',
    `order_fulfillment_status` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL DEFAULT '' COMMENT '订单履行完成的程度，参考 com.yuanmeng.qifu.eg.feign.order.constants.OrderFulfillmentStatusEnum',
    `order_payment_status`     varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL DEFAULT '' COMMENT '订单支付状态，可能的值有 FAILED（买家付款或退款失败）、FULLY_REFUNDED（订单全额退款）、PAID（订单已全额支付）、PARTIALLY_REFUNDED（订单部分退款）、PENDING（买家付款或卖家退款待处理）',
    `seller_id`                varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '销售订单的卖家的唯一用户 ID',
    `original_md5`             varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '参数md5',
    `create_user_id`           bigint(20)                                                    NOT NULL DEFAULT 0 COMMENT '创建人id',
    `create_by`                varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL DEFAULT '' COMMENT '创建人名称',
    `create_time`              bigint(20)                                                    NOT NULL COMMENT '创建时间',
    `update_user_id`           bigint(20)                                                    NOT NULL DEFAULT 0 COMMENT '更新人ID',
    `update_by`                varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL DEFAULT '' COMMENT '更新人名称',
    `update_time`              bigint(20)                                                    NOT NULL DEFAULT 0 COMMENT '更新时间',
    `deleted`                  bigint(20)                                                    NOT NULL DEFAULT 0 COMMENT '删除标识：0=未删除，id=以删除',
    PRIMARY KEY (`id`) USING BTREE,
    INDEX `idx_channel_seller_id_order_id` (`channel`, `order_app_seller_id`, `order_id`) USING BTREE,
    INDEX `idx_last_modified_time` (`channel`, `order_app_seller_id`, `last_modified_date_time`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 1
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '电商订单表'
  ROW_FORMAT = DYNAMIC;


-- ----------------------------
-- Table structure for eg_order_order_detail
-- ----------------------------
DROP TABLE IF EXISTS `eg_order_order_detail`;
CREATE TABLE `eg_order_order_detail`
(
    `id`             bigint(20)                                                    NOT NULL AUTO_INCREMENT,
    `order_id`       bigint(20)                                                    NOT NULL DEFAULT 0 COMMENT 'order 表 id',
    `line_item_id`   varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '订单行项目的唯一标识符。一旦承诺从卖方处购买，就会创建此字段。',
    `quantity`       int(8)                                                        NOT NULL DEFAULT 0 COMMENT '订单中行项目的单位数',
    `title`          varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT 'listing title',
    `sku`            varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '卖家定义的库存单位 （SKU）。此库存编码在卖家的库存中必须是唯一的。',
    `create_user_id` bigint(20)                                                    NOT NULL DEFAULT 0 COMMENT '创建人id',
    `create_by`      varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL DEFAULT '' COMMENT '创建人名称',
    `create_time`    bigint(20)                                                    NOT NULL COMMENT '创建时间',
    `update_user_id` bigint(20)                                                    NOT NULL DEFAULT 0 COMMENT '更新人ID',
    `update_by`      varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL DEFAULT '' COMMENT '更新人名称',
    `update_time`    bigint(20)                                                    NOT NULL DEFAULT 0 COMMENT '更新时间',
    `deleted`        bigint(20)                                                    NOT NULL DEFAULT 0 COMMENT '删除标识：0=未删除，id=以删除',
    PRIMARY KEY (`id`) USING BTREE,
    INDEX `idx_order_id` (`order_id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 1
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '电商平台订单详情'
  ROW_FORMAT = DYNAMIC;


-- ----------------------------
-- Table structure for eg_order_order_original
-- ----------------------------
DROP TABLE IF EXISTS `eg_order_order_original`;
CREATE TABLE `eg_order_order_original`
(
    `id`             bigint(20)                                                   NOT NULL AUTO_INCREMENT,
    `order_id`       bigint(20)                                                   NOT NULL DEFAULT 0 COMMENT 'order 表 id',
    `original`       text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci        NULL COMMENT '原始订单信息',
    `create_user_id` bigint(20)                                                   NOT NULL DEFAULT 0 COMMENT '创建人id',
    `create_by`      varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '创建人名称',
    `create_time`    bigint(20)                                                   NOT NULL COMMENT '创建时间',
    `update_user_id` bigint(20)                                                   NOT NULL DEFAULT 0 COMMENT '更新人ID',
    `update_by`      varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '更新人名称',
    `update_time`    bigint(20)                                                   NOT NULL DEFAULT 0 COMMENT '更新时间',
    `deleted`        bigint(20)                                                   NOT NULL DEFAULT 0 COMMENT '删除标识：0=未删除，id=以删除',
    PRIMARY KEY (`id`) USING BTREE,
    INDEX `idx_order_id` (`order_id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 1
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '电商平台订单原始信息表'
  ROW_FORMAT = DYNAMIC;


-- ----------------------------
-- Table structure for eg_spi
-- ----------------------------
DROP TABLE IF EXISTS `eg_spi`;
CREATE TABLE `eg_spi`
(
    `id`                 bigint(20)                                                    NOT NULL AUTO_INCREMENT,
    `type`               int(4)                                                        NOT NULL COMMENT 'spi 类型：1=订单信息同步',
    `server_code`        varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL COMMENT '服务编码，针对type唯一',
    `server_name`        varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL COMMENT '服务名称，feign调用服务名',
    `server_description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '服务描述',
    `secret`             varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT 'SPI请求密钥',
    `create_user_id`     bigint(20)                                                    NOT NULL DEFAULT 0 COMMENT '创建人id',
    `create_by`          varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL DEFAULT '' COMMENT '创建人名称',
    `create_time`        bigint(20)                                                    NOT NULL COMMENT '创建时间',
    `update_user_id`     bigint(20)                                                    NOT NULL DEFAULT 0 COMMENT '更新人ID',
    `update_by`          varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL DEFAULT '' COMMENT '更新人名称',
    `update_time`        bigint(20)                                                    NOT NULL DEFAULT 0 COMMENT '更新时间',
    `deleted`            bigint(20)                                                    NOT NULL DEFAULT 0 COMMENT '删除标识：0=未删除，id=以删除',
    PRIMARY KEY (`id`) USING BTREE,
    INDEX `idx_type_server_code` (`type`, `server_code`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 1
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = 'SPI服务信息表'
  ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for eg_wework_event_member
-- ----------------------------
DROP TABLE IF EXISTS `eg_wework_event_member`;
CREATE TABLE `eg_wework_event_member`
(
    `id`                bigint(20)                                                    NOT NULL AUTO_INCREMENT,
    `suite_id`          varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL COMMENT '第三方应用ID',
    `auth_corp_id`      varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL COMMENT '授权企业的CorpID',
    `info_type`         varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL DEFAULT 'change_contact' COMMENT '固定为change_contact',
    `timestamp`         bigint(20)                                                    NOT NULL COMMENT '时间戳',
    `change_type`       varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL DEFAULT 'create_user' COMMENT '固定为create_user',
    `user_id`           varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL COMMENT '成员UserID',
    `open_user_id`      varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL     DEFAULT NULL COMMENT '全局唯一,对于同一个服务商，不同应用获取到企业内同一个成员的OpenUserID是相同的',
    `new_user_id`       varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL     DEFAULT NULL COMMENT '新的UserID，变更时推送（userid由系统生成时可更改一次）',
    `name`              varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL     DEFAULT NULL COMMENT '成员名称',
    `department`        varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL     DEFAULT NULL COMMENT '成员所在部门列表(逗号分隔)',
    `main_department`   int(11)                                                       NOT NULL DEFAULT 1 COMMENT '主部门',
    `is_leader_in_dept` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL     DEFAULT NULL COMMENT '表示所在部门是否为上级(逗号分隔)，0-否，1-是',
    `direct_leader`     varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL     DEFAULT NULL COMMENT '直属上级UserID(逗号分隔)',
    `mobile`            varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL     DEFAULT NULL COMMENT '手机号码',
    `position`          varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL     DEFAULT NULL COMMENT '职位信息',
    `gender`            tinyint(4)                                                    NOT NULL DEFAULT 0 COMMENT '性别。0表示未定义，1表示男性，2表示女性。',
    `email`             varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL     DEFAULT NULL COMMENT '邮箱',
    `biz_mail`          varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL     DEFAULT NULL COMMENT '企业邮箱',
    `status`            tinyint(4)                                                    NOT NULL DEFAULT 4 COMMENT '激活状态: 1=已激活，2=已禁用，4=未激活，5=退出企业。',
    `avatar`            varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL     DEFAULT NULL COMMENT '头像url',
    `alias`             varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL     DEFAULT NULL COMMENT '成员别名',
    `telephone`         varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL     DEFAULT NULL COMMENT '座机',
    `mem_change_cnt`    varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL     DEFAULT NULL COMMENT '成员变更消息',
    `create_user_id`    bigint(20)                                                    NOT NULL DEFAULT 0 COMMENT '创建人ID',
    `create_by`         varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL DEFAULT '' COMMENT '创建人名称',
    `create_time`       bigint(20)                                                    NOT NULL COMMENT '创建时间',
    `update_user_id`    bigint(20)                                                    NOT NULL DEFAULT 0 COMMENT '更新人id',
    `update_by`         varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL DEFAULT '' COMMENT '更新人名称',
    `update_time`       bigint(20)                                                    NOT NULL DEFAULT 0 COMMENT '更新时间',
    `deleted`           bigint(20)                                                    NOT NULL DEFAULT 0 COMMENT '是否删除：0=否，id=是',
    PRIMARY KEY (`id`) USING BTREE,
    INDEX `idx_user_id` (`user_id`) USING BTREE,
    INDEX `idx_auth_corp_id` (`auth_corp_id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 23105705
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '成员事件表'
  ROW_FORMAT = DYNAMIC;


-- ----------------------------
-- Table structure for eg_wework_member
-- ----------------------------
DROP TABLE IF EXISTS `eg_wework_member`;
CREATE TABLE `eg_wework_member`
(
    `id`                bigint(20)                                                    NOT NULL COMMENT '自增id',
    `user_id`           varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL COMMENT '用户唯一标识',
    `name`              varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL COMMENT '用户姓名',
    `alias`             varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL     DEFAULT NULL COMMENT '用户别名',
    `mobile`            varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL     DEFAULT NULL COMMENT '手机号码（带国际区号）',
    `position`          varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL     DEFAULT NULL COMMENT '职务信息',
    `gender`            tinyint(4)                                                    NULL     DEFAULT NULL COMMENT '性别（1-男，2-女）',
    `email`             varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL     DEFAULT NULL COMMENT '企业邮箱',
    `biz_mail`          varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL     DEFAULT NULL COMMENT '腾讯企业邮箱',
    `telephone`         varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL     DEFAULT NULL COMMENT '座机号码',
    `direct_leader`     varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL     DEFAULT NULL COMMENT '直属上级UserID',
    `enable`            tinyint(1)                                                    NULL     DEFAULT 1 COMMENT '启用状态（1-启用，0-禁用）',
    `avatar_mediaid`    varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL     DEFAULT NULL COMMENT '头像媒体ID',
    `address`           varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL     DEFAULT NULL COMMENT '办公地址',
    `main_department`   bigint(20)                                                    NULL     DEFAULT NULL COMMENT '主部门ID',
    `to_invite`         tinyint(1)                                                    NULL     DEFAULT 1 COMMENT '是否发送邀请',
    `external_position` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL     DEFAULT NULL COMMENT '对外职务',
    `create_user_id`    bigint(20)                                                    NOT NULL DEFAULT 0 COMMENT '创建人ID',
    `create_by`         varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL DEFAULT '' COMMENT '创建人名称',
    `create_time`       bigint(20)                                                    NOT NULL COMMENT '创建时间',
    `update_user_id`    bigint(20)                                                    NOT NULL DEFAULT 0 COMMENT '更新人id',
    `update_by`         varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL DEFAULT '' COMMENT '更新人名称',
    `update_time`       bigint(20)                                                    NOT NULL DEFAULT 0 COMMENT '更新时间',
    `deleted`           bigint(20)                                                    NOT NULL DEFAULT 0 COMMENT '是否删除：0=否，id=是',
    PRIMARY KEY (`id`) USING BTREE,
    INDEX `idx_user_id` (`user_id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '企业微信成员表'
  ROW_FORMAT = DYNAMIC;


-- ----------------------------
-- Table structure for eg_wework_member_dept
-- ----------------------------
DROP TABLE IF EXISTS `eg_wework_member_dept`;
CREATE TABLE `eg_wework_member_dept`
(
    `id`             bigint(20)                                                   NOT NULL COMMENT '自增id',
    `user_id`        varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '用户唯一标识',
    `name`           varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '用户姓名',
    `dept_id`        bigint(20)                                                   NOT NULL COMMENT '部门id',
    `create_user_id` bigint(20)                                                   NOT NULL DEFAULT 0 COMMENT '创建人ID',
    `create_by`      varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '创建人名称',
    `create_time`    bigint(20)                                                   NOT NULL COMMENT '创建时间',
    `update_user_id` bigint(20)                                                   NOT NULL DEFAULT 0 COMMENT '更新人id',
    `update_by`      varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '更新人名称',
    `update_time`    bigint(20)                                                   NOT NULL DEFAULT 0 COMMENT '更新时间',
    `deleted`        bigint(20)                                                   NOT NULL DEFAULT 0 COMMENT '是否删除：0=否，id=是',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `uk_user_dept` (`user_id`, `dept_id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '成员部门关联表'
  ROW_FORMAT = DYNAMIC;


-- ----------------------------
-- Table structure for eg_wework_department
-- ----------------------------
DROP TABLE IF EXISTS `eg_wework_department`;
CREATE TABLE `eg_wework_department`
(
    `id`             bigint(20)                                                   NOT NULL COMMENT '自增id',
    `dept_id`        bigint(20)                                                   NOT NULL COMMENT '部门id',
    `name`           varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '部门名称',
    `name_en`        varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL     DEFAULT NULL COMMENT '英文部门名称',
    `parent_id`      bigint(20)                                                   NULL     DEFAULT NULL COMMENT '父部门id',
    `create_user_id` bigint(20)                                                   NOT NULL DEFAULT 0 COMMENT '创建人ID',
    `create_by`      varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '创建人名称',
    `create_time`    bigint(20)                                                   NOT NULL COMMENT '创建时间',
    `update_user_id` bigint(20)                                                   NOT NULL DEFAULT 0 COMMENT '更新人id',
    `update_by`      varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '更新人名称',
    `update_time`    bigint(20)                                                   NOT NULL DEFAULT 0 COMMENT '更新时间',
    `deleted`        bigint(20)                                                   NOT NULL DEFAULT 0 COMMENT '是否删除：0=否，id=是',
    PRIMARY KEY (`id`) USING BTREE,
    INDEX `idx_dept_id` (`dept_id`) USING BTREE,
    INDEX `idx_dept_parent_id` (`dept_id`, `parent_id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '企业微信部门表'
  ROW_FORMAT = DYNAMIC;

SET FOREIGN_KEY_CHECKS = 1;
```

##### qifu-saas-eg数据库DML

- 测试

```sql
INSERT INTO `eg_order_app` (`id`, `channel`, `app_name`, `client_id`, `client_secret`, `dev_id`,
                                               `scopes`, `redirect_uri`, `attach_info`, `create_user_id`, `create_by`,
                                               `create_time`, `update_user_id`, `update_by`, `update_time`, `deleted`)
VALUES (4, 4, '', '132783', 'RMS5Jt8B6jpjECsSKnb0sL2d2kLHrXSJ', '', NULL,
        'https://tqifutest-api.texous.cn/qifu-saas-eg/open/order/oauth/callback/4', NULL, 0, '', 1, 0, '', 0, 0);
```

- UAT

```sql
INSERT INTO `eg_order_app` (`id`, `channel`, `app_name`, `client_id`, `client_secret`, `dev_id`,
                                               `scopes`, `redirect_uri`, `attach_info`, `create_user_id`, `create_by`,
                                               `create_time`, `update_user_id`, `update_by`, `update_time`, `deleted`)
VALUES (4, 4, '', '132783', 'RMS5Jt8B6jpjECsSKnb0sL2d2kLHrXSJ', '', NULL,
        'https://qifu.uat-api.keyfil.com/qifu-saas-eg/open/order/oauth/callback/4', NULL, 0, '', 1, 0, '', 0, 0);
```

- 生产

```sql
INSERT INTO `eg_order_app` (`id`, `channel`, `app_name`, `client_id`, `client_secret`, `dev_id`,
                                               `scopes`, `redirect_uri`, `attach_info`, `create_user_id`, `create_by`,
                                               `create_time`, `update_user_id`, `update_by`, `update_time`, `deleted`)
VALUES (4, 4, '', '132783', 'RMS5Jt8B6jpjECsSKnb0sL2d2kLHrXSJ', '', NULL,
        'https://qifu.api.keyfil.com/qifu-saas-eg/open/order/oauth/callback/4', NULL, 0, '', 1, 0, '', 0, 0);
```

#### Nacos配置文件 (开发测试)

```yaml
rocketmq:
  name-server: rocketmq.qifu.com:30938
  producer:
    group: qifu-saas-eg
    namespace: dev
    # 发送消息超时时间，默认3000
    sendMessageTimeout: 10000
  consumer:
    group: qifu-saas-eg
    namespace: dev
    # 一次拉取消息最大值，注意是拉取消息的最大值而非消费最大值
    pull-batch-size: 10

qifu:
  eg:
    ebay:
      authorize-url: https://auth.sandbox.ebay.com/oauth2/authorize
      token-url: https://api.sandbox.ebay.com/identity/v1/oauth2/token
      order-url: https://api.sandbox.ebay.com/sell/fulfillment/v1/order
      shipping-fulfillment-url: https://api.sandbox.ebay.com/sell/fulfillment/v1/order/{orderId}/shipping_fulfillment
      challenge-verification-token: 'dfcDlKJ35c693cFi90Mc3CCiu776fsfgs'
      notification-endpoint: 'https://wxwork.texous.cn/open/order/callback/1'
    consumer-group:
      order-spi: egOrderSpiConsumerGroup
      wework-event-webhook: egWeworkEventWebhookConsumerGroup
    wework-map:
      keyfil:
        webhooks:
          #- 生产
          - url: http://172.17.229.30:18088/api/pssystem/event/changeContact
          #- 测试
          #- - url: http://172.17.229.30:18080/api/pssystem/event/changeContact
            timeout: 6000
            events:
              - change_contact

yuanmeng:
  redis:
    cache-manager:
      enable: true
  web:
    filter:
      enable-user-login: true
      external-url-list:
        - "/v3/api-docs"
        - "/callback"
        - "/oauth"
        - "/wework/verify"
        - "/open/"
```

### 其余配置

#### 开发者平台配置

1. 各个平台需要创建生产应用，并激活
2. 添加 eg_order_app 表记录
3. 生产需要把 sandbox 链接改为 product 链接

----

## 开发说明

### 功能列表

- 添加电商对接
- 添加企微通讯录回调
