用户账变 用户钱包

This commit is contained in:
cano
2024-03-10 00:44:58 +08:00
parent 025dab4c2c
commit 6d242ae973
17 changed files with 1617 additions and 16 deletions

View File

@ -10,6 +10,7 @@ use App\Tools\Times;
use App\Tools\Tools;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Symfony\Contracts\Service;
class WalletPlatformBalanceTransactionModel extends WalletBaseModel
{
@ -156,17 +157,22 @@ class WalletPlatformBalanceTransactionModel extends WalletBaseModel
}
//成功提现处理
function withdrawSuccByUserTransactionId($user_transaction_id, $remark = ''): bool
function withdrawSuccByUserTransactionId($user_transaction_id,$entered_amount, $remark = ''): bool
{
try{
Db::beginTransaction();
$resModel = $this->findItemByWhere(['from_user_transaction_id' => $user_transaction_id, 'type' => self::TYPE_USER_WITHDRAW]);
if (!$resModel) return false;
if (!in_array($resModel->status, [self::STATUS_WAITING_QUEUE, self::STATUS_CHAIN_WAITING_CALLBACK])) return false;
$resModel->status = self::STATUS_SUCCESS;
if(!empty($remark)) $resModel->remark = $remark;
$resModel->updated_at = Times::getNowDateTime();
$res = $resModel->save();
if (!$resModel) throw new ModelException('user transaction not found');
if (!in_array($resModel->status, [self::STATUS_WAITING_QUEUE, self::STATUS_CHAIN_WAITING_CALLBACK])) throw new ModelException('status error');
$updateItems = [
'id' => $resModel->id,
'status' => self::STATUS_SUCCESS,
'updated_at' => Times::getNowDateTime(),
'entered_amount' => $entered_amount,
'fee_amount' => Db::raw('received_amount - '.$entered_amount),
];
if(!empty($remark)) $updateItems['remark'] = $remark;
$res = $this->updateItem($updateItems);
if(!$res) throw new ModelException('save error');
//扣除平台冻结余额
@ -196,9 +202,13 @@ class WalletPlatformBalanceTransactionModel extends WalletBaseModel
if (!$resModel) throw new ModelException('user transaction not found');
if (!in_array($resModel->status, [self::STATUS_WAITING_QUEUE, self::STATUS_CHAIN_WAITING_CALLBACK])) throw new ModelException('status error');
//更改账变状态
$resModel->status = self::STATUS_FAIL;
if(!empty($remark)) $resModel->remark = $remark;
$res = $resModel->save();
$updateItems = [
'id' => $resModel->id,
'status' => self::STATUS_FAIL,
'updated_at' => Times::getNowDateTime(),
];
if(!empty($remark)) $updateItems['remark'] = $remark;
$res = $this->updateItem($updateItems);
if (!$res) throw new ModelException('save error');
//解冻平台余额