-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSalesSummResponse.php
164 lines (139 loc) · 3.73 KB
/
SalesSummResponse.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<?php
/**
* @todo Essa API foi desenvolvida em ambiente de teste (óbvio), justamente por isso não é possível
* prever todos os retornos possíveis, bem como o formato de vários resultados. Posteriormente, esse atributos
* devem se tornar arrays.
*/
class SalesSummResponse {
/**
* Data em que foi realizada a consulta
* @var string $dataRequisicao
*/
private $dataRequisicao;
/**
* Horário em que a consulta foi realizada
* @var string $horaRequisicao
*/
private $horaRequisicao;
/**
* Número de filiação entre a loja e a Rede
* @var string $filiacao
*/
private $filiacao;
/**
* Código de retorno
* @var integer $codigo
*/
private $codigo;
/**
* Mensagem de retorno
* @var string $mensagem
*/
private $mensagem;
/**
* Data de geração do resumo de vendas
* @var string $dataResumo (formato: DD/MM/AAAA)
*/
private $dataResumo;
/**
* Quantidade de vendas no período
* @var integer $qtdVendas
*/
private $qtdVendas;
/**
* Valor total das vendas
* @var float $valorTotal
*/
private $valorTotal;
/**
* Valor líquido das vendas
* @var float $valorLiquido
*/
private $valorLiquido;
//Os valores abaixo são retornados pelo Webservice, mas não são mencionados na documentação oficial
//private $row_count;
//private $nu_rv;
//private $text;
/**
* @param array $retorno - XML de resposta convertido em array
*/
function __construct($retorno){
if(isset($retorno['root'])){
$root = $retorno['root'];
$this->codigo = $root['codret'];
$this->mensagem = $root['msgret'];
if($this->getCodigo() != 0){
throw new Exception($this->getMensagem());
}
$this->row_count = $root['resumoVendas']['@attributes']['row_count'];
$resumo = $root['resumoVendas']['rv'];
$atributos = $resumo['@attributes'];
$this->dataResumo = $atributos['dt_rv'];
$this->qtdVendas = $atributos['qtd_cv'];
$this->valorTotal = $atributos['val_totl_pago'];
$this->valorLiquido = $atributos['val_totl_lqdo'];
//$this->nu_rv = $atributos['nu_rv'];
//$this->text = $atributos['text'];
}
if(isset($retorno['HEADER'])){
$header = $retorno['HEADER'];
$this->dataRequisicao = Data::stringParaData($header['DATA_REQUISICAO']);
$this->horaRequisicao = Data::stringParaHora($header['HORA_REQUISICAO']);
$this->filiacao = $header['FILIACAO'];
}
}
/**
* @return string
*/
public function getDataRequisicao(){
return $this->dataRequisicao;
}
/**
* @return string
*/
public function getHoraRequisicao(){
return $this->horaRequisicao;
}
/**
* @return string
*/
public function getFiliacao(){
return $this->filiacao;
}
/**
* @return integer
*/
public function getCodigo(){
return $this->codigo;
}
/**
* @return string
*/
public function getMensagem(){
return $this->mensagem;
}
/**
* @return string
*/
public function getDataResumo(){
return $this->dataResumo;
}
/**
* @return integer
*/
public function getQtdVendas(){
return $this->qtdVendas;
}
/**
* @return float
*/
public function getValorTotal(){
return $this->valorTotal;
}
/**
* @return float
*/
public function getValorLiquido(){
return $this->valorLiquidor;
}
}