feat: 抖音面单自定义区模板出口域名改为可配置路由

- 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,由运行时代码动态拼装
This commit is contained in:
liufumingren 2026-08-02 00:35:08 +08:00
parent 8ee12374b3
commit 05b71b2f31
6 changed files with 28 additions and 5 deletions

View File

@ -8,5 +8,19 @@ class TemplateController extends Controller {
const result = await service.systems.setting.printTemplate.getXmlByTemplate(ctx.params.id); const result = await service.systems.setting.printTemplate.getXmlByTemplate(ctx.params.id);
ctx.body = result; ctx.body = result;
} }
/**
* 输出抖音面单自定义区模板 XML(douyin1.xml)
*/
async douyinCustomArea() {
const { ctx } = this;
ctx.type = 'application/xml';
ctx.body = `<?xml version="1.0" encoding="UTF-8"?>
<layout id="CUSTOM_AREA" width="97" height="60" left="0" top="111" style="">
<layout width="57" height="30" left="2" top="2" style="">
<text style="fontFamily:宋体;fontSize:9;fontWeight:600"><![CDATA[<%=_data.productInfo%>]]></text>
</layout>
</layout>`;
}
} }
module.exports = TemplateController; module.exports = TemplateController;

View File

@ -1584,8 +1584,10 @@ function resolveDouyinParams(orderExpress) {
* @param {Object} orderExpress 快递单对象。 * @param {Object} orderExpress 快递单对象。
* @param {Object} orderDelivery 订单对象。 * @param {Object} orderDelivery 订单对象。
* @param {Object} policyConfig 策略配置对象。 * @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') { if (platform !== 'douyin') {
return; return;
} }
@ -1697,7 +1699,8 @@ function applyDouyinExpressFieldMapping(platform, skeleton, orderExpress, orderD
} }
const customContent = contents[1]; const customContent = contents[1];
if (!toTrimmedString(customContent.templateURL)) { 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 = isPlainObject(customContent.data) ? customContent.data : {};
customContent.data.productInfo = customProductInfo || '无拣货信息'; customContent.data.productInfo = customProductInfo || '无拣货信息';
@ -2415,7 +2418,8 @@ function buildPlatformRequestSkeleton(input = {}) {
orderExpressForCompose, orderExpressForCompose,
orderDeliveryForCompose, orderDeliveryForCompose,
policyConfig, policyConfig,
extraCustomLines extraCustomLines,
options.customAreaBaseUrl
); );
applyJdExpressFieldMapping( applyJdExpressFieldMapping(

View File

@ -50,6 +50,9 @@ module.exports = app => {
// 打印模板 // 打印模板
router.get('/template/xml/:id', controller.template.xml); 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.get('/auth/printSetting/:code', controller.auth.printerSetting);
router.post('/auth/printSetting/', controller.auth.printerSetting); router.post('/auth/printSetting/', controller.auth.printerSetting);

View File

@ -3055,6 +3055,7 @@ ${waveFilterSql}
documentId, documentId,
packageMaterialName: suggestedPackageMaterialName, packageMaterialName: suggestedPackageMaterialName,
extraCustomLines, extraCustomLines,
customAreaBaseUrl: this.ctx.app.config.customAreaBaseUrl || '',
}, },
}); });
const printData = this.extractSinglePlatformPrintData(printPayload); const printData = this.extractSinglePlatformPrintData(printPayload);

View File

@ -210,6 +210,8 @@ module.exports = appInfo => {
batchSize: 50, batchSize: 50,
force: false, force: false,
}; };
// 打印自定义区模板出口域名
config.customAreaBaseUrl = 'https://api.ye4s.com';
return { return {
...config, ...config,

View File

@ -47,8 +47,7 @@
{ {
"data": { "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验视员:" "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"
} }
] ]
} }