本文整理汇总了PHP中Bitrix\Sale\Order::getPaymentCollection方法的典型用法代码示例。如果您正苦于以下问题:PHP Order::getPaymentCollection方法的具体用法?PHP Order::getPaymentCollection怎么用?PHP Order::getPaymentCollection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bitrix\Sale\Order
的用法示例。
在下文中一共展示了Order::getPaymentCollection方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPaymentsInfo
protected static function getPaymentsInfo(Order $order)
{
$payments = $order->getPaymentCollection();
if (!$payments) {
return array();
}
$result = array();
/** @var $payment \Bitrix\Sale\Payment */
foreach ($payments as $payment) {
$id = $payment->getField("PAY_SYSTEM_ID");
$ptId = $order->getPersonTypeId();
if (!$id || !$ptId) {
continue;
}
$params = OrderPayment::getPaySystemParams($id, $ptId);
if (!$params) {
continue;
}
$result[] = array("ID" => $payment->getId(), "NAME" => $params["NAME"], "LOGOTIP_PATH" => $params["LOGOTIP_PATH"], "IS_PAYED" => $payment->isPaid());
}
return $result;
}
示例2: getView
public static function getView(Order $order, OrderBasket $orderBasket, $selectPayment = null, $selectId = null)
{
// prepare data
$orderId = $order->getId();
$data = $orderBasket->prepareData();
$items = $data['ITEMS'];
$documents = array();
$itemNo = 0;
/** @var \Bitrix\Sale\Payment $payment */
foreach ($order->getPaymentCollection() as $payment) {
$documents[] = $payment;
}
/** @var \Bitrix\Sale\Shipment $shipment */
foreach ($order->getShipmentCollection() as $shipment) {
if (!$shipment->isSystem()) {
if (!$shipment->isCanceled() && $shipment->isShipped()) {
/** @var \Bitrix\Sale\ShipmentItem $shipmentItem */
foreach ($shipment->getShipmentItemCollection() as $shipmentItem) {
$basketItem = $shipmentItem->getBasketItem();
if (isset($items[$basketItem->getBasketCode()])) {
$item =& $items[$basketItem->getBasketCode()];
if ($shippedQuantity =& $item['SHIPPED_QUANTITY']) {
$shippedQuantity += (double) $shipmentItem->getField('QUANTITY');
} else {
$shippedQuantity = (double) $shipmentItem->getField('QUANTITY');
}
}
}
}
$documents[] = $shipment;
}
}
unset($item, $shippedQuantity);
usort($documents, array(__CLASS__, 'sortDocumentsByDate'));
// render view
ob_start();
?>
<div class="adm-s-order-table-ddi">
<table class="adm-s-order-table-ddi-table adm-s-bus-ordertable-option" style="width: 100%;">
<thead>
<tr>
<td class="tac"><?php
echo Loc::getMessage('SALE_OANALYSIS_ITEM_NUMBER');
?>
</td>
<td><?php
echo Loc::getMessage('SALE_OANALYSIS_ITEM_NAME');
?>
</td>
<td class="tac"><?php
echo Loc::getMessage('SALE_OANALYSIS_ITEM_PROPERTIES');
?>
</td>
<td class="tac"><?php
echo Loc::getMessage('SALE_OANALYSIS_ITEM_PLANNED');
?>
</td>
<td class="tac"><?php
echo Loc::getMessage('SALE_OANALYSIS_ITEM_SHIPPED');
?>
</td>
<td class="tac"><?php
echo Loc::getMessage('SALE_OANALYSIS_ITEM_TO_SHIP');
?>
</td>
</tr>
</thead>
<tbody>
<?php
foreach ($items as $item) {
$properties = '<table style="margin: auto; width: 50%;">';
if (is_array($item['SKU_PROPS'])) {
foreach ($item['SKU_PROPS'] as $skuProp) {
$properties .= '<tr>';
$properties .= '<td style="text-align: left;">' . htmlspecialcharsbx($skuProp['NAME']) . ' : ' . '</td>';
if (isset($skuProp['VALUE']['PICT']) && $skuProp['VALUE']['PICT']) {
$properties .= '<td><span class="color"><img src="' . $skuProp['VALUE']['PICT'] . '" alt=""></span></td>';
} else {
$properties .= '<td><span>' . htmlspecialcharsbx($skuProp['VALUE']['NAME']) . '</span></td>';
}
$properties .= '</tr>';
}
}
$properties .= '</table>';
if (!($quantity = (double) $item['QUANTITY'])) {
$quantity = 0;
}
if (!($shippedQuantity = $item['SHIPPED_QUANTITY'])) {
$shippedQuantity = 0;
}
?>
<tr class="bdb-line">
<td class="tac"><?php
echo ++$itemNo;
?>
</td>
<td style="text-align: left;"><a class="fwb" href="<?php
echo $item['EDIT_PAGE_URL'];
?>
"><?php
//.........这里部分代码省略.........
示例3: updateData
/**
* @param Order $order
* @param $payments
* @param bool $canSetPaid
* @return Result
* @throws Main\ArgumentOutOfRangeException
* @throws Main\ObjectNotFoundException
* @throws UserMessageException
*/
public static function updateData(Order &$order, $payments, $canSetPaid = false)
{
global $USER;
$result = new Result();
$data['PAYMENT'] = array();
if (!$order) {
throw new UserMessageException('Order does not exist');
}
foreach ($payments as $payment) {
$paymentId = intval($payment['PAYMENT_ID']);
$isNew = $paymentId <= 0;
$paymentCollection = $order->getPaymentCollection();
/** @var \Bitrix\Sale\Payment $paymentItem */
if ($isNew) {
$paymentItem = $paymentCollection->createItem();
} else {
$paymentItem = $paymentCollection->getItemById($paymentId);
if (!$paymentItem) {
throw new UserMessageException('Payment does not exist');
}
}
self::$defaultFields = $paymentItem->getFieldValues();
$isReturn = isset($payment['IS_RETURN']) && $payment['IS_RETURN'] == 'Y';
/** @var \Bitrix\Sale\PaySystemService $paymentService */
$paymentService = PaySystemService::load($payment['PAY_SYSTEM_ID']);
if (!$paymentService) {
$result->addError(new EntityError(Loc::getMessage('SALE_ORDER_PAYMENT_ERROR_PAYSYSTEM')));
}
$paymentFields = array('PAY_SYSTEM_ID' => $payment['PAY_SYSTEM_ID'], 'COMPANY_ID' => isset($payment['COMPANY_ID']) ? $payment['COMPANY_ID'] : 0, 'SUM' => $payment['SUM'], 'PAY_VOUCHER_NUM' => $payment['PAY_VOUCHER_NUM'], 'PAY_RETURN_NUM' => $payment['PAY_RETURN_NUM'], 'PAY_RETURN_COMMENT' => $payment['PAY_RETURN_COMMENT'], 'COMMENTS' => $payment['COMMENTS'], 'PAY_SYSTEM_NAME' => $paymentService ? $paymentService->getName() : '');
if ($isNew) {
$paymentFields['DATE_BILL'] = new DateTime();
}
if (!empty($payment['PAY_RETURN_DATE'])) {
try {
$paymentFields['PAY_RETURN_DATE'] = new Date($payment['PAY_RETURN_DATE']);
} catch (Main\ObjectException $exception) {
$result->addError(new EntityError(Loc::getMessage('SALE_ORDER_PAYMENT_ERROR_RETURN_DATE_FORMAT')));
}
}
if (!empty($payment['PAY_VOUCHER_DATE'])) {
try {
$paymentFields['PAY_VOUCHER_DATE'] = new Date($payment['PAY_VOUCHER_DATE']);
} catch (Main\ObjectException $exception) {
$result->addError(new EntityError(Loc::getMessage('SALE_ORDER_PAYMENT_ERROR_VOUCHER_DATE_FORMAT')));
}
}
if (isset($payment['RESPONSIBLE_ID'])) {
$paymentFields['RESPONSIBLE_ID'] = !empty($payment['RESPONSIBLE_ID']) ? $payment['RESPONSIBLE_ID'] : $USER->GetID();
if ($payment['RESPONSIBLE_ID'] != $paymentItem->getField('RESPONSIBLE_ID')) {
$paymentFields['DATE_RESPONSIBLE_ID'] = new DateTime();
if (!$isNew) {
$paymentFields['EMP_RESPONSIBLE_ID'] = $USER->GetID();
}
}
}
if ($result->isSuccess()) {
if ($paymentItem->getField('PAID') != $payment['PAID'] && $paymentItem->getField('IS_RETURN') == 'Y') {
$setResult = $paymentItem->setReturn('N');
if (!$setResult->isSuccess()) {
$result->addErrors($setResult->getErrors());
}
}
if ($isReturn && $payment['OPERATION_ID'] == 'RETURN') {
$setResult = $paymentItem->setReturn('Y');
if (!$setResult->isSuccess()) {
$result->addErrors($setResult->getErrors());
}
}
$setResult = $paymentItem->setFields($paymentFields);
if (!$setResult->isSuccess()) {
$result->addErrors($setResult->getErrors());
}
if (!$canSetPaid) {
$setResult = $paymentItem->setPaid($payment['PAID']);
if (!$setResult->isSuccess()) {
$result->addErrors($setResult->getErrors());
}
}
if ($payment['ORDER_STATUS_ID']) {
$order->setField('STATUS_ID', $payment['ORDER_STATUS_ID']);
}
}
$data['PAYMENT'][] = $paymentItem;
}
$result->setData($data);
return $result;
}
示例4: getOrderFields
/**
* @param Sale\Order $order
*
* @return array
*/
public static function getOrderFields(Sale\Order $order)
{
$result = new Sale\Result();
$paymentSystemId = false;
$deliveryId = false;
/** @var Sale\PaymentCollection $paymentCollection */
if ($paymentCollection = $order->getPaymentCollection()) {
/** @var Sale\Payment $payment */
if ($payment = $paymentCollection->rewind()) {
$paymentSystemId = $payment->getPaymentSystemId();
}
}
/** @var Sale\ShipmentCollection $shipe */
if ($shipmentCollection = $order->getShipmentCollection()) {
/** @var Sale\Shipment $shipment */
foreach ($shipmentCollection as $shipment) {
if ($shipment->getDeliveryId() > 0) {
$deliveryId = $shipment->getDeliveryId();
break;
}
}
}
$fields = array("SITE_ID" => $order->getSiteId(), "LID" => $order->getSiteId(), "PERSON_TYPE_ID" => $order->getPersonTypeId(), "PRICE" => $order->getPrice(), "CURRENCY" => $order->getCurrency(), "USER_ID" => $order->getUserId(), "PAY_SYSTEM_ID" => $paymentSystemId, "PRICE_DELIVERY" => $order->getDeliveryPrice(), "DELIVERY_ID" => $deliveryId, "DISCOUNT_VALUE" => $order->getDiscountPrice(), "TAX_VALUE" => $order->getTaxValue(), "TRACKING_NUMBER" => $order->getField('TRACKING_NUMBER'), "PAYED" => $order->getField('PAYED'), "CANCELED" => $order->getField('CANCELED'), "STATUS_ID" => $order->getField('STATUS_ID'), "RESERVED" => $order->getField('RESERVED'));
$orderFields = static::convertOrderToArray($order);
if (is_array($orderFields)) {
$orderFields = $fields + $orderFields;
$orderFields = static::convertDateFieldsToOldFormat($orderFields);
}
$result->setData(array('FIELDS' => $fields, 'ORDER_FIELDS' => $orderFields));
return $result;
}
示例5: fillEmptyOrderData
/**
* Fill empty order data.
*
* @param Order $order Order object.
* @return void
*/
protected function fillEmptyOrderData(Order $order)
{
$this->orderData = array('ID' => $order->getId(), 'USER_ID' => $order->getUserId(), 'SITE_ID' => $order->getSiteId(), 'ORDER_PRICE' => $order->getPrice(), 'ORDER_WEIGHT' => 0, 'CURRENCY' => $order->getCurrency(), 'PERSON_TYPE_ID' => $order->getPersonTypeId(), 'BASKET_ITEMS' => array(), 'PRICE_DELIVERY' => 0, 'PRICE_DELIVERY_DIFF' => 0, 'DELIVERY_ID' => 0, 'CUSTOM_PRICE_DELIVERY' => 'N', 'SHIPMENT_CODE' => 0, 'SHIPMENT_ID' => 0);
$paymentCollection = $order->getPaymentCollection();
/** @var Payment $payment */
foreach ($paymentCollection as $payment) {
if ($payment->isInner()) {
continue;
}
if (!isset($this->orderData['PAY_SYSTEM_ID'])) {
$this->orderData['PAY_SYSTEM_ID'] = $payment->getPaymentSystemId();
break;
}
}
unset($payment, $paymentCollection);
if (!isset($this->orderData['PAY_SYSTEM_ID'])) {
$this->orderData['PAY_SYSTEM_ID'] = 0;
}
}