wallet_fix
This commit is contained in:
@ -27,6 +27,7 @@ class WalletPlatformBalanceTransactionModel extends WalletBaseModel
|
||||
'from_user_transaction_id',
|
||||
'from_uid',
|
||||
'wallet_addr',
|
||||
'from_wallet_transaction_id',
|
||||
'received_amount',
|
||||
'entered_amount',
|
||||
'fee_amount',
|
||||
@ -69,6 +70,7 @@ class WalletPlatformBalanceTransactionModel extends WalletBaseModel
|
||||
$entered_amount,
|
||||
$platform_id,
|
||||
$currency_code,
|
||||
$from_uid = '',
|
||||
$from_user_transaction_id = '',
|
||||
$from_wallet_addr_id = '',
|
||||
$wallet_addr = '',
|
||||
@ -109,6 +111,7 @@ class WalletPlatformBalanceTransactionModel extends WalletBaseModel
|
||||
'currency_type' => $resWalletPlatformBalanceModel->currency_type,
|
||||
'from_wallet_addr_id' => $from_wallet_addr_id,
|
||||
'from_user_transaction_id' => $from_user_transaction_id,
|
||||
'from_uid' => $from_uid,
|
||||
'wallet_addr' => $wallet_addr,
|
||||
'received_amount' => $received_amount,
|
||||
'entered_amount' => $entered_amount,
|
||||
@ -130,11 +133,12 @@ class WalletPlatformBalanceTransactionModel extends WalletBaseModel
|
||||
$amount,
|
||||
$platform_id,
|
||||
$currency_code,
|
||||
$uid,
|
||||
): \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Builder|bool
|
||||
{
|
||||
try {
|
||||
Db::beginTransaction();
|
||||
$resModel = $this->addPlatformTransaction(self::TYPE_USER_WITHDRAW, self::STATUS_WAITING_QUEUE, $amount,$amount, $platform_id, $currency_code);
|
||||
$resModel = $this->addPlatformTransaction(self::TYPE_USER_WITHDRAW, self::STATUS_WAITING_QUEUE, $amount,$amount, $platform_id, $currency_code,$uid);
|
||||
if(!$resModel) throw new ModelException('addPlatformTransaction error');
|
||||
$oWalletPlatformBalanceModel = new WalletPlatformBalanceModel();
|
||||
$res = $oWalletPlatformBalanceModel->findPlatformBalance($platform_id,$currency_code);
|
||||
@ -213,6 +217,8 @@ class WalletPlatformBalanceTransactionModel extends WalletBaseModel
|
||||
}
|
||||
|
||||
function newRechargePlatformTransaction(
|
||||
$resWalletAddrTransactionModel,
|
||||
$resWalletPlatformUserTransactionModel,
|
||||
$amount,
|
||||
$platform_id,
|
||||
$currency_code,
|
||||
@ -220,7 +226,7 @@ class WalletPlatformBalanceTransactionModel extends WalletBaseModel
|
||||
{
|
||||
try {
|
||||
Db::beginTransaction();
|
||||
$resModel = $this->addPlatformTransaction(self::TYPE_USER_RECHARGE, self::STATUS_SUCCESS, $amount,$amount, $platform_id, $currency_code);
|
||||
$resModel = $this->addPlatformTransaction(self::TYPE_USER_RECHARGE, self::STATUS_SUCCESS, $amount,$amount, $platform_id, $currency_code,$resWalletPlatformUserTransactionModel->uid,$resWalletPlatformUserTransactionModel->id,$resWalletAddrTransactionModel->wallet_addr_id,$resWalletAddrTransactionModel->wallet_addr);
|
||||
if(!$resModel) throw new ModelException('addPlatformTransaction error');
|
||||
$oWalletPlatformBalanceModel = new WalletPlatformBalanceModel();
|
||||
$resWalletPlatformBalanceModel = $oWalletPlatformBalanceModel->findPlatformBalance($platform_id,$currency_code);
|
||||
|
||||
@ -32,6 +32,7 @@ class WalletPlatformUserTransactionModel extends WalletBaseModel
|
||||
'currency_type',
|
||||
'from_wallet_addr_id',
|
||||
'wallet_addr',
|
||||
'from_wallet_transaction_id',
|
||||
'received_amount',
|
||||
'entered_amount',
|
||||
'fee_amount',
|
||||
@ -88,7 +89,7 @@ class WalletPlatformUserTransactionModel extends WalletBaseModel
|
||||
|
||||
//冻结平台余额并增加账变
|
||||
$oWalletPlatformBalanceTransactionModel = new WalletPlatformBalanceTransactionModel();
|
||||
$resWalletPlatformBalanceTransactionModel = $oWalletPlatformBalanceTransactionModel->newWithdrawPlatformTransaction($amount, $platform_id, $currency_code);
|
||||
$resWalletPlatformBalanceTransactionModel = $oWalletPlatformBalanceTransactionModel->newWithdrawPlatformTransaction($amount, $platform_id, $currency_code,$uid);
|
||||
if (!$resWalletPlatformBalanceTransactionModel) throw new ModelException('newWithdrawPlatformTransaction error');
|
||||
|
||||
//根据币种计算费率
|
||||
@ -137,7 +138,7 @@ class WalletPlatformUserTransactionModel extends WalletBaseModel
|
||||
return $this->addItem($insert);
|
||||
}
|
||||
|
||||
function addRechargeTransaction($platform_id, $uid, $oWalletCurrencyModel, $amount, $desc_key = null, $desc = '', $remark = ''): \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Builder|bool
|
||||
function addRechargeTransaction($resWalletAddrTransactionModel,$platform_id, $uid, $oWalletCurrencyModel, $amount, $desc_key = null, $desc = '', $remark = ''): \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Builder|bool
|
||||
{
|
||||
$amount = abs($amount);
|
||||
$insert = [
|
||||
@ -148,6 +149,9 @@ class WalletPlatformUserTransactionModel extends WalletBaseModel
|
||||
'currency_id' => $oWalletCurrencyModel->id,
|
||||
'currency_code' => $oWalletCurrencyModel->code,
|
||||
'currency_type' => $oWalletCurrencyModel->type,
|
||||
'from_wallet_addr_id' => $resWalletAddrTransactionModel->wallet_addr_id,
|
||||
'wallet_addr' => $resWalletAddrTransactionModel->wallet_addr,
|
||||
'from_wallet_transaction_id' => $resWalletAddrTransactionModel->id,
|
||||
'received_amount' => $amount,
|
||||
'entered_amount' => $amount,
|
||||
'desc_key' => $desc_key ?? '',
|
||||
@ -158,14 +162,14 @@ class WalletPlatformUserTransactionModel extends WalletBaseModel
|
||||
return $this->addItem($insert);
|
||||
}
|
||||
|
||||
function addTransactionWithPlatformBalance($platform_id, $uid, $oWalletCurrencyModel, $amount, $desc_key = null, $desc = '', $remark = '')
|
||||
function addTransactionWithPlatformBalance($resWalletAddrTransactionModel,$platform_id, $uid, $oWalletCurrencyModel, $amount, $desc_key = null, $desc = '', $remark = '')
|
||||
{
|
||||
try {
|
||||
Db::beginTransaction();
|
||||
$resModel = $this->addRechargeTransaction($platform_id, $uid, $oWalletCurrencyModel, $amount, $desc_key, $desc, $remark);
|
||||
$resModel = $this->addRechargeTransaction($resWalletAddrTransactionModel,$platform_id, $uid, $oWalletCurrencyModel, $amount, $desc_key, $desc, $remark);
|
||||
if(!$resModel) throw new ModelException('addRechargeTransaction error');
|
||||
$oWalletPlatformBalanceTransactionModel = new WalletPlatformBalanceTransactionModel();
|
||||
$res = $oWalletPlatformBalanceTransactionModel->newRechargePlatformTransaction($amount, $platform_id, $oWalletCurrencyModel->code);
|
||||
$res = $oWalletPlatformBalanceTransactionModel->newRechargePlatformTransaction($resWalletAddrTransactionModel,$resModel,$amount, $platform_id, $oWalletCurrencyModel->code);
|
||||
if(!$res) throw new ModelException('newRechargePlatformTransaction error');
|
||||
Db::commit();
|
||||
return true;
|
||||
@ -334,6 +338,7 @@ class WalletPlatformUserTransactionModel extends WalletBaseModel
|
||||
|
||||
//给用户增加账变/平台增加账变增加余额
|
||||
$this->addTransactionWithPlatformBalance(
|
||||
$resWalletAddrTransactionModel,
|
||||
$resWalletPlatformUserWalletAddrModel->platform_id,
|
||||
$resWalletPlatformUserWalletAddrModel->uid,
|
||||
$resWalletCurrencyModel,
|
||||
|
||||
Reference in New Issue
Block a user