Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
payment.php
1<?php
9
10use Bitrix\Main;
12
13Loc::loadMessages(__FILE__);
14
31class PaymentTable extends Main\Entity\DataManager
32{
33 public static function getTableName()
34 {
35 return 'b_sale_order_payment';
36 }
37
38 public static function getUfId()
39 {
40 return 'PAYMENT';
41 }
42
43 public static function getMap()
44 {
45 return array(
46 'ID' => array(
47 'data_type' => 'integer',
48 'primary' => true,
49 'autocomplete' => true,
50 'title' => Loc::getMessage('ORDER_PAYMENT_ENTITY_ID_FIELD'),
51 ),
52 'ORDER_ID' => array(
53 'data_type' => 'integer',
54 'required' => true,
55 'title' => Loc::getMessage('ORDER_PAYMENT_ENTITY_ORDER_ID_FIELD'),
56 ),
57 new Main\Entity\StringField(
58 'ACCOUNT_NUMBER',
59 array(
60 'size' => 100
61 )
62 ),
63 'ORDER' => array(
64 'data_type' => 'Order',
65 'reference' => array(
66 '=this.ORDER_ID' => 'ref.ID'
67 )
68 ),
69
70 new Main\Entity\BooleanField(
71 'PAID',
72 array(
73 'values' => array('N','Y'),
74 'default_value' => 'N'
75 )
76 ),
77 'DATE_PAID' => array(
78 'data_type' => 'datetime',
79 'title' => Loc::getMessage('ORDER_PAYMENT_ENTITY_DATE_PAID_FIELD'),
80 ),
81 'EMP_PAID_ID' => array(
82 'data_type' => 'integer',
83 'title' => Loc::getMessage('ORDER_PAYMENT_ENTITY_EMP_PAID_ID_FIELD'),
84 ),
85 'EMP_PAID_BY' => array(
86 'data_type' => 'Bitrix\Main\User',
87 'reference' => array(
88 '=this.EMP_PAID_ID' => 'ref.ID'
89 )
90 ),
91 'PAY_SYSTEM_ID' => array(
92 'data_type' => 'integer',
93 'required' => true,
94 'title' => Loc::getMessage('ORDER_PAYMENT_ENTITY_PAY_SYSTEM_ID_FIELD'),
95 ),
96 'PAY_SYSTEM' => array(
97 'data_type' => 'Bitrix\Sale\Internals\PaySystemAction',
98 'reference' => array(
99 '=this.PAY_SYSTEM_ID' => 'ref.ID'
100 )
101 ),
102 'PS_STATUS' => array(
103 'data_type' => 'boolean',
104 'values' => array('N','Y'),
105 'validation' => array(__CLASS__, 'validatePsStatus'),
106 'title' => Loc::getMessage('ORDER_PAYMENT_ENTITY_PS_STATUS_FIELD'),
107 ),
108 'PS_STATUS_CODE' => array(
109 'data_type' => 'string',
110 'validation' => array(__CLASS__, 'validatePsStatusCode'),
111 'title' => Loc::getMessage('ORDER_PAYMENT_ENTITY_PS_STATUS_CODE_FIELD'),
112 ),
113 'PS_INVOICE_ID' => array(
114 'data_type' => 'string',
115 'title' => Loc::getMessage('ORDER_PAYMENT_ENTITY_PS_INVOICE_ID_FIELD'),
116 ),
117 'PS_STATUS_DESCRIPTION' => array(
118 'data_type' => 'string',
119 'validation' => array(__CLASS__, 'validatePsStatusDescription'),
120 'title' => Loc::getMessage('ORDER_PAYMENT_ENTITY_PS_STATUS_DESCRIPTION_FIELD'),
121 ),
122 'PS_STATUS_MESSAGE' => array(
123 'data_type' => 'string',
124 'validation' => array(__CLASS__, 'validatePsStatusMessage'),
125 'title' => Loc::getMessage('ORDER_PAYMENT_ENTITY_PS_STATUS_MESSAGE_FIELD'),
126 ),
127 'PS_SUM' => array(
128 'data_type' => 'float',
129 'title' => Loc::getMessage('ORDER_PAYMENT_ENTITY_PS_SUM_FIELD'),
130 ),
131 'PS_CURRENCY' => array(
132 'data_type' => 'string',
133 'validation' => array(__CLASS__, 'validatePsCurrency'),
134 'title' => Loc::getMessage('ORDER_PAYMENT_ENTITY_PS_CURRENCY_FIELD'),
135 ),
136 'PS_RESPONSE_DATE' => array(
137 'data_type' => 'datetime',
138 'title' => Loc::getMessage('ORDER_PAYMENT_ENTITY_PS_RESPONSE_DATE_FIELD'),
139 ),
140 'PS_RECURRING_TOKEN' => array(
141 'data_type' => 'string',
142 'validation' => array(__CLASS__, 'validatePsRecurringToken'),
143 'title' => Loc::getMessage('ORDER_PAYMENT_ENTITY_PS_RECURRING_TOKEN_FIELD'),
144 ),
145 'PS_CARD_NUMBER' => array(
146 'data_type' => 'string',
147 'validation' => array(__CLASS__, 'validatePsCardNumber'),
148 'title' => Loc::getMessage('ORDER_PAYMENT_ENTITY_PS_CARD_NUMBER_FIELD'),
149 ),
150 'PAY_VOUCHER_NUM' => array(
151 'data_type' => 'string',
152 'validation' => array(__CLASS__, 'validatePayVoucherNum'),
153 'title' => Loc::getMessage('ORDER_PAYMENT_ENTITY_PAY_VOUCHER_NUM_FIELD'),
154 ),
155 'PAY_VOUCHER_DATE' => array(
156 'data_type' => 'date',
157 'title' => Loc::getMessage('ORDER_PAYMENT_ENTITY_PAY_VOUCHER_DATE_FIELD'),
158 ),
159 'DATE_PAY_BEFORE' => array(
160 'data_type' => 'date',
161 'title' => Loc::getMessage('ORDER_PAYMENT_ENTITY_DATE_PAY_BEFORE_FIELD'),
162 ),
163 'DATE_BILL' => array(
164 'data_type' => 'datetime',
165 'title' => Loc::getMessage('ORDER_PAYMENT_ENTITY_DATE_BILL_FIELD'),
166 ),
167 'XML_ID' => array(
168 'data_type' => 'string',
169 'validation' => array(__CLASS__, 'validateXmlId'),
170 'title' => Loc::getMessage('ORDER_PAYMENT_ENTITY_XML_ID_FIELD'),
171 ),
172 new Main\Entity\FloatField(
173 'SUM',
174 array(
175 'default_value' => '0.0000',
176 'required' => true,
177 )
178 ),
179 'PRICE_COD' => array(
180 'data_type' => 'float',
181 'required' => false,
182 'title' => Loc::getMessage('ORDER_PAYMENT_ENTITY_PRICE_COD_FIELD'),
183 ),
184 'CURRENCY' => array(
185 'data_type' => 'string',
186 'required' => true,
187 'validation' => array(__CLASS__, 'validateCurrency'),
188 'title' => Loc::getMessage('ORDER_PAYMENT_ENTITY_CURRENCY_FIELD'),
189 ),
190 'PAY_SYSTEM_NAME' => array(
191 'data_type' => 'string',
192 'required' => true,
193 'validation' => array(__CLASS__, 'validatePaySystemName'),
194 'title' => Loc::getMessage('ORDER_PAYMENT_ENTITY_PAY_SYSTEM_NAME_FIELD'),
195 ),
196 'RESPONSIBLE_ID' => array(
197 'data_type' => 'integer',
198 'title' => Loc::getMessage('ORDER_PAYMENT_ENTITY_RESPONSIBLE_ID_FIELD')
199 ),
200 'RESPONSIBLE_BY' => array(
201 'data_type' => 'Bitrix\Main\User',
202 'reference' => array(
203 '=this.RESPONSIBLE_ID' => 'ref.ID'
204 )
205 ),
206 'EMP_RESPONSIBLE_ID' => array(
207 'data_type' => 'integer',
208 'title' => Loc::getMessage('ORDER_PAYMENT_ENTITY_EMP_RESPONSIBLE_ID_FIELD')
209 ),
210 'EMP_RESPONSIBLE_BY' => array(
211 'data_type' => 'Bitrix\Main\User',
212 'reference' => array(
213 '=this.EMP_RESPONSIBLE_ID' => 'ref.ID'
214 )
215 ),
216 'DATE_RESPONSIBLE_ID' => array(
217 'data_type' => 'datetime',
218 'title' => Loc::getMessage('ORDER_PAYMENT_ENTITY_DATE_RESPONSIBLE_ID_FIELD')
219 ),
220 'COMMENTS' => array(
221 'data_type' => 'string',
222 'title' => Loc::getMessage('ORDER_PAYMENT_ENTITY_COMMENTS_FIELD')
223 ),
224 'COMPANY_ID' => array(
225 'data_type' => 'integer',
226 'title' => Loc::getMessage('ORDER_PAYMENT_ENTITY_COMPANY_ID_FIELD')
227 ),
228 'COMPANY_BY' => array(
229 'data_type' => 'Bitrix\Sale\Internals\Company',
230 'reference' => array(
231 '=this.COMPANY_ID' => 'ref.ID'
232 )
233 ),
234 'PAY_RETURN_NUM' => array(
235 'data_type' => 'string',
236 'validation' => array(__CLASS__, 'validatePayVoucherNum'),
237 'title' => Loc::getMessage('ORDER_PAYMENT_ENTITY_PAY_RETURN_NUM_FIELD'),
238 ),
239 'PAY_RETURN_DATE' => array(
240 'data_type' => 'date',
241 'title' => Loc::getMessage('ORDER_PAYMENT_ENTITY_PAY_RETURN_DATE_FIELD'),
242 ),
243 new Main\Entity\IntegerField('EMP_RETURN_ID'),
244
245 new Main\Entity\ReferenceField(
246 'EMP_RETURN_BY',
247 '\Bitrix\Main\User',
248 array('=this.USER_ID' => 'ref.EMP_RETURN_ID'),
249 array('join_type' => 'INNER')
250 ),
251
252 'PAY_RETURN_COMMENT' => array(
253 'data_type' => 'string',
254 'title' => Loc::getMessage('ORDER_PAYMENT_ENTITY_PAY_RETURN_COMMENT_FIELD'),
255 ),
256 new Main\Entity\EnumField(
257 'IS_RETURN',
258 array(
259 'values' => array('N','Y','P'),
260 'default_value' => 'N'
261 )
262 ),
263
264 new Main\Entity\BooleanField(
265 'MARKED',
266 array(
267 'values' => array('N','Y'),
268 'default_value' => 'N'
269 )
270 ),
271
272 new Main\Entity\DatetimeField('DATE_MARKED'),
273
274 new Main\Entity\IntegerField('EMP_MARKED_ID'),
275
276 new Main\Entity\ReferenceField(
277 'EMP_MARKED_BY',
278 '\Bitrix\Main\User',
279 array('=this.EMP_MARKED_ID' => 'ref.ID'),
280 array('join_type' => 'INNER')
281 ),
282
283 'REASON_MARKED' => array(
284 'data_type' => 'string',
285 'validation' => array(__CLASS__, 'validateReasonMarked'),
286 'title' => Loc::getMessage('ORDER_PAYMENT_ENTITY_REASON_MARKED_FIELD'),
287 ),
288
289 new Main\Entity\BooleanField(
290 'UPDATED_1C',
291 array(
292 'values' => array('N', 'Y')
293 )
294 ),
295
296 new Main\Entity\StringField('ID_1C'),
297
298 new Main\Entity\StringField('VERSION_1C'),
299
300 new Main\Entity\EnumField(
301 'EXTERNAL_PAYMENT',
302 array(
303 'values' => array('N', 'Y', 'F')
304 )
305 ),
306 );
307 }
308
314 public static function validatePaid()
315 {
316 return array(
317 new Main\Entity\Validator\Length(null, 1),
318 );
319 }
325 public static function validatePsStatus()
326 {
327 return array(
328 new Main\Entity\Validator\Length(null, 1),
329 );
330 }
336 public static function validatePsStatusCode()
337 {
338 return array(
339 new Main\Entity\Validator\Length(null, 255),
340 );
341 }
347 public static function validatePsStatusDescription()
348 {
349 return array(
350 new Main\Entity\Validator\Length(null, 512),
351 );
352 }
358 public static function validatePsStatusMessage()
359 {
360 return array(
361 new Main\Entity\Validator\Length(null, 250),
362 );
363 }
369 public static function validatePsCurrency()
370 {
371 return array(
372 new Main\Entity\Validator\Length(null, 3),
373 );
374 }
380 public static function validatePayVoucherNum()
381 {
382 return array(
383 new Main\Entity\Validator\Length(null, 20),
384 );
385 }
391 public static function validatePayReturnNum()
392 {
393 return array(
394 new Main\Entity\Validator\Length(null, 20),
395 );
396 }
402 public static function validateXmlId()
403 {
404 return array(
405 new Main\Entity\Validator\Length(null, 255),
406 );
407 }
413 public static function validateCurrency()
414 {
415 return array(
416 new Main\Entity\Validator\Length(null, 3),
417 );
418 }
424 public static function validatePaySystemName()
425 {
426 return array(
427 new Main\Entity\Validator\Length(null, 128),
428 );
429 }
435 public static function validateReasonMarked()
436 {
437 return array(
438 new Main\Entity\Validator\Length(null, 255),
439 );
440 }
441
447 public static function validatePsRecurringToken()
448 {
449 return array(
450 new Main\Entity\Validator\Length(null, 255),
451 );
452 }
453
459 public static function validatePsCardNumber()
460 {
461 return array(
462 new Main\Entity\Validator\Length(null, 64),
463 );
464 }
465
466 public static function deleteWithItems(int $id) : Main\Entity\DeleteResult
467 {
468 if ($id <= 0)
469 {
470 throw new Main\ArgumentNullException("id");
471 }
472
473 $itemsList = PayableItemTable::getList(
474 [
475 "filter" => ["=PAYMENT_ID" => $id],
476 "select" => ["ID"]
477 ]
478 );
479 while ($item = $itemsList->fetch())
480 {
481 PayableItemTable::delete($item["ID"]);
482 }
483
484 return static::delete($id);
485 }
486}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static getList(array $parameters=array())