116 lines
3.4 KiB
JavaScript
116 lines
3.4 KiB
JavaScript
'use strict';
|
||
|
||
/**
|
||
* 货主报表投递计划 Model。
|
||
* 每个货主(store_id)对每个报表定义(report_definition_id)可配置每日多个投递时间点
|
||
* (schedule_times JSON 数组),由分钟级扫描调度按 HH:mm 命中后生成并投递报表。
|
||
*
|
||
* @param {import('egg').Application} app Egg 应用实例。
|
||
* @return {import('sequelize').ModelCtor<import('sequelize').Model>} Sequelize 模型。
|
||
*/
|
||
module.exports = app => {
|
||
const { BIGINT, INTEGER, STRING, TINYINT, DATE } = app.Sequelize;
|
||
|
||
const ReportDeliveryPlan = app.model.define('report_delivery_plan', {
|
||
id: {
|
||
type: BIGINT(20).UNSIGNED,
|
||
primaryKey: true,
|
||
autoIncrement: true,
|
||
allowNull: false,
|
||
comment: '主键',
|
||
},
|
||
store_id: {
|
||
type: BIGINT(20).UNSIGNED,
|
||
allowNull: false,
|
||
comment: '货主ID(wms_store.id)',
|
||
},
|
||
report_definition_id: {
|
||
type: BIGINT(20).UNSIGNED,
|
||
allowNull: false,
|
||
comment: '报表定义ID(wms_report_definition.id)',
|
||
},
|
||
name: {
|
||
type: STRING(100),
|
||
allowNull: true,
|
||
comment: '计划名称(前端展示用,缺省时可用报表名称兜底)',
|
||
},
|
||
schedule_times: {
|
||
type: app.Sequelize.JSON,
|
||
allowNull: false,
|
||
comment: '每日投递时间点数组,如 ["08:30","17:00"](HH:mm)',
|
||
},
|
||
channel: {
|
||
type: STRING(20),
|
||
allowNull: false,
|
||
defaultValue: 'inbox',
|
||
comment: '投递渠道:inbox=站内信群(wecom/link 已弃用)',
|
||
},
|
||
enabled: {
|
||
type: TINYINT(1),
|
||
allowNull: false,
|
||
defaultValue: 1,
|
||
comment: '是否启用:0=停用 1=启用',
|
||
},
|
||
late_grace_minutes: {
|
||
type: INTEGER(11),
|
||
allowNull: false,
|
||
defaultValue: 60,
|
||
comment: '补投宽限分钟:重启/漏跑后在该窗口内补投,超窗作废',
|
||
},
|
||
notify_template: {
|
||
type: STRING(500),
|
||
allowNull: true,
|
||
comment: '文本通知模板,支持 {time}/{url}/{report_name}/{biz_date} 标签',
|
||
},
|
||
notify_group_ids: {
|
||
type: app.Sequelize.JSON,
|
||
allowNull: true,
|
||
comment: '通知群ID数组(wms_inbox_group.id,多选;空=不指定群)',
|
||
},
|
||
notify_member_ids: {
|
||
type: app.Sequelize.JSON,
|
||
allowNull: true,
|
||
comment: '通知成员ID数组(外部IM用户ID,多选;目标侧支持数组)',
|
||
},
|
||
remark: {
|
||
type: STRING(500),
|
||
allowNull: true,
|
||
comment: '备注',
|
||
},
|
||
created_at: {
|
||
type: DATE,
|
||
allowNull: false,
|
||
defaultValue: app.Sequelize.literal('CURRENT_TIMESTAMP'),
|
||
comment: '创建时间',
|
||
},
|
||
updated_at: {
|
||
type: DATE,
|
||
allowNull: false,
|
||
defaultValue: app.Sequelize.literal('CURRENT_TIMESTAMP'),
|
||
comment: '更新时间',
|
||
},
|
||
deleted_at: {
|
||
type: DATE,
|
||
allowNull: true,
|
||
comment: '软删除时间',
|
||
},
|
||
}, {
|
||
tableName: 'wms_report_delivery_plan',
|
||
freezeTableName: true,
|
||
underscored: true,
|
||
timestamps: true,
|
||
createdAt: 'created_at',
|
||
updatedAt: 'updated_at',
|
||
deletedAt: 'deleted_at',
|
||
paranoid: true,
|
||
comment: '货主报表投递计划表',
|
||
indexes: [
|
||
{ name: 'uk_store_report_definition', unique: true, fields: [ 'store_id', 'report_definition_id', 'deleted_at' ] },
|
||
{ name: 'idx_enabled_deleted', fields: [ 'enabled', 'deleted_at' ] },
|
||
{ name: 'idx_deleted_at', fields: [ 'deleted_at' ] },
|
||
],
|
||
});
|
||
|
||
return ReportDeliveryPlan;
|
||
};
|