Пример #1
0
        public void TestIOWA()
        {
            //Test weights
            List <decimal> weights = new List <decimal>()
            {
                0.4M, 0.3M, 0.2M, 0.1M
            };

            List <decimal> rating = new List <decimal>()
            {
                0.5M, 0.5M, 0.2M, 0.7M
            };

            //Create Aggregation
            IAggregation aggregation = AggregationFactory.CreateParamAggregation(AggregationType.IOWA, weights, rating);

            //Test Values
            List <decimal> values = new List <decimal>()
            {
                0.8M, 0.2M, 0.9M, 0.9M
            };

            decimal result = aggregation.Calc(values);

            Assert.AreEqual(0.7M, Math.Round(result, 1));
        }
Пример #2
0
        public void TestIOWG()
        {
            //Test weights
            List <decimal> weights = new List <decimal>()
            {
                0.5M, 0.5M, 0, 0
            };

            List <decimal> rating = new List <decimal>()
            {
                7, 2, 10, 3
            };

            //Create Aggregation
            IAggregation aggregation = AggregationFactory.CreateParamAggregation(AggregationType.IOWG, weights, rating);

            //Test Values
            List <decimal> values = new List <decimal>()
            {
                1, 1, 1, 1
            };

            decimal result = aggregation.Calc(values);

            Assert.AreEqual(4M, result);
        }
Пример #3
0
        public void TestIGOWA()
        {
            //Test weights
            List <decimal> weights = new List <decimal>()
            {
                0.2M, 0.2M, 0.3M, 0.3M
            };

            List <decimal> rating = new List <decimal>()
            {
                7, 2, 10, 3
            };

            decimal alfa = 1;

            //Create Aggregation
            IAggregation aggregation = AggregationFactory.CreateParamAggregation(AggregationType.IGOWA, weights, rating, alfa);

            //Test Values
            List <decimal> values = new List <decimal>()
            {
                25, 40, 20, 60
            };

            decimal result = aggregation.Calc(values);

            Assert.AreEqual(39, Math.Round(result, 1));
        }
Пример #4
0
        public void TestPOWA()
        {
            //Test weights
            List <decimal> weights = new List <decimal>()
            {
                0.2M, 0.2M, 0.2M, 0.4M
            };

            List <decimal> p = new List <decimal>()
            {
                0.4M, 0.2M, 0.3M, 0.1M
            };

            decimal beta = 0.5M;

            //Create Aggregation
            IAggregation aggregation = AggregationFactory.CreateParamAggregation(AggregationType.POWA, weights, p, beta);

            //Test Values
            List <decimal> values = new List <decimal>()
            {
                20, 40, 50, 30
            };

            decimal result = aggregation.Calc(values);

            Assert.AreEqual(33M, Math.Round(result, 1));
        }
Пример #5
0
        public void TestASPOWA()
        {
            //Test weights
            List <decimal> weights = new List <decimal>()
            {
                0.5M, 0.3M, 0.2M
            };

            List <decimal> p = new List <decimal>()
            {
                0.7M, 1M, 0.5M
            };

            decimal beta = 0.3M;

            //Create Aggregationk
            IAggregation aggregation = AggregationFactory.CreateParamAggregation(AggregationType.ASPOWA_MIN, weights, p, beta);

            //Test Values
            List <decimal> values = new List <decimal>()
            {
                70M, 50M, 60M
            };

            decimal result = aggregation.Calc(values);

            Assert.AreEqual(53.90M, result);
        }
Пример #6
0
        public void Instantiate_ColumnTypeandAggregationFunction_CorrectAggregation(ColumnType columnType, AggregationFunctionType function, Type expectedType)
        {
            var factory     = new AggregationFactory();
            var aggregation = factory.Instantiate(columnType, function, Array.Empty <IScalarResolver>(), Array.Empty <IAggregationStrategy>());

            Assert.That(aggregation, Is.Not.Null);
            Assert.That(aggregation.Function, Is.TypeOf(expectedType));
        }
Пример #7
0
        public void BuyInsuranceByCashOrCredit(string OrderId, List <PassengerDto> passengerDtos, int payType, string pwd)
        {
            //构建保险订单数据结构
            var insuranceOrderBuilder = AggregationFactory.CreateBuiler <InsuranceOrderBuilder>();
            var insuranceOrder        = insuranceOrderBuilder.CreateInsuranceOrder();

            insuranceOrder.OrderId          = OrderId;
            insuranceOrder.InsuranceRecords = new List <InsuranceRecord>();

            var order = this._iOrderRepository.FindAll(p => p.OrderId == OrderId).FirstOrDefault();

            //填写Passenger信息
            foreach (var passer in order.Passengers)
            {
                foreach (var passengerDto in passengerDtos)
                {
                    if (passengerDto.Id == passer.Id)
                    {
                        passer.PassengerType = passengerDto.PassengerType;
                        passer.SexType       = passengerDto.SexType;
                        passer.Birth         = passengerDto.Birth;
                        passer.IdType        = passengerDto.IdType;
                        passer.CardNo        = passengerDto.CardNo;
                    }
                }
            }

            //转换请求数据结构
            InsuranceRecordBuilder insuranceRecordBuilder = new InsuranceRecordBuilder();

            foreach (var passer in passengerDtos)
            {
                foreach (var skyway in passer.SkyWays)
                {
                    if (skyway.InsuranceCount > 0)
                    {
                        InsuranceRecord record = insuranceRecordBuilder.CreateInsuranceRecord();
                        record.Count       = skyway.InsuranceCount;
                        record.SkyWayId    = skyway.SkyWayId;
                        record.PassengerId = passer.Id;
                        insuranceOrder.InsuranceRecords.Add(record);
                    }
                }
            }
            //如果没有需要申请的保险,则终止请求
            if (insuranceOrder.InsuranceRecords.Count == 0)
            {
                return;
            }

            var insuranceDomainService = ObjectFactory.GetInstance <InsuranceDomainService>();

            insuranceDomainService.SaveInsurance(insuranceOrder, AuthManager.GetCurrentUser(), true);

            this.unitOfWork.Commit();
        }
Пример #8
0
        public void Instantiate_ConcantenationText_CorrectAggregation()
        {
            var factory     = new AggregationFactory();
            var aggregation = factory.Instantiate(ColumnType.Text, AggregationFunctionType.Concatenation, new List <IScalarResolver> {
                new LiteralScalarResolver <string>("+")
            }.ToArray(), Array.Empty <IAggregationStrategy>());

            Assert.That(aggregation, Is.Not.Null);
            Assert.That(aggregation.Function, Is.TypeOf <ConcatenationText>());
        }
Пример #9
0
 public void Handle(OrderStatusChangedEvent domainEvent)
 {
     if (domainEvent.OldStatus == Common.Enums.EnumOrderStatus.WaitIssue && domainEvent.NewStatus == Common.Enums.EnumOrderStatus.WaitReimburseWithPlatformRepelIssue)
     {
         //生成退款单
         var bulider = AggregationFactory.CreateBuiler <PlatformRefundBuilder>();
         var order   = bulider.CreateRefundOrder(Common.Enums.EnumPlatformRefundType.RepelIssue, domainEvent.Order.OrderId, "平台拒绝出票,退款");
         unitOfWorkRepository.PersistCreationOf(order);
     }
 }
Пример #10
0
        public void BuyInsuranceManually(RequestBuyInsuranceManually request)
        {
            if (request == null)
            {
                throw new CustomException(10004, "请求不可为空。");
            }
            //构建保险订单数据结构
            var insuranceOrderBuilder = AggregationFactory.CreateBuiler <InsuranceOrderBuilder>();
            var insuranceOrder        = insuranceOrderBuilder.CreateInsuranceOrder();

            insuranceOrder.InsuranceRecords = new List <InsuranceRecord>();
            //转换请求数据结构
            InsuranceRecordBuilder insuranceRecordBuilder = new InsuranceRecordBuilder();
            InsuranceRecord        record = insuranceRecordBuilder.CreateInsuranceRecord();

            record.Count        = request.Count;
            record.FlightNumber = request.FlightNumber;
            record.IdType       = request.IdType;
            if (record.IdType == EnumIDType.BirthDate &&
                request.Birth != null)
            {
                record.CardNo = request.Birth.Value.ToString("yyyy-MM-dd");
            }
            else
            {
                record.CardNo = request.CardNo;
            }
            record.InsuranceLimitEndTime   = request.InsuranceLimitEndTime;
            record.InsuranceLimitStartTime = request.InsuranceLimitStartTime;
            record.InsuredName             = request.InsuredName;
            record.Mobile        = request.Mobile;
            record.PNR           = request.PNR;
            record.SexType       = request.SexType;
            record.ToCityName    = request.ToCityName;
            record.InsureType    = EnumInsureMethod.Manually;
            record.PassengerType = request.PassengerType;
            record.Birth         = request.Birth;
            record.StartDateTime = request.StartDateTime;

            insuranceOrder.InsuranceRecords.Add(record);

            //如果没有需要申请的保险,则终止请求
            if (insuranceOrder.InsuranceRecords.Count == 0)
            {
                return;
            }

            var insuranceDomainService = ObjectFactory.GetInstance <InsuranceDomainService>();

            insuranceDomainService.SaveInsurance(insuranceOrder, AuthManager.GetCurrentUser(), true, false);

            this.unitOfWork.Commit();
            //根据request创建保险记录
        }
Пример #11
0
        public void TestAverage()
        {
            //Create Aggregation
            IAggregation aggregation = AggregationFactory.CreateSimpleAggregation(AggregationType.AVERAGE);

            //Test Values
            List <decimal> values = new List <decimal>()
            {
                1.0M, 0.6M, 0.5M, 0.3M
            };

            decimal result = aggregation.Calc(values);

            Assert.AreEqual(0.6M, result);
        }
Пример #12
0
        public void AddBussinessmen(BPiaoBao.AppServices.StationContracts.SystemSetting.SystemMap.RequestCarrier carrier)
        {
            if (carrier == null)
            {
                throw new CustomException(501, "输入信息不完整");
            }
            var curentUser = AuthManager.GetCurrentUser();
            var isexist    = this.businessmanRepository.FindAll(p => p.Code == carrier.Code).Count() > 0;

            if (isexist)
            {
                throw new CustomException(500, string.Format("{0}已存在", carrier.Code));
            }
            var builder      = AggregationFactory.CreateBuiler <BusinessmanBuilder>();
            var carrierModel = builder.CreateCarrier(AutoMapper.Mapper.Map <BPiaoBao.AppServices.StationContracts.SystemSetting.SystemMap.RequestCarrier, Carrier>(carrier));

            carrierModel.CheckRule();
            var cashbagModel = accountClientProxy.AddCompany(curentUser.CashbagCode, curentUser.CashbagKey, new BPiaoBao.Cashbag.Domain.Models.CashCompanyInfo
            {
                ClientAccount = carrier.Code,
                Contact       = carrier.ContactWay.Contact,
                CpyName       = carrier.Name,
                Moblie        = carrier.ContactWay.Tel,
                Province      = carrier.ContactWay.Province,
                City          = carrier.ContactWay.City,
                Address       = carrier.ContactWay.Address
            });

            try
            {
                carrierModel.CashbagCode = cashbagModel.PayAccount;
                carrierModel.CashbagKey  = cashbagModel.Token;
                this.unitOfWorkRepository.PersistCreationOf(carrierModel);
                this.unitOfWork.Commit();
            }
            catch (Exception e)
            {
                if (cashbagModel != null)
                {
                    accountClientProxy.DeleteCashBagBusinessman(curentUser.CashbagCode, cashbagModel.PayAccount, curentUser.CashbagKey);
                }
                Logger.WriteLog(LogType.ERROR, "添加商户发生异常", e);
                throw new CustomException(500, "添加商户发生异常");
            }
        }
Пример #13
0
        public void AddSupplier(RequestSupplier requestSupplier)
        {
            if (requestSupplier == null)
            {
                throw new CustomException(500, "输入信息丢失");
            }
            var isexist = this.businessmanRepository.FindAll(p => p.Code == requestSupplier.Code).Count() > 0;

            if (isexist)
            {
                throw new CustomException(500, string.Format("{0}已存在", requestSupplier.Code));
            }
            var      curentUser         = AuthManager.GetCurrentUser();
            var      businessmanBuilder = AggregationFactory.CreateBuiler <BusinessmanBuilder>();
            Supplier supplier           = businessmanBuilder.CreateSupplier(Mapper.Map <RequestSupplier, Supplier>(requestSupplier));

            supplier.CarrierCode = curentUser.Code;
            supplier.CheckRule();
            var cashbagModel = accountClientProxy.AddCompany(curentUser.CashbagCode, curentUser.CashbagKey, new BPiaoBao.Cashbag.Domain.Models.CashCompanyInfo
            {
                ClientAccount = requestSupplier.Code,
                Contact       = requestSupplier.ContactWay.Contact,
                CpyName       = requestSupplier.Name,
                Moblie        = requestSupplier.ContactWay.Tel,
                Province      = requestSupplier.ContactWay.Province,
                City          = requestSupplier.ContactWay.City,
                Address       = requestSupplier.ContactWay.Address
            });

            try
            {
                supplier.CashbagCode           = cashbagModel.PayAccount;
                supplier.CashbagKey            = cashbagModel.Token;
                supplier.SupLocalPolicySwitch  = false;
                supplier.SupRemotePolicySwitch = false;
                unitOfWorkRepository.PersistCreationOf(supplier);
                unitOfWork.Commit();
            }
            catch (Exception e)
            {
                Logger.WriteLog(LogType.ERROR, "添加商户发生异常", e);
                accountClientProxy.DeleteCashBagBusinessman(curentUser.CashbagCode, cashbagModel.PayAccount, curentUser.CashbagKey);
                throw new CustomException(500, "添加商户发生异常");
            }
        }
Пример #14
0
        public void SaveFrePasser(FrePasserDto passer)
        {
            var builder   = AggregationFactory.CreateBuiler <FrePasserBuilder>();
            var frePasser = builder.CreateFrePasser();

            frePasser.PasserType      = passer.PasserType;
            frePasser.Name            = passer.Name.Trim();
            frePasser.CertificateType = passer.CertificateType;
            frePasser.CertificateNo   = passer.CertificateNo;
            frePasser.Mobile          = passer.Mobile;
            frePasser.AirCardNo       = passer.AirCardNo;
            frePasser.Remark          = passer.Remark;
            frePasser.Birth           = passer.Birth;
            frePasser.SexType         = passer.SexType;
            frePasser.BusinessmanCode = _code;
            unitOfWorkRepository.PersistCreationOf(frePasser);
            unitOfWork.Commit();
        }
Пример #15
0
        public void TestOWA()
        {
            //Test weights
            List <decimal> weights = new List <decimal>()
            {
                0.2M, 0.3M, 0.1M, 0.4M
            };

            //Create Aggregation
            IAggregation aggregation = AggregationFactory.CreateWeightAggregation(AggregationType.OWA, weights);

            //Test Values
            List <decimal> values = new List <decimal>()
            {
                1.0M, 0.6M, 0.5M, 0.3M
            };

            decimal result = aggregation.Calc(values);

            Assert.AreEqual(0.55M, result);
        }
Пример #16
0
        public void TestOWG()
        {
            //Test weights
            List <decimal> weights = new List <decimal>()
            {
                0.5M, 0.5M, 0, 0
            };

            //Create Aggregation
            IAggregation aggregation = AggregationFactory.CreateWeightAggregation(AggregationType.OWG, weights);

            //Test Values
            List <decimal> values = new List <decimal>()
            {
                1, 1, 1, 1
            };

            decimal result = aggregation.Calc(values);

            Assert.AreEqual(4M, result);
        }
Пример #17
0
 /// <summary>
 /// 保存用户操作行为
 /// </summary>
 /// <param name="businessmanCode"></param>
 /// <param name="businessmanName"></param>
 /// <param name="businessmanType"></param>
 /// <param name="carrierCode"></param>
 /// <param name="contactName"></param>
 /// <param name="OperatorName"></param>
 /// <param name="enumBeOperate"></param>
 private void Save(string businessmanCode, string businessmanName, string businessmanType, string carrierCode, string contactName, string OperatorName, EnumBehaviorOperate enumBeOperate)
 {
     try
     {
         var builder      = AggregationFactory.CreateBuiler <BehaviorStatBuilder>();
         var behaviorStat = builder.CreateBehaviorStat();
         behaviorStat.BusinessmanCode = businessmanCode;
         behaviorStat.BusinessmanName = businessmanName;
         behaviorStat.BusinessmanType = businessmanType;
         behaviorStat.CarrierCode     = carrierCode;
         behaviorStat.ContactName     = contactName;
         behaviorStat.OperatorName    = OperatorName;
         behaviorStat.OpDateTime      = DateTime.Now;
         behaviorStat.BehaviorOperate = (int)enumBeOperate;
         unitOfWorkRepository.PersistCreationOf(behaviorStat);
         unitOfWork.Commit();
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Пример #18
0
        private void SaveInsuranceConfigNoCommit(InsuranceConfigData req)
        {
            var model = this._iInsuranceConfigRepository.FindAll(p => p.BusinessmanCode.Equals(_code)).FirstOrDefault();

            if (model != null)
            {
                model.IsOpen      = req.IsOpen;
                model.SinglePrice = req.SinglePrice;
                model.LeaveCount  = req.LeaveCount;
                this.unitOfWorkRepository.PersistUpdateOf(model);
            }
            else
            {
                var builder = AggregationFactory.CreateBuiler <InsuranceConfigBuilder>();
                var m       = builder.CreateInsuranceConfig();
                m.BusinessmanCode = _code;
                m.BusinessmanName = _bussinessName;
                m.IsOpen          = req.IsOpen;
                m.SinglePrice     = req.SinglePrice;
                m.LeaveCount      = req.LeaveCount;
                this.unitOfWorkRepository.PersistCreationOf(m);
            }
        }
Пример #19
0
        public void TestGOWA()
        {
            //Test weights
            List <decimal> weights = new List <decimal>()
            {
                0.5M, 0.3M, 0.2M
            };

            decimal param = 2;

            //Create Aggregation
            IAggregation aggregation = AggregationFactory.CreateParamAggregation(AggregationType.GOWA, weights, param);

            //Test Values
            List <decimal> values = new List <decimal>()
            {
                0.6M, 0.45M, 0.5M
            };

            decimal result = aggregation.Calc(values);

            Assert.AreEqual(0.5436M, Math.Round(result, 4));
        }
            public async Task CreatesNewEntityIfNoPossibleAggregation()
            {
                var inputPath = "howdy";
                var input     = new ParsedIncident(Incident, inputPath, ComponentStatus.Degraded);

                var providedPath = "hello";

                PathProvider
                .Setup(x => x.Get(input))
                .Returns(providedPath);

                var aggregationWithDifferentPath = new TEntityAggregation
                {
                    AffectedComponentPath = "other path",
                    StartTime             = input.StartTime
                };

                var aggregationAfter = new TEntityAggregation
                {
                    AffectedComponentPath = providedPath,
                    StartTime             = input.StartTime + TimeSpan.FromDays(1)
                };

                var aggregationBefore = new TEntityAggregation
                {
                    AffectedComponentPath = providedPath,
                    StartTime             = input.StartTime - TimeSpan.FromDays(2),
                    EndTime = input.StartTime - TimeSpan.FromDays(1)
                };

                var activeAggregationToDeactivate = new TEntityAggregation
                {
                    AffectedComponentPath = providedPath,
                    StartTime             = input.StartTime
                };

                var inactiveAggregationToDeactivate = new TEntityAggregation
                {
                    AffectedComponentPath = providedPath,
                    StartTime             = input.StartTime,
                    EndTime = input.EndTime
                };

                Table.SetupQuery(
                    aggregationWithDifferentPath,
                    aggregationAfter,
                    aggregationBefore,
                    activeAggregationToDeactivate,
                    inactiveAggregationToDeactivate);

                Strategy
                .Setup(x => x.CanBeAggregatedByAsync(input, activeAggregationToDeactivate))
                .ReturnsAsync(false);

                Strategy
                .Setup(x => x.CanBeAggregatedByAsync(input, inactiveAggregationToDeactivate))
                .ReturnsAsync(false);

                var createdAggregation = new TEntityAggregation();

                AggregationFactory
                .Setup(x => x.CreateAsync(input))
                .ReturnsAsync(createdAggregation);

                var result = await Provider.GetAsync(input);

                Assert.Equal(createdAggregation, result);

                Strategy
                .Verify(
                    x => x.CanBeAggregatedByAsync(It.IsAny <ParsedIncident>(), aggregationWithDifferentPath),
                    Times.Never());

                Strategy
                .Verify(
                    x => x.CanBeAggregatedByAsync(It.IsAny <ParsedIncident>(), aggregationAfter),
                    Times.Never());

                Strategy
                .Verify(
                    x => x.CanBeAggregatedByAsync(It.IsAny <ParsedIncident>(), aggregationBefore),
                    Times.Never());

                Strategy
                .Verify(
                    x => x.CanBeAggregatedByAsync(It.IsAny <ParsedIncident>(), activeAggregationToDeactivate),
                    Times.Once());

                Strategy
                .Verify(
                    x => x.CanBeAggregatedByAsync(It.IsAny <ParsedIncident>(), inactiveAggregationToDeactivate),
                    Times.Once());
            }
Пример #21
0
        static void Main(string[] args)
        {
            // Preparation of Meta Data
            MetaDataManager metaDataManager = new MetaDataManager();
            List <Segment>  segments        = metaDataManager.GetSegments();

            Dictionary <Segment, HierarchyMetaData> metaData = new Dictionary <Segment, HierarchyMetaData>();

            foreach (Segment segment in segments)
            {
                metaData.Add(segment, new HierarchyMetaData(metaDataManager.GetHierarchyMembers(segment.Id)));
            }

            //List<TimeHierarchy> timeHierarchies = metaDataManager.GetTimeHierarchies();
            //Utility.PopulateLRValues(timeHierarchies);

            List <DimensionSelection> selections = new List <DimensionSelection>()
            {
                new DimensionSelection()
                {
                    SegmentID = 1, SelectedMembers = new List <int>()
                    {
                        1
                    }, Option = ExtendedMemberOption.SelectedAndAllChildern
                },
                new DimensionSelection()
                {
                    SegmentID = 2, SelectedMembers = new List <int>()
                    {
                        1
                    }, Option = ExtendedMemberOption.SelectedAndAllChildern
                }
                //,new DimensionSelection(){ SegmentID = 3, SelectedMembers = new List<int>(){ 1 }, Option = ExtendedMemberOption.SelectedAndAllChildern }
                //,new DimensionSelection(){ SegmentID = 4, SelectedMembers = new List<int>(){ 1 }, Option = ExtendedMemberOption.SelectedAndAllChildern }
            };

            selections = metaDataManager.ApplyDefaultSegmentMemberIDs(segments, selections);

            List <GLRecord> lstGLRecord = metaDataManager.GetSourceData();
            Dictionary <DimensionSelection, IAggregation <ExtendedHierarchyMember> > selectionAggregations = new Dictionary <DimensionSelection, IAggregation <ExtendedHierarchyMember> >();

            foreach (DimensionSelection selection in selections)
            {
                AggregationFactory <ExtendedHierarchyMember> aggregationFactory = new AggregationFactory <ExtendedHierarchyMember>(selection.SelectedMembers, metaData[segments.FirstOrDefault(x => x.Id == selection.SegmentID)].Members.ToList());
                IAggregation <ExtendedHierarchyMember>       aggregation        = aggregationFactory.Create(selection.Option);
                lstGLRecord.RemoveAll(x => !aggregation.RelevantLeafIDs.Contains(x.GLMembers.SegmentValues.FirstOrDefault(z => z.Key == selection.SegmentID).Value));
                selectionAggregations.Add(selection, aggregation);
            }

            foreach (KeyValuePair <DimensionSelection, IAggregation <ExtendedHierarchyMember> > selectionAggregation in selectionAggregations)
            {
                DimensionAggregationFactory <ExtendedHierarchyMember, HierarchyMemberAncestor> dimensionAggregationFactory =
                    new DimensionAggregationFactory <ExtendedHierarchyMember, HierarchyMemberAncestor>(selectionAggregation.Key.SegmentID, lstGLRecord, selectionAggregation.Value, metaData[segments.FirstOrDefault(x => x.Id == selectionAggregation.Key.SegmentID)].MemberAncestors.ToList());

                switch (selectionAggregation.Key.Option)
                {
                case ExtendedMemberOption.Leaves:
                default:
                    break;

                case ExtendedMemberOption.Selected:
                    if (lstGLRecord.Select(x => x.GLMembers.SegmentValues.FirstOrDefault(z => z.Key == selectionAggregation.Key.SegmentID).Value).Except(selectionAggregation.Value.DisplayMembers.Select(x => x.Id)).Count() > 0)
                    {
                        foreach (ExtendedHierarchyMember extendedHierarchyMember in selectionAggregation.Value.DisplayMembers)
                        {
                            DimensionMember dimensionMember = new DimensionMember(extendedHierarchyMember);
                            dimensionMember.Accept(dimensionAggregationFactory.Create(CompositionType.Part));
                        }
                    }
                    break;

                case ExtendedMemberOption.Children:
                case ExtendedMemberOption.AllChildren:
                case ExtendedMemberOption.SelectedAndChildren:
                case ExtendedMemberOption.SelectedAndAllChildern:
                case ExtendedMemberOption.SelectedAndLeaves:
                case ExtendedMemberOption.SelectedAndParents:
                    int maxDepth = selectionAggregation.Value.DisplayMembers.Where(x => x.MemberType == MemberType.Rollup).Max(z => z.Level);
                    int minDepth = selectionAggregation.Value.DisplayMembers.Where(x => x.MemberType == MemberType.Rollup).Min(z => z.Level);
                    for (int level = maxDepth; level >= minDepth; level--)
                    {
                        foreach (ExtendedHierarchyMember extendedHierarchyMember in selectionAggregation.Value.DisplayMembers.Where(x => x.MemberType == MemberType.Rollup && x.Level == level))
                        {
                            if (!selectionAggregation.Value.DisplayMembers.Any(x => x.MemberType == MemberType.Rollup && (x.ParentId == extendedHierarchyMember.Id)))
                            {
                                DimensionMember dimensionMember = new DimensionMember(extendedHierarchyMember);
                                dimensionMember.Accept(dimensionAggregationFactory.Create(CompositionType.Part));
                            }
                            else
                            {
                                DimensionWholePartHierarchy dimensionWholePartHierarchy = new DimensionWholePartHierarchy(selectionAggregation.Value.DisplayMembers.Where(x => x.ParentId == extendedHierarchyMember.Id || x.Id == extendedHierarchyMember.Id).ToList());
                                dimensionWholePartHierarchy.Accept(dimensionAggregationFactory.Create(CompositionType.Composite));
                            }
                        }
                    }
                    break;
                }
                lstGLRecord.RemoveAll(x => selectionAggregation.Value.PostProcessDeleteMemberIDs.Contains(x.GLMembers.SegmentValues.FirstOrDefault(z => z.Key == selectionAggregation.Key.SegmentID).Value));
            }

            Utility.Export(lstGLRecord, segments, metaData);
        }
Пример #22
0
        public void SaveInsurance(RequestInsurance req)
        {
            //request不能为空
            if (req == null)
            {
                throw new CustomException(111113, "传入保单信息为空");
            }

            //构建保险订单数据结构
            var insuranceOrderBuilder = AggregationFactory.CreateBuiler <InsuranceOrderBuilder>();
            var insuranceOrder        = insuranceOrderBuilder.CreateInsuranceOrder();

            insuranceOrder.OrderId          = req.OrderId;
            insuranceOrder.InsuranceRecords = new List <InsuranceRecord>();
            var order = this._iOrderRepository.FindAll(p => p.OrderId == req.OrderId).FirstOrDefault();

            //填写Passenger信息
            foreach (var passer in order.Passengers)
            {
                foreach (var passengerDto in req.UnexpectedPassenger)
                {
                    if (passengerDto.Id == passer.Id)
                    {
                        passer.PassengerType = passengerDto.PassengerType;
                        passer.SexType       = passengerDto.SexType;
                        passer.Birth         = passengerDto.Birth;
                        passer.IdType        = passengerDto.IdType;
                        passer.CardNo        = passengerDto.CardNo;
                        //极速退处理
                        if (passengerDto.IsInsuranceRefund)
                        {
                            passer.IsInsuranceRefund    = passengerDto.IsInsuranceRefund;
                            passer.InsuranceRefunrPrice = passengerDto.InsuranceRefunrPrice;
                        }
                    }
                }
            }

            InsuranceRecordBuilder insuranceRecordBuilder = new InsuranceRecordBuilder();

            if (req.BuyInsuranceAllCount > 0)
            {
                foreach (var passer in req.UnexpectedPassenger)
                {
                    foreach (var skyway in passer.SkyWays)
                    {
                        if (skyway.InsuranceCount > 0)
                        {
                            InsuranceRecord record = insuranceRecordBuilder.CreateInsuranceRecord();
                            record.Count       = skyway.InsuranceCount;
                            record.SkyWayId    = skyway.SkyWayId;
                            record.PassengerId = passer.Id;

                            insuranceOrder.InsuranceRecords.Add(record);
                        }
                    }
                }

                if (insuranceOrder.InsuranceRecords.Count > 0)
                {
                    var insuranceDomainService = ObjectFactory.GetInstance <InsuranceDomainService>();
                    insuranceDomainService.SaveInsurance(insuranceOrder, AuthManager.GetCurrentUser());
                }
            }


            this.unitOfWork.Commit();
        }
Пример #23
0
        public override decimal Calc(List <decimal> values)
        {
            List <int> indexes = new List <int>();

            for (int i = 0; i < values.Count; i++)
            {
                indexes.Add(i);
            }

            AggrerationUtil au = new AggrerationUtil();
            IEnumerable <IEnumerable <int> > permutationResult = au.Permutation <int>(indexes);

            decimal globalK    = 0M;
            bool    initGlobal = false;

            foreach (IEnumerable <int> e in permutationResult)
            {
                List <int> curentPermutation = e.ToList();

                List <decimal> curentPermutationP = new List <decimal>();

                foreach (int i in e)
                {
                    curentPermutationP.Add(p[i]);
                }

                // First max Aggregation
                // Result is pSigma
                List <decimal> pSigma  = new List <decimal>();
                decimal        lastMax = 0m;
                for (int i = 0; i < curentPermutationP.Count; i++)
                {
                    decimal curentPValue = curentPermutationP[i];
                    if (i > 0)
                    {
                        decimal max = Math.Max(curentPValue, lastMax);
                        curentPValue = max - lastMax;
                        lastMax      = max;
                    }
                    else
                    {
                        lastMax = curentPValue;
                    }
                    pSigma.Add(curentPValue);
                }

                List <decimal> permValues = new List <decimal>();
                foreach (int i in e)
                {
                    permValues.Add(values[i]);
                }

                //Calculate local K
                decimal localK = 0;
                for (int i = 0; i < pSigma.Count; i++)
                {
                    localK += pSigma[i] * permValues[i];
                }

                //Ckeck initial
                if (!initGlobal)
                {
                    initGlobal = true;
                    globalK    = localK;
                }

                globalK = checkASPOWAAggregationType(this.type, globalK, localK);
            }

            IAggregation aggregation = AggregationFactory.CreateWeightAggregation(AggregationType.OWA, this.weights);
            decimal      owaValue    = aggregation.Calc(values);

            return(this.beta * owaValue + (1 - this.beta) * globalK);
        }
Пример #24
0
        /// <summary>
        /// 新增特价政策
        /// </summary>
        /// <param name="policy"></param>
        public void AddSpeaiaPolicy(RequestSpecialPolicy policy)
        {
            var           currentUser = AuthManager.GetCurrentUser();
            var           builder     = AggregationFactory.CreateBuiler <LocalPolicyBuilder>();
            SpecialPolicy localPolicy = builder.CreateSpecialPolicy(Mapper.Map <RequestSpecialPolicy, SpecialPolicy>(policy));

            localPolicy.CreateMan = currentUser.OperatorName;
            localPolicy.RoleType  = currentUser.Type;
            localPolicy.Code      = currentUser.Code;
            if (currentUser.Type == "Supplier")
            {
                localPolicy.CarrierCode = currentUser.CarrierCode;
                var bm = this.businessmanRepository.FindAllNoTracking(p => p.Code == currentUser.CarrierCode).OfType <Carrier>().FirstOrDefault();
                if (bm != null)
                {
                    localPolicy.CarrierWeek             = bm.RestWork.WeekDay;
                    localPolicy.Carrier_AnnulTicketTime = new BPiaoBao.DomesticTicket.Platform.Plugin.StartAndEndTime
                    {
                        StartTime = bm.NormalWork.ServiceOnLineTime,
                        EndTime   = bm.NormalWork.ServiceUnLineTime
                    };;
                    localPolicy.Carrier_ReturnTicketTime = new BPiaoBao.DomesticTicket.Platform.Plugin.StartAndEndTime
                    {
                        StartTime = bm.NormalWork.ServiceOnLineTime,
                        EndTime   = bm.NormalWork.ServiceUnLineTime
                    };;
                    localPolicy.Carrier_WorkTime = new BPiaoBao.DomesticTicket.Platform.Plugin.StartAndEndTime
                    {
                        StartTime = bm.NormalWork.WorkOnLineTime,
                        EndTime   = bm.NormalWork.WorkUnLineTime
                    };
                    localPolicy.Carrier_WeekAnnulTicketTime = new BPiaoBao.DomesticTicket.Platform.Plugin.StartAndEndTime
                    {
                        StartTime = bm.RestWork.ServiceOnLineTime,
                        EndTime   = bm.RestWork.ServiceUnLineTime
                    };;
                    localPolicy.Carrier_WeekReturnTicketTime = new BPiaoBao.DomesticTicket.Platform.Plugin.StartAndEndTime
                    {
                        StartTime = bm.RestWork.ServiceOnLineTime,
                        EndTime   = bm.RestWork.ServiceUnLineTime
                    };;
                    localPolicy.Carrier_WeekWorkTime = new BPiaoBao.DomesticTicket.Platform.Plugin.StartAndEndTime
                    {
                        StartTime = bm.RestWork.WorkOnLineTime,
                        EndTime   = bm.RestWork.WorkUnLineTime
                    };
                }
                var supbm = this.businessmanRepository.FindAllNoTracking(p => p.Code == currentUser.Code).OfType <Supplier>().FirstOrDefault();
                if (supbm != null)
                {
                    localPolicy.SupplierWeek    = supbm.SupRestWork.WeekDay;
                    localPolicy.AnnulTicketTime = new BPiaoBao.DomesticTicket.Platform.Plugin.StartAndEndTime
                    {
                        StartTime = supbm.SupNormalWork.ServiceOnLineTime,
                        EndTime   = supbm.SupNormalWork.ServiceUnLineTime
                    };;
                    localPolicy.ReturnTicketTime = new BPiaoBao.DomesticTicket.Platform.Plugin.StartAndEndTime
                    {
                        StartTime = supbm.SupNormalWork.ServiceOnLineTime,
                        EndTime   = supbm.SupNormalWork.ServiceUnLineTime
                    };;
                    localPolicy.WorkTime = new BPiaoBao.DomesticTicket.Platform.Plugin.StartAndEndTime
                    {
                        StartTime = supbm.SupNormalWork.WorkOnLineTime,
                        EndTime   = supbm.SupNormalWork.WorkUnLineTime
                    };
                    localPolicy.WeekAnnulTicketTime = new BPiaoBao.DomesticTicket.Platform.Plugin.StartAndEndTime
                    {
                        StartTime = supbm.SupRestWork.ServiceOnLineTime,
                        EndTime   = supbm.SupRestWork.ServiceUnLineTime
                    };;
                    localPolicy.WeekReturnTicketTime = new BPiaoBao.DomesticTicket.Platform.Plugin.StartAndEndTime
                    {
                        StartTime = supbm.SupRestWork.ServiceOnLineTime,
                        EndTime   = supbm.SupRestWork.ServiceUnLineTime
                    };;
                    localPolicy.WeeKWorkTime = new BPiaoBao.DomesticTicket.Platform.Plugin.StartAndEndTime
                    {
                        StartTime = supbm.SupRestWork.WorkOnLineTime,
                        EndTime   = supbm.SupRestWork.WorkUnLineTime
                    };
                }
            }
            else
            {
                localPolicy.CarrierCode = currentUser.Code;
                var bm = this.businessmanRepository.FindAllNoTracking(p => p.Code == currentUser.Code).OfType <Carrier>().FirstOrDefault();
                if (bm != null)
                {
                    localPolicy.CarrierWeek             = bm.RestWork.WeekDay;
                    localPolicy.Carrier_AnnulTicketTime = new BPiaoBao.DomesticTicket.Platform.Plugin.StartAndEndTime
                    {
                        StartTime = bm.NormalWork.ServiceOnLineTime,
                        EndTime   = bm.NormalWork.ServiceUnLineTime
                    };;
                    localPolicy.Carrier_ReturnTicketTime = new BPiaoBao.DomesticTicket.Platform.Plugin.StartAndEndTime
                    {
                        StartTime = bm.NormalWork.ServiceOnLineTime,
                        EndTime   = bm.NormalWork.ServiceUnLineTime
                    };;
                    localPolicy.Carrier_WorkTime = new BPiaoBao.DomesticTicket.Platform.Plugin.StartAndEndTime
                    {
                        StartTime = bm.NormalWork.WorkOnLineTime,
                        EndTime   = bm.NormalWork.WorkUnLineTime
                    };
                    localPolicy.Carrier_WeekAnnulTicketTime = new BPiaoBao.DomesticTicket.Platform.Plugin.StartAndEndTime
                    {
                        StartTime = bm.RestWork.ServiceOnLineTime,
                        EndTime   = bm.RestWork.ServiceUnLineTime
                    };;
                    localPolicy.Carrier_WeekReturnTicketTime = new BPiaoBao.DomesticTicket.Platform.Plugin.StartAndEndTime
                    {
                        StartTime = bm.RestWork.ServiceOnLineTime,
                        EndTime   = bm.RestWork.ServiceUnLineTime
                    };;
                    localPolicy.Carrier_WeekWorkTime = new BPiaoBao.DomesticTicket.Platform.Plugin.StartAndEndTime
                    {
                        StartTime = bm.RestWork.WorkOnLineTime,
                        EndTime   = bm.RestWork.WorkUnLineTime
                    };
                }
            }
            unitOfWorkRepository.PersistCreationOf(localPolicy);
            unitOfWork.Commit();
        }
Пример #25
0
        /// <summary>
        /// 分销商购买保险
        /// </summary>
        /// <param name="buyCount"></param>
        /// <param name="pwd"></param>
        /// <param name="businessmanCode"></param>
        /// <param name="businessmanName"></param>
        /// <param name="carrierCode"></param>
        /// <param name="payUser"></param>
        public void PurchaseInsuranceFromCarrier(int buyCount, string pwd, EnumPayMethod payMethod, string businessmanCode, string businessmanName, string carrierCode, string operatorCode, string operatorName, CurrentUserInfo payUser, string remark = "")
        {
            var carrier = this._businessmanRepository.FindAll(p => p.Code == carrierCode && p is Carrier).OfType <Carrier>().FirstOrDefault();
            //获取当前运营商保险配置
            var carrierCfg = this._iInsuranceConfigRepository.FindAll(p => p.BusinessmanCode == carrierCode).FirstOrDefault();
            //获取分销商保险配置
            var buyerCfg = this._iInsuranceConfigRepository.FindAll(p => p.BusinessmanCode == businessmanCode).FirstOrDefault();

            if (carrierCfg == null || !carrierCfg.IsOpen)
            {
                throw new CustomException(11114, "运营商保险功能未开启");
            }
            if (buyCount > carrierCfg.LeaveCount)
            {
                string type = payUser == null ? "赠送" : "购买";
                throw new CustomException(11115, "最多仅可" + type + carrierCfg.LeaveCount + "份保险。");
            }
            //单价
            decimal singlePrice = payUser == null ? 0 : carrierCfg.SinglePrice;

            //运营商购买记录
            var logBuiler = AggregationFactory.CreateBuiler <InsurancePurchaseByBussinessmanBuilder>();
            var log       = logBuiler.CreateInsurancePurchaseByBussinessman();

            log.PayNo            = log.GetPayNo();
            log.BeforeLeaveCount = buyerCfg == null ? 0 : buyerCfg.LeaveCount;                                           //购买前剩余
            log.AfterLeaveCount  = log.BeforeLeaveCount + buyCount;                                                      //购买后剩余
            log.DepositCount     = buyCount;                                                                             //购买数量
            log.TotalPrice       = Math.Round((singlePrice * buyCount), 2);                                              //总价
            log.SinglePrice      = singlePrice;                                                                          //单价
            log.BusinessmanCode  = businessmanCode;                                                                      //商户号
            log.BusinessmanName  = businessmanName;                                                                      //商户名称
            log.PayWay           = payMethod;                                                                            //支付类别
            log.RecordType       = payUser == null ? EnumInsurancePurchaseType.Offer : EnumInsurancePurchaseType.Normal; //记录类别
            log.CarrierCode      = carrierCode;
            log.CarrierName      = carrier.Name;
            log.OperatorAccount  = operatorCode;
            log.OperatorName     = operatorName;
            log.Remark           = remark;
            log.PayFee           = Math.Round(log.TotalPrice * SystemConsoSwitch.Rate, 2);

            #region 支付

            DataBill databill = new DataBill();
            CashbagConfigurationElement setting = SettingSection.GetInstances().Cashbag;
            string  moneyDispatch = "";
            decimal infMoney      = databill.Round(log.TotalPrice * carrier.Rate, 2);
            //支出配置,分销商,支出保险全额
            //moneyDispatch += currentUser.CashbagCode + "^" + insuranceOrder.PayMoney + "^" + EnumOperationType.Insurance.ToEnumDesc();
            //收入配置
            moneyDispatch += "|" + carrier.CashbagCode + "^" + log.TotalPrice + "^" + EnumOperationType.InsuranceReceivables.ToEnumDesc();
            //保险手续费支出
            moneyDispatch += "|" + carrier.CashbagCode + "^" + (-infMoney) + "^" + EnumOperationType.InsuranceServer.ToEnumDesc();
            //手续费收入配置
            moneyDispatch += "|" + setting.CashbagCode + "^" + infMoney + "^" + EnumOperationType.InsuranceServer.ToEnumDesc();

            var payResult = string.Empty;

            if (payUser != null)
            {
                if (_iPayMentClientProxy == null)
                {
                    _iPayMentClientProxy = new CashbagPaymentClientProxy();
                }
                switch (log.PayWay)
                {
                //现金账户
                case EnumPayMethod.Account:
                    //    payResult = _iPayMentClientProxy.PaymentByCashAccount(payUser.CashbagCode, payUser.CashbagKey,
                    //log.PayNo, "购买保险", log.TotalPrice, pwd, moneyDispatch);
                    var resultc = _iPayMentClientProxy.PaymentByCashAccount(payUser.CashbagCode, payUser.CashbagKey, log.PayNo, "购买保险", log.TotalPrice, pwd, moneyDispatch);
                    if (resultc.Item1)
                    {
                        //该订单已经被在线支付时写入日志
                        Logger.WriteLog(LogType.INFO, "订单已经支付,交易号为" + resultc.Item2 + "支付方式为" + resultc.Item3);
                        throw new CustomException(0001, "订单已经支付,交易号为" + resultc.Item2 + "支付方式为" + resultc.Item3);
                    }
                    payResult = resultc.Item2;
                    break;

                //信用账户
                case EnumPayMethod.Credit:
                    var result = _iPayMentClientProxy.PaymentByCreditAccount(payUser.CashbagCode, payUser.CashbagKey, log.PayNo, "购买保险", log.TotalPrice, pwd, moneyDispatch);
                    if (result.Item1)
                    {
                        //该订单已经被在线支付时写入日志
                        Logger.WriteLog(LogType.INFO, "订单已经支付,交易号为" + result.Item2 + "支付方式为" + result.Item3);
                        throw new CustomException(0001, "订单已经支付,交易号为" + result.Item2 + "支付方式为" + result.Item3);
                    }
                    payResult = result.Item2;
                    break;
                }
            }
            #endregion

            //如果存在交易号,即支付成功
            if (!string.IsNullOrEmpty(payResult))
            {
                log.OutTradeNo = payResult;                 //设置交易号
                log.BuyState   = EnumInsurancePayStatus.OK; //设置交易状态
                //设置运营商剩余数量
                carrierCfg.LeaveCount -= buyCount;
                this.unitOfWorkRepository.PersistUpdateOf(carrierCfg);
                //设置分销商剩余数量
                if (buyerCfg != null)
                {
                    buyerCfg.LeaveCount = log.AfterLeaveCount;
                    this.unitOfWorkRepository.PersistUpdateOf(buyerCfg);
                }
                else
                {
                    var builder = AggregationFactory.CreateBuiler <InsuranceConfigBuilder>();
                    var m       = builder.CreateInsuranceConfig();
                    m.BusinessmanCode = businessmanCode;
                    m.BusinessmanName = businessmanName;
                    m.IsOpen          = true;
                    m.SinglePrice     = carrierCfg.SinglePrice;
                    m.LeaveCount      = buyCount;
                    m.ConfigType      = EnumInsuranceConfigType.Buyer;
                    this.unitOfWorkRepository.PersistCreationOf(m);
                }
            }
            else if (payUser == null)
            {
                log.BuyState = EnumInsurancePayStatus.Offer;
                //设置运营商剩余数量
                carrierCfg.LeaveCount -= buyCount;
                this.unitOfWorkRepository.PersistUpdateOf(carrierCfg);
                //设置分销商剩余数量
                if (buyerCfg != null)
                {
                    buyerCfg.LeaveCount = log.AfterLeaveCount;
                    this.unitOfWorkRepository.PersistUpdateOf(buyerCfg);
                }
                else
                {
                    var builder = AggregationFactory.CreateBuiler <InsuranceConfigBuilder>();
                    var m       = builder.CreateInsuranceConfig();
                    m.BusinessmanCode = businessmanCode;
                    m.BusinessmanName = businessmanName;
                    m.IsOpen          = true;
                    m.SinglePrice     = carrierCfg.SinglePrice;
                    m.LeaveCount      = buyCount;
                    m.ConfigType      = EnumInsuranceConfigType.Buyer;
                    this.unitOfWorkRepository.PersistCreationOf(m);
                }
            }
            //否则交易失败
            else
            {
                log.BuyState = EnumInsurancePayStatus.NoPay;
            }

            log.BuyTime = DateTime.Now;
            this.unitOfWorkRepository.PersistCreationOf(log);
        }
Пример #26
0
        /// <summary>
        /// 运营商批发保险
        /// </summary>
        /// <param name="buyCount">购买保险的数量</param>
        /// <param name="pwd"></param>
        /// <param name="carrierCode"></param>
        /// <param name="carrierName"></param>
        /// <param name="payUser"></param>
        public void BuyInsuranceByCashByCarrier(int buyCount, string pwd, string carrierCode, string carrierName, string operatorCode, string operatorName, CurrentUserInfo payUser, string remark = "")
        {
            //获取保险配置
            var cfg = InsuranceSection.GetInsuranceConfigurationSection();

            if (!cfg.CtrlInsuranceCollection.IsEnabled)
            {
                throw new CustomException(11112, "保险功能未开启");
            }
            //最大能够购买的数量
            var canBuyMaxCount =
                (from InsuranceElement ctrl in cfg.CtrlInsuranceCollection
                 select ctrl).Where(m => m.IsCurrent).FirstOrDefault().LeaveCount;

            if (buyCount > canBuyMaxCount)
            {
                string type = payUser == null ? "赠送" : "购买";
                throw new CustomException(11113, "最多仅可" + type + canBuyMaxCount + "份保险。");
            }

            //获取当前运营商保险信息
            var model = this._iInsuranceConfigRepository.FindAll(p => p.BusinessmanCode == carrierCode).FirstOrDefault();

            //获取单价
            decimal singlePrice = payUser == null ? 0 : cfg.CtrlInsuranceCollection.SinglePrice;

            //运营商购买记录
            var logBuiler = AggregationFactory.CreateBuiler <InsuranceDepositLogBuilder>();
            var log       = logBuiler.CreateInsuranceDepositLog();

            log.PayNo            = log.GetPayNo();
            log.BeforeLeaveCount = model == null ? 0 : model.LeaveCount;                                               //购买前剩余
            log.AfterLeaveCount  = log.BeforeLeaveCount + buyCount;                                                    //购买后剩余
            log.DepositCount     = buyCount;                                                                           //购买数量
            log.TotalPrice       = Math.Round((singlePrice * buyCount), 2);                                            //总价
            log.SinglePrice      = singlePrice;                                                                        //单价
            log.BusinessmanCode  = carrierCode;                                                                        //商户号
            log.BusinessmanName  = carrierName;                                                                        //商户名称
            log.PayWay           = EnumPayMethod.Account;                                                              //支付类别
            log.Remark           = remark;
            log.RecordType       = payUser == null ? EnumInsuranceDepositType.Offer : EnumInsuranceDepositType.Normal; //记录类别
            log.OperatorAccount  = operatorCode;
            log.OperatorName     = operatorName;
            log.PayFee           = Math.Round(SystemConsoSwitch.Rate * log.TotalPrice, 2);
            if (_iPayMentClientProxy == null)
            {
                _iPayMentClientProxy = new CashbagPaymentClientProxy();
            }
            var payResult = string.Empty;

            if (payUser != null)
            {
                //现金账户
                //payResult = _iPayMentClientProxy.PaymentByCashAccount(payUser.CashbagCode, payUser.CashbagKey,
                //    log.PayNo, "购买保险", log.TotalPrice, pwd);
                var resultc = _iPayMentClientProxy.PaymentByCashAccount(payUser.CashbagCode, payUser.CashbagKey, log.PayNo, "购买保险", log.TotalPrice, pwd);
                if (resultc.Item1)
                {
                    //该订单已经被在线支付时写入日志
                    Logger.WriteLog(LogType.INFO, "订单已经支付,交易号为" + resultc.Item2 + "支付方式为" + resultc.Item3);
                    throw new CustomException(0001, "订单已经支付,交易号为" + resultc.Item2 + "支付方式为" + resultc.Item3);
                }
                payResult = resultc.Item2;
            }
            //如果存在交易号,即支付成功
            if (!string.IsNullOrEmpty(payResult))
            {
                log.OutTradeNo = payResult;                 //设置交易号
                log.BuyState   = EnumInsurancePayStatus.OK; //设置交易状态
                //设置剩余数量
                foreach (var m in (from InsuranceElement ctrl in cfg.CtrlInsuranceCollection
                                   select ctrl).Where(m => m.IsCurrent))
                {
                    m.LeaveCount -= buyCount;
                    break;
                }
                //保存配置信息
                InsuranceSection.Save();
                //保存当前分销商商户保险配置
                if (model != null)
                {
                    model.LeaveCount = log.AfterLeaveCount;
                    this.unitOfWorkRepository.PersistUpdateOf(model);
                }
                else
                {
                    var builder = AggregationFactory.CreateBuiler <InsuranceConfigBuilder>();
                    var m       = builder.CreateInsuranceConfig();
                    m.BusinessmanCode = carrierCode;
                    m.BusinessmanName = carrierName;
                    m.IsOpen          = true;
                    m.SinglePrice     = singlePrice;
                    m.LeaveCount      = buyCount;
                    m.ConfigType      = EnumInsuranceConfigType.Carrier;
                    this.unitOfWorkRepository.PersistCreationOf(m);
                }
            }
            else if (payUser == null)
            {
                log.BuyState = EnumInsurancePayStatus.Offer;
                //设置剩余数量
                foreach (var m in (from InsuranceElement ctrl in cfg.CtrlInsuranceCollection
                                   select ctrl).Where(m => m.IsCurrent))
                {
                    m.LeaveCount -= buyCount;
                    break;
                }
                //保存配置信息
                InsuranceSection.Save();
                //保存当前分销商商户保险配置
                if (model != null)
                {
                    model.LeaveCount = log.AfterLeaveCount;
                    this.unitOfWorkRepository.PersistUpdateOf(model);
                }
                else
                {
                    var builder = AggregationFactory.CreateBuiler <InsuranceConfigBuilder>();
                    var m       = builder.CreateInsuranceConfig();
                    m.BusinessmanCode = carrierCode;
                    m.BusinessmanName = carrierName;
                    m.IsOpen          = true;
                    m.SinglePrice     = singlePrice;
                    m.LeaveCount      = buyCount;
                    m.ConfigType      = EnumInsuranceConfigType.Carrier;
                    this.unitOfWorkRepository.PersistCreationOf(m);
                }
            }
            //否则交易失败
            else
            {
                log.BuyState = EnumInsurancePayStatus.NoPay;
            }

            log.BuyTime = DateTime.Now;
            this.unitOfWorkRepository.PersistCreationOf(log);
        }
Пример #27
0
        public void Instantiate_ColumnTypeAndAggregationFunction_CorrectAggregation(ColumnType columnType, AggregationFunctionType function)
        {
            var factory = new AggregationFactory();

            Assert.Throws <ArgumentException>(() => factory.Instantiate(columnType, function, Array.Empty <IScalarResolver>(), Array.Empty <IAggregationStrategy>()));
        }
Пример #28
0
        private IEnumerable <AggregationResult> GetAggregationResult(Project project, AggregationType aggregationType, decimal?lambda = null)
        {
            var aggregationResult = new AggregationResult();

            aggregationResult.Items   = new List <AggregationResultItem>();
            aggregationResult.Project = project;

            IAggregation aggregation = null;

            switch (aggregationType)
            {
            case AggregationType.MIN:
            case AggregationType.MAX:
            case AggregationType.AVERAGE:
                aggregation = AggregationFactory.CreateSimpleAggregation(aggregationType);
                foreach (var alternative in project.Alternatives.OrderBy(x => x.AlternativeId))
                {
                    var row = project.FinalAssessment.Items.Where(x => x.AlternativeId == alternative.AlternativeId)
                              .OrderBy(x => x.FactorId).ToList();
                    var points = row.Select(x => x.Points).ToList();

                    var calculatedAggregation = aggregation.Calc(points);
                    aggregationResult.Items.Add(new AggregationResultItem()
                    {
                        Alternative = alternative,
                        Aggregation = calculatedAggregation,
                    });
                }
                break;

            case AggregationType.OWA:
            case AggregationType.OWG:
                foreach (var weight in project.WeightGenerationResults)
                {
                    aggregationResult         = new AggregationResult();
                    aggregationResult.Items   = new List <AggregationResultItem>();
                    aggregationResult.Project = project;
                    aggregationResult.Weight  = weight;

                    foreach (var alternative in project.Alternatives.OrderBy(x => x.AlternativeId))
                    {
                        var row = project.FinalAssessment.Items.Where(x => x.AlternativeId == alternative.AlternativeId)
                                  .OrderBy(x => x.FactorId).ToList();
                        var points = row.Select(x => x.Points).ToList();

                        List <decimal> weights = weight.GetWeights(alternative);

                        aggregation = AggregationFactory.CreateWeightAggregation(aggregationType, weights.ToList());

                        var calculatedAggregation = aggregation.Calc(points);
                        aggregationResult.Items.Add(new AggregationResultItem()
                        {
                            Alternative = alternative,
                            Aggregation = calculatedAggregation
                        });
                    }

                    yield return(aggregationResult);
                }
                break;

            case AggregationType.IOWA:
            case AggregationType.IOWG:
                foreach (var weight in project.WeightGenerationResults)
                {
                    aggregationResult         = new AggregationResult();
                    aggregationResult.Items   = new List <AggregationResultItem>();
                    aggregationResult.Project = project;
                    aggregationResult.Weight  = weight;

                    foreach (var alternative in project.Alternatives.OrderBy(x => x.AlternativeId))
                    {
                        var row = project.FinalAssessment.Items.Where(x => x.AlternativeId == alternative.AlternativeId)
                                  .OrderBy(x => x.FactorId).ToList();
                        var points = row.Select(x => x.Points).ToList();

                        List <decimal> weights = weight.GetWeights(alternative);
                        List <decimal> ratings = weight.GetRatings(alternative);

                        aggregation = AggregationFactory.CreateParamAggregation(aggregationType, weights.ToList(), ratings);

                        var calculatedAggregation = aggregation.Calc(points);
                        aggregationResult.Items.Add(new AggregationResultItem()
                        {
                            Alternative = alternative,
                            Aggregation = calculatedAggregation
                        });
                    }

                    yield return(aggregationResult);
                }
                break;

            case AggregationType.IGOWA:
                foreach (var weight in project.WeightGenerationResults)
                {
                    aggregationResult         = new AggregationResult();
                    aggregationResult.Items   = new List <AggregationResultItem>();
                    aggregationResult.Project = project;
                    aggregationResult.Weight  = weight;

                    foreach (var alternative in project.Alternatives.OrderBy(x => x.AlternativeId))
                    {
                        var row = project.FinalAssessment.Items.Where(x => x.AlternativeId == alternative.AlternativeId)
                                  .OrderBy(x => x.FactorId).ToList();
                        var points = row.Select(x => x.Points).ToList();

                        List <decimal> weights = weight.GetWeights(alternative);
                        List <decimal> ratings = weight.GetRatings(alternative);

                        aggregation = AggregationFactory.CreateParamAggregation(aggregationType, weights.ToList(), ratings, lambda.Value);

                        var calculatedAggregation = aggregation.Calc(points);
                        aggregationResult.Items.Add(new AggregationResultItem()
                        {
                            Alternative = alternative,
                            Aggregation = calculatedAggregation
                        });
                    }

                    yield return(aggregationResult);
                }
                break;

            case AggregationType.GOWA:
                foreach (var weight in project.WeightGenerationResults)
                {
                    aggregationResult         = new AggregationResult();
                    aggregationResult.Items   = new List <AggregationResultItem>();
                    aggregationResult.Project = project;
                    aggregationResult.Weight  = weight;
                    aggregationResult.Lambda  = lambda;

                    foreach (var alternative in project.Alternatives.OrderBy(x => x.AlternativeId))
                    {
                        var row = project.FinalAssessment.Items.Where(x => x.AlternativeId == alternative.AlternativeId)
                                  .OrderBy(x => x.FactorId).ToList();
                        var points = row.Select(x => x.Points).ToList();

                        List <decimal> weights = weight.GetWeights(alternative);

                        aggregation = AggregationFactory.CreateParamAggregation(aggregationType, weights.ToList(), lambda.Value);

                        var calculatedAggregation = aggregation.Calc(points);
                        aggregationResult.Items.Add(new AggregationResultItem()
                        {
                            Alternative = alternative,
                            Aggregation = calculatedAggregation
                        });
                    }

                    yield return(aggregationResult);
                }
                break;

            case AggregationType.POWA:
                foreach (var weight in project.WeightGenerationResults)
                {
                    aggregationResult         = new AggregationResult();
                    aggregationResult.Items   = new List <AggregationResultItem>();
                    aggregationResult.Project = project;
                    aggregationResult.Weight  = weight;
                    aggregationResult.Lambda  = lambda;

                    foreach (var alternative in project.Alternatives.OrderBy(x => x.AlternativeId))
                    {
                        var row = project.FinalAssessment.Items.Where(x => x.AlternativeId == alternative.AlternativeId)
                                  .OrderBy(x => x.FactorId).ToList();
                        var points = row.Select(x => x.Points).ToList();

                        List <decimal> weights = weight.GetWeights(alternative);

                        List <decimal> probabilities = weight.GetProbabilities(alternative);

                        aggregation = AggregationFactory.CreateParamAggregation(aggregationType, weights.ToList(), probabilities, lambda);

                        var calculatedAggregation = aggregation.Calc(points);
                        aggregationResult.Items.Add(new AggregationResultItem()
                        {
                            Alternative = alternative,
                            Aggregation = calculatedAggregation
                        });
                    }

                    yield return(aggregationResult);
                }
                break;

            case AggregationType.ASPOWA_MIN:
            case AggregationType.ASPOWA_MAX:
            case AggregationType.ASPOWA_MEAN:
                foreach (var weight in project.WeightGenerationResults)
                {
                    aggregationResult         = new AggregationResult();
                    aggregationResult.Items   = new List <AggregationResultItem>();
                    aggregationResult.Project = project;
                    aggregationResult.Weight  = weight;
                    aggregationResult.Lambda  = lambda;

                    foreach (var alternative in project.Alternatives.OrderBy(x => x.AlternativeId))
                    {
                        var row = project.FinalAssessment.Items.Where(x => x.AlternativeId == alternative.AlternativeId)
                                  .OrderBy(x => x.FactorId).ToList();
                        var points = row.Select(x => x.Points).ToList();

                        List <decimal> weights = weight.GetWeights(alternative);

                        List <decimal> possibilities = weight.GetPossibilities(alternative);

                        aggregation = AggregationFactory.CreateParamAggregation(aggregationType, weights.ToList(), possibilities, lambda);

                        var calculatedAggregation = aggregation.Calc(points);
                        aggregationResult.Items.Add(new AggregationResultItem()
                        {
                            Alternative = alternative,
                            Aggregation = calculatedAggregation
                        });
                    }

                    yield return(aggregationResult);
                }
                break;
            }

            yield return(aggregationResult);
        }