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