tahesab 2

This commit is contained in:
2026-06-07 18:27:04 +03:30
parent 20ed4ee3ad
commit 484f05a073
6 changed files with 398 additions and 88 deletions
@@ -173,7 +173,7 @@ class CustomerController extends Controller
$companyName = $this->Config('name_fa');
$companyurl = $this->Config('app_url');
$referrer = $customer->referral;
$referrer = $customer->referrer();
$gift_permision = true;
if ($referrer) {
$total_referrals = Customer::where('referral_to_id', $referrer->referral_id)->where('is_legal', '!=', 0)->count();
@@ -187,12 +187,12 @@ class CustomerController extends Controller
$Withdraw = Withdraw::create([
'user_id' => $customer->id,
'customer_id' => $customer->referral->id,
'customer_id' => $referrer->id,
"cash" => 0,
"gold" => $gift_for_inviter,
'sts' => 5,
]);
$wallet_interface = new WalletInterface($customer->referral->id, 2);
$wallet_interface = new WalletInterface($referrer->id, 2);
new TransactionInterface($wallet_interface, $_inp = [
"cash" => 0,
"gold" => $gift_for_inviter,
@@ -202,10 +202,10 @@ class CustomerController extends Controller
'withdraw_id' => $Withdraw->id,
'start_at' => now(),
], 8, true, false);
$transaction = Transaction::where('customer_id', $customer->referral->id)->latest()->first();
$transaction = Transaction::where('customer_id', $referrer->id)->latest()->first();
TransactionsAdmin::create([
'customer_id' => $customer->id,
'customer_to_id' => $customer->referral->id,
'customer_to_id' => $referrer->id,
'user_id' => $customer->id,
'wallet' => null, // یا مقدار مناسب دیگری
'transaction_id' => $transaction->id,
@@ -216,15 +216,15 @@ class CustomerController extends Controller
'balance_cash' => 0, // یا مقدار مناسب دیگری
'withdraw_id' => $Withdraw->id,
]);
$referrerWallet = Wallet::where('owner', $customer->referral->id)->first();
$referrerWallet = Wallet::where('owner', $referrer->id)->first();
if($this->Config('send_to_tahesab') == "true"){
try {
$tahesab = new TahesabController();
$tahesab->goldReward([
'customer_id' => $customer->referral->id,
'value' => $gift_for_inviter,
'desc' => 'پاداش بابت معرفی',
]);
$tahesab->referrerGoldReward(
$customer,
(float) $gift_for_inviter,
'پاداش بابت معرفی'
);
}catch (\Exception $e){
return response($e->getMessage(), 500);
}