/// <summary>
        /// Возврат распределенной суммы на баланс клиента
        /// Если есть распределение на этот заказ, то создаем новый платеж с распределенной суммой
        /// для ее возврата на баланс клиента и последующего перераспределения
        /// </summary>
        /// <param name="uow">Unit of work</param>
        /// <param name="order">Заказ</param>
        /// <param name="refundPaymentReason">Причина возврата суммы на баланс</param>
        public void ReturnAllocatedSumToClientBalance(
            IUnitOfWork uow, Order order, RefundPaymentReason refundPaymentReason = RefundPaymentReason.OrderCancellation)
        {
            if (!HasAllocatedSum(uow, order.Id, out var paymentItems, out var allocatedSum))
            {
                return;
            }

            CreateNewPaymentForReturnAllocatedSumToClientBalance(uow, order, allocatedSum, paymentItems, refundPaymentReason);
        }
        private void CreateNewPaymentForReturnAllocatedSumToClientBalance(
            IUnitOfWork uow, Order order, decimal allocatedSum, IList <PaymentItem> paymentItems, RefundPaymentReason refundPaymentReason)
        {
            foreach (var paymentItem in paymentItems)
            {
                paymentItem.CancelAllocation();
                uow.Save(paymentItem);
            }

            var     payment  = paymentItems.Select(x => x.Payment).First();
            var     orderSum = order.OrderSum;
            decimal sum;

            if (orderSum > 0)
            {
                sum = allocatedSum <= orderSum ? allocatedSum : orderSum;
            }
            else
            {
                sum = allocatedSum;
            }

            var newPayment = payment.CreatePaymentForReturnAllocatedSumToClientBalance(sum, order.Id, refundPaymentReason);

            if (order.OrderPaymentStatus != OrderPaymentStatus.UnPaid)
            {
                order.OrderPaymentStatus =
                    order.PaymentType == PaymentType.cashless
                                                ? OrderPaymentStatus.UnPaid
                                                : OrderPaymentStatus.None;
            }

            uow.Save(newPayment);
        }