wallet tron transactions

This commit is contained in:
cano
2024-03-25 06:15:36 +08:00
parent 4b8f205e86
commit 489090382f
83 changed files with 5424 additions and 1343 deletions

View File

@ -67,57 +67,70 @@ class WalletPlatformBalanceModel extends WalletBaseModel
}
return $resModel;
}
//增加平台余额
function incAvailableBalance($id, $amount): bool
function frozenAmount($id,$amount): bool|int
{
$amount = abs($amount);
$oModel = $this->newQuery()->where('id', $id)->first(['total_amount', 'available_amount']);
if (!$oModel) throw new ModelException('找不到id');
$oModel->frozen_amount = Db::raw('total_amount + ' . $amount);
$oModel->available_amount = Db::raw('available_amount + ' . $amount);
return $oModel->save();
$updateItem = [
'id' => $id,
'frozen_amount' => DB::raw('frozen_amount + '. $amount),
'available_amount' => DB::raw('available_amount - '. $amount),
];
return $this->updateItem($updateItem);
}
//扣除平台余额
function decAvailableBalance($id, $amount): bool
function unFrozenAmount($id,$amount): bool|int
{
$amount = abs($amount);
$oModel = $this->newQuery()->where('id', $id)->first(['total_amount', 'available_amount']);
if (!$oModel) throw new ModelException('找不到id');
$oModel->frozen_amount = Db::raw('total_amount - ' . $amount);
$oModel->available_amount = Db::raw('available_amount - ' . $amount);
return $oModel->save();
$updateItem = [
'id' => $id,
'frozen_amount' => DB::raw('frozen_amount - '. $amount),
'available_amount' => DB::raw('available_amount + '. $amount),
];
return $this->updateItem($updateItem);
}
function decFrozenAmountById($id, $amount): int
function subFrozenAmount($id, $amount): bool|int
{
$amount = abs($amount);
$oModel = $this->newQuery()->where('id', $id)->first(['total_amount', 'frozen_amount']);
if (!$oModel) throw new ModelException('找不到id');
$oModel->frozen_amount = Db::raw('frozen_amount - ' . $amount);
$oModel->total_amount = Db::raw('total_amount - ' . $amount);
return $oModel->save();
$updateItem = [
'id' => $id,
'total_amount' => DB::raw('total_amount - '. $amount),
'frozen_amount' => DB::raw('frozen_amount - '. $amount),
];
return $this->updateItem($updateItem);
}
function unFrozenAmountById($id, $amount): int
function addFrozenAmount($id, $amount): bool|int
{
$amount = abs($amount);
$oModel = $this->newQuery()->where('id', $id)->first(['frozen_amount', 'available_amount']);
if (!$oModel) throw new ModelException('找不到id');
$oModel->frozen_amount = Db::raw('frozen_amount - ' . $amount);
$oModel->available_amount = Db::raw('available_amount + ' . $amount);
return $oModel->save();
$updateItem = [
'id' => $id,
'total_amount' => DB::raw('total_amount + '. $amount),
'frozen_amount' => DB::raw('frozen_amount + '. $amount),
];
return $this->updateItem($updateItem);
}
function frozenAmountById($id, $amount): int
function subAvailableAmount($id, $amount): bool|int
{
$amount = abs($amount);
$oModel = $this->newQuery()->where('id', $id)->first(['frozen_amount', 'available_amount']);
if (!$oModel) throw new ModelException('找不到id');
$oModel->frozen_amount = Db::raw('frozen_amount + ' . $amount);
$oModel->available_amount = Db::raw('available_amount - ' . $amount);
return $oModel->save();
$updateItem = [
'id' => $id,
'total_amount' => DB::raw('total_amount - '. $amount),
'available_amount' => DB::raw('available_amount - '. $amount),
];
return $this->updateItem($updateItem);
}
function addAvailableAmount($id, $amount): bool|int
{
$amount = abs($amount);
$updateItem = [
'id' => $id,
'total_amount' => DB::raw('total_amount + '. $amount),
'available_amount' => DB::raw('available_amount + '. $amount),
];
return $this->updateItem($updateItem);
}