Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
provideraccountpay.php
1<?php
9namespace Bitrix\Sale;
10
11use Bitrix\Main,
16
17if (!Loader::includeModule('sale'))
18 return false;
19
24class ProviderAccountPay implements \IBXSaleProductProvider
25{
30 public static function GetProductData($fields)
31 {
32 $fields["CAN_BUY"] = 'Y';
33 $fields["AVAILABLE_QUANTITY"] = 100000000;
34 return $fields;
35
36 }
37
38 public static function OrderProduct($fields)
39 {
40 $fields["AVAILABLE_QUANTITY"] = 'Y';
41 return $fields;
42 }
43
44 public static function CancelProduct($fields)
45 {
46 }
47
48 public static function DeliverProduct($fields)
49 {
50 }
51
52 public static function ViewProduct($fields)
53 {
54 }
55
56 public static function RecurringOrderProduct($fields)
57 {
58 }
59
60 public static function GetStoresCount($arParams = array())
61 {
62 }
63
64 public static function GetProductStores($fields)
65 {
66 }
67
68 public static function ReserveProduct($fields)
69 {
70 $fields['QUANTITY_RESERVED'] = $fields['QUANTITY_ADD'];
71 $fields['RESULT'] = true;
72 return $fields;
73 }
74
75 public static function CheckProductBarcode($fields)
76 {
77 }
78
83 public static function DeductProduct($fields)
84 {
86 $basketItem = $fields['BASKET_ITEM'];
87 $orderId = (int)$basketItem->getField('ORDER_ID');
88 $currency = $basketItem->getField('CURRENCY');
89
90 $propertyCollection = $basketItem->getPropertyCollection();
91
92 $item = $propertyCollection->getPropertyValues();
93 $sum = (float)($item['SUM_OF_CHARGE']['VALUE']) * (float)($basketItem->getQuantity());
94
96 $basket = $basketItem->getCollection();
97 $order = $basket->getOrder();
98 $userId = $order->getUserId();
99
100 $resultUpdateUserAccount = \CSaleUserAccount::UpdateAccount($userId, ($fields["UNDO_DEDUCTION"]==='N'?$sum:-$sum), $currency, "MANUAL", $orderId, "Payment to user account");
101
102 if ($resultUpdateUserAccount)
103 {
104 $fields['RESULT'] = true;
105 }
106 else
107 {
108 return false;
109 }
110
111 return $fields;
112 }
113}
static GetStoresCount($arParams=array())