A good algorithm for generating an order number

前端 未结 10 1454
青春惊慌失措
青春惊慌失措 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:12

    One simple option is to use the date and time, eg. 0912012359, and if two orders are received in the same minute, simply increment the second order by a minute (it doesn't matter if the time is out, it's just an order number).

    If you don't want the date to be visible, then calculate it as the number of minutes since a fixed point in time, eg. when you started taking orders or some other arbitary date. Again, with the duplicate check/increment.

    Your competitors will glean nothing from this, and it's easy to implement.

提交回复
热议问题