public void TestMethodInsurance() { BootStrapper.Boot(); //var oser = ObjectFactory.GetInstance<OrderService>(); //var model = oser.GetOrderByOrderId("04630474482726633176"); //var str = JsonConvert.SerializeObject(model); //Console.WriteLine(str); var service = ObjectFactory.GetInstance <InsuranceService>(); var dto = new RequestInsurance(); dto.OrderId = "05049269408530754042";//1个乘客 //dto.OrderId = "05283589118296006288";//4个乘客 //dto.SinglePrice = 20.00M; //dto.IsBuyRefundInsurance = true; //dto.Passenger = new List<PassengerDto>() { new PassengerDto() { CardNo = "513722198911054516" } }; // dto.Passenger = new List<PassengerDto>() { new PassengerDto() { CardNo = "520201197209083216" }, new PassengerDto() { CardNo = "123654789" }, new PassengerDto() { CardNo = "G1452362" }, new PassengerDto() { CardNo = "513722198911054516" } }; service.SaveInsurance(dto); var req = new RequestQueryInsurance(); var m1 = service.QueryInsurance(null, 1, 20); var str1 = JsonConvert.SerializeObject(m1); Console.WriteLine(str1); }
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(); }