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" + } } ] }