handled refer_id for jbit

This commit is contained in:
2026-06-02 15:25:16 +03:30
parent 5ab2d2c65e
commit 6cbbde9834
@@ -197,10 +197,15 @@ class CustomerController extends Controller
$companyName = $this->Config('name_fa'); $companyName = $this->Config('name_fa');
$companyurl = $this->Config('app_url'); $companyurl = $this->Config('app_url');
$referrer = $customer->referral; $referrer = $customer->referral;
$total_referrals = Customer::where('referral_to_id', $referrer->referral_id)->where('is_legal', '!=', 0)->get()->count(); $gift_permision = true;
$referral_limit = Setting::where('key', 'referral_limit')->first(); if ($referrer) {
$gift_permision = $referral_limit->is_active ? $total_referrals < $referral_limit->value ? true : false : true ; $total_referrals = Customer::where('referral_to_id', $referrer->referral_id)->where('is_legal', '!=', 0)->count();
if ($gift_permision && $gift_for_inviter > 0) { $referral_limit = Setting::where('key', 'referral_limit')->first();
$gift_permision = $referral_limit && $referral_limit->is_active
? $total_referrals < $referral_limit->value
: true;
}
if ($referrer && $gift_permision && $gift_for_inviter > 0) {
// dd($gift_for_inviter > 0, $gift_for_invited > 0); // dd($gift_for_inviter > 0, $gift_for_invited > 0);
$Withdraw = Withdraw::create([ $Withdraw = Withdraw::create([
@@ -273,7 +278,7 @@ class CustomerController extends Controller
$transaction = Transaction::where('customer_id', $customer->id)->latest()->first(); $transaction = Transaction::where('customer_id', $customer->id)->latest()->first();
TransactionsAdmin::create([ TransactionsAdmin::create([
'customer_id' => $customer->id, 'customer_id' => $customer->id,
'customer_to_id' => $customer->referal->id, 'customer_to_id' => $customer->id,
'user_id' => $customer->id, 'user_id' => $customer->id,
'wallet' => null, // یا مقدار مناسب دیگری 'wallet' => null, // یا مقدار مناسب دیگری
'transaction_id' => $transaction->id, 'transaction_id' => $transaction->id,