|
|
|
@ -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,13 +150,16 @@ 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()
|
|
|
|
|
db['id'][id]['bal'] = fix_sub(db['id'][id]['bal'], amount)
|
|
|
|
|
write(db)
|
|
|
|
|
stat_run(amount*-1)
|
|
|
|
|
return 'OK'
|
|
|
|
|
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'
|
|
|
|
|
|
|
|
|
|