STUDY WHILE YOU ARE BORING


  • 首頁

  • 搜索

  • 技术

  • Tags

  • 关于我

UPS Shipment IdentifyID (SHIPID) 如何生成?

發表於 November 25, 2014   |   作者: Tim   |   分类: 技术   |   评论

UPS 电子打单发票页上面有一个 ShipID 俗称「短单号」。是根据长单号自动计算出来的,那么是怎么计算出来的呢?
正常单号:1Z4V90A96768678127
短单号:4V90A9N3SKP

那么这个号是怎么计算出来的呢?
从往上找了很多资料都没有找到,最有线索的一篇文章是下面这篇:

Generating the UPS shipment ID per packing list Conversion of a string
with BASE26 calculation

  1. Tracking ID: 1Z 123 X56 Y6 4400 0050

  2. Exclude the Data Identifier 1Z: __ 123 X56 Y6 4400 0050

  3. Exclude the shipper number: __ Y6 4400 0050

  4. Exclude the service indicator and check digit: _ __ 4400 005

  5. Calculate 4400 005 : 26**4 = 9,628

  6. Calculate (4400 005 - (9*264)) : 263 = 16,341
  7. Calculate (4400 005 - (9264) - (16263)) : 26**2 = 8,883

  8. Calculate (4400 005 - (9264) - (16263) - (826*2)) : 26 = 22,961
  9. Calculate 4400 005 - (9264) - (16263) - (8262) - (2226) = 25,000
    5 intermediate results: 9 16 8 22
  10. Base 26 cross reference

Value: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
Converted Value: 3 4 7 8 9 B C D F G H J K L M N P Q R S T V W X Y Z

  1. G P F W Z
  2. Final Shipment Number: 123X 56GP FWZ
    上面一段说明,大家能给我说说最后的shipment number 是怎么计算的吗,主要是5-9不明白什么意思,没见过这种计算方式

http://ajava.org/thread-537-1-1.html

再次证实了这个号码是根据正常单号算出来的!!!
但是这个文章的内容没有人解答,原文中下面的解答也是瞎猜,测试其他单号并不能计算出来。
最后经过我的详细研究,终于给「公婆」了!

  1. 首先前面4步是没有错的,抽取出对应的需要转换的数字,取第10位到第17位的数字 4400005
  2. 重点来了!这窜数字经过一系列的运算就能转换出 G P F W Z
  3. 前面加上帐号位(从第3位到第8位),就是 123X56GPFWZ

是不是很简单?

下面是详细的方法,以1Z4V90A96768678127为例:

  1. 抽取2至8位,4V90A9
  2. 抽取10到17位$num10(6867812),10进制转换为26进制$num26(f0jcg)
  3. 如果转换后的26进制$num26长度小于5位,末尾补3
  4. 按照0~25 从字典(3 4 7 8 9 B C D F G H J K L M N P Q R S T V W X Y Z)中取值替换,例如 f是15,那么f=N。以此类推,f0jcg=N3SKP
  5. 拼合步骤1),得到 4V90A9N3SKP
ups
php isset 的坑 - 正确判断数组里面的键是否存在
当redmine遇上https 的svn

钜添

56 文章
2 分類
1 页面
GitHub 日记技术
php apache centos macos mysql https shadowsocks mac 微信 ups svn javascript outline accesskey Chrome Extension letsencrypt ssl free certification certbo wildcard renew cloudflare pgsql 归档 binlog isset array_key_exists redmine axure
© 2026 钜添   |   文章 RSS     |  登录
由 Typecho 强力驱动
主題 - NexT
Send message encrypted and private - Msg2
Build your Under Construction Page without hosting - UnderConstruct.IO