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?! ?

Menu