A good algorithm for generating an order number

前端 未结 10 1467
青春惊慌失措
青春惊慌失措 2021-01-31 06:27

As much as I like using GUIDs as the unique identifiers in my system, it is not very user-friendly for fields like an order number where a customer may have to repeat that to a

10条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-31 07:02

    Your 10 digit requirement is a huge limitation. Consider a two stage approach.

    1. Use a GUID
    2. Prefix the GUID with a 10 digit (or 5 or 4 digit) hash of the GUID.

    You will have multiple hits on the hash value. But not that many. The customer service people will very easily be able to figure out which order is in question based on additional information from the customer.

提交回复
热议问题