|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of gpupo/netshoes-sdk |
|
5
|
|
|
* Created by Gilmar Pupo <[email protected]> |
|
6
|
|
|
* For the information of copyright and license you should read the file |
|
7
|
|
|
* LICENSE which is distributed with this source code. |
|
8
|
|
|
* Para a informação dos direitos autorais e de licença você deve ler o arquivo |
|
9
|
|
|
* LICENSE que é distribuído com este código-fonte. |
|
10
|
|
|
* Para obtener la información de los derechos de autor y la licencia debe leer |
|
11
|
|
|
* el archivo LICENSE que se distribuye con el código fuente. |
|
12
|
|
|
* For more information, see <http://www.g1mr.com/>. |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
namespace Gpupo\NetshoesSdk\Entity\Order; |
|
16
|
|
|
|
|
17
|
|
|
use Gpupo\Common\Entity\CollectionInterface; |
|
18
|
|
|
use Gpupo\CommonSdk\Entity\EntityAbstract; |
|
19
|
|
|
use Gpupo\CommonSdk\Entity\EntityInterface; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @method string getAgreedDate() Acesso a agreedDate |
|
23
|
|
|
* @method setAgreedDate(string $agreedDate) Define agreedDate |
|
24
|
|
|
* @method string getBusinessUnit() Acesso a businessUnit |
|
25
|
|
|
* @method setBusinessUnit(string $businessUnit) Define businessUnit |
|
26
|
|
|
* @method bool getDevolutionRequested() Acesso a devolutionRequested |
|
27
|
|
|
* @method setDevolutionRequested(boolean $devolutionRequested) Define devolutionRequested |
|
28
|
|
|
* @method bool getExchangeRequested() Acesso a exchangeRequested |
|
29
|
|
|
* @method setExchangeRequested(boolean $exchangeRequested) Define exchangeRequested |
|
30
|
|
|
* @method setOrderDate(string $orderDate) Define orderDate |
|
31
|
|
|
* @method string getOrderNumber() Acesso a orderNumber |
|
32
|
|
|
* @method setOrderNumber(string $orderNumber) Define orderNumber |
|
33
|
|
|
* @method setOrderStatus(string $orderStatus) Define orderStatus |
|
34
|
|
|
* @method string getOrderType() Acesso a orderType |
|
35
|
|
|
* @method setOrderType(string $orderType) Define orderType |
|
36
|
|
|
* @method string getOriginNumber() Acesso a originNumber |
|
37
|
|
|
* @method setOriginNumber(string $originNumber) Define originNumber |
|
38
|
|
|
* @method string getOriginSite() Acesso a originSite |
|
39
|
|
|
* @method setOriginSite(string $originSite) Define originSite |
|
40
|
|
|
* @method string getPaymentDate() Acesso a paymentDate |
|
41
|
|
|
* @method setPaymentDate(string $paymentDate) Define paymentDate |
|
42
|
|
|
* @method Gpupo\NetshoesSdk\Entity\Order\Shippings\Shippings getShippings() Acesso a shippings |
|
43
|
|
|
* @method setShippings(Gpupo\NetshoesSdk\Entity\Order\Shippings\Shippings $shippings) Define shippings |
|
44
|
|
|
* @method float getTotalCommission() Acesso a totalCommission |
|
45
|
|
|
* @method setTotalCommission(float $totalCommission) Define totalCommission |
|
46
|
|
|
* @method float getTotalDiscount() Acesso a totalDiscount |
|
47
|
|
|
* @method setTotalDiscount(float $totalDiscount) Define totalDiscount |
|
48
|
|
|
* @method float getTotalFreight() Acesso a totalFreight |
|
49
|
|
|
* @method setTotalFreight(float $totalFreight) Define totalFreight |
|
50
|
|
|
* @method float getTotalGross() Acesso a totalGross |
|
51
|
|
|
* @method setTotalGross(float $totalGross) Define totalGross |
|
52
|
|
|
* @method float getTotalNet() Acesso a totalNet |
|
53
|
|
|
* @method setTotalNet(float $totalNet) Define totalNet |
|
54
|
|
|
* @method float getTotalQuantity() Acesso a totalQuantity |
|
55
|
|
|
* @method setTotalQuantity(float $totalQuantity) Define totalQuantity |
|
56
|
|
|
*/ |
|
57
|
|
|
class Order extends EntityAbstract implements EntityInterface, CollectionInterface |
|
58
|
|
|
{ |
|
59
|
|
|
protected $primaryKey = 'orderNumber'; |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @codeCoverageIgnore |
|
63
|
|
|
*/ |
|
64
|
|
|
public function getSchema() |
|
65
|
|
|
{ |
|
66
|
|
|
return [ |
|
67
|
|
|
'agreedDate' => 'string', |
|
68
|
|
|
'businessUnit' => 'string', |
|
69
|
|
|
'devolutionRequested' => 'boolean', |
|
70
|
|
|
'exchangeRequested' => 'boolean', |
|
71
|
|
|
'orderDate' => 'string', |
|
72
|
|
|
'orderNumber' => 'string', |
|
73
|
|
|
'orderStatus' => 'string', |
|
74
|
|
|
'orderType' => 'string', |
|
75
|
|
|
'originNumber' => 'string', |
|
76
|
|
|
'originSite' => 'string', |
|
77
|
|
|
'paymentDate' => 'string', |
|
78
|
|
|
'shippings' => 'object', |
|
79
|
|
|
'totalCommission' => 'number', |
|
80
|
|
|
'totalDiscount' => 'number', |
|
81
|
|
|
'totalFreight' => 'number', |
|
82
|
|
|
'totalGross' => 'number', |
|
83
|
|
|
'totalNet' => 'number', |
|
84
|
|
|
'totalQuantity' => 'number', |
|
85
|
|
|
]; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
4 |
|
protected function setUp() |
|
89
|
|
|
{ |
|
90
|
4 |
|
$this->setOptionalSchema(['devolutionRequested', 'exchangeRequested']); |
|
91
|
4 |
|
} |
|
92
|
|
|
|
|
93
|
1 |
|
public function toLog() |
|
94
|
|
|
{ |
|
95
|
1 |
|
return $this->partitionByArrayKey([ |
|
96
|
1 |
|
'orderDate', |
|
97
|
|
|
'orderNumber', |
|
98
|
|
|
'orderStatus', |
|
99
|
|
|
'orderType', |
|
100
|
|
|
'originNumber', |
|
101
|
|
|
'originSite', |
|
102
|
|
|
'paymentDate', |
|
103
|
|
|
'totalFreight', |
|
104
|
|
|
'totalNet', |
|
105
|
|
|
'totalQuantity', |
|
106
|
|
|
]); |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
8 |
|
public function getShipping() |
|
110
|
|
|
{ |
|
111
|
8 |
|
$shipping = $this->getShippings()->first(); |
|
112
|
|
|
|
|
113
|
8 |
|
if (empty($shipping)) { |
|
114
|
1 |
|
throw new \Exception('Shipping Missed!'); |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
7 |
|
return $shipping; |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
5 |
|
public function getOrderStatus() |
|
121
|
|
|
{ |
|
122
|
5 |
|
$value = $this->get('orderStatus'); |
|
123
|
|
|
|
|
124
|
5 |
|
return strtolower($value); |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
3 |
|
public function getInvoice() |
|
128
|
|
|
{ |
|
129
|
3 |
|
return $this->getShipping()->getInvoice(); |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
4 |
|
public function getItems() |
|
133
|
|
|
{ |
|
134
|
4 |
|
return $this->getShipping()->getItems(); |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
1 |
|
public function check() |
|
138
|
|
|
{ |
|
139
|
1 |
|
$this->setRequiredSchema(['businessUnit', 'orderDate', 'orderNumber']); |
|
140
|
|
|
|
|
141
|
1 |
|
return $this->isValid(); |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
5 |
|
public function getOrderDate() |
|
145
|
|
|
{ |
|
146
|
5 |
|
$od = $this->get('orderDate'); |
|
147
|
|
|
|
|
148
|
5 |
|
if (intval($od) === $od) { |
|
149
|
3 |
|
return date('Y-m-d', $od / 1000); |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
3 |
|
return $od; |
|
153
|
|
|
} |
|
154
|
|
|
} |
|
155
|
|
|
|