Update codebase
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
// food/courier/delivered.php — تسليم الطلب — تثبيت المال (capture) وقيد أرباح السائق
|
||||
require_once __DIR__ . '/../connect_courier.php';
|
||||
|
||||
$orderId = filterRequest('order_id', 'int');
|
||||
if (!$orderId) jsonError('order_id is required');
|
||||
|
||||
$order = foodAssertOrderOwnership($orderId, 'courier', $food_courier_id);
|
||||
food_transition_status($orderId, 'delivered', 'courier', $food_courier_id);
|
||||
|
||||
if ($order['payment_method'] === 'wallet') {
|
||||
// المبلغ خُصم بالكامل عند الإنشاء (انظر ملاحظة foodWalletMove) — capture هنا تسجيل محاسبي فقط
|
||||
$food_con->prepare(
|
||||
"INSERT INTO food_order_payments (order_id, type, amount, status) VALUES (?,'capture',?,'success')"
|
||||
)->execute([$orderId, (int)$order['grand_total']]);
|
||||
} else {
|
||||
// نقداً: السائق حصّل grand_total كاملاً من الزبون. يحتفظ بـ delivery_fee (أجرته)
|
||||
// ويبقى ديناً عليه الباقي (items_total+service_fee — حصة المطعم والمنصة) حتى يُسوّى
|
||||
// إدارياً. هذا قيد محاسبي فقط هنا — لا حركة مالية آلية فعلية بعد (انظر التنبيه في
|
||||
// admin/payouts.php حول عدم وجود عقد API مؤكد لتحصيل ديون السائق النقدية آلياً).
|
||||
$courierOwed = (int)$order['grand_total'] - (int)$order['delivery_fee'];
|
||||
$food_con->prepare(
|
||||
"INSERT INTO food_order_payments (order_id, type, amount, status) VALUES (?,'cash_settlement',?,'pending')"
|
||||
)->execute([$orderId, $courierOwed]);
|
||||
}
|
||||
|
||||
// قيد أرباح السائق (أجرة التوصيل) — مُتراكم عمداً بقرار المالك: الأجرة
|
||||
// تُصرف دورياً مع مقاصّة دَين النقد، لا فورياً عند كل تسليم. صرفها منفصلة
|
||||
// عن الدَين يعني الدفع للسائق بينما هو يحمل مال المنصة من الطلبات النقدية.
|
||||
//
|
||||
// التسوية في food/admin/courier_settlement.php.
|
||||
//
|
||||
// (تصحيح لملاحظة سابقة هنا: عقد S2S لإيداع أرباح من المنصة **موجود
|
||||
// ومؤكد** — driverWallet/add_s2s_reward.php، وهو مستخدم في تعويض عدم
|
||||
// الحضور ورسوم الإلغاء وتعويضات الشكاوى.)
|
||||
$food_con->prepare(
|
||||
"INSERT INTO food_order_payments (order_id, type, amount, status) VALUES (?,'courier_payout',?,'pending')"
|
||||
)->execute([$orderId, (int)$order['delivery_fee']]);
|
||||
|
||||
jsonSuccess(['order_id' => $orderId, 'status' => 'delivered']);
|
||||
Reference in New Issue
Block a user