Beispiel #1
0
        /// <summary>
        /// 修正退款的应收/退金额
        /// </summary>
        private void reviseRefundAnticipation(NormalPayDetailBill payBill, NormalRefundDetailBill refundBill, IEnumerable <NormalRefundDetailBill> refundedBills)
        {
            var refundedAmount = refundedBills.Sum(item => item.Anticipation);

            if (Math.Abs(payBill.Anticipation) < Math.Abs(refundBill.Anticipation + refundedAmount))
            {
                refundBill.Anticipation = (payBill.Anticipation + refundedAmount) * -1;
            }
        }
Beispiel #2
0
        /// <summary>
        /// 修改应该退还的服务费
        /// </summary>
        private void reviseRefundServiceCharge(NormalPayDetailBill payBill, NormalRefundDetailBill refundBill, IEnumerable <NormalRefundDetailBill> refundedBills)
        {
            var refundedServiceCharge = refundedBills.Sum(item => item.ServiceCharge);

            if (Math.Abs(payBill.ServiceCharge) < Math.Abs(refundBill.ServiceCharge + refundedServiceCharge))
            {
                refundBill.ServiceCharge = (payBill.ServiceCharge + refundedServiceCharge) * -1;
            }
        }
Beispiel #3
0
        /// <summary>
        /// 修正退还的加价金额
        /// </summary>
        private void reviseRefundIncreasing(NormalPayDetailBill payBill, NormalRefundDetailBill refundBill, IEnumerable <NormalRefundDetailBill> refundedBills)
        {
            var refundedIncreasing = refundedBills.Sum(item => item.Increasing);

            if (Math.Abs(payBill.Increasing) < Math.Abs(refundBill.Increasing + refundedIncreasing))
            {
                refundBill.Increasing = (payBill.Increasing + refundedIncreasing) * -1;
            }
        }
Beispiel #4
0
        /// <summary>
        /// 修改应该退还的佣金
        /// </summary>
        private void reviseRefundCommission(NormalPayDetailBill payBill, NormalRefundDetailBill refundBill, IEnumerable <NormalRefundDetailBill> refundedBills)
        {
            var refundedCommission = refundedBills.Sum(item => item.Commission);

            if (Math.Abs(payBill.Commission) < Math.Abs(refundBill.Commission + refundedCommission))
            {
                refundBill.Commission = (payBill.Commission + refundedCommission) * -1;
            }
        }
Beispiel #5
0
        /// <summary>
        /// 生成差错退款账单明细
        /// </summary>
        private NormalRefundDetailBill makeRefundDetailBill(NormalPayDetailBill payBill, ErrorRefundFlight refundFlight, IEnumerable <NormalRefundDetailBill> refundedBills)
        {
            var result = new NormalRefundDetailBill(payBill.Passenger, payBill.Flight);

            result.Anticipation = GetErrorRefundAnticipation(refundFlight);
            reviseRefundAnticipation(payBill, result, refundedBills);
            result.TradeFee = CalcTradeFee(result.Anticipation);
            reviseRefundTradeFee(payBill, result, refundedBills);
            return(result);
        }
Beispiel #6
0
        /// <summary>
        /// 修改退款时的交易手续费
        /// </summary>
        private void reviseRefundTradeFee(NormalPayDetailBill payBill, NormalRefundDetailBill refundBill, IEnumerable <NormalRefundDetailBill> refundedBills)
        {
            var refundedTradeFee     = refundedBills.Sum(item => item.TradeFee);
            var refundedAnticipation = refundedBills.Sum(b => b.Anticipation);
            var refundAnticipation   = refundedAnticipation + refundBill.Anticipation;

            // 退款金额与收款金额相同时,直接全退手续费
            // 退还的手续费不能超过收取的手续费
            if (Math.Abs(payBill.Anticipation) == Math.Abs(refundAnticipation) ||
                Math.Abs(payBill.TradeFee) < Math.Abs(refundBill.TradeFee + refundedTradeFee))
            {
                refundBill.TradeFee = (payBill.TradeFee + refundedTradeFee) * -1;
            }
        }
Beispiel #7
0
        /// <summary>
        /// 生成退款账单明细
        /// </summary>
        private NormalRefundDetailBill makeRefundDetailBill(NormalPayDetailBill payBill, RefundInfo refundInfo, IEnumerable <NormalRefundDetailBill> refundedBills)
        {
            var refundFlight = refundInfo == null ? null : refundInfo.GetFlight(payBill.Flight.Id);
            var result       = new NormalRefundDetailBill(payBill.Passenger, payBill.Flight)
            {
                RefundRate = refundFlight == null ? 0 : refundFlight.Rate,
                RefundFee  = refundFlight == null ? 0 : GetRefundFee(payBill.Flight, payBill.Passenger, refundFlight)
            };

            result.Commission = GetRefundCommission(payBill);
            reviseRefundCommission(payBill, result, refundedBills);
            result.Increasing = refundFlight == null ? payBill.Increasing * -1 : GetRefundIncreasing(payBill, refundFlight.RefundServiceCharge.HasValue);
            reviseRefundIncreasing(payBill, result, refundedBills);
            result.ServiceCharge = refundFlight == null ? payBill.ServiceCharge * -1 : GetRefundServiceCharge(refundInfo.HasSupplier, refundFlight);
            reviseRefundServiceCharge(payBill, result, refundedBills);
            result.Anticipation = refundFlight == null ? payBill.Anticipation * -1 : GetRefundAnticipation(payBill, result.Commission, result.Increasing, result.ServiceCharge, result.RefundRate, result.RefundFee);
            reviseRefundAnticipation(payBill, result, refundedBills);
            result.TradeFee = CalcTradeFee(result.Anticipation);
            reviseRefundTradeFee(payBill, result, refundedBills);
            return(result);
        }