fix(lastleg): prevent transfer business number collisions

This commit is contained in:
2026-10-06 00:20:43 +08:00
parent 4bde1a8352
commit 60543adf63
3 changed files with 18 additions and 3 deletions
@@ -47,6 +47,11 @@ public class LastlegOrderNoGenerator {
// Return numbers are independent business identifiers, not truncated database IDs.
// Keep every UUID bit; the longest result (RETU + 25 base-36 digits) fits VARCHAR(32).
if (returnPrefix != null) return returnPrefix + "-" + encodeReturnUuid(UUID.randomUUID());
// Transfer numbers also identify synthetic inbound events globally. Truncating
// a database ID to six digits can collide between unrelated fresh transfers.
if ("TRANSFER".equals(code) || "WAREHOUSE_TRANSFER".equals(code)) {
return "WT-" + encodeReturnUuid(UUID.randomUUID());
}
String type = normalizeType(businessType);
return type + "-" + warehouseCode(warehouse) + "-"
+ LocalDate.now().format(DateTimeFormatter.BASIC_ISO_DATE) + "-"