Skip to content

Commit c1a8e23

Browse files
committed
修复request_id 可能重复的bug
1 parent 8c7a07f commit c1a8e23

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

linkv_sdk/live/live.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def SuccessOrderByLiveOpenID(live_open_id: str, order_type: int, gold: int, mone
102102
'nonce_str': nonce,
103103
'app_id': config().app_key,
104104
'uid': live_open_id,
105-
'request_id': genUniqueIDString(),
105+
'request_id': genUniqueIDString(config().app_key),
106106
'type': str(order_type),
107107
'value': str(gold),
108108
'money': str(money),
@@ -160,7 +160,7 @@ def ChangeGoldByLiveOpenID(live_open_id: str, order_type: int, gold: int, expr:
160160
'nonce_str': nonce,
161161
'app_id': config().app_key,
162162
'uid': live_open_id,
163-
'request_id': genUniqueIDString(),
163+
'request_id': genUniqueIDString(config().app_key),
164164
'type': str(order_type),
165165
'value': str(gold),
166166
}
@@ -279,8 +279,11 @@ def GetGoldByLiveOpenID(self, live_open_id: str) -> dict:
279279
return super(LvLIVE, self).GetGoldByLiveOpenID(live_open_id)
280280

281281

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

285288

286289
def genRandomString() -> str:

0 commit comments

Comments
 (0)