This commit is contained in:
2026-06-14 21:09:43 +03:30
parent 6f86e8242c
commit b84b2df01a
9 changed files with 287 additions and 66 deletions
@@ -69,6 +69,30 @@ class ProductController extends SuperController
}
public function archiveTable(Request $request)
{
$data = $request->all();
if (isset($data['select']) && is_null($data['select'])) {
$data['select'] = [];
}
$query_table = Product::onlyTrashed()->with($this->with);
TableEngine::create($query_table, $data)
->initSearch($this->search)
->select($this->select)
->export($query_table);
return $query_table;
}
public function archive($id)
{
$product = Product::onlyTrashed()->findOrFail($id);
$product->restore();
return response()->json(true);
}
public function editProducts(Request $request)
{
if (isset($request->auto_open_at, $request->auto_close_at)) {
+20 -29
View File
@@ -90,35 +90,24 @@ class Controller extends BaseController
$send_sms = true;
$user = User::where('mobile', $to)->first() ?: Customer::where('mobile', $to)->first();
if ($user) {
//
// // Telegram
// if (isset($credentials['telegram']) && $user->telegram) {
// try {
// $res = Http::get("https://api.wwwapp.ir/telegran_send.php", [
// 'botToken' => $credentials['telegram']['token'],
// 'chatId' => $user->telegram,
// 'message' => "جناب {$user->name} {$msg}",
// ]);
// $data = $res->json();
// if (isset($data['success']) && $data['success'] === true) {
// $platforms[] = "telegram:{$user->telegram}";
// $send_sms = false;
// }
// } catch (\Exception $e) {
// }
// }
//
// Bale
if (isset($credentials['bale']) && $user->bale) {
$baleToken = trim((string) ($credentials['bale']['token'] ?? ''));
$baleChatId = trim((string) ($user->bale ?? ''));
if ($baleToken !== '' && $baleChatId !== '') {
try {
Http::withoutVerifying()->get("https://tapi.bale.ai/{$credentials['bale']['token']}/sendMessage", [
'chat_id' => $user->bale,
'text' => "جناب {$user->name} \n{$msg}",
]);
$platforms[] = "bale:{$user->bale}";
$send_sms = false;
} catch (\Exception $e) {
return $e->getMessage();
$baleResponse = Http::withoutVerifying()->get(
"https://tapi.bale.ai/bot{$baleToken}/sendMessage",
[
'chat_id' => $baleChatId,
'text' => "جناب {$user->name} \n{$msg}",
]
);
$balePayload = $baleResponse->json();
if ($baleResponse->successful() && ($balePayload['ok'] ?? false) === true) {
$platforms[] = "bale:{$baleChatId}";
$send_sms = false;
}
} catch (\Throwable $e) {
report($e);
}
}
}
@@ -153,7 +142,9 @@ class Controller extends BaseController
'platform' => 'rayegansms',
]);
$platforms[] = "rayegansms:{$to}";
$platforms[] = $response->successful()
? "rayegansms:{$to}"
: "rayegansms_failed:{$to}:{$response->status()}";
}
@@ -583,13 +583,17 @@ class SingleOrderController extends Controller
User::where('send_sms', 1)->get()->each(function ($admin) use ($message, $data, $transactionType, $companyName) {
$this->send($admin->mobile, $message);
});
$wallet = Wallet::where('owner', $data['customer_id'])->whereNull('fund_id')->first();
$wallet = Wallet::where('owner', $data['customer_id'])
->whereNull('fund_id')
->whereNull('product_id')
->first();
$balanceLabel = self::metalTypeLabel();
// $pricePerGram = $totalPrice / $amount;
$goldBalance = $wallet ? ($wallet->gold ?? 0) : 0;
$cashBalance = $wallet ? ($wallet->cash ?? 0) : 0;
$customerMessage = "$companyName\n$transactionType {$subjectTitle}\nگرم: {$amount}\n" .
"مبلغ کل: " . number_format($totalPrice) . "\n\n" .
"موجودی {$balanceLabel}: {$wallet->gold}\n" .
"مانده ریالی: " . number_format($wallet->cash) . "\n" .
"موجودی {$balanceLabel}: {$goldBalance}\n" .
"مانده ریالی: " . number_format($cashBalance) . "\n" .
$this->Config('app_url');
@@ -181,21 +181,27 @@ class RequestsController extends Controller
// $this->send($admin->mobile, $messageExam);
// });
$wallet = Wallet::where('owner', $data['customer_id'])->whereNull('fund_id')->first();
$wallet = Wallet::where('owner', $data['customer_id'])
->whereNull('fund_id')
->whereNull('product_id')
->first();
if($data['method'] == 'cash') {
$pricePerGram = $data['total_price'];
}elseif ($data['method'] == 'gold') {
$pricePerGram = $data['total_price'] / $data['amount'];
}
$goldBalance = $wallet ? ($wallet->gold ?? 0) : 0;
$cashBalance = $wallet ? ($wallet->cash ?? 0) : 0;
if($data['method'] == 'cash') {
$customerMessage = "$companyName\nبرداشت ریالی \nمبلغ: {$data['amount']}\n" .
"\nموجودی طلایی: {$wallet->gold}\n" .
"مانده ریالی: " . number_format($wallet->cash) . "\n" . $this->Config('app_url');
"\nموجودی طلایی: {$goldBalance}\n" .
"مانده ریالی: " . number_format($cashBalance) . "\n" . $this->Config('app_url');
}elseif ($data['method'] == 'gold') {
$customerMessage = "$companyName\nبرداشت طلایی \nگرم: {$data['amount']}\nقیمت گرم: " . number_format($pricePerGram) .
"\nمبلغ کل: " . number_format($data['total_price']) . "\nموجودی طلایی: {$wallet->gold}\n" .
"مانده ریالی: " . number_format($wallet->cash) . "\n" . $this->Config('app_url');
"\nمبلغ کل: " . number_format($data['total_price']) . "\nموجودی طلایی: {$goldBalance}\n" .
"مانده ریالی: " . number_format($cashBalance) . "\n" . $this->Config('app_url');
}