Skip to content

Commit 85c2aa7

Browse files
committed
修复request_id可能重复的bug
1 parent 51475a5 commit 85c2aa7

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

linkv_sdk/live/live.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def SuccessOrderByLiveOpenID(live_open_id, order_type, gold, money, expr, platfo
100100
'nonce_str': nonce,
101101
'app_id': config().app_key,
102102
'uid': live_open_id,
103-
'request_id': genUniqueIDString(),
103+
'request_id': genUniqueIDString(config().app_key),
104104
'type': str(order_type),
105105
'value': str(gold),
106106
'money': str(money),
@@ -153,13 +153,13 @@ def SuccessOrderByLiveOpenID(live_open_id, order_type, gold, money, expr, platfo
153153

154154
@staticmethod
155155
def ChangeGoldByLiveOpenID(live_open_id, order_type, gold, expr, optional_reason=''):
156-
156+
print(genUniqueIDString(config().app_key))
157157
nonce = genRandomString()
158158
params = {
159159
'nonce_str': nonce,
160160
'app_id': config().app_key,
161161
'uid': live_open_id,
162-
'request_id': genUniqueIDString(),
162+
'request_id': genUniqueIDString(config().app_key),
163163
'type': str(order_type),
164164
'value': str(gold),
165165
}
@@ -278,8 +278,11 @@ def GetGoldByLiveOpenID(self, live_open_id):
278278
return super(LvLIVE, self).GetGoldByLiveOpenID(live_open_id)
279279

280280

281-
def genUniqueIDString():
282-
return ''.join(random.sample('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890', 32))
281+
def genUniqueIDString(app_key):
282+
return '{}-{}'.format(
283+
app_key[2:],
284+
''.join(random.sample('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890', 9)),
285+
)
283286

284287

285288
def genRandomString():

0 commit comments

Comments
 (0)