fix(inbox): queryPackVideo 打包视频地址拼接 CDN 域名
This commit is contained in:
parent
3352fbaff6
commit
63713bf490
@ -2163,14 +2163,6 @@ class InboxFunctionsService extends Service {
|
||||
const toCreate = expressList.filter(e => !existingWaybillIds.has(e.id));
|
||||
const alreadyExist = existingASList.map(r => r.after_sale_no);
|
||||
|
||||
const existedPairs = expressList
|
||||
.filter(e => existingWaybillIds.has(e.id))
|
||||
.map(e => {
|
||||
const row = existingASList.find(r => Number(r.waybill_id) === Number(e.id));
|
||||
return { waybill: e.waybill_code, as_no: (row && row.after_sale_no) || '' };
|
||||
})
|
||||
.filter(p => p.as_no);
|
||||
|
||||
// 第三步:创建工单(含原文)并映射 waybill_id → 工单号
|
||||
const createdNos = [];
|
||||
const waybillToAsNo = {}; // waybill_id → after_sale_no 映射(新建 + 已存在)
|
||||
@ -2285,12 +2277,18 @@ class InboxFunctionsService extends Service {
|
||||
}
|
||||
}
|
||||
|
||||
// 第六步:客户回信模板(单号+诉求+工单)
|
||||
const createdPairs = toCreate.map(e => ({
|
||||
waybill: e.waybill_code,
|
||||
as_no: waybillToAsNo[e.id] || '',
|
||||
}));
|
||||
const lines = [ ...createdPairs, ...existedPairs ].map(p => `运单${p.waybill} ${issue.label}问题已登记,工单:${p.as_no}`);
|
||||
// 第六步:客户回信模板(单号+诉求,区分是否已通知快递)
|
||||
const REPLY_TEXT = {
|
||||
addr: { done: '修改地址已经登记', notify: '并已通知快递修改' },
|
||||
return: { done: '催退回已经登记', notify: '并已通知快递处理' },
|
||||
};
|
||||
const replyText = REPLY_TEXT[issue.sub_type] || REPLY_TEXT.addr;
|
||||
const lines = expressList.map(e => {
|
||||
const head = `运单${e.waybill_code}${replyText.done}`;
|
||||
return notifiedWaybillIds.has(e.id)
|
||||
? `${head}·${replyText.notify}`
|
||||
: `${head},稍后客服将人工跟进`;
|
||||
});
|
||||
if (notFound.length > 0) {
|
||||
lines.push(`未找到运单:${notFound.join('、')},请核实单号`);
|
||||
}
|
||||
@ -2308,7 +2306,7 @@ class InboxFunctionsService extends Service {
|
||||
after_sale_nos: [ ...createdNos, ...alreadyExist ],
|
||||
notified_groups: notifiedTotal,
|
||||
not_found: notFound,
|
||||
message: `${lines.join('\n')},稍后客服将人工核实跟进`,
|
||||
message: lines.join('\n'),
|
||||
direct_reply: true,
|
||||
},
|
||||
};
|
||||
@ -3172,9 +3170,11 @@ class InboxFunctionsService extends Service {
|
||||
},
|
||||
raw: true,
|
||||
});
|
||||
// 视频地址拼接 CDN 域名(与 order.packing.list、queryReturn 对齐)
|
||||
const recordingComputerId = await this._getRecordingComputerId(warehouseId);
|
||||
const urls = videos
|
||||
.filter(v => String(v.status || '') !== 'failed')
|
||||
.map(v => String(v.video_url || '').trim())
|
||||
.map(v => this._buildVideoUrl(warehouseId, recordingComputerId, v.video_url))
|
||||
.filter(Boolean);
|
||||
|
||||
if (urls.length === 0) {
|
||||
@ -3924,6 +3924,45 @@ class InboxFunctionsService extends Service {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取仓库的录制电脑 ID(带缓存)。
|
||||
* @param {number} warehouseId 仓库ID
|
||||
* @return {Promise<number|null>} 录制电脑ID,找不到返回 null
|
||||
*/
|
||||
async _getRecordingComputerId(warehouseId) {
|
||||
const cacheKey = `_recordingComputer_${warehouseId}`;
|
||||
if (this[cacheKey] !== undefined) {
|
||||
return this[cacheKey];
|
||||
}
|
||||
const row = await this.ctx.model.PrintComputer.findOne({
|
||||
where: { warehouse_id: warehouseId, is_recording: true, deleted_at: null },
|
||||
attributes: [ 'id' ],
|
||||
raw: true,
|
||||
});
|
||||
this[cacheKey] = row ? row.id : null;
|
||||
return this[cacheKey];
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建视频完整 URL。
|
||||
* 格式:http://w{warehouseId}-c{recordingComputerId}.o.gztbyc.com{videoPath}
|
||||
* @param {number} warehouseId 仓库ID
|
||||
* @param {number|null} recordingComputerId 录制电脑ID
|
||||
* @param {string} videoPath 视频路径
|
||||
* @return {string} 完整 URL
|
||||
*/
|
||||
_buildVideoUrl(warehouseId, recordingComputerId, videoPath) {
|
||||
const path = String(videoPath || '').trim();
|
||||
if (!path || !recordingComputerId) {
|
||||
return path;
|
||||
}
|
||||
// 已是完整 URL 时原样返回,避免重复拼接
|
||||
if (/^https?:\/\//i.test(path)) {
|
||||
return path;
|
||||
}
|
||||
return `http://w${warehouseId}-c${recordingComputerId}.o.gztbyc.com${path}`;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = InboxFunctionsService;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user