Update: 2026-08-02 17:52:28
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
// food/merchant_ops/reject.php — المطعم يرفض الطلب — استرجاع فوري إن دُفع من المحفظة
|
||||
require_once __DIR__ . '/../connect_merchant.php';
|
||||
|
||||
$orderId = filterRequest('order_id', 'int');
|
||||
$reason = filterRequest('reason');
|
||||
if (!$orderId) jsonError('order_id is required');
|
||||
|
||||
$order = foodAssertOrderOwnership($orderId, 'merchant', (string)$food_merchant_id);
|
||||
food_transition_status($orderId, 'rejected', 'merchant', (string)$food_merchant_user_id, $reason);
|
||||
|
||||
if ($order['payment_method'] === 'wallet') {
|
||||
$refunded = foodWalletMove(
|
||||
(string)$order['passenger_id'], (int)$order['grand_total'], 'add',
|
||||
"food-refund-{$orderId}", "Food order #{$orderId} rejected by merchant"
|
||||
);
|
||||
$food_con->prepare(
|
||||
"INSERT INTO food_order_payments (order_id, type, amount, status) VALUES (?,'release',?,?)"
|
||||
)->execute([$orderId, (int)$order['grand_total'], $refunded ? 'success' : 'failed']);
|
||||
|
||||
if (!$refunded) appLog("[FOOD][MERCHANT][reject] refund FAILED for order $orderId — needs manual reconciliation", 'ERROR');
|
||||
}
|
||||
|
||||
jsonSuccess(['order_id' => $orderId, 'status' => 'rejected']);
|
||||
Reference in New Issue
Block a user