fix(rider): البحث عن مكان والمحفظة الحقيقية وأسماء الخريطة
## البحث لم يكن يستجيب — غلافان مختلفان
مثبت بـcurl: /geocoding/search يرجّع {"results":[…]} بينما /geocoding/reverse
يرجّع مصفوفة عارية. افترضتُ كليهما مصفوفة، فكان البحث يفشل صامتاً — ولهذا
«تحديد من الخريطة» يعمل (يستعمل reverse) والبحث لا. أُضيفت رسالة «لا نتائج»
كي لا يبقى الفراغ غامضاً، وأيقونة لكل صنف مكان.
## المحفظة صارت دفعاً حقيقياً لا كاش-إن
كنت أستعمل POST /wallet/topup — وهو بوصف الخادم كاش-إن تجريبي يزيد الرصيد
بلا دفع. المسار الصحيح موجود أصلاً: POST /payments/charge مع provider
وpurpose، وسجلّ بوابات فيه cash · paymob · syriatel · mtn ومحوّل فاتورة
لـ cliq · shamcash · zaincash.
كليك وشام كاش وزين كاش تعمل بنمط **الفاتورة** — نفس ما يفعله سيرو حرفياً
(create_cliq_invoice.php): الخادم يولّد مرجعاً ويعرض حساب الاستلام، ويحوّل
المستخدم، والتسوية تصل لاحقاً بمطابقة رسالة المزوّد. لا بوابة تحويل حيّة.
- InvoiceSheet يعرض المرجع وحساب الاستلام بزرّي نسخ — الرقم يُحوَّل في تطبيق
بنك آخر فالنسخ ليس رفاهية
- يُقال صراحةً أن الرصيد لا يزيد الآن، قبل الضغط لا بعده
- حساب استلام غير مضبوط للمستأجر يُعرض كخطأ لا كتعليمات ناقصة
- أسماء المزوّدين صُحّحت لتطابق PaymentGatewayRegistry حرفياً (syriatel لا
syriatel_cash…) — أي اسم آخر يرجّع 400
- qi_card حُذف: لا محوّل له على الخادم
- السائق: chargeCredit بنيّة credit_topup للرصيد التشغيلي
## الخريطة وواجهة «إلى أين»
- أسماء البداية والنهاية تُرسم فوق الخريطة (نمط سيرو) كطبقة فلاتر لا marker
- البطاقة المطوية صارت حقل بحث بارزاً مع الموقع الحالي فوقه
- حقل البحث يفتح مركّزاً مع زرّ مسح
## أداة
tool/sync_from_rider.sh كان يستثني ملفَّي ARB فيُسقط كل مفتاح مشترك جديد
ويكسر بناء السائق — تكرّر ثلاث مرات. صارا يُنسخان ثم تُفرض نصوص السائق فوقهما.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
e22cc5c7e4
commit
6a33cc7241
@@ -28,16 +28,30 @@ class WalletCubit extends Cubit<WalletState> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> topup(num amount) async {
|
||||
/// شحن حقيقي. **لا يزيد الرصيد فوراً** إلا في نمط الدفع الفوري — الفاتورة
|
||||
/// تُعرض للمستخدم ويحوّل، والتسوية تصل لاحقاً عبر مطابقة رسالة المزوّد.
|
||||
Future<void> topup({required num amount, required String provider}) async {
|
||||
if (amount <= 0) return;
|
||||
emit(state.copyWith(action: WalletAction.toppingUp));
|
||||
try {
|
||||
await _repo.topup(amount);
|
||||
final result = await _repo.charge(
|
||||
amount: amount,
|
||||
provider: provider,
|
||||
currency: state.currency,
|
||||
);
|
||||
if (isClosed) return;
|
||||
emit(state.copyWith(action: WalletAction.topupDone));
|
||||
// الرصيد يُعاد جلبه من الخادم لا يُحسب محلياً: المال لا يُقدَّر
|
||||
// في التطبيق (docs/23 §0.2).
|
||||
await load();
|
||||
|
||||
if (result.isInstant) {
|
||||
emit(state.copyWith(action: WalletAction.topupDone));
|
||||
// الرصيد يُعاد جلبه من الخادم لا يُحسب محلياً: المال لا يُقدَّر
|
||||
// في التطبيق (docs/23 §0.2).
|
||||
await load();
|
||||
return;
|
||||
}
|
||||
emit(state.copyWith(
|
||||
action: WalletAction.invoiceReady,
|
||||
invoice: result,
|
||||
));
|
||||
} on ApiException {
|
||||
if (!isClosed) emit(state.copyWith(action: WalletAction.topupFailed));
|
||||
}
|
||||
|
||||
@@ -3,8 +3,9 @@ import 'package:equatable/equatable.dart';
|
||||
import '../../../core/ui/view_status.dart';
|
||||
import '../data/models/wallet.dart';
|
||||
import '../data/models/wallet_txn.dart';
|
||||
import '../data/wallet_repository.dart';
|
||||
|
||||
enum WalletAction { none, toppingUp, topupFailed, topupDone }
|
||||
enum WalletAction { none, toppingUp, topupFailed, topupDone, invoiceReady }
|
||||
|
||||
class WalletState extends Equatable {
|
||||
const WalletState({
|
||||
@@ -12,6 +13,7 @@ class WalletState extends Equatable {
|
||||
this.wallet,
|
||||
this.transactions = const [],
|
||||
this.action = WalletAction.none,
|
||||
this.invoice,
|
||||
this.error,
|
||||
});
|
||||
|
||||
@@ -23,6 +25,9 @@ class WalletState extends Equatable {
|
||||
/// المعروض خلفه.
|
||||
final WalletAction action;
|
||||
|
||||
/// فاتورة تحويل بانتظار الدفع — تُعرض للمستخدم بمرجعها وحساب الاستلام.
|
||||
final TopupResult? invoice;
|
||||
|
||||
final String? error;
|
||||
|
||||
String get currency => wallet?.currency ?? '';
|
||||
@@ -32,6 +37,7 @@ class WalletState extends Equatable {
|
||||
Wallet? wallet,
|
||||
List<WalletTxn>? transactions,
|
||||
WalletAction? action,
|
||||
TopupResult? invoice,
|
||||
String? error,
|
||||
}) {
|
||||
return WalletState(
|
||||
@@ -39,10 +45,12 @@ class WalletState extends Equatable {
|
||||
wallet: wallet ?? this.wallet,
|
||||
transactions: transactions ?? this.transactions,
|
||||
action: action ?? this.action,
|
||||
invoice: invoice ?? this.invoice,
|
||||
error: error ?? this.error,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [status, wallet, transactions, action, error];
|
||||
List<Object?> get props =>
|
||||
[status, wallet, transactions, action, invoice?.reference, error];
|
||||
}
|
||||
|
||||
@@ -2,6 +2,33 @@ import '../../../core/api/api_client.dart';
|
||||
import 'models/wallet.dart';
|
||||
import 'models/wallet_txn.dart';
|
||||
|
||||
/// نتيجة الشحن — ثلاثة أنماط: فوري · فاتورة · إعادة توجيه.
|
||||
class TopupResult {
|
||||
const TopupResult({
|
||||
required this.status,
|
||||
this.reference,
|
||||
this.transferTarget,
|
||||
this.instructions,
|
||||
this.redirectUrl,
|
||||
});
|
||||
|
||||
final String status;
|
||||
|
||||
/// مرجع الفاتورة الذي يذكره المستخدم عند التحويل — به تُطابَق رسالة
|
||||
/// المزوّد لاحقاً.
|
||||
final String? reference;
|
||||
|
||||
/// حساب/رقم استلام المستأجر عند هذا المزوّد.
|
||||
final String? transferTarget;
|
||||
|
||||
final String? instructions;
|
||||
final String? redirectUrl;
|
||||
|
||||
bool get isInvoice => reference != null;
|
||||
bool get isInstant => status == 'success';
|
||||
bool get isRedirect => redirectUrl != null;
|
||||
}
|
||||
|
||||
class WalletRepository {
|
||||
WalletRepository(this._api);
|
||||
|
||||
@@ -20,8 +47,35 @@ class WalletRepository {
|
||||
.toList(growable: false);
|
||||
}
|
||||
|
||||
Future<void> topup(num amount) =>
|
||||
_api.post<Map<String, dynamic>>('/wallet/topup', body: {'amount': amount});
|
||||
/// شحن حقيقي عبر `POST /payments/charge`.
|
||||
///
|
||||
/// **لا يزيد الرصيد فوراً.** كليك وشام كاش وزين كاش تعمل بنمط الفاتورة:
|
||||
/// الخادم يولّد مرجعاً ويعرض حساب الاستلام، ثم يحوّل المستخدم، والتسوية
|
||||
/// تصل لاحقاً عبر مطابقة رسالة المزوّد. هذا **نفس مسار سيرو** حرفياً.
|
||||
/// PayMob وحده يرجّع رابط إعادة توجيه، و`cash` وحده فوري.
|
||||
Future<TopupResult> charge({
|
||||
required num amount,
|
||||
required String provider,
|
||||
required String currency,
|
||||
}) async {
|
||||
final res = await _api.post<Map<String, dynamic>>(
|
||||
'/payments/charge',
|
||||
body: {
|
||||
'amount': amount,
|
||||
'provider': provider,
|
||||
'purpose': 'topup',
|
||||
'currency': currency,
|
||||
},
|
||||
);
|
||||
final payment = res['payment'] as Map<String, dynamic>?;
|
||||
return TopupResult(
|
||||
status: payment?['status'] as String? ?? 'pending',
|
||||
reference: res['reference'] as String?,
|
||||
transferTarget: res['transferTarget'] as String?,
|
||||
instructions: res['instructions'] as String?,
|
||||
redirectUrl: res['redirectUrl'] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
// ── السحب: خطوتان لا خطوة ────────────────────────────────────────────
|
||||
// `request` يرسل رمزاً **بلا خصم**، و`confirm` هو ما يخصم ويحجز
|
||||
|
||||
@@ -17,6 +17,7 @@ import '../../../core/ui/tripz_text_field.dart';
|
||||
import '../cubit/wallet_cubit.dart';
|
||||
import '../cubit/wallet_state.dart';
|
||||
import 'widgets/balance_card.dart';
|
||||
import 'widgets/invoice_sheet.dart';
|
||||
import 'widgets/txn_tile.dart';
|
||||
|
||||
/// محفظة الراكب — **رصيدٌ دفعه ولم يستهلكه**، أي التزامٌ على المنصّة.
|
||||
@@ -50,6 +51,12 @@ class _WalletPageState extends State<WalletPage> {
|
||||
SnackBar(content: Text(l10n.walletTopupFailed)),
|
||||
);
|
||||
}
|
||||
// الفاتورة تُعرض فور جهوزها: المستخدم يحتاج المرجع وحساب الاستلام
|
||||
// قبل أن يغادر التطبيق ليحوّل.
|
||||
final invoice = state.invoice;
|
||||
if (state.action == WalletAction.invoiceReady && invoice != null) {
|
||||
TripzSheet.show(context, child: InvoiceSheet(invoice: invoice));
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
return TripzScaffold(
|
||||
@@ -124,12 +131,13 @@ class _WalletPageState extends State<WalletPage> {
|
||||
onSelect: (c) => setState(() => channel = c),
|
||||
),
|
||||
const SizedBox(height: Space.md),
|
||||
// صراحةٌ مقصودة: الخادم يصف هذه النقطة بـ«كاش-إن تجريبي». إخفاء
|
||||
// ذلك يجعل المستخدم يظنّ أنه دفع فعلاً.
|
||||
StatusBanner(
|
||||
message: l10n.walletTopupNote,
|
||||
tone: BannerTone.warning,
|
||||
),
|
||||
// الشحن ليس فورياً في قنوات الفاتورة — يُقال قبل الضغط لا بعده.
|
||||
if (channel != PaymentChannel.cash)
|
||||
StatusBanner(
|
||||
message: l10n.walletInvoicePending,
|
||||
tone: BannerTone.info,
|
||||
icon: Icons.schedule_rounded,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -138,7 +146,9 @@ class _WalletPageState extends State<WalletPage> {
|
||||
onPressed: () {
|
||||
final amount = num.tryParse(controller.text.trim());
|
||||
Navigator.of(context).pop();
|
||||
if (amount != null) _cubit.topup(amount);
|
||||
if (amount != null) {
|
||||
_cubit.topup(amount: amount, provider: channel.wire);
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import '../../../../core/design/tokens.dart';
|
||||
import '../../../../core/design/tripz_colors.dart';
|
||||
import '../../../../core/design/typography.dart';
|
||||
import '../../../../core/l10n/l10n.dart';
|
||||
import '../../../../core/ui/status_banner.dart';
|
||||
import '../../data/wallet_repository.dart';
|
||||
|
||||
/// فاتورة التحويل — نمط سيرو حرفياً (`create_cliq_invoice.php`).
|
||||
///
|
||||
/// المستخدم يحوّل بنفسه إلى حساب المشغّل ويذكر المرجع، والتسوية تصل لاحقاً
|
||||
/// بمطابقة رسالة المزوّد. **الرصيد لا يزيد الآن** — وهذا يُقال صراحةً بدل
|
||||
/// أن ينتظر المستخدم رقماً لن يتغيّر.
|
||||
class InvoiceSheet extends StatelessWidget {
|
||||
const InvoiceSheet({super.key, required this.invoice});
|
||||
|
||||
final TopupResult invoice;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = context.l10n;
|
||||
final target = invoice.transferTarget;
|
||||
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Text(l10n.walletInvoiceTitle, style: context.texts.titleLarge),
|
||||
const SizedBox(height: Space.md),
|
||||
|
||||
// حساب الاستلام قد لا يكون مضبوطاً للمستأجر — يُقال بوضوح بدل تعليمات
|
||||
// ناقصة تُرسل المال إلى لا مكان.
|
||||
if (target == null || target.isEmpty)
|
||||
StatusBanner(message: l10n.walletNoTarget, tone: BannerTone.danger)
|
||||
else
|
||||
_CopyRow(label: l10n.walletInvoiceTarget, value: target),
|
||||
|
||||
const SizedBox(height: Space.sm),
|
||||
if (invoice.reference != null)
|
||||
_CopyRow(label: l10n.walletInvoiceRef, value: invoice.reference!),
|
||||
|
||||
const SizedBox(height: Space.md),
|
||||
StatusBanner(
|
||||
message: l10n.walletInvoicePending,
|
||||
tone: BannerTone.info,
|
||||
icon: Icons.schedule_rounded,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// قيمة مع زرّ نسخ — الرقم يُحوَّل يدوياً في تطبيق بنك آخر، فالنسخ ليس رفاهية.
|
||||
class _CopyRow extends StatelessWidget {
|
||||
const _CopyRow({required this.label, required this.value});
|
||||
|
||||
final String label;
|
||||
final String value;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: Space.page,
|
||||
decoration: BoxDecoration(
|
||||
color: context.colors.surfaceContainerHighest,
|
||||
borderRadius: Radii.card_,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
style: context.texts.labelSmall?.copyWith(
|
||||
color: context.colors.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: Space.xxs),
|
||||
SelectableText(
|
||||
value,
|
||||
textDirection: TextDirection.ltr,
|
||||
style: numericStyle(context.texts.titleMedium),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.copy_rounded),
|
||||
tooltip: context.l10n.walletCopy,
|
||||
onPressed: () {
|
||||
Clipboard.setData(ClipboardData(text: value));
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(context.l10n.walletCopied)),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user