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