Exemplo n.º 1
0
        /// <summary>
        /// 生成采购支付账单
        /// </summary>
        /// <param name="trade">交易信息</param>
        /// <param name="tradeDeduction">交易方信息</param>
        public static Distribution.Domain.Bill.Pay.NormalPayBill ProducePurchasePayBill(Distribution.Domain.TradeInfo trade, Distribution.Domain.TradeDeduction tradeDeduction)
        {
            if (trade == null)
            {
                throw new ArgumentNullException("trade");
            }
            if (trade.Passengers == null || !trade.Passengers.Any())
            {
                throw new CustomException("缺少乘机人信息");
            }
            if (trade.Flights == null || !trade.Flights.Any())
            {
                throw new CustomException("缺少航班信息");
            }
            if (tradeDeduction == null)
            {
                throw new ArgumentNullException("tradeDeduction");
            }
            if (tradeDeduction.Purchaser == null)
            {
                throw new CustomException("缺少买家信息");
            }
            var originalPayBill = DistributionQueryService.QueryNormalPayBill(trade.Id);

            if (originalPayBill != null)
            {
                throw new RepeatedItemException("支付账单已存在");
            }

            var payBill = new Distribution.Domain.Bill.Pay.NormalPayBill(trade.Id)
            {
                Remark = "预订出票"
            };
            var tradeRolePayBills = new List <Distribution.Domain.Bill.Pay.Normal.NormalPayRoleBill>();
            // 采购方
            var purchaserDeduction = tradeDeduction.Purchaser;
            var purchaser          = new Distribution.Domain.Role.Purchaser(purchaserDeduction.Owner);

            payBill.Purchaser = purchaser.MakePayBill(trade, purchaserDeduction.Deduction);
            tradeRolePayBills.Add(payBill.Purchaser);
            // 分润方
            foreach (var royaltyDeduction in tradeDeduction.Royalties)
            {
                if (royaltyDeduction.Deduction.Rebate != 0 || royaltyDeduction.Deduction.Increasing != 0)
                {
                    var royalty        = new Distribution.Domain.Role.Royalty(royaltyDeduction.Owner);
                    var royaltyPayBill = royalty.MakePayBill(trade, royaltyDeduction.Deduction);
                    payBill.AddRoyalty(royaltyPayBill);
                    tradeRolePayBills.Add(royaltyPayBill);
                }
            }
            // 平台
            var platform = new Distribution.Domain.Role.Platform();

            payBill.Platform = platform.MakePayBill(trade, tradeRolePayBills, tradeDeduction.Platform);
            return(payBill);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 生成分润方支付账单
        /// </summary>
        /// <param name="trade">交易信息</param>
        /// <param name="tradeDeduction">交易方信息</param>
        /// <param name="payBill">原支付账单</param>
        /// <param name="reproduceRoyaltyBill">是否重新生成分润方账单</param>
        public static Distribution.Domain.Bill.Pay.NormalPayBill ProduceProvidePayBill(Distribution.Domain.TradeInfo trade, Distribution.Domain.TradeDeduction tradeDeduction, Distribution.Domain.Bill.Pay.NormalPayBill payBill, bool reproduceRoyaltyBill)
        {
            if (trade == null)
            {
                throw new ArgumentNullException("trade");
            }
            if (trade.Passengers == null || !trade.Passengers.Any())
            {
                throw new CustomException("缺少乘机人信息");
            }
            if (trade.Flights == null || !trade.Flights.Any())
            {
                throw new CustomException("缺少航班信息");
            }
            if (tradeDeduction == null)
            {
                throw new ArgumentNullException("tradeDeduction");
            }
            if (tradeDeduction.Provider == null)
            {
                throw new CustomException("缺少出票方信息");
            }
            if (trade.IsThirdRelation && tradeDeduction.Supplier == null)
            {
                throw new CustomException("缺少产品方信息");
            }
            if (payBill == null)
            {
                throw new NotFoundException("支付账单不存在");
            }
            if (payBill.Purchaser == null)
            {
                throw new CustomException("账单信息数据错误,缺少买家账单信息");
            }

            var tradeRolePayBills = new List <Distribution.Domain.Bill.Pay.Normal.NormalPayRoleBill>();

            // 采购方
            payBill.Purchaser.Source.ReviseParValue(trade.Flights);
            tradeRolePayBills.Add(payBill.Purchaser);
            // 出票方
            var provider        = new Distribution.Domain.Role.Provider(tradeDeduction.Provider.Owner);
            var providerPayBill = provider.MakePayBill(trade, tradeDeduction.Provider.Deduction);

            payBill.Provider = providerPayBill;
            tradeRolePayBills.Add(providerPayBill);
            // 资源方
            if (trade.IsThirdRelation && tradeDeduction.Supplier != null)
            {
                var supplier        = new Distribution.Domain.Role.Supplier(tradeDeduction.Supplier.Owner);
                var supplierPayBill = supplier.MakePayBill(trade, tradeDeduction.Supplier.Deduction);
                payBill.Supplier = supplierPayBill;
                tradeRolePayBills.Add(supplierPayBill);
            }
            // 分润方
            if (reproduceRoyaltyBill)
            {
                payBill.RemoveRoyalties();
                foreach (var royaltyDeduction in tradeDeduction.Royalties)
                {
                    if (royaltyDeduction.Deduction.Rebate != 0 || royaltyDeduction.Deduction.Increasing != 0)
                    {
                        var royalty        = new Distribution.Domain.Role.Royalty(royaltyDeduction.Owner);
                        var royaltyPayBill = royalty.MakePayBill(trade, royaltyDeduction.Deduction);
                        payBill.AddRoyalty(royaltyPayBill);
                        tradeRolePayBills.Add(royaltyPayBill);
                    }
                }
            }
            else
            {
                foreach (var royaltyBill in payBill.Royalties)
                {
                    royaltyBill.Source.ReviseParValue(trade.Flights);
                    tradeRolePayBills.Add(royaltyBill);
                }
            }
            // 平台
            var platform = new Distribution.Domain.Role.Platform();

            payBill.Platform = platform.MakePayBill(trade, tradeRolePayBills, tradeDeduction.Platform);
            return(payBill);
        }