Исправление отрицательных значений coins_add, coins_del

main
Your Name 2 weeks ago
parent 15f882085a
commit f3eb0c9435

@ -134,7 +134,7 @@ class Coins_add(BaseModel):
amount: str
@app.post('/api/coins_add/')
def coins_add(it: Coins_add):
token, id, amount = it.token, it.id, float(it.amount)
token, id, amount = it.token, it.id, abs(float(it.amount))
if token_check(token):
db = read()
db['id'][id]['bal'] = fix_add(db['id'][id]['bal'], amount)
@ -150,15 +150,18 @@ class Coins_del(BaseModel):
amount: str
@app.post('/api/coins_del/')
def coins_del(it: Coins_del):
token, id, amount = it.token, it.id, float(it.amount)
token, id, amount = it.token, it.id, abs(float(it.amount))
if token_check(token):
db = read()
if db['id'][id]['bal'] >= amount:
db['id'][id]['bal'] = fix_sub(db['id'][id]['bal'], amount)
write(db)
stat_run(amount*-1)
return 'OK'
else:
return 'Error'
else:
return 'Error'
class Coins_transfer(BaseModel):
token: str

Loading…
Cancel
Save