本文整理汇总了PHP中Bitrix\Sale\Order::getSumPaid方法的典型用法代码示例。如果您正苦于以下问题:PHP Order::getSumPaid方法的具体用法?PHP Order::getSumPaid怎么用?PHP Order::getSumPaid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bitrix\Sale\Order
的用法示例。
在下文中一共展示了Order::getSumPaid方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepareData
public static function prepareData(Order $order)
{
$currencyBudget = 0;
if ($order->getUserId() > 0) {
$res = \CSaleUserAccount::getList(array(), array('USER_ID' => $order->getUserId(), 'CURRENCY' => $order->getCurrency(), 'LOCKED' => 'N'), false, false, array('CURRENT_BUDGET'));
$userAccount = $res->Fetch();
$currencyBudget = $userAccount['CURRENT_BUDGET'];
}
$payable = $order->getPrice() - $order->getSumPaid();
$price = $order->getPrice();
$sumPaid = $order->getSumPaid();
$data = array('PRICE' => $price ? $price : 0, 'SUM_PAID' => $sumPaid ? $sumPaid : 0, 'PAYABLE' => $payable >= 0 ? $payable : 0, 'CURRENCY' => $order->getCurrency(), 'BUYER_BUDGET' => $currencyBudget, 'STATUS_ID' => $order->getField('STATUS_ID'));
return $data;
}
示例2: payFromBudget
/**
* Paid from internal account
*
* @param Sale\Order $order Entity of the order.
* @param bool $pay Flag making donations to internal account.
* @param null $paidFormUserBudget
* @return Sale\Result
* @throws Main\ObjectNotFoundException
* @throws \Bitrix\Main\ArgumentOutOfRangeException
* @throws \Bitrix\Main\InvalidOperationException
*/
public static function payFromBudget(Sale\Order $order, $pay, $paidFormUserBudget = null)
{
$result = new Sale\Result();
/** @var Sale\Payment|null $paymentOuter */
$paymentInner = null;
/** @var Sale\Payment|null $paymentOuter */
$paymentOuter = null;
/** @var Sale\PaymentCollection $paymentCollection */
if (!($paymentCollection = $order->getPaymentCollection())) {
throw new Main\ObjectNotFoundException('Entity "PaymentCollection" not found');
}
if (count($paymentCollection) > 2) {
return $result;
}
$needSum = $order->getPrice() - $order->getSumPaid();
if ($needSum > 0) {
/** @var Sale\Payment $payment */
foreach ($paymentCollection as $payment) {
if (!$payment->isInner()) {
$paymentOuter = $payment;
break;
}
}
if (!$pay || $pay && $paidFormUserBudget === false) {
/** @var Sale\Payment $paymentInner */
if (!($paymentInner = $paymentCollection->getInnerPayment())) {
throw new Main\ObjectNotFoundException('Entity inner "Payment" not found');
}
$userBudget = Sale\Internals\UserBudgetPool::getUserBudget($order->getUserId(), $order->getCurrency());
$setSum = $userBudget;
if ($userBudget >= $needSum) {
$setSum = $needSum;
}
if ($paymentInner->getId() == 0) {
$paymentInnerFields = array('SUM' => $setSum, 'CURRENCY' => $order->getCurrency(), 'DATE_BILL' => new Main\Type\DateTime());
$r = $paymentInner->setFields($paymentInnerFields);
if (!$r->isSuccess()) {
$result->addErrors($r->getErrors());
}
} else {
if ($paymentInner->getSum() < $needSum) {
$paymentInner->setField('SUM', $needSum - $paymentInner->getSum());
}
}
if ($pay && $paidFormUserBudget === false) {
$paymentOuter->setField('SUM', $needSum - $setSum);
}
$payment = $paymentInner;
} else {
$payment = $paymentOuter;
}
if ($pay) {
if ($payment === null) {
$paySystemId = static::getDefaultPaySystemId($order->getPersonTypeId());
/** @var Sale\PaySystemService $paysystem */
if ($paysystem = Sale\PaySystemService::load($paySystemId)) {
$payment = Sale\Payment::create($paymentCollection, $paysystem);
$payment->setField('SUM', $needSum);
$payment->setField('DATE_BILL', new Main\Type\DateTime());
$paymentCollection->addItem($payment);
}
}
$operationPayment = $payment;
if ($paidFormUserBudget === false) {
$operationPayment = $paymentOuter;
}
$r = Sale\Internals\PaySystemInner::createOperation($order, $operationPayment, Sale\Internals\PaySystemInner::OPERATION_CREDIT);
if (!$r->isSuccess()) {
$result->addErrors($r->getErrors());
}
}
if ($payment->isReturn() && $payment->isInner()) {
/** @var Sale\Result $r */
$r = $payment->setReturn('N');
} else {
/** @var Sale\Result $r */
$r = $payment->setPaid('Y');
if ($r->isSuccess()) {
if ($pay) {
$operationPayment = $payment;
if ($paidFormUserBudget === false) {
$operationPayment = $paymentOuter;
/** @var Sale\Result $resultPayment */
$resultPayment = $paymentOuter->setPaid('Y');
if (!$resultPayment->isSuccess()) {
$result->addErrors($resultPayment->getErrors());
}
}
/** @var Sale\Result $r */
//.........这里部分代码省略.........
示例3: getTotalPrices
public static function getTotalPrices(Order $order, OrderBasket $orderBasket, $needRecalculate = true)
{
$result = array('PRICE_TOTAL' => $order->getPrice(), 'TAX_VALUE' => $order->getTaxValue(), 'PRICE_DELIVERY_DISCOUNTED' => $order->getDeliveryPrice(), 'SUM_PAID' => $order->getSumPaid());
$result["SUM_UNPAID"] = $result["PRICE_TOTAL"] - $result["SUM_PAID"];
if (!$result["PRICE_DELIVERY_DISCOUNTED"]) {
$result["PRICE_DELIVERY_DISCOUNTED"] = 0;
}
if (!$result["TAX_VALUE"]) {
$result["TAX_VALUE"] = 0;
}
$orderDiscount = $order->getDiscount();
if ($orderDiscount) {
$discountsList = self::getDiscountsApplyResult($order, $needRecalculate);
} else {
$discountsList = array();
}
if (isset($discountsList["PRICES"]["DELIVERY"]["DISCOUNT"])) {
$result['DELIVERY_DISCOUNT'] = $discountsList["PRICES"]["DELIVERY"]["DISCOUNT"];
} else {
$result['DELIVERY_DISCOUNT'] = 0;
}
$result['PRICE_DELIVERY'] = $result['PRICE_DELIVERY_DISCOUNTED'] + $result['DELIVERY_DISCOUNT'];
$basketData = $orderBasket->prepareData(array("DISCOUNTS" => $discountsList));
$result["PRICE_BASKET_DISCOUNTED"] = $basketData["BASKET_PRICE"];
$result["PRICE_BASKET"] = $basketData["BASKET_PRICE_BASE"];
return $result;
}