fixed some bugs

This commit is contained in:
2026-07-23 17:53:10 +03:30
parent a405075230
commit d8b685524b
3 changed files with 15 additions and 17 deletions
@@ -25,11 +25,9 @@ class BankAccountController extends SuperController
public function destroy($id) public function destroy($id)
{ {
$account = BankAccount::findOrFail($id); $account = BankAccount::where('customer_id', auth('customer')->id())->findOrFail($id);
if ($account->sts != 3 && $account->sts != 2) { $account->delete();
throw new UnprocessableEntityHttpException('امکان حذف این کارت بانکی وجود ندارد'); return response()->json(true);
}
return parent::destroy($id);
} }
public function listActiveBankAccount() public function listActiveBankAccount()
@@ -97,21 +95,15 @@ class BankAccountController extends SuperController
return response()->json($data); return response()->json($data);
} else { } else {
$message = "احرازهویت برای شماره کارت کاربر " . $user->name . " توسط جیبیت انجام نشد. لطفا از پنل ادمین اقدام کنید. "; $message = 'احراز هویت کارت بانکی برای کاربر ' . $user->name . ' توسط جیبیت ناموفق بود. کارت ثبت نشد.';
if (self::isSmsNotifEnabled('sms_notif_bank_card_admin')) { if (self::isSmsNotifEnabled('sms_notif_bank_card_admin')) {
User::where('send_sms', 1)->get()->each(function ($admin) use ($message) { User::where('send_sms', 1)->get()->each(function ($admin) use ($message) {
$this->SendMessage($admin->mobile, $message); $this->SendMessage($admin->mobile, $message);
}); });
} }
$BA = BankAccount::create([ throw new UnprocessableEntityHttpException(
'customer_id' => $user->id, 'احراز هویت کارت بانکی ناموفق بود. کارت معتبر نیست و ثبت نشد.'
'cart_number' => $request->cart_number, );
'first_name' => $user->fname,
'last_name' => $user->lname,
'sts' => 1,
]);
throw new UnprocessableEntityHttpException('شماره کارت شما برای ادمین ارسال شد و پس از تایید قابل استفاده می باشد.');
return $apiData;
} }
} }
$customer = Customer::find(auth('customer')->id()); $customer = Customer::find(auth('customer')->id());
@@ -1490,12 +1490,15 @@ class SingleOrderController extends Controller
$scPct = (float) ($data['service_charge_percentage'] ?? 0); $scPct = (float) ($data['service_charge_percentage'] ?? 0);
if ($scGold > 0 || $scRial > 0) { if ($scGold > 0 || $scRial > 0) {
$feeAsset = (string) ($data['fee_asset'] ?? 'rial');
$fromMetal = $feeAsset === 'gold';
$assetLabel = $fromMetal ? 'از فلز/مقدار' : 'از ریال';
$goldLabel = rtrim(rtrim(number_format($scGold, 4, '.', ''), '0'), '.') . ' گرم'; $goldLabel = rtrim(rtrim(number_format($scGold, 4, '.', ''), '0'), '.') . ' گرم';
$detailParts = []; $detailParts = [];
if ($scPct > 0) { if ($scPct > 0) {
$detailParts[] = rtrim(rtrim(number_format($scPct, 4, '.', ''), '0'), '.') . '%'; $detailParts[] = rtrim(rtrim(number_format($scPct, 4, '.', ''), '0'), '.') . '%';
} }
if ($scGold > 0 && $priceOriginal > 0) { if ($fromMetal && $scGold > 0 && $priceOriginal > 0) {
$detailParts[] = $goldLabel . ' × ' . number_format($priceOriginal) . ' = ' . number_format($scRial) . ' ریال'; $detailParts[] = $goldLabel . ' × ' . number_format($priceOriginal) . ' = ' . number_format($scRial) . ' ریال';
} elseif ($scRial > 0 && $priceOriginal > 0) { } elseif ($scRial > 0 && $priceOriginal > 0) {
$goldEquiv = $scRial / $priceOriginal; $goldEquiv = $scRial / $priceOriginal;
@@ -1504,15 +1507,17 @@ class SingleOrderController extends Controller
} else { } else {
$detailParts[] = number_format($scRial) . ' ریال'; $detailParts[] = number_format($scRial) . ' ریال';
} }
$detailParts[] = $assetLabel;
$receiptLines[] = [ $receiptLines[] = [
'kind' => 'service_charge', 'kind' => 'service_charge',
'key' => 'service_charge', 'key' => 'service_charge',
'label' => 'کارمزد معامله', 'label' => 'کارمزد معامله · ' . $assetLabel,
'is_percent' => $scPct > 0, 'is_percent' => $scPct > 0,
'raw' => $scPct, 'raw' => $scPct,
'gold' => $scGold, 'gold' => $scGold,
'rial' => $scRial, 'rial' => $scRial,
'fee_asset' => $feeAsset,
'per_unit' => $amount > 0 ? ($scRial / $amount) : 0, 'per_unit' => $amount > 0 ? ($scRial / $amount) : 0,
'amount_units' => $amount, 'amount_units' => $amount,
'total' => $scRial, 'total' => $scRial,
+1
View File
@@ -176,6 +176,7 @@ Route::middleware('auth:user')->group(function (){
Route::post('account/table', [BankAccountController::class, 'table']); Route::post('account/table', [BankAccountController::class, 'table']);
Route::get('account/{id}', [BankAccountController::class, 'show']); Route::get('account/{id}', [BankAccountController::class, 'show']);
Route::post('account/sts', [BankAccountController::class, 'changeSts']); Route::post('account/sts', [BankAccountController::class, 'changeSts']);
Route::delete('account/{id}', [BankAccountController::class, 'destroy']);
Route::post('wallet/tahesab', [TahesabController::class, 'wallet']); Route::post('wallet/tahesab', [TahesabController::class, 'wallet']);
Route::post('tahesab/table', [TahesabController::class, 'table']); Route::post('tahesab/table', [TahesabController::class, 'table']);