oms/backend/app/model/orderDeliveryItem.js
liufumingren 489563a4b2 feat(backend): 仪表盘报表接口、配置裁剪、单号 5 位与账号名称/头像
- 仪表盘报表:新增 app/service/dashboard.js + app/controller/dashboard.js +
  app/lib/billStatus.js,注册 GET /api/dashboard/report(jwtAuth + principalCheck),
  一次聚合返回概览指标、发货单/入库单/出库单状态分布与待办、近 N 天单据量与
  出入库数量趋势、库存 Top 商品、最近出入库流水;warehouse_id 只过滤单据与流水
  (product_stocks 无仓库维度);契约 dashboard* 同步到 swagger
- 接口配置裁剪:仓库接口配置只保留 api_version 与 item_name_with_spec;
  历史 warehouse_apis.extra 冗余键、owner_code 配置、递交/回传设置一并清理
  (迁移 20260915002400~02800)
- 入库/出库/发货单报文与字段对齐 WMS 标准:去掉 ownerCode、operatorCode 等多余字段,
  入库明细补 itemId;发货单明细去掉无意义的 owner_code(迁移 20260915002600)
- 单号 5 位起:四张单据表 AUTO_INCREMENT 提到 10000(迁移 20260915002900)
- 账号名称/头像按主体维护:principal_users 增 name/avatar 并回填(迁移 20260915003000/03100),
  新增 app/lib/accountProfile.js(关联表名称/头像 → users 兜底);审核人写入 operator/operator_name;
  register 不再写 nickname、updateProfile 仅接受邮箱/手机号
- 出库单推送/锁库存链路的配套调整(outboundOrderPush、订单与发货单控制器)

Co-Authored-By: GitHub Copilot <noreply@github.com>
2026-09-14 16:09:35 +08:00

53 lines
3.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use strict';
/**
* 发货单明细模型(子表商品明细),对应 order_delivery_items 表
*
* 字段口径对齐奇门 `request.orderLines.orderLine` 与 WMS 侧明细落库结构(见迁移注释):
* - plan_qty 必须 > 0;item_id / item_code 至少一个
* - order_line_no 缺省按行序号;inventory_type OMS 落 ZP/CC(推送时映射 ZC/CC)
* @param {Egg.Application} app egg application
* @return {object} orderDeliveryItem model
*/
module.exports = app => {
const { BIGINT, STRING, DECIMAL, JSON, DATE } = app.Sequelize;
const OrderDeliveryItem = app.model.define('order_delivery_item', {
id: { type: BIGINT.UNSIGNED, primaryKey: true, autoIncrement: true, comment: '主键' },
principal_id: { type: BIGINT.UNSIGNED, allowNull: false, comment: '所属主体ID' },
order_delivery_id: { type: BIGINT.UNSIGNED, allowNull: false, comment: '所属发货单ID(order_deliveries.id)' },
// 历史数据来源:order_items.id(仅搬迁数据有值)
legacy_order_item_id: { type: BIGINT.UNSIGNED, comment: '历史数据来源:order_items.id(非搬迁数据为 NULL)' },
order_line_no: { type: STRING(20), allowNull: false, defaultValue: '', comment: '行号(orderLineNo,缺省按行序号)' },
item_id: { type: BIGINT.UNSIGNED, comment: 'WMS 内部商品ID(itemId,取自 warehouse_products.wms_item_id)' },
item_code: { type: STRING(100), comment: '商品编码(itemCode)' },
item_name: { type: STRING(255), comment: '商品名称(itemName)' },
plan_qty: { type: DECIMAL(12, 3), allowNull: false, defaultValue: 0, comment: '计划数量(planQty,必须 > 0)' },
actual_price: { type: DECIMAL(12, 2), comment: '实际单价(actualPrice)' },
retail_price: { type: DECIMAL(12, 2), comment: '零售价(retailPrice)' },
ext_code: { type: STRING(100), comment: '外部编码(extCode)' },
inventory_type: {
type: STRING(10),
allowNull: false,
defaultValue: 'ZP',
comment: '库存类型:ZP=正品 CC=残次(对齐 WMS 行级 inventoryType,推送时映射 ZC/CC)',
},
source_order_code: { type: STRING(50), comment: '来源订单编码(sourceOrderCode)' },
sub_source_order_code: { type: STRING(50), comment: '子来源订单编码(subSourceOrderCode)' },
stock_id: { type: BIGINT.UNSIGNED, comment: 'WMS 仓库库存ID(stockId,手工建单直传)' },
extend_props: { type: JSON, comment: '扩展属性(extendProps)' },
created_at: { type: DATE, comment: '创建时间' },
updated_at: { type: DATE, comment: '更新时间' },
}, {
tableName: 'order_delivery_items',
comment: '发货单明细(子表商品明细)',
});
OrderDeliveryItem.associate = () => {
app.model.OrderDeliveryItem.belongsTo(app.model.OrderDelivery, { foreignKey: 'order_delivery_id', as: 'order' });
app.model.OrderDeliveryItem.belongsTo(app.model.Principal, { foreignKey: 'principal_id', as: 'principal' });
};
return OrderDeliveryItem;
};