From 05b71b2f31efbd94d23b446d754e6f8d3c3f0431 Mon Sep 17 00:00:00 2001 From: liufumingren Date: Sun, 2 Aug 2026 00:35:08 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=8A=96=E9=9F=B3=E9=9D=A2=E5=8D=95?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E5=8C=BA=E6=A8=A1=E6=9D=BF=E5=87=BA?= =?UTF-8?q?=E5=8F=A3=E5=9F=9F=E5=90=8D=E6=94=B9=E4=B8=BA=E5=8F=AF=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - config.default.js: 新增 customAreaBaseUrl 出口域名配置 - router.js: 新增 GET /mb/douyin1.xml 路由 - controller/template.js: 新增 douyinCustomArea() 方法输出静态 XML - printer_data_builder.js: applyDouyinExpressFieldMapping 支持 customAreaBaseUrl 参数 - order_print.js: 将 app.config.customAreaBaseUrl 传入 buildPlatformRequestSkeleton - douyin.json: 移除硬编码 templateURL,由运行时代码动态拼装 --- app/controller/template.js | 14 ++++++++++++++ app/lib/printer_data_builder.js | 10 +++++++--- app/router.js | 3 +++ app/service/systems/order_print.js | 1 + config/config.default.js | 2 ++ printer_data_template/douyin.json | 3 +-- 6 files changed, 28 insertions(+), 5 deletions(-) diff --git a/app/controller/template.js b/app/controller/template.js index 33c5868..21cf12e 100644 --- a/app/controller/template.js +++ b/app/controller/template.js @@ -8,5 +8,19 @@ class TemplateController extends Controller { const result = await service.systems.setting.printTemplate.getXmlByTemplate(ctx.params.id); ctx.body = result; } + + /** + * 输出抖音面单自定义区模板 XML(douyin1.xml) + */ + async douyinCustomArea() { + const { ctx } = this; + ctx.type = 'application/xml'; + ctx.body = ` + + + ]]> + +`; + } } module.exports = TemplateController; diff --git a/app/lib/printer_data_builder.js b/app/lib/printer_data_builder.js index c389d8e..8f4cfa7 100644 --- a/app/lib/printer_data_builder.js +++ b/app/lib/printer_data_builder.js @@ -1584,8 +1584,10 @@ function resolveDouyinParams(orderExpress) { * @param {Object} orderExpress 快递单对象。 * @param {Object} orderDelivery 订单对象。 * @param {Object} policyConfig 策略配置对象。 + * @param {string[]} extraCustomLines 额外的自定义文本行。 + * @param {string} customAreaBaseUrl 自定义区模板出口域名。 */ -function applyDouyinExpressFieldMapping(platform, skeleton, orderExpress, orderDelivery, policyConfig, extraCustomLines = []) { +function applyDouyinExpressFieldMapping(platform, skeleton, orderExpress, orderDelivery, policyConfig, extraCustomLines = [], customAreaBaseUrl = '') { if (platform !== 'douyin') { return; } @@ -1697,7 +1699,8 @@ function applyDouyinExpressFieldMapping(platform, skeleton, orderExpress, orderD } const customContent = contents[1]; if (!toTrimmedString(customContent.templateURL)) { - customContent.templateURL = 'http://www.ye4s.com/mb/douyin1.xml'; + const baseUrl = toTrimmedString(customAreaBaseUrl) || 'http://www.ye4s.com'; + customContent.templateURL = baseUrl + '/mb/douyin1.xml'; } customContent.data = isPlainObject(customContent.data) ? customContent.data : {}; customContent.data.productInfo = customProductInfo || '无拣货信息'; @@ -2415,7 +2418,8 @@ function buildPlatformRequestSkeleton(input = {}) { orderExpressForCompose, orderDeliveryForCompose, policyConfig, - extraCustomLines + extraCustomLines, + options.customAreaBaseUrl ); applyJdExpressFieldMapping( diff --git a/app/router.js b/app/router.js index c583b96..fb4cd42 100644 --- a/app/router.js +++ b/app/router.js @@ -50,6 +50,9 @@ module.exports = app => { // 打印模板 router.get('/template/xml/:id', controller.template.xml); + // 打印自定义区模板(抖音面单等) + router.get('/mb/douyin1.xml', controller.template.douyinCustomArea); + // 打印台设置 router.get('/auth/printSetting/:code', controller.auth.printerSetting); router.post('/auth/printSetting/', controller.auth.printerSetting); diff --git a/app/service/systems/order_print.js b/app/service/systems/order_print.js index 3db9e1a..86d833a 100644 --- a/app/service/systems/order_print.js +++ b/app/service/systems/order_print.js @@ -3055,6 +3055,7 @@ ${waveFilterSql} documentId, packageMaterialName: suggestedPackageMaterialName, extraCustomLines, + customAreaBaseUrl: this.ctx.app.config.customAreaBaseUrl || '', }, }); const printData = this.extractSinglePlatformPrintData(printPayload); diff --git a/config/config.default.js b/config/config.default.js index 79dc675..7e1a222 100644 --- a/config/config.default.js +++ b/config/config.default.js @@ -210,6 +210,8 @@ module.exports = appInfo => { batchSize: 50, force: false, }; + // 打印自定义区模板出口域名 + config.customAreaBaseUrl = 'https://api.ye4s.com'; return { ...config, diff --git a/printer_data_template/douyin.json b/printer_data_template/douyin.json index be5d3f9..fe21b24 100644 --- a/printer_data_template/douyin.json +++ b/printer_data_template/douyin.json @@ -47,8 +47,7 @@ { "data": { "productInfo": "#0 B1340646-1-1 商品总数 【2】\nE1区06-11-01 6949517008816;6949517008342;6949517008229 【1】 0\nE1区06-08-01 69000007 【1】 0\n\n验视员:" - }, - "templateURL": "http://www.ye4s.com/mb/douyin1.xml" + } } ] }