Bitrix-D7  20.0.0
Класс ConverterDocumentShipment
Граф наследования:ConverterDocumentShipment:
Converter ConverterDocumentShipmentInvoice ConverterDocumentShipment

Открытые члены

 resolveParams ($documentImport)
 
 externalize (array $fields)
 
 externalizeItems (array $taxes, array $info)
 
 externalizeStories (array $stories, array $info)
 
 externalizeTaxes (array $items, array $info)
 
- Открытые члены унаследованные от Converter
 encode ($text, $textType="")
 
 decode ($text, $textType="")
 

Открытые статические члены

static sanitizeFields ($shipment=null, array &$fields, ISettings $settings)
 
- Открытые статические члены унаследованные от Converter
static getHtmlConverter ()
 
static getXmlConverter ()
 
static getEmptyConverter ()
 
static initTextType ($textType)
 

Защищенные члены

 getFieldsInfo ()
 
 getBasePriceDelivery ($list=[])
 

Дополнительные унаследованные члены

- Поля данных унаследованные от Converter
const TEXT = "text"
 
const HTML = "html"
 

Подробное описание

См. определение в файле converterdocumentshipment.php строка 20

Методы

◆ externalize()

externalize ( array  $fields)

См. определение в файле converterdocumentshipment.php строка 173

174  {
175  $result = array();
176 
177  $traits = $fields['TRAITS'];
178  $items = $fields['ITEMS'];
179  $stories = isset($fields['STORIES']) ? $fields['STORIES']: array();
180  $taxes = $fields['TAXES'];
181  $businessValue = $fields['BUSINESS_VALUE'];
182 
183  $availableFields = $this->getFieldsInfo();
184 
185  /** @var ISettingsExport $settings */
186  $settings = $this->getSettings();
187 
188  foreach ($availableFields as $k=>$v)
189  {
190  $value='';
191  switch ($k)
192  {
193  case 'ID':
194  $value = ($traits['ID_1C']<>'' ? $traits['ID_1C']:$traits['ID']);
195  break;
196  case 'NUMBER':
197  $value = $traits['ID'];
198  break;
199  case 'DATE':
200  $value = $traits['DATE_INSERT'];
201  break;
202  case 'OPERATION':
203  $value = DocumentBase::resolveDocumentTypeName($this->getDocmentTypeId());
204  break;
205  case 'ROLE':
206  $value = DocumentBase::getLangByCodeField('SELLER');
207  break;
208  case 'CURRENCY':
209  $replaceCurrency = $settings->getReplaceCurrency();
210  $value = substr($replaceCurrency<>'' ? $replaceCurrency:$traits[$k], 0, 3);
211  break;
212  case 'CURRENCY_RATE':
213  $value = self::CURRENCY_RATE_DEFAULT;;
214  break;
215  case 'AMOUNT':
216  $price = 0;
217  foreach ($items as $item)
218  {
219  if($item['PRODUCT_XML_ID'] !== ImportOneCBase::DELIVERY_SERVICE_XMLID)
220  $price = $price + $item['PRICE'] * $item['QUANTITY'];
221  }
222 
223  $value = $price + $traits['PRICE_DELIVERY'];
224 
225  break;
226  case 'VERSION':
227  $value = $traits['VERSION'];
228  break;
229  case 'NUMBER_BASE':// ?????
230  $value = $traits['ORDER_ID'];
231  break;
232  case 'TAXES':
233  if(count($taxes)>0)
234  $value = $this->externalizeTaxes($taxes, $v);
235  break;
236  case 'STORIES':
237  if(count($stories)>0)
238  $value = $this->externalizeStories($stories, $v);
239  break;
240  case 'TIME':
241  $value = $traits['DATE_INSERT'];
242  break;
243  case 'COMMENT':
244  $value = $traits['COMMENTS'];
245  break;
246  case 'ITEMS':
247  if(count($items)>0)
248  $value = $this->externalizeItems($items, $v);
249  break;
250  case 'REK_VALUES':
251  $value=array();
252  foreach($v['FIELDS'] as $name=>$fieldInfo)
253  {
254  $valueRV='';
255  switch($name)
256  {
257  case 'PRICE_DELIVERY':
258  $valueRV = (strlen($traits['PRICE_DELIVERY'])>0? $traits['PRICE_DELIVERY']:"0.0000");
259  break;
260  case 'DATE_ALLOW_DELIVERY':
261  case 'DELIVERY_LOCATION':
262  case 'DATE_DEDUCTED':
263  case 'REASON_UNDO_DEDUCTED':
264  case 'RESERVED':
265  case 'REASON_MARKED':
266  case 'TRACKING_NUMBER':
267  $valueRV = $traits[$name];
268  break;
269  case 'CANCEL':
270  $valueRV = $traits['CANCELED'];
271  break;
272  case 'DELIVERY_SYSTEM_ID':
273  $valueRV = $traits['DELIVERY_ID'];
274  break;
275  case 'DELIVERY_STATUS':
276  $valueRV = $traits['STATUS_ID'];
277  break;
278  case 'DELIVERY_DEDUCTED':
279  $valueRV = $traits['DEDUCTED'];
280  break;
281  case 'DELIVERY':
282  $valueRV = $traits['DELIVERY_NAME'];
283  break;
284  case 'DELIVERY_DATE_CANCEL':
285  $valueRV = $traits['DATE_CANCELED'];
286  break;
287  case 'CANCEL_REASON':
288  $valueRV = $traits['REASON_CANCELED'];
289  break;
290  case 'SITE_NAME':
291  $valueRV = '['.$traits['LID'].'] '.static::getSiteNameByLid($traits['LID']);
292  break;
293  case 'REKV':
294  $value = array_merge($value, $this->externalizeRekv($businessValue[$name], $fieldInfo));
295  break;
296  }
297  if(!in_array($name, array('REKV')))
298  {
299  $value[] = $this->externalizeRekvValue($name, $valueRV, $fieldInfo);
300  }
301  }
302  break;
303  }
304  if(!in_array($k, array('TAXES', 'STORES', 'ITEMS', 'REK_VALUES')))
305  {
306  $this->externalizeField($value, $v);
307  }
308 
309  $result[$k] = $value;
310  }
311  $result = $this->modifyTrim($result);
312  return $result;
313  }

◆ externalizeItems()

externalizeItems ( array  $taxes,
array  $info 
)

Переопределяется в ConverterDocumentShipmentInvoice и ConverterDocumentShipment.

См. определение в файле converterdocumentshipment.php строка 315

316  {
317  /** @var ConverterDocumentOrder $converter */
319  return $converter->externalizeItems($taxes, $info);
320  }

◆ externalizeStories()

externalizeStories ( array  $stories,
array  $info 
)

См. определение в файле converterdocumentshipment.php строка 322

323  {
324  /** @var ConverterDocumentOrder $converter */
326  return $converter->externalizeStories($stories, $info);
327  }

◆ externalizeTaxes()

externalizeTaxes ( array  $items,
array  $info 
)

См. определение в файле converterdocumentshipment.php строка 329

330  {
331  /** @var ConverterDocumentOrder $converter */
333  return $converter->externalizeTaxes($items, $info);
334  }

◆ getBasePriceDelivery()

getBasePriceDelivery (   $list = [])
protected

Переопределяется в ConverterDocumentShipment.

См. определение в файле converterdocumentshipment.php строка 336

337  {
338  if(is_array($list) && count($list)>0)
339  {
340  foreach($list as $item)
341  {
342  foreach($item as $fields)
343  {
344  if($fields['TYPE'] == ImportBase::ITEM_SERVICE)
345  {
346  //if((!empty($shipment)? $shipment->getPrice():'') != $item["PRICE"])
347  //{
348  //$fields["CUSTOM_PRICE_DELIVERY"] = "Y";
349  return $fields["PRICE"];
350  //$fields["CURRENCY"] = $settings->getCurrency();
351  //}
352  //break 2;
353  }
354  }
355  }
356  }
357  return 0;
358  }

◆ getFieldsInfo()

getFieldsInfo ( )
protected
Возвращает
array

Переопределяется в ConverterDocumentShipment.

См. определение в файле converterdocumentshipment.php строка 25

26  {
28  }

◆ resolveParams()

resolveParams (   $documentImport)
Аргументы
$documentImport
Возвращает
array
Исключения
ArgumentException

См. определение в файле converterdocumentshipment.php строка 35

36  {
37  if(!($documentImport instanceof DocumentBase))
38  throw new ArgumentException("Document must be instanceof DocumentBase");
39 
40  $result = array();
41 
42  $params = $documentImport->getFieldValues();
43 
44  $availableFields = Shipment::getAvailableFields();
45 
46  foreach ($availableFields as $k)
47  {
48  switch($k)
49  {
50  case 'ID_1C':
51  case 'VERSION_1C':
52  if(isset($params[$k]))
53  $fields[$k] = $params[$k];
54  break;
55  case 'COMMENTS':
56  if(isset($params['COMMENT']))
57  $fields[$k] = $params['COMMENT'];
58  break;
59  case 'DELIVERY_DOC_DATE':
60  if(isset($params['1C_DATE']))
61  $fields[$k] = $params['1C_DATE'];
62  break;
63  case 'DELIVERY_DOC_NUM':
64  if(isset($params['REK_VALUES']['1C_DELIVERY_NUM']))
65  $fields[$k] = $params['REK_VALUES']['1C_DELIVERY_NUM'];
66  break;
67  case 'DEDUCTED':
68  $deducted='';
69  $cancel='';
70 
71  if(isset($params['REK_VALUES']['DEDUCTED']))
72  $deducted = $params['REK_VALUES']['DEDUCTED'];
73  if(isset($params['REK_VALUES']['CANCEL']))
74  $cancel = $params['REK_VALUES']['CANCEL'];
75 
76  if($deducted == 'Y')
77  $fields[$k] = 'Y';
78  elseif($cancel == 'Y')
79  $fields[$k] = 'N';
80  break;
81  case 'ALLOW_DELIVERY':
82  $value='';
83  if(isset($params['REK_VALUES']['DEDUCTED']))
84  $value = $params['REK_VALUES']['DEDUCTED'];
85 
86  if($value == 'Y')
87  $fields[$k] = 'Y';
88  break;
89  case 'TRACKING_NUMBER':
90  if(isset($params['REK_VALUES']['1C_TRACKING_NUMBER']))
91  $fields[$k] = $params['REK_VALUES']['1C_TRACKING_NUMBER'];
92  break;
93  case 'BASE_PRICE_DELIVERY':
94  $fields["BASE_PRICE_DELIVERY"] = $this->getBasePriceDelivery($params['ITEMS']);
95  break;
96  case 'DELIVERY_ID':
97  $deliverySystemId = 0;
98  if(isset($params['REK_VALUES']['DELIVERY_SYSTEM_ID']))
99  {
100  $deliverySystemId = $params['REK_VALUES']['DELIVERY_SYSTEM_ID'];
101  }
102 
103  if($deliverySystemId<=0)
104  {
105  if(isset($params['REK_VALUES']['DELIVERY_SYSTEM_ID_DEFAULT']))
106  {
107  $deliverySystemId = $params['REK_VALUES']['DELIVERY_SYSTEM_ID_DEFAULT'];
108  }
109  }
110 
111  /** @var ImportSettings $settings */
112  $settings = $this->getSettings();
113 
114  if($deliverySystemId<=0)
115  {
116  $deliverySystemId = $settings->shipmentServiceFor($this->getEntityTypeId());
117  }
118 
119  if($deliverySystemId<=0)
120  {
121  $deliverySystemId = $settings->shipmentServiceDefaultFor($this->getEntityTypeId());
122  }
123 
124  $fields[$k] = $deliverySystemId;
125  break;
126  }
127  }
128 
129  $result['TRAITS'] = isset($fields)? $fields:array();
130  $result['ITEMS'] = isset($params['ITEMS'])? $this->modifyItemIdByItemName($params['ITEMS']):array();
131  $result['TAXES'] = isset($params['TAXES'])? $params['TAXES']:array();
132 
133  return $result;
134  }

◆ sanitizeFields()

static sanitizeFields (   $shipment = null,
array &  $fields,
ISettings  $settings 
)
static
Аргументы
Shipment | null$shipment
array$fields
Исключения
ArgumentException

См. определение в файле converterdocumentshipment.php строка 141

142  {
143  if(!empty($shipment) && !($shipment instanceof Shipment))
144  throw new ArgumentException("Entity must be instanceof Shipment");
145 
146  foreach($fields as $k=>$v)
147  {
148  switch($k)
149  {
150  case 'BASE_PRICE_DELIVERY':
151  if((!empty($shipment)? $shipment->getPrice():'') != $v)
152  {
153  /** @var ISettingsImport $settings */
154  $fields['CURRENCY'] = $settings->getCurrency();
155  $fields['CUSTOM_PRICE_DELIVERY'] = "Y";
156  }
157  else
158  {
159  unset($fields['BASE_PRICE_DELIVERY']);
160  }
161  break;
162  case 'DELIVERY_ID':
163  if(!empty($shipment))
164  {
165  unset($fields['DELIVERY_ID']);
166  }
167  break;
168  }
169  }
170  unset($fields['ID']);
171  }

Объявления и описания членов класса находятся в файле:
Bitrix\Sale\Exchange\OneC\ConverterDocumentShipment\externalizeTaxes
externalizeTaxes(array $items, array $info)
Definition: converterdocumentshipment.php:329
Bitrix\Sale\Exchange\OneC\DocumentBase\resolveDocumentTypeName
static resolveDocumentTypeName($typeId)
Definition: documentbase.php:168
if
if( $request->getPost( 'event') !==null)
Definition: sale/lib/rest/synchronization/push.php:10
Bitrix\Sale\Exchange\OneC\ShipmentDocument\getFieldsInfo
static getFieldsInfo()
Definition: shipmentdocument.php:19
Bitrix\Sale\Exchange\OneC\ConverterDocumentShipment\externalizeItems
externalizeItems(array $taxes, array $info)
Definition: converterdocumentshipment.php:315
Bitrix\Sale\Shipment\getAvailableFields
static getAvailableFields()
Definition: shipment.php:85
Bitrix\Sale\Exchange\ImportOneCBase\DELIVERY_SERVICE_XMLID
const DELIVERY_SERVICE_XMLID
Definition: importonecbase.php:25
Bitrix\Sale\Exchange\OneC\DocumentBase\getLangByCodeField
static getLangByCodeField($code)
Definition: documentbase.php:793
Bitrix\Sale\Exchange\OneC\ConverterDocumentShipment\getBasePriceDelivery
getBasePriceDelivery($list=[])
Definition: converterdocumentshipment.php:336
Bitrix\Sale\Exchange\OneC\ConverterDocumentShipment\getFieldsInfo
getFieldsInfo()
Definition: converterdocumentshipment.php:25
Bitrix\Sale\Exchange\OneC\ConverterFactory\create
static create($typeId)
Definition: converterfactory.php:18
Bitrix\Sale\Exchange\ImportBase\ITEM_SERVICE
const ITEM_SERVICE
Definition: importbase.php:11
Bitrix\Sale\Exchange\EntityType\ORDER
const ORDER
Definition: sale/lib/exchange/entitytype.php:8
Bitrix\Sale\Exchange\OneC\ConverterDocumentShipment\externalizeStories
externalizeStories(array $stories, array $info)
Definition: converterdocumentshipment.php:322