コード例 #1
0
        public EResponseBase <DataBill> Add(DataBill dataBill)
        {
            EResponseBase <DataBill> response = new EResponseBase <DataBill>();

            try
            {
                dataBill.Customer.State     = true;
                dataBill.Customer.CreatedAt = DateTime.Now;
                dataBill.Bill.CreatedAt     = DateTime.Now;
                dataBill.Bill.State         = true;
                dataBill.Bill.BillDetails   = dataBill.BillDetails;
                dataBill.Bill.Customer      = dataBill.Customer;
                using (var context = new DataContext())
                {
                    context.Bills.Add(dataBill.Bill);
                    context.SaveChanges();
                }
                response.Status  = true;
                response.Message = "Success";
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
                response.Status  = false;
            }
            return(response);
        }
コード例 #2
0
ファイル: UnitTest3.cs プロジェクト: goldmon/BPiaoBao
        public void TestData()
        {
            DataBill dataBill = new DataBill();
            decimal  d        = 181.00m;
            decimal  ff       = 0m;

            ff = dataBill.CeilAddTen(d);
        }
コード例 #3
0
ファイル: CheckoutController.cs プロジェクト: banhmiomama/VT
        public string ExecuteBill(string data, string Email)
        {
            try
            {
                DataTable dt = new DataTable();

                DataBill dataDetail = JsonConvert.DeserializeObject <DataBill>(data);
                int      CustomerID = (int)HttpContext.Session.GetInt32(Comon.GlobalClient.CustomerID);
                using (Models.ExecuteDataBase confunc = new Models.ExecuteDataBase())
                {
                    dt = confunc.ExecuteDataTable("[YYY_sp_Bill_Insert]", CommandType.StoredProcedure
                                                  , "@CustomerID", SqlDbType.Int, CustomerID
                                                  , "@ScheduleID", SqlDbType.Int, dataDetail.ScheduleID
                                                  , "@Quan", SqlDbType.Int, dataDetail.Quan
                                                  , "@Price", SqlDbType.Float, dataDetail.Price);
                }

                //MimeMessage message = new MimeMessage();
                //message.Subject = "VTCinema";

                //BodyBuilder bodyBuilder = new BodyBuilder();
                //bodyBuilder.HtmlBody = "<h1>Hello World!</h1>";
                //bodyBuilder.TextBody = "hello every !";
                //message.Body = bodyBuilder.ToMessageBody();

                //message.From.Add(new MailboxAddress("VTCinema"));
                //message.To.Add(new MailboxAddress(Email));
                //using (var client = new SmtpClient())
                //{
                //    client.Connect("smtp.gmail.com"
                //    , 587
                //    , MailKit.Security.SecureSocketOptions.StartTls);
                //    client.Authenticate("*****@*****.**", "CuBaKhoTinh1804");
                //    client.Send(message);
                //    client.Disconnect(true);
                //}

                return(dt.Rows[0][0].ToString());
            }
            catch (Exception ex)
            {
                return("0");
            }
        }
コード例 #4
0
ファイル: FrmBill.cs プロジェクト: tai8292/cdio
        private void reportBill_Load(object sender, EventArgs e)
        {
            //tạo đối tượng và đưa dữ liệu và dataBill
            DataBillTableAdapters.BILLTableAdapter       bill       = new DataBillTableAdapters.BILLTableAdapter();
            DataBillTableAdapters.BILLDETAILTableAdapter billDetail = new DataBillTableAdapters.BILLDETAILTableAdapter();
            DataBillTableAdapters.DISHTableAdapter       dish       = new DataBillTableAdapters.DISHTableAdapter();
            DataBillTableAdapters.CUSTOMERTableAdapter   cus        = new DataBillTableAdapters.CUSTOMERTableAdapter();
            DataBillTableAdapters.EMPLOYEETableAdapter   emp        = new DataBillTableAdapters.EMPLOYEETableAdapter();
            DataBill data = new DataBill();

            dish.Fill(data.DISH);
            bill.Fill(data.BILL, int.Parse(this.billID));
            billDetail.Fill(data.BILLDETAIL, int.Parse(this.billID));
            cus.Fill(data.CUSTOMER, int.Parse(this.cusID));
            emp.Fill(data.EMPLOYEE, int.Parse(this.empID));
            rpBill r = new rpBill();

            //đưa dữ liệu từ databill và CystalReport
            r.SetDataSource(data);
            this.reportBill.ReportSource = r;
        }
コード例 #5
0
 public JsonResult <EResponseBase <DataBill> > InsertBill(DataBill dataBill)
 {
     return(Json(Service.Add(dataBill)));
 }
コード例 #6
0
        public override object Execute()
        {
            //记录时间
            StringBuilder sbLog = new StringBuilder();
            Stopwatch     watch = new Stopwatch();

            try
            {
                watch.Start();
                string    platformCode = getParame("platformCode").ToString();
                string    policyId     = getParame("policyId").ToString();
                string    operatorName = getParame("operatorName").ToString();
                string    source       = getParame("source").ToString();
                PolicyDto policyUI     = source != "back" ? (getParame("policy") as PolicyDto) : null;

                decimal TotlePaidPirce = 0m;
                OldOutOrderId = order.OutOrderId;
                string          innerPlatformCode = "系统";
                DataBill        databill          = new DataBill();
                DomesticService domesticService   = ObjectFactory.GetInstance <DomesticService>();
                UserRelation    userRealtion      = domesticService.GetUserRealtion(order.BusinessmanCode);
                bool            IspolicyIsNull    = false;

                if (policyUI != null)
                {
                    //赋值
                    order.Policy = PolicyDtoPolicy(policyUI, order.Policy, source);
                }
                else
                {
                    #region 原获取政策
                    PolicyParam policyParam = new PolicyParam();
                    policyParam.code              = order.BusinessmanCode;
                    policyParam.PnrContent        = order.PnrContent;
                    policyParam.OrderId           = order.OrderId;
                    policyParam.OrderType         = order.OrderType;
                    policyParam.OrderSource       = order.OrderSource;
                    policyParam.IsChangePnrTicket = order.IsChangePnrTicket;
                    policyParam.IsDestine         = order.OrderSource == EnumOrderSource.WhiteScreenDestine ? true : false;
                    Passenger pasData = order.Passengers.Where(p => p.PassengerType != EnumPassengerType.Baby).FirstOrDefault();
                    if (pasData != null)
                    {
                        policyParam.defFare   = pasData.SeatPrice.ToString();
                        policyParam.defTAX    = pasData.ABFee.ToString();
                        policyParam.defRQFare = pasData.RQFee.ToString();
                    }
                    if (order.Policy == null)
                    {
                        IspolicyIsNull = true;
                        order.Policy   = new Policy();
                    }
                    Policy         localPolicy   = null;
                    PlatformPolicy policy        = null;
                    PlatformOrder  platformOrder = null;
                    PolicyService  policyService = ObjectFactory.GetInstance <PolicyService>();
                    watch.Stop();
                    sbLog.AppendFormat("初始话变量时间:{0}\r\n", watch.Elapsed.ToString());
                    watch.Restart();

                    if (platformCode != innerPlatformCode)
                    {
                        PnrData pnrData = PnrHelper.GetPnrData(order.PnrContent);
                        policy = PlatformFactory.GetPlatformByCode(platformCode).GetPoliciesByPnrContent(order.PnrContent, order.IsLowPrice, pnrData).Find((p) => p.Id == policyId);
                        watch.Stop();
                        sbLog.AppendFormat("0.调用方法【GetPlatformByCode】用时:{0}\r\n", watch.Elapsed.ToString());
                        watch.Restart();

                        if (policy == null)
                        {
                            localPolicy = GetLocalPolicy(policyParam, policyId, innerPlatformCode, userRealtion, IspolicyIsNull, policyService, localPolicy);
                            watch.Stop();
                            sbLog.AppendFormat("1.调用方法【GetLocalPolicy】用时:{0}\r\n", watch.Elapsed.ToString());
                            watch.Restart();
                            if (localPolicy != null)
                            {
                                order.Policy = localPolicy;
                            }
                            else
                            {
                                throw new OrderCommException("政策发生变动,请重新获取政策!!!");
                            }
                        }
                        else
                        {
                            SetInterface(platformCode, operatorName, source, ref TotlePaidPirce, policy, userRealtion, ref platformOrder, pnrData);
                            watch.Stop();
                            sbLog.AppendFormat("2.调用方法【SetInterface】用时:{0}\r\n", watch.Elapsed.ToString());
                            watch.Restart();
                        }
                    }
                    else
                    {
                        localPolicy = GetLocalPolicy(policyParam, policyId, innerPlatformCode, userRealtion, IspolicyIsNull, policyService, localPolicy);
                        watch.Stop();
                        sbLog.AppendFormat("3.调用方法【GetLocalPolicy】用时:{0}\r\n", watch.Elapsed.ToString());
                        watch.Restart();
                        if (localPolicy == null)
                        {
                            PnrData pnrData = PnrHelper.GetPnrData(order.PnrContent);
                            localPolicy = policyService.GetInterfacePolicy(policyParam, "", userRealtion, pnrData).Find((p) => p.PolicyId == policyId);
                            watch.Stop();
                            sbLog.AppendFormat("4.调用方法【GetInterfacePolicy】用时:{0}\r\n", watch.Elapsed.ToString());
                            watch.Restart();
                            if (localPolicy != null)
                            {
                                policy.AreaCity    = localPolicy.AreaCity;
                                policy.Id          = localPolicy.PolicyId;
                                policy.PolicyPoint = localPolicy.PolicyPoint;
                                if (source != "back")
                                {
                                    policy.PolicyPoint = localPolicy.PaidPoint;
                                }
                                policy.ReturnMoney      = localPolicy.ReturnMoney;
                                policy.IsLow            = localPolicy.IsLow;
                                policy.SeatPrice        = localPolicy.SeatPrice;
                                policy.ABFee            = localPolicy.ABFee;
                                policy.RQFee            = localPolicy.RQFee;
                                policy.Remark           = localPolicy.Remark;
                                policy.IsChangePNRCP    = localPolicy.IsChangePNRCP;
                                policy.IsSp             = localPolicy.IsSp;
                                policy.PolicyType       = localPolicy.PolicyType;
                                policy.WorkTime         = localPolicy.WorkTime;
                                policy.ReturnTicketTime = localPolicy.ReturnTicketTime;
                                policy.AnnulTicketTime  = localPolicy.AnnulTicketTime;
                                policy.CPOffice         = localPolicy.CPOffice;
                                policy.IssueSpeed       = localPolicy.IssueSpeed;
                                TotlePaidPirce          = platformOrder.TotlePaidPirce;

                                SetInterface(platformCode, operatorName, source, ref TotlePaidPirce, policy, userRealtion, ref platformOrder, pnrData);
                                watch.Stop();
                                sbLog.AppendFormat("5.调用方法【GetInterfacePolicy】用时:{0}\r\n", watch.Elapsed.ToString());
                                watch.Restart();
                            }
                            else
                            {
                                if (localPolicy == null)
                                {
                                    throw new OrderCommException("政策发生变动,请重新获取政策!");
                                }
                            }
                        }
                        else
                        {
                            //赋值
                            order.Policy = localPolicy;
                        }
                    }
                    #endregion
                }


                decimal _OrderMoney = 0m;
                if (source != "back")
                {
                    //扣点组类型
                    DeductionType deductionType = order.Policy.PolicySourceType == EnumPolicySourceType.Local ? DeductionType.Local : (order.Policy.PolicySourceType == EnumPolicySourceType.Share ? DeductionType.Share : DeductionType.Interface);
                    if (policyUI != null)
                    {
                        order.Policy.PolicyPoint = order.Policy.PaidPoint;
                    }
                    PlatformDeductionParam pfDp = new PlatformDeductionParam();
                    foreach (SkyWay leg in order.SkyWays)
                    {
                        pfDp.FlyLineList.Add(new FlyLine()
                        {
                            CarrayCode   = leg.CarrayCode,
                            FromCityCode = leg.FromCityCode,
                            ToCityCode   = leg.ToCityCode
                        });
                    }
                    //匹配扣点规则
                    domesticService.MatchDeductionRole(order.Policy, pfDp, order.SkyWays[0].CarrayCode, userRealtion.deductionGroup, userRealtion, deductionType);
                    watch.Stop();
                    sbLog.AppendFormat("6.调用方法【MatchDeductionRole】用时:{0}\r\n", watch.Elapsed.ToString());
                    watch.Restart();

                    //佣金
                    order.Policy.Commission = databill.GetCommission(order.Policy.PolicyPoint, order.Policy.SeatPrice, order.Policy.ReturnMoney);
                    //单人支付金额 根据选择的政策 设置价格
                    for (int i = 0; i < order.Passengers.Count; i++)
                    {
                        Passenger p = order.Passengers[i];
                        if (p.PassengerType != EnumPassengerType.Baby)
                        {
                            p.SeatPrice = order.Policy.SeatPrice;
                            p.ABFee     = order.Policy.ABFee;
                            p.RQFee     = order.Policy.RQFee;
                            p.PayMoney  = databill.GetPayPrice(order.Policy.SeatPrice, order.Policy.ABFee, order.Policy.RQFee, order.Policy.PolicyPoint, order.Policy.ReturnMoney);
                        }
                        else
                        {
                            p.PayMoney = databill.GetPayPrice(p.SeatPrice, p.ABFee, p.RQFee, 0, 0);
                        }
                    }
                    _OrderMoney = order.Passengers.Sum(p => p.PayMoney);
                    order.OrderCommissionTotalMoney = order.Passengers.Sum(p => p.PassengerType != EnumPassengerType.Baby ? databill.GetCommission(order.Policy.PolicyPoint, order.Policy.SeatPrice, order.Policy.ReturnMoney) : 0);
                }

                #region 支付信息
                if (order.OrderPay == null)
                {
                    order.OrderPay = new OrderPay();
                }

                order.OrderPay.OrderId   = order.OrderId;
                order.OrderPay.PaidMoney = TotlePaidPirce;
                if (source != "back")
                {
                    order.OrderPay.PayMoney  = _OrderMoney;
                    order.OrderMoney         = _OrderMoney;
                    order.OrderPay.PayStatus = EnumPayStatus.NoPay;
                }
                order.OrderPay.PaidStatus    = EnumPaidStatus.NoPaid;
                order.OrderPay.TradePoundage = 0m;
                order.OrderPay.SystemFee     = 0m;
                order.CpOffice = order.Policy.CPOffice;
                #endregion


                #region 根据政策扣点明细计算支付分润
                if (source != "back")
                {
                    domesticService.CreateBillDetails(order, userRealtion);
                    watch.Stop();
                    sbLog.AppendFormat("7.调用方法【CreateBillDetails】用时:{0}\r\n", watch.Elapsed.ToString());
                }
                #endregion
                order.WriteLog(new OrderLog()
                {
                    OperationContent  = string.Format("{0}选择政策,政策:{1},编号:{2},订单号:{3},出票速度:{4}", source, order.Policy.PolicyPoint, order.Policy.PolicyId, order.OrderId, order.Policy.IssueSpeed),
                    OperationDatetime = DateTime.Now,
                    OperationPerson   = operatorName,
                    IsShowLog         = false
                });

                order.WriteLog(new OrderLog()
                {
                    OperationContent  = string.Format("选择政策,订单号:{0},出票速度:{1}", order.OrderId, order.Policy.IssueSpeed),
                    OperationDatetime = DateTime.Now,
                    OperationPerson   = operatorName,
                    IsShowLog         = true
                });

                if (source == "back")
                {
                    //order.ChangeStatus(EnumOrderStatus.WaitAndPaid);
                    order.ChangeStatus(EnumOrderStatus.PayWaitCreatePlatformOrder);
                }
                else
                {
                    order.ChangeStatus(EnumOrderStatus.NewOrder);
                }
            }
            finally
            {
                if (sbLog.ToString() != "")
                {
                    new CommLog().WriteLog("NewSelectPolicyBehavior", sbLog.ToString());
                }
            }
            if (order.Policy.PolicySourceType == EnumPolicySourceType.Interface)
            {
                order.Policy.Code        = string.Empty;
                order.Policy.Name        = string.Empty;
                order.Policy.CashbagCode = string.Empty;
            }
            return(null);
        }
コード例 #7
0
ファイル: OrderMapper.cs プロジェクト: goldmon/BPiaoBao
        public static PolicyDto ToPolicyDto(this Policy policy, Order order)
        {
            DataBill databill   = new DataBill();
            decimal  PayMoney   = databill.GetPayPrice(policy.SeatPrice, policy.ABFee, policy.RQFee, policy.PolicyPoint, policy.ReturnMoney);
            decimal  Commission = databill.GetCommission(policy.PolicyPoint, policy.SeatPrice, policy.ReturnMoney);
            var      _p         = new PolicyDto()
            {
                Commission             = Commission,
                AreaCity               = policy.AreaCity,
                Id                     = policy.PolicyId,
                PlatformCode           = policy.PlatformCode,
                PlatformName           = policy.PlatformCode,
                Point                  = policy.PolicyPoint,
                DownPoint              = policy.DownPoint,
                PaidPoint              = policy.PaidPoint,
                OriginalPolicyPoint    = policy.OriginalPolicyPoint,
                ReturnMoney            = policy.ReturnMoney,
                IsChangePNRCP          = policy.IsChangePNRCP,
                IssueTicketWay         = ((int)policy.EnumIssueTicketWay).ToString(),
                IsSp                   = policy.IsSp,
                IsLow                  = policy.IsLow,
                PolicyType             = policy.PolicyType,
                WorkTime               = policy.WorkTime.ToString(),
                ReturnTicketTime       = policy.ReturnTicketTime.ToString(),
                AnnulTicketTime        = policy.AnnulTicketTime.ToString(),
                TFGTime                = FormatPNR.GetIntersectionTimeSlot(policy.ReturnTicketTime.ToString(), policy.AnnulTicketTime.ToString()),
                CPOffice               = policy.CPOffice,
                IssueSpeed             = policy.IssueSpeed,
                Remark                 = policy.Remark,
                PolicySourceType       = EnumItemManager.GetDesc(policy.PolicySourceType),
                CarryCode              = policy.CarryCode,
                PolicyOwnUserRole      = ((int)policy.PolicyOwnUserRole).ToString(),
                Code                   = policy.Code,
                Name                   = policy.Name,
                CashbagCode            = policy.CashbagCode,
                Rate                   = policy.Rate,
                CarrierCode            = policy.CarrierCode,
                SeatPrice              = policy.SeatPrice,
                ABFee                  = policy.ABFee,
                RQFee                  = policy.RQFee,
                TicketPrice            = policy.SeatPrice + policy.ABFee + policy.RQFee,
                PayMoney               = PayMoney,
                DefaultPolicySource    = order.OrderType,
                PolicySpecialType      = policy.PolicySpecialType,
                SpecialPriceOrDiscount = policy.SpecialPriceOrDiscount,
                TodayGYCode            = policy.TodayGYCode
            };
            var currentUser = AuthManager.GetCurrentUser();

            if (currentUser.Type == "Buyer")
            {
                _p.ShowPolicySource = EnumItemManager.GetDesc(policy.PolicySourceType);
            }
            else if (currentUser.Type == "Carrier")
            {
                if (policy.PolicySourceType != EnumPolicySourceType.Local)
                {
                    _p.ShowPolicySource = "系统";
                }
                else if (currentUser.Code == policy.Code)
                {
                    _p.ShowPolicySource = policy.PolicyType;
                }
                else
                {
                    _p.ShowPolicySource = policy.Code;
                }
            }
            else if (currentUser.Type == "Supplier")
            {
                _p.ShowPolicySource = policy.PolicyType;
            }
            else
            {
                if (policy.PolicySourceType == EnumPolicySourceType.Interface)
                {
                    _p.ShowPolicySource = policy.PlatformCode;
                }
                else
                {
                    _p.ShowPolicySource = policy.Code;
                }
            }
            return(_p);
        }
コード例 #8
0
ファイル: OrderMapper.cs プロジェクト: goldmon/BPiaoBao
        public static OrderDto ToOrderDto(this Order p, OrderDto result = null)
        {
            var         temp        = p.OrderLogs.Where(x => x.OperationContent.Contains("拒绝出票")).FirstOrDefault();
            DataBill    databill    = new DataBill();
            PnrResource pnrResource = new PnrResource();

            if (result == null)
            {
                result = new OrderDto();
            }
            result.HasAfterSale              = p.HasAfterSale;
            result.OutOrderId                = p.OutOrderId;
            result.OrderId                   = p.OrderId;
            result.IsSupplier                = AuthManager.GetCurrentUser().Type == "Supplier" ? true : false;
            result.IsCarrier                 = AuthManager.GetCurrentUser().Code == p.CarrierCode ? true : false;
            result.CurrentCode               = AuthManager.GetCurrentUser().Code;
            result.UserRole                  = AuthManager.GetCurrentUser().Type;
            result.CPMoney                   = p.CPMoney;
            result.OrderMoney                = p.OrderMoney;
            result.Remark                    = p.Remark;
            result.PnrCode                   = p.PnrCode;
            result.CarrierCode               = p.CarrierCode;
            result.BigCode                   = p.BigCode;
            result.PNRContent                = p.PnrContent;
            result.OrderStatus               = (int)p.OrderStatus;
            result.BusinessmanName           = p.BusinessmanName;
            result.BusinessmanCode           = p.BusinessmanCode;
            result.CreateTime                = p.CreateTime;
            result.LockAccount               = p.LockAccount;
            result.IsCompleted               = p.CoordinationStatus;
            result.OrderCommissionTotalMoney = p.OrderCommissionTotalMoney;
            result.PnrSource                 = p.PnrSource;
            result.IsChangePnrTicket         = p.IsChangePnrTicket;
            result.IsLowPrice                = p.IsLowPrice;
            result.HaveBabyFlag              = p.HaveBabyFlag;
            result.RealRemark                = temp != null ? temp.OperationContent : string.Empty;
            result.OrderSource               = p.OrderSource;
            result.OldOrderId                = p.OldOrderId;
            result.YdOffice                  = p.YdOffice;
            result.CpOffice                  = p.CpOffice;
            result.OrderType                 = p.OrderType.ToString();
            result.PayInfo                   = new OrderPayDto();
            if (p.OrderPay != null)
            {
                result.PayInfo.PayMethodCode     = p.OrderPay.PayMethodCode;
                result.PayInfo.PayDateTime       = p.OrderPay.PayDateTime;
                result.PayInfo.PaidMethod        = p.OrderPay.PaidMethod == null ? null : p.OrderPay.PaidMethod.ToString();
                result.PayInfo.PayDateTime       = p.OrderPay.PayDateTime;
                result.PayInfo.PayMethod         = GetPayMethod(p.OrderPay.PayMethod == null ? null : p.OrderPay.PayMethod.ToString());
                result.PayInfo.PaidMoney         = p.OrderPay.PaidMoney;
                result.PayInfo.PayMoney          = p.OrderPay.PayMoney;
                result.PayInfo.PaidSerialNumber  = p.OrderPay.PaidSerialNumber;
                result.PayInfo.PaySerialNumber   = p.OrderPay.PaySerialNumber;
                result.PayInfo.SystemFee         = p.OrderPay.SystemFee;
                result.PayInfo.TradePoundage     = p.OrderPay.TradePoundage;
                result.PayInfo.PaidStatus        = p.OrderPay.PaidStatus;
                result.PayInfo.PayStatus         = p.OrderPay.PayStatus;
                result.PayInfo.PayBillDetailDtos = p.OrderPay.PayBillDetails.Select(x => new PayBillDetailDto()
                {
                    ID          = x.ID,
                    Code        = x.Code,
                    CashbagCode = x.CashbagCode,
                    AdjustType  = x.AdjustType,
                    Money       = x.Money,
                    Name        = x.Name,
                    OpType      = x.OpType.ToEnumDesc(),
                    Point       = x.Point,
                    Remark      = x.Remark
                }).ToList();
                if (p.OrderPay.PaidDateTime.HasValue)
                {
                    DateTime ticketTime = DateTime.Now;
                    if (p.IssueTicketTime.HasValue)
                    {
                        ticketTime = p.IssueTicketTime.Value;
                    }
                    result.Time = (int)ticketTime.Subtract(p.OrderPay.PaidDateTime.Value).TotalMinutes;
                }
            }
            result.Policy = new PolicyDto();
            if (p.Policy != null)
            {
                result.Policy = p.Policy.ToPolicyDto(p);
            }

            result.Passengers = p.Passengers
                                .Select(x => new PassengerDto()
            {
                Id                   = x.Id,
                PassengerName        = x.PassengerName,
                CardNo               = x.CardNo,
                TaxFee               = x.ABFee,
                RQFee                = x.RQFee,
                SeatPrice            = x.SeatPrice,
                Mobile               = x.Mobile,
                PassengerType        = x.PassengerType,                   //.ToEnumDesc(),
                TicketNumber         = x.TicketNumber,
                TravelNumber         = x.TravelNumber,
                PassengerTripStatus  = x.PassengerTripStatus,
                PayMoney             = x.PayMoney,
                BuyInsuranceCount    = x.BuyInsuranceCount,
                BuyInsurancePrice    = x.BuyInsurancePrice,
                IsInsuranceRefund    = x.IsInsuranceRefund,
                InsuranceRefunrPrice = x.InsuranceRefunrPrice,
                IdType               = x.IdType,
                SexType              = x.SexType,
                Birth                = x.Birth,
                CPMoney              = x.CPMoney
            }).ToList();
            result.SkyWays = p.SkyWays
                             .Select(k => new SkyWayDto()
            {
                SkyWayId        = k.Id,
                FromCityCode    = k.FromCityCode,
                ToCityCode      = k.ToCityCode,
                FromCity        = pnrResource.GetCityInfo(k.FromCityCode) == null ? "" : pnrResource.GetCityInfo(k.FromCityCode).city.Name,
                ToCity          = pnrResource.GetCityInfo(k.ToCityCode) == null ? "" : pnrResource.GetCityInfo(k.ToCityCode).city.Name,
                CarrayShortName = pnrResource.GetAirInfo(k.CarrayCode) == null ? "" : pnrResource.GetAirInfo(k.CarrayCode).Carry.AirShortName,
                CarrayCode      = k.CarrayCode,
                StartDateTime   = k.StartDateTime,
                ToDateTime      = k.ToDateTime,
                FlightNumber    = k.FlightNumber,
                FromTerminal    = k.FromTerminal,
                Seat            = k.Seat,
                ToTerminal      = k.ToTerminal,
                Discount        = k.Discount.HasValue ? k.Discount.Value : 0m,
                FlightModel     = k.FlightModel
            }).ToList();


            return(result);
        }
コード例 #9
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);
        }