🐛 修复底层修改导致的扫码登陆部分情况报错

This commit is contained in:
KimigaiiWuyi 2023-09-22 00:09:22 +08:00
parent 887d25ac2a
commit e101d942a2
2 changed files with 16 additions and 13 deletions

View File

@ -237,33 +237,32 @@ async def _deal_ck(bot_id: str, mes: str, user_id: str) -> str:
fp = await mys_api.generate_fp_by_uid(uid) fp = await mys_api.generate_fp_by_uid(uid)
# 往数据库添加内容 # 往数据库添加内容
if uid and await GsUser.user_exists(uid): if uid_bind and await GsUser.user_exists(uid_bind):
await GsUser.update_data_by_uid( await GsUser.update_data_by_uid(
uid, uid_bind,
bot_id, bot_id,
cookie=account_cookie, cookie=account_cookie,
status=None, status=None,
stoken=app_cookie, stoken=app_cookie,
sr_uid=sr_uid, sr_uid=sr_uid_bind,
fp=fp, fp=fp,
) )
elif sr_uid and await GsUser.user_exists(sr_uid, 'sr'): elif sr_uid_bind and await GsUser.user_exists(sr_uid_bind, 'sr'):
await GsUser.update_data_by_uid( await GsUser.update_data_by_uid(
sr_uid, sr_uid_bind,
bot_id, bot_id,
'sr', 'sr',
cookie=account_cookie, cookie=account_cookie,
status=None, status=None,
stoken=app_cookie, stoken=app_cookie,
sr_uid=sr_uid,
fp=fp, fp=fp,
) )
else: else:
await GsUser.insert_data( await GsUser.insert_data(
user_id=user_id, user_id=user_id,
bot_id=bot_id, bot_id=bot_id,
uid=uid, uid=uid_bind,
sr_uid=sr_uid, sr_uid=sr_uid_bind,
mys_id=account_id, mys_id=account_id,
cookie=account_cookie, cookie=account_cookie,
stoken=app_cookie if app_cookie else None, stoken=app_cookie if app_cookie else None,
@ -271,8 +270,10 @@ async def _deal_ck(bot_id: str, mes: str, user_id: str) -> str:
push_switch='off', push_switch='off',
bbs_switch='off', bbs_switch='off',
draw_switch='off', draw_switch='off',
region=SERVER.get(uid[0], 'cn_gf01') if uid else None, region=SERVER.get(uid_bind[0], 'cn_gf01') if uid_bind else None,
sr_region=SR_SERVER.get(sr_uid[0], None) if sr_uid else None, sr_region=SR_SERVER.get(sr_uid_bind[0], None)
if sr_uid_bind
else None,
fp=fp, fp=fp,
device_id=device_id, device_id=device_id,
sr_push_switch='off', sr_push_switch='off',

View File

@ -111,11 +111,13 @@ class BaseBotIDModel(BaseIDModel):
game_name: Optional[str] = None, game_name: Optional[str] = None,
**data, **data,
) -> int: ) -> int:
if not await cls.data_exist(uid=uid): uid_name = cls.get_gameid_name(game_name)
return await cls.full_insert_data(uid=uid, bot_id=bot_id, **data) if not await cls.data_exist(**{uid_name: uid}):
data[uid_name] = uid
return await cls.full_insert_data(bot_id=bot_id, **data)
sql = update(cls).where( sql = update(cls).where(
getattr(cls, cls.get_gameid_name(game_name)) == uid, getattr(cls, uid_name) == uid,
cls.bot_id == bot_id, cls.bot_id == bot_id,
) )
if data is not None: if data is not None: