1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Onurkacmaz\LaravelN11\Models; |
4
|
|
|
|
5
|
|
|
use Onurkacmaz\LaravelN11\Exceptions\N11Exception; |
6
|
|
|
use Onurkacmaz\LaravelN11\Interfaces\OrderInterface; |
7
|
|
|
use Onurkacmaz\LaravelN11\Service; |
8
|
|
|
use SoapClient; |
9
|
|
|
|
10
|
|
|
class Order extends Service implements OrderInterface |
11
|
|
|
{ |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* @var SoapClient|null |
15
|
|
|
*/ |
16
|
|
|
private $_client; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Category constructor |
20
|
|
|
* endPoint set edildi. |
21
|
|
|
* @throws N11Exception|\SoapFault |
22
|
|
|
*/ |
23
|
|
|
public function __construct() |
24
|
|
|
{ |
25
|
|
|
parent::__construct(); |
26
|
|
|
$this->_client = $this->setEndPoint(self::END_POINT); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @param array $searchData |
31
|
|
|
* @return object |
32
|
|
|
* @description Verilen arama kriterlerine göre sipariş bilgisi ile beraber sipariş maddelerini de listelemek için kullanılır. |
33
|
|
|
*/ |
34
|
|
|
public function getOrderDetail(array $searchData = []): object { |
35
|
|
|
$this->_parameters["searchData"] = $searchData; |
36
|
|
|
return $this->_client->DetailedOrderList($this->_parameters); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @param array $searchData |
41
|
|
|
* @return object |
42
|
|
|
* @description Bu metot sipariş ile ilgili özet bilgileri listelemek için kullanılır. |
43
|
|
|
*/ |
44
|
|
|
public function getOrders(array $searchData = []): object { |
45
|
|
|
$this->_parameters["searchData"] = $searchData; |
46
|
|
|
return $this->_client->OrderList($this->_parameters); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @param int $orderId |
51
|
|
|
* @return object |
52
|
|
|
* @description Sipariş N11 ID bilgisi kullanarak sipariş detaylarını almak için kullanılır, sipariş N11 ID bilgisine OrderService OrderList veya DetailedOrderList metotlarıyla ulaşılabilir. |
53
|
|
|
* n11 platform üzerinden kargo ücretinin ödenmesi ve bunun tahsilat bilgileri “serviceItemList” alanından ulaşılabilir. |
54
|
|
|
*/ |
55
|
|
|
public function orderDetail(int $orderId): object { |
56
|
|
|
$this->_parameters["orderRequest"] = [ |
57
|
|
|
"id" => $orderId |
58
|
|
|
]; |
59
|
|
|
$this->_client->OrderDetail($this->_parameters); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @param int $orderId |
64
|
|
|
* @param int $numberOfPackages |
65
|
|
|
* @return object |
66
|
|
|
* @description Sistemde mağazadan kaç adet paket geleceğini görmek isteyen kargo firmaları için NumberofPackage (Paket Sayısı) alanı tanımlanmıştır. |
67
|
|
|
* NumberofPackage alanına izin verilen kargo firmaları ile gönderim sağlayan mağazalar, sipariş onaylanırken kaç adet paket çıkışı yapacağına dair adet girmesi gerekmektedir. |
68
|
|
|
* Mağazanın gireceği adet sayısına göre kargo firması tarafımıza barkod gönderimi sağlayacaktır. |
69
|
|
|
* ,Mevcut sistemde NumberofPackage kullanmayacak kargo firmaları ile sipariş gönderen mağazalar bu alanı boş gönderebileceklerdir. |
70
|
|
|
* |
71
|
|
|
* Sipariş maddesinin n11 ID si kullanılarak kabul edilmesi için kullanılır. |
72
|
|
|
* Kabul edilen sipariş daha sonra mağaza tarafından reddedilemez. |
73
|
|
|
* Sipariş n11 ID sine OrderService içinden OrderDetail veya DetailedOrderList metodu kullanılarak erişilir. |
74
|
|
|
*/ |
75
|
|
|
public function orderItemAccept(int $orderId, int $numberOfPackages): object { |
76
|
|
|
$this->_parameters["orderItem"] = [ |
77
|
|
|
"id" => $orderId |
78
|
|
|
]; |
79
|
|
|
$this->_parameters["numberOfPackages"] = $numberOfPackages; |
80
|
|
|
$this->_client->OrderItemAccept($this->_parameters); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @param int $orderId |
85
|
|
|
* @param string $rejectReason |
86
|
|
|
* @param string $rejectReasonType |
87
|
|
|
* @return object |
88
|
|
|
* @description Sipariş maddesinin n11 ID si kullanılarak reddedilmesi için kullanılır. |
89
|
|
|
* Reddedilen sipariş daha sonra mağaza tarafından kabul edilemez. |
90
|
|
|
* Sipariş n11 ID sine OrderService içinden OrderDetail veya DetailedOrderList metodu kullanılarak erişilir. |
91
|
|
|
*/ |
92
|
|
|
public function orderItemReject(int $orderId, string $rejectReason, string $rejectReasonType = self::OUT_OF_STOCK): object { |
93
|
|
|
$this->_parameters["orderItemList"] = [ |
94
|
|
|
"orderItem" => [ |
95
|
|
|
"id" => $orderId |
96
|
|
|
] |
97
|
|
|
]; |
98
|
|
|
$this->_parameters["rejectReason"] = $rejectReason; |
99
|
|
|
$this->_parameters["rejectReasonType"] = $rejectReasonType; |
100
|
|
|
$this->_client->OrderItemReject($this->_parameters); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @param int $orderId |
105
|
|
|
* @return object |
106
|
|
|
* @description Sipariş maddesinin n11 ID si kullanılarak kargoya verilmesi için kullanılır. |
107
|
|
|
* Sipariş n11 ID sine OrderService içinden OrderDetail veya DetailedOrderList metodu kullanılarak erişilir. |
108
|
|
|
* Ön koşul olarak güncelleme yapılmak istenen sipariş maddesinin durumunun (OrderItemStatus) “Ödendi” veya “Kabul edildi” olması gerekmektedir. |
109
|
|
|
* Aksi durumda “ön koşullar sağlanamadı” cevabı alınır. |
110
|
|
|
* Kargo şirketlerinin listesi için ShipmentCompanyService den GetShipmentCompanies metodu kullanılmalıdır. |
111
|
|
|
*/ |
112
|
|
|
public function makeOrderItemShipment(int $orderId): object { |
113
|
|
|
$this->_parameters["orderItemList"] = [ |
114
|
|
|
"orderItem" => [ |
115
|
|
|
"id" => $orderId |
116
|
|
|
] |
117
|
|
|
]; |
118
|
|
|
$this->_client->MakeOrderItemShipment($this->_parameters); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
} |
122
|
|
|
|