diff --git a/app/Http/Controllers/Pargar/PargarInboundController.php b/app/Http/Controllers/Pargar/PargarInboundController.php index 54c718e..a5b5939 100644 --- a/app/Http/Controllers/Pargar/PargarInboundController.php +++ b/app/Http/Controllers/Pargar/PargarInboundController.php @@ -173,9 +173,13 @@ class PargarInboundController extends Controller $documents = $orders->map(function (Order $order) { $customer = Customer::find((int) ($order->customer_id ?? 0)); + // direction اپ: 1=خرید مشتری، 2=فروش مشتری + // OrderType پرگار از دید فروشگاه است: خرید مشتری = فروش فروشگاه (-1)، فروش مشتری = خرید فروشگاه (1) + $isCustomerBuy = (int) ($order->direction ?? 1) === 1; + return [ 'OrderId' => (string) $order->id, - 'OrderType' => (int) ($order->direction ?? 1) === 1 ? 1 : -1, + 'OrderType' => $isCustomerBuy ? -1 : 1, 'PriceType' => 1, 'CustomerAccountId' => (int) ($customer->pargar_account_id ?? 0), 'ItemId' => 11,