Thoughts on WeChat Pay's convenience of inquiring when recording the order number

A reward system in which openid and ID (1-999999) users click on the payment notify to get out_trade_no,
I want to write information about who rewards whom to the database, then openid (28 bits) + random 4 bits take up exactly 32 bits. However, random 4-bit strings can easily cause repetition of the order number, so years, months, days, plus strings are usually used, but if ID is used, once the ID changes, or due to other reasons, the payment data will not correspond.
another way is to insert all the required information to the database when generating payment information, and then update this record when it is successfully notified, but this results in a waste of server resources.
there is another way to use ID (6) + the other party"s openid.substring (0Jing 14) + year, month and day (180910) + random (6)
6 "14" 6 "6" 32, but if there is a lot of payment information in a day, there may still be duplication.
what do you experts usually do? The participants themselves would like to give a small reward. :)

Jun.04,2021

another way is to insert all the required information to the database when generating payment information, and then update this record when it is successfully notified, but this results in a waste of server resources.

Why do you think Wechat asked you to provide a merchant order number?
openid corresponds to a single service principal. Or, now that you mention "reward", at least it won't generate too much data. The order number of Alipay is only 40?! ?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e634e6-45a37.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e634e6-45a37.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?