Fix Pay insurance subscriptions
This commit is contained in:
parent
98aaea4201
commit
8b6adb870e
|
@ -609,7 +609,7 @@ class InsuranceSubscriptionController extends Controller
|
||||||
return $this->errorResponse(trans('messages.incorrect_user_password'));
|
return $this->errorResponse(trans('messages.incorrect_user_password'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($user->balance_nano_health < $subscription->total_bonus_amount) {
|
if ($user->wallet->balance < $subscription->total_bonus_amount) {
|
||||||
return $this->errorResponse(trans('errors.insufficient_balance'));
|
return $this->errorResponse(trans('errors.insufficient_balance'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -623,7 +623,9 @@ class InsuranceSubscriptionController extends Controller
|
||||||
$walletHyperviseur->balance_princ += $subscription->total_bonus_amount;
|
$walletHyperviseur->balance_princ += $subscription->total_bonus_amount;
|
||||||
$walletHyperviseur->save();
|
$walletHyperviseur->save();
|
||||||
|
|
||||||
$user->balance_nano_health -= $subscription->total_bonus_amount;
|
$user->balance_nano_health += $subscription->total_bonus_amount;
|
||||||
|
$user->wallet->balance -= $subscription->total_bonus_amount;
|
||||||
|
$user->wallet->save();
|
||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
$insuredId = $this->generateInsuredID();
|
$insuredId = $this->generateInsuredID();
|
||||||
|
|
|
@ -116,4 +116,9 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Network::class, 'network_id');
|
return $this->belongsTo(Network::class, 'network_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function wallet()
|
||||||
|
{
|
||||||
|
return $this->hasOne(WalletsUser::class, 'idUser');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Reliese Model.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class WalletsUser
|
||||||
|
*
|
||||||
|
* @property int $id
|
||||||
|
* @property float $balance
|
||||||
|
* @property Carbon $createdAt
|
||||||
|
* @property int $idUser
|
||||||
|
*
|
||||||
|
* @property User $user
|
||||||
|
* @property Collection|WalletIlinkTransaction[] $wallet_ilink_transactions
|
||||||
|
*
|
||||||
|
* @package App\Models
|
||||||
|
*/
|
||||||
|
class WalletsUser extends Model
|
||||||
|
{
|
||||||
|
public $timestamps = false;
|
||||||
|
protected $table = 'wallets_users';
|
||||||
|
protected $casts = [
|
||||||
|
'balance' => 'float',
|
||||||
|
'idUser' => 'int'
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $dates = [
|
||||||
|
'createdAt'
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'balance',
|
||||||
|
'createdAt',
|
||||||
|
'idUser'
|
||||||
|
];
|
||||||
|
|
||||||
|
public function user()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class, 'idUser');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function wallet_ilink_transactions()
|
||||||
|
{
|
||||||
|
return $this->hasMany(WalletIlinkTransaction::class, 'id_wallet_user');
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue