diff --git a/backend/app/contract/index.js b/backend/app/contract/index.js
index 25dea96..d908c9a 100644
--- a/backend/app/contract/index.js
+++ b/backend/app/contract/index.js
@@ -1185,7 +1185,7 @@ module.exports = {
outer_sku_id: { type: 'string', description: '平台规格ID' },
title: { type: 'string', description: '商品标题' },
spec: { type: 'string', description: '规格' },
- platform_type: { type: 'string', description: '外部平台类型' },
+ platform_type: { type: 'string', description: '外部平台类型(已转换为系统预设平台编码,如 PDD / DYXD / SPH)' },
status: { type: 'integer', description: '状态:1在售 0下架' },
bind_type: { type: 'integer', description: '绑定类型:0未绑定 1系统商品 2组合商品' },
product_id: { type: 'integer', description: '绑定的系统商品ID' },
@@ -1245,7 +1245,7 @@ module.exports = {
price: { type: 'number', description: '店铺售价' },
stock: { type: 'integer', description: '采集到的库存' },
status: { type: 'integer', description: '店铺商品状态:1在售 0下架' },
- platform_type: { type: 'string', description: '外部平台类型:TouTiao/Taobao/Pinduoduo 等(外部平台采集时有值)' },
+ platform_type: { type: 'string', description: '系统预设平台编码(PDD/DYXD/SPH…,见 app/lib/platformCode.js),外部平台采集时有值' },
external_shop_id: { type: 'string', description: '外部平台的店铺ID(如店管家 ShopId)' },
unbound_order_count: { type: 'integer', description: '引用该商品但未绑定系统商品的订单数(列表接口回填,0 表示无待处理订单)' },
bind_type: { type: 'integer', description: '绑定类型:0未绑定 1系统商品 2组合商品' },
@@ -1474,8 +1474,8 @@ module.exports = {
pre_delivery_order_id: { type: 'string', description: '预发货单ID(手工单不填写)' },
is_urgency: { type: 'string', description: '是否紧急:Y / N(默认 N)' },
invoice_flag: { type: 'string', description: '是否需要发票:Y / N(默认 N)' },
- source_platform_code: { type: 'string', description: '来源平台编码(手工单不填写)' },
- source_platform_name: { type: 'string', description: '来源平台名称(手工单不填写)' },
+ source_platform_code: { type: 'string', description: '来源平台编码:系统预设平台编码(PDD/DYXD/SPH…,手工单不填写)' },
+ source_platform_name: { type: 'string', description: '来源平台名称(如「拼多多」,手工单不填写)' },
shop_nick: { type: 'string', description: '店铺名称(取所选店铺,系统派生)' },
seller_nick: { type: 'string', description: '卖家名称(手工单不填写)' },
buyer_nick: { type: 'string', description: '买家名称(手工单不填写)' },
diff --git a/backend/app/lib/platformCode.js b/backend/app/lib/platformCode.js
new file mode 100644
index 0000000..48d2934
--- /dev/null
+++ b/backend/app/lib/platformCode.js
@@ -0,0 +1,150 @@
+'use strict';
+
+/**
+ * 系统预设平台编码。
+ *
+ * 外部打单平台(店管家等)返回的是各自的平台标识(Pinduoduo / TouTiao / WxVideo…),
+ * 订单落库、推送 WMS(奇门 sourcePlatformCode/sourcePlatformName)需要统一口径,
+ * 因此全系统只认这里的一套预设编码,外部标识通过别名表映射过来。
+ */
+const PLATFORM_PRESETS = [
+ { code: '1688', name: '阿里巴巴' },
+ { code: 'DW', name: '得物' },
+ { code: 'DYCS', name: '抖音超市' },
+ { code: 'DYGX', name: '抖音供销' },
+ { code: 'DYXD', name: '抖音小店' },
+ { code: 'JD', name: '京东' },
+ { code: 'KS', name: '快手' },
+ { code: 'MAOCHAO', name: '天猫超市' },
+ { code: 'MTYYJK', name: '美团医药健康' },
+ { code: 'OFFLINE', name: '线下' },
+ { code: 'OTHER', name: '其他' },
+ { code: 'PDD', name: '拼多多' },
+ { code: 'SPH', name: '视频号' },
+ { code: 'TB', name: '淘宝' },
+ { code: 'TGC', name: '淘工厂' },
+ { code: 'TM', name: '天猫' },
+ { code: 'XHS', name: '小红书' },
+];
+
+/** 预设编码 -> 名称 */
+const PLATFORM_NAME_BY_CODE = new Map(PLATFORM_PRESETS.map(item => [ item.code, item.name ]));
+
+/** 未知平台统一落到「其他」 */
+const PLATFORM_UNKNOWN_CODE = 'OTHER';
+
+/**
+ * 外部标识 / 中文名 -> 预设编码(全部按小写比对)。
+ * 只放通用别名;各打单平台自己的枚举(如店管家 PlatformType)在对应 service 里硬编码。
+ */
+const PLATFORM_ALIASES = {
+ // 1688 / 阿里巴巴
+ 1688: '1688',
+ ali: '1688',
+ alibaba: '1688',
+ 阿里巴巴: '1688',
+ // 得物
+ dw: 'DW',
+ dewu: 'DW',
+ 得物: 'DW',
+ // 抖音系
+ dycs: 'DYCS',
+ 抖音超市: 'DYCS',
+ dygx: 'DYGX',
+ 抖音供销: 'DYGX',
+ dyxd: 'DYXD',
+ douyin: 'DYXD',
+ doudian: 'DYXD',
+ toutiao: 'DYXD',
+ 抖店: 'DYXD',
+ 抖音: 'DYXD',
+ 抖音小店: 'DYXD',
+ // 京东
+ jd: 'JD',
+ jingdong: 'JD',
+ 京东: 'JD',
+ // 快手
+ ks: 'KS',
+ kuaishou: 'KS',
+ 快手: 'KS',
+ // 天猫超市
+ maochao: 'MAOCHAO',
+ tmcs: 'MAOCHAO',
+ 天猫超市: 'MAOCHAO',
+ // 美团医药健康
+ mtyyjk: 'MTYYJK',
+ meituan: 'MTYYJK',
+ 美团: 'MTYYJK',
+ 美团医药健康: 'MTYYJK',
+ // 线下 / 其他
+ offline: 'OFFLINE',
+ 线下: 'OFFLINE',
+ other: 'OTHER',
+ 其他: 'OTHER',
+ // 拼多多
+ pdd: 'PDD',
+ pinduoduo: 'PDD',
+ 拼多多: 'PDD',
+ // 视频号
+ sph: 'SPH',
+ wxvideo: 'SPH',
+ wechatvideo: 'SPH',
+ 视频号: 'SPH',
+ // 淘宝
+ tb: 'TB',
+ taobao: 'TB',
+ 淘宝: 'TB',
+ // 淘工厂
+ tgc: 'TGC',
+ taobaofactory: 'TGC',
+ 淘工厂: 'TGC',
+ // 天猫
+ tm: 'TM',
+ tmall: 'TM',
+ 天猫: 'TM',
+ // 小红书
+ xhs: 'XHS',
+ xiaohongshu: 'XHS',
+ redbook: 'XHS',
+ 小红书: 'XHS',
+};
+
+/**
+ * 解析外部平台标识为预设编码:先查别名表,本身就是预设编码时直接返回,未知落到 OTHER
+ * @param {*} raw 外部平台标识(大小写、中英文均可)
+ * @return {string} 预设编码
+ */
+function resolvePlatformCode(raw) {
+ const key = String(raw == null ? '' : raw).trim().toLowerCase();
+ if (!key) return PLATFORM_UNKNOWN_CODE;
+ if (PLATFORM_NAME_BY_CODE.has(key.toUpperCase())) return key.toUpperCase();
+ return PLATFORM_ALIASES[key] || PLATFORM_UNKNOWN_CODE;
+}
+
+/**
+ * 预设编码对应的中文名,未知编码原样返回(便于排查)
+ * @param {*} code 平台编码
+ * @return {string} 平台名称
+ */
+function platformNameOf(code) {
+ const key = String(code == null ? '' : code).trim().toUpperCase();
+ return PLATFORM_NAME_BY_CODE.get(key) || String(code == null ? '' : code);
+}
+
+/**
+ * 解析为「编码 + 名称」:订单表 source_platform_code / source_platform_name 直接落这两个值
+ * @param {*} raw 外部平台标识
+ * @return {{code: string, name: string}} 预设平台
+ */
+function resolvePlatform(raw) {
+ const code = resolvePlatformCode(raw);
+ return { code, name: platformNameOf(code) };
+}
+
+module.exports = {
+ PLATFORM_PRESETS,
+ PLATFORM_UNKNOWN_CODE,
+ resolvePlatform,
+ resolvePlatformCode,
+ platformNameOf,
+};
diff --git a/backend/app/lib/printPlatform/base.js b/backend/app/lib/printPlatform/base.js
index 9cfbc5c..cfdb4dd 100644
--- a/backend/app/lib/printPlatform/base.js
+++ b/backend/app/lib/printPlatform/base.js
@@ -178,12 +178,15 @@ class PrintPlatformService {
* 否则会写进待审核形成脏单。被过滤掉的订单号通过 finished 返回,上层据此作废本地未处理的副本。
* 需返回统一结构,避免上层直接依赖各平台字段:
* { total, hosts: [命中来源], skipped, finished: [{ external_order_id, platform_status }], list: [{
- * external_order_id, external_shop_id, external_shop_name, platform_type, platform_status,
+ * external_order_id, external_shop_id, external_shop_name, platform_type, platform_code, platform_name,
+ * platform_status,
* order_no, total_amount, pay_amount, receiver, remark,
* external_created_at, external_updated_at, raw,
* items: [{ external_item_id, outer_item_id, outer_sku_id, sku_code, name, spec, image,
* quantity, price, total_amount, relation_base_product, base_product, raw }],
* }] }
+ * platform_code / platform_name 必须是 app/lib/platformCode.js 里的系统预设平台编码(PDD / DYXD / SPH…),
+ * platform_type 保留平台原始标识仅作留痕。
* 明细只保留平台商品快照,系统商品匹配由上层依据店铺商品绑定关系完成。
* @param {Object} shop OMS 店铺记录(type=2,external_data 为平台返回的商家原始结构)
* @param {Object} [options] 查询参数(startTime / endTime)
diff --git a/backend/app/lib/printPlatform/dgj.js b/backend/app/lib/printPlatform/dgj.js
index adb9d57..ab65068 100644
--- a/backend/app/lib/printPlatform/dgj.js
+++ b/backend/app/lib/printPlatform/dgj.js
@@ -1,6 +1,7 @@
'use strict';
const PrintPlatformService = require('./base');
+const { resolvePlatform } = require('../platformCode');
/** 店管家商家门户站点 */
const PORTAL_ORIGIN = 'https://tfxportal.dgjapp.com';
@@ -56,6 +57,40 @@ const FALLBACK_PRODUCT_HOSTS = [
/** 商品列表单页条数(平台允许 200) */
const PRODUCT_PAGE_SIZE = 200;
+/**
+ * 店管家 PlatformType -> 系统预设平台编码(硬编码,新增平台时在此补充)。
+ * 系统预设见 app/lib/platformCode.js;未收录的统一落到 OTHER(其他)。
+ */
+const PLATFORM_TYPE_PRESETS = {
+ pinduoduo: 'PDD',
+ toutiao: 'DYXD',
+ douyin: 'DYXD',
+ doudian: 'DYXD',
+ wxvideo: 'SPH',
+ alibaba: '1688',
+ 1688: '1688',
+ taobao: 'TB',
+ tmall: 'TM',
+ jingdong: 'JD',
+ jd: 'JD',
+ kuaishou: 'KS',
+ xiaohongshu: 'XHS',
+ dewu: 'DW',
+ meituan: 'MTYYJK',
+ offline: 'OFFLINE',
+};
+
+/**
+ * 把店管家的 PlatformType 转成系统预设平台(编码 + 名称)
+ * @param {*} platformType 店管家 PlatformType(如 Pinduoduo / TouTiao / WxVideo)
+ * @return {{code: string, name: string}} 预设平台
+ */
+function resolveOrderPlatform(platformType) {
+ const key = String(platformType == null ? '' : platformType).trim().toLowerCase();
+ const presetCode = PLATFORM_TYPE_PRESETS[key];
+ return resolvePlatform(presetCode || platformType);
+}
+
/**
* 平台侧「已发货 / 已终结」的订单状态(ErpState):
* sended=已发货、success=交易成功、close=交易关闭,其余为各平台交易状态的等价写法。
@@ -869,7 +904,7 @@ class DgjService extends PrintPlatformService {
const productRaw = { ...data };
delete productRaw.Skus;
- const platformType = truncate(data.PlatformType, 32);
+ const platformType = resolveOrderPlatform(data.PlatformType).code;
const externalShopId = data.ShopId == null ? '' : truncate(data.ShopId, 64);
const status = isProductOnSale(data.Status) ? 1 : 0;
@@ -1092,13 +1127,18 @@ class DgjService extends PrintPlatformService {
const logicOrderId = String(data.LogicOrderId || '').trim();
const platformOrderId = String(data.PlatformOrderId || '').trim();
const externalOrderId = logicOrderId || platformOrderId;
+ // 平台类型转系统预设编码(PDD / DYXD / SPH…),订单表与推 WMS 都用这一套
+ const platform = resolveOrderPlatform(data.PlatformType);
return {
external_order_id: externalOrderId,
// 平台单号保留下来展示/查询用(与外部环境对账时需要)
platform_order_no: platformOrderId || null,
external_shop_id: data.ShopId == null ? '' : String(data.ShopId),
external_shop_name: truncate(data.ShopName || data.AgentShopName || data.SelfShopName, 128),
+ // 原始值仅作留痕;落库用 platform_code / platform_name
platform_type: truncate(data.PlatformType, 32),
+ platform_code: platform.code,
+ platform_name: platform.name,
platform_status: truncate(data.ErpState || data.Status, 32),
order_no: externalOrderId,
total_amount: toNumber(data.TotalAmount),
@@ -1322,6 +1362,15 @@ class DgjService extends PrintPlatformService {
static isOrderFinished(row) {
return isOrderFinished(row);
}
+
+ /**
+ * 店管家 PlatformType 转系统预设平台(供脚本迁移历史数据复用同一口径)
+ * @param {string} platformType 店管家 PlatformType
+ * @return {{code: string, name: string}} 预设平台
+ */
+ static resolveOrderPlatform(platformType) {
+ return resolveOrderPlatform(platformType);
+ }
}
module.exports = DgjService;
diff --git a/backend/app/model/order.js b/backend/app/model/order.js
index 70cdb66..389b748 100644
--- a/backend/app/model/order.js
+++ b/backend/app/model/order.js
@@ -16,7 +16,7 @@ module.exports = app => {
shop_id: { type: BIGINT.UNSIGNED, comment: '所属店铺ID,为空表示未关联店铺' },
external_print_account_id: { type: BIGINT.UNSIGNED, comment: '来源外部打单账号ID' },
external_order_id: { type: STRING(64), comment: '平台订单唯一标识(店管家为系统编号 LogicOrderId,平台单号见 external_data)' },
- platform_type: { type: STRING(32), comment: '平台类型:TouTiao/Taobao/Pinduoduo 等' },
+ platform_type: { type: STRING(32), comment: '平台类型:系统预设平台编码(PDD/DYXD/SPH…)' },
platform_status: { type: STRING(32), comment: '平台侧订单状态' },
external_shop_id: { type: STRING(64), comment: '平台侧店铺ID(店管家 ShopId)' },
external_shop_name: { type: STRING(128), comment: '平台侧店铺名称' },
diff --git a/backend/app/model/shopProduct.js b/backend/app/model/shopProduct.js
index 7a2c400..55c776f 100644
--- a/backend/app/model/shopProduct.js
+++ b/backend/app/model/shopProduct.js
@@ -23,7 +23,7 @@ module.exports = app => {
price: { type: DECIMAL(12, 2), comment: '店铺售价' },
stock: { type: INTEGER, allowNull: false, defaultValue: 0, comment: '采集到的库存' },
status: { type: TINYINT, allowNull: false, defaultValue: 1, comment: '店铺商品状态:1在售 0下架' },
- platform_type: { type: STRING(32), comment: '外部平台类型:TouTiao/Taobao/Pinduoduo 等' },
+ platform_type: { type: STRING(32), comment: '平台类型:系统预设平台编码(PDD/DYXD/SPH…)' },
external_shop_id: { type: STRING(64), comment: '外部平台的店铺ID(如店管家 ShopId)' },
bind_type: { type: TINYINT, allowNull: false, defaultValue: 0, comment: '绑定类型:0未绑定 1系统商品 2组合商品' },
product_id: { type: BIGINT.UNSIGNED, comment: '绑定的系统商品ID,未绑定为空' },
diff --git a/backend/app/service/externalPrintOrder.js b/backend/app/service/externalPrintOrder.js
index 820e38b..76f575d 100644
--- a/backend/app/service/externalPrintOrder.js
+++ b/backend/app/service/externalPrintOrder.js
@@ -226,7 +226,8 @@ class ExternalPrintOrderService extends Service {
remark: item.remark || null,
external_print_account_id: account.id,
external_order_id: externalOrderId,
- platform_type: item.platform_type || null,
+ // 统一落系统预设平台编码(PDD / DYXD / SPH…),原始平台标识见 external_data
+ platform_type: item.platform_code || item.platform_type || null,
platform_status: item.platform_status || null,
external_shop_id: item.external_shop_id || null,
external_shop_name: item.external_shop_name || null,
@@ -363,8 +364,9 @@ class ExternalPrintOrderService extends Service {
item_amount: Number(itemAmount.toFixed(2)),
item_total: Number(itemTotal.toFixed(3)),
item_kind: lines.length,
- source_platform_code: truncateText(item.platform_type, 50),
- source_platform_name: truncateText(item.platform_type, 200),
+ // 系统预设平台编码/名称(推 WMS 的 sourcePlatformCode/sourcePlatformName 同源)
+ source_platform_code: truncateText(item.platform_code || item.platform_type, 50),
+ source_platform_name: truncateText(item.platform_name || item.platform_type, 200),
buyer_message: truncateText(item.remark, 500),
place_order_time: item.external_created_at,
pay_time: item.external_updated_at,
diff --git a/backend/package.json b/backend/package.json
index f458991..af34714 100644
--- a/backend/package.json
+++ b/backend/package.json
@@ -21,6 +21,7 @@
"order-index:repair": "node scripts/repair-order-index.js",
"orders:cleanup-shipped": "node scripts/cleanup-shipped-pending-orders.js",
"orders:migrate-logic-id": "node scripts/migrate-logic-order-id.js",
+ "platforms:migrate": "node scripts/migrate-platform-codes.js",
"deploy": "npm run deploy:prod",
"deploy:prod": "npm --prefix ../tools run deploy --",
"deploy:backend": "npm --prefix ../tools run deploy:backend --",
diff --git a/backend/scripts/migrate-platform-codes.js b/backend/scripts/migrate-platform-codes.js
new file mode 100644
index 0000000..6324ab6
--- /dev/null
+++ b/backend/scripts/migrate-platform-codes.js
@@ -0,0 +1,101 @@
+'use strict';
+
+/**
+ * 把外部打单平台写下的「平台类型」统一迁移为系统预设平台编码/名称。
+ *
+ * 背景:早期把店管家的 PlatformType(Pinduoduo / TouTiao / WxVideo…)直接写进了
+ * orders.platform_type、订单状态表的 source_platform_code/source_platform_name、
+ * 店铺商品的 platform_type;系统预设见 app/lib/platformCode.js(PDD / DYXD / SPH…),
+ * 推送 WMS 的 sourcePlatformCode/sourcePlatformName 也要求这套口径。
+ *
+ * 用法:
+ * node scripts/migrate-platform-codes.js # 只统计(dry-run)
+ * node scripts/migrate-platform-codes.js --apply # 执行迁移
+ */
+const mm = require('egg-mock');
+const DgjService = require('../app/lib/printPlatform/dgj');
+const { ORDER_STATUS } = require('../app/lib/orderStatus');
+
+/** 需要迁移来源平台编码的状态表 */
+const STATUS_TABLES = Object.values(ORDER_STATUS).map(status => `order_status_${status}`);
+
+(async () => {
+ const apply = process.argv.includes('--apply');
+ const app = mm.app();
+ await app.ready();
+ const ctx = app.mockContext();
+ const select = sql => ctx.model.query(sql, { type: app.Sequelize.QueryTypes.SELECT });
+
+ /** scope -> 需要迁移的旧值统计 */
+ const plans = new Map();
+ const add = (scope, oldValue, count) => {
+ const platform = DgjService.resolveOrderPlatform(oldValue);
+ if (oldValue === platform.code) return;
+ const key = `${scope}|${oldValue}`;
+ const exists = plans.get(key);
+ if (exists) exists.count += Number(count);
+ else plans.set(key, { scope, oldValue, code: platform.code, name: platform.name, count: Number(count) });
+ };
+
+ const orderRows = await select("SELECT platform_type AS v, COUNT(*) AS c FROM `orders` WHERE platform_type IS NOT NULL AND platform_type <> '' GROUP BY platform_type");
+ for (const row of orderRows) add('orders.platform_type', row.v, row.c);
+
+ const shopProductRows = await select("SELECT platform_type AS v, COUNT(*) AS c FROM `shop_products` WHERE platform_type IS NOT NULL AND platform_type <> '' GROUP BY platform_type");
+ for (const row of shopProductRows) add('shop_products.platform_type', row.v, row.c);
+
+ for (const table of STATUS_TABLES) {
+ const rows = await select(
+ `SELECT source_platform_code AS v, COUNT(*) AS c FROM \`${table}\`
+ WHERE source_platform_code IS NOT NULL AND source_platform_code <> ''
+ GROUP BY source_platform_code`
+ );
+ for (const row of rows) add('order_status.source_platform_code', row.v, row.c);
+ }
+
+ const changes = [ ...plans.values() ];
+ for (const item of changes) {
+ console.log(`${item.scope}:${item.oldValue} → ${item.code}(${item.name})× ${item.count}`);
+ }
+ console.log(`待迁移项 ${changes.length} 类`);
+
+ if (!changes.length || !apply) {
+ if (changes.length) console.log('[dry-run] 未写库,确认后加 --apply 执行');
+ await app.close();
+ process.exit(0);
+ }
+
+ const transaction = await ctx.model.transaction();
+ try {
+ for (const item of changes) {
+ if (item.scope === 'orders.platform_type') {
+ await ctx.model.query('UPDATE `orders` SET platform_type = ? WHERE platform_type = ?', {
+ replacements: [ item.code, item.oldValue ], transaction,
+ });
+ } else if (item.scope === 'shop_products.platform_type') {
+ await ctx.model.query('UPDATE `shop_products` SET platform_type = ? WHERE platform_type = ?', {
+ replacements: [ item.code, item.oldValue ], transaction,
+ });
+ } else {
+ for (const table of STATUS_TABLES) {
+ await ctx.model.query(
+ `UPDATE \`${table}\` SET source_platform_code = ?, source_platform_name = ? WHERE source_platform_code = ?`,
+ { replacements: [ item.code, item.name, item.oldValue ], transaction }
+ );
+ }
+ }
+ }
+ await transaction.commit();
+ console.log(`已迁移 ${changes.length} 类平台编码/名称`);
+ } catch (err) {
+ await transaction.rollback();
+ console.error(`迁移失败,已回滚:${err.message}`);
+ await app.close();
+ process.exit(1);
+ }
+
+ await app.close();
+ process.exit(0);
+})().catch(err => {
+ console.error(err);
+ process.exit(1);
+});
diff --git a/backend/test/app/lib/platformCode.test.js b/backend/test/app/lib/platformCode.test.js
new file mode 100644
index 0000000..3628ca8
--- /dev/null
+++ b/backend/test/app/lib/platformCode.test.js
@@ -0,0 +1,54 @@
+'use strict';
+
+const { assert } = require('egg-mock/bootstrap');
+const { resolvePlatform, resolvePlatformCode, platformNameOf, PLATFORM_PRESETS } = require('../../../app/lib/platformCode');
+const DgjService = require('../../../app/lib/printPlatform/dgj');
+
+describe('platformCode 预设平台编码', () => {
+ it('预设编码表覆盖 17 个平台且编码唯一', () => {
+ const codes = PLATFORM_PRESETS.map(item => item.code);
+ assert.strictEqual(codes.length, 17);
+ assert.strictEqual(new Set(codes).size, 17);
+ });
+
+ it('店管家 PlatformType 映射到预设编码', () => {
+ const cases = {
+ Pinduoduo: 'PDD',
+ TouTiao: 'DYXD',
+ WxVideo: 'SPH',
+ Alibaba: '1688',
+ Taobao: 'TB',
+ KuaiShou: 'KS',
+ Tmall: 'TM',
+ JingDong: 'JD',
+ XiaoHongShu: 'XHS',
+ DeWu: 'DW',
+ MeiTuan: 'MTYYJK',
+ Offline: 'OFFLINE',
+ };
+ for (const [ raw, expect ] of Object.entries(cases)) {
+ assert.strictEqual(DgjService.resolveOrderPlatform(raw).code, expect, raw);
+ }
+ });
+
+ it('预设编码/中文名/大小写都能解析', () => {
+ assert.strictEqual(resolvePlatformCode('pdd'), 'PDD');
+ assert.strictEqual(resolvePlatformCode('TB'), 'TB');
+ assert.strictEqual(resolvePlatformCode('拼多多'), 'PDD');
+ assert.strictEqual(resolvePlatformCode('抖音小店'), 'DYXD');
+ assert.strictEqual(resolvePlatformCode('视频号'), 'SPH');
+ });
+
+ it('未知平台落到 OTHER(其他)', () => {
+ assert.strictEqual(resolvePlatformCode('unknown-platform'), 'OTHER');
+ assert.strictEqual(resolvePlatformCode(''), 'OTHER');
+ assert.strictEqual(resolvePlatformCode(null), 'OTHER');
+ assert.deepStrictEqual(resolvePlatform('xyz'), { code: 'OTHER', name: '其他' });
+ });
+
+ it('名称反查与兜底', () => {
+ assert.strictEqual(platformNameOf('PDD'), '拼多多');
+ assert.strictEqual(platformNameOf('1688'), '阿里巴巴');
+ assert.strictEqual(platformNameOf('WHATEVER'), 'WHATEVER');
+ });
+});
diff --git a/frontend/src/api/orderStatus.ts b/frontend/src/api/orderStatus.ts
index 8eeaa37..1bf9306 100644
--- a/frontend/src/api/orderStatus.ts
+++ b/frontend/src/api/orderStatus.ts
@@ -97,6 +97,10 @@ export interface OrderStatusItem {
status_label?: string
/** 是否外部打单平台拉取的订单(店铺由平台决定,不可修改) */
is_external?: boolean
+ /** 来源平台:系统预设编码(PDD / DYXD / SPH…,见 constants/platform.ts) */
+ source_platform_code?: string | null
+ /** 来源平台名称(如「拼多多」) */
+ source_platform_name?: string | null
remark: string | null
/** —— 老发货单口径字段(为容纳老表而扩展) —— */
order_type?: string | null
diff --git a/frontend/src/constants/platform.ts b/frontend/src/constants/platform.ts
new file mode 100644
index 0000000..926aaf4
--- /dev/null
+++ b/frontend/src/constants/platform.ts
@@ -0,0 +1,39 @@
+/**
+ * 系统预设平台编码(与后端 app/lib/platformCode.js 保持一致)。
+ *
+ * 外部打单平台(店管家等)返回的平台标识会在后端统一转换成这里的编码,
+ * 前端展示时按编码取中文名,避免直接把 PDD / DYXD 之类的编码露给用户。
+ */
+export interface PlatformPreset {
+ code: string
+ name: string
+}
+
+export const PLATFORM_PRESETS: PlatformPreset[] = [
+ { code: '1688', name: '阿里巴巴' },
+ { code: 'DW', name: '得物' },
+ { code: 'DYCS', name: '抖音超市' },
+ { code: 'DYGX', name: '抖音供销' },
+ { code: 'DYXD', name: '抖音小店' },
+ { code: 'JD', name: '京东' },
+ { code: 'KS', name: '快手' },
+ { code: 'MAOCHAO', name: '天猫超市' },
+ { code: 'MTYYJK', name: '美团医药健康' },
+ { code: 'OFFLINE', name: '线下' },
+ { code: 'OTHER', name: '其他' },
+ { code: 'PDD', name: '拼多多' },
+ { code: 'SPH', name: '视频号' },
+ { code: 'TB', name: '淘宝' },
+ { code: 'TGC', name: '淘工厂' },
+ { code: 'TM', name: '天猫' },
+ { code: 'XHS', name: '小红书' },
+]
+
+const PLATFORM_NAME_BY_CODE = new Map(PLATFORM_PRESETS.map((item) => [item.code, item.name]))
+
+/** 平台编码 -> 中文名;未知编码原样返回,空值显示 '-' */
+export function platformNameOf(code?: string | null): string {
+ const key = String(code ?? '').trim()
+ if (!key) return '-'
+ return PLATFORM_NAME_BY_CODE.get(key.toUpperCase()) || key
+}
diff --git a/frontend/src/views/Order/StatusPanel.vue b/frontend/src/views/Order/StatusPanel.vue
index 3680b13..ba92e0a 100644
--- a/frontend/src/views/Order/StatusPanel.vue
+++ b/frontend/src/views/Order/StatusPanel.vue
@@ -8,6 +8,7 @@ import RecordPickerDialog from '@/components/RecordPickerDialog.vue'
import OrderFormDialog from './OrderFormDialog.vue'
import { DEFAULT_PAGE_SIZE, useListPage } from '@/composables/useListPage'
import { formatDateTime } from '@/utils/datetime'
+import { platformNameOf } from '@/constants/platform'
import {
ORDER_STAGE_META,
archiveOrders,
@@ -787,6 +788,9 @@ onMounted(async () => {
{{ platformOrderNoOf(detailRow) }}
+
+ {{ platformNameOf(detailRow.source_platform_code) }}
+
{{ detailRow.status_label || ORDER_STAGE_META[detailRow.status]?.label }}
diff --git a/frontend/src/views/ShopProduct/Index.vue b/frontend/src/views/ShopProduct/Index.vue
index bbdabb9..3d9c019 100644
--- a/frontend/src/views/ShopProduct/Index.vue
+++ b/frontend/src/views/ShopProduct/Index.vue
@@ -19,6 +19,7 @@ import ListPager from '@/components/ListPager.vue'
import OperationLogPanel from '@/components/OperationLogPanel.vue'
import { DEFAULT_PAGE_SIZE, useListPage } from '@/composables/useListPage'
import VirtualSelect from '@/components/VirtualSelect.vue'
+import { platformNameOf } from '@/constants/platform'
const BIND_TAGS: Record = { 0: 'info', 1: 'success', 2: 'warning' }
const BIND_LABELS: Record = { 0: '未绑定', 1: '系统商品', 2: '组合商品' }
@@ -585,7 +586,7 @@ onBeforeUnmount(() => {
{{ row.shop?.name || '-' }}
- {{ row.platform_type || '-' }}
+ {{ platformNameOf(row.platform_type) }}