public void SendSmsForPhone(string OrderId, string Content, int[] PassengerId) { string code = AuthManager.GetCurrentUser().Code; var businessman = businessmanRepository.FindAll(x => x.Code == code).SingleOrDefault(); CurrentUserInfo currentUser = AuthManager.GetCurrentUser(); if (currentUser == null) { throw new CustomException(404, "获取信息失败,请稍后再试!"); } if (string.IsNullOrEmpty(Content)) { throw new CustomException(400, "发送短信内容不能为空!"); } var mOrder = orderRepository.FindAll(x => x.OrderId == OrderId).FirstOrDefault(); ChangeOrder mafterOrder = null; if (mOrder.HasAfterSale == true) { mafterOrder = afterSaleOrderRepository.FindAll(p => p.Order.OrderId == mOrder.OrderId && p is ChangeOrder).Select(p => p as ChangeOrder).FirstOrDefault(); } PnrResource pnrResource = new PnrResource(); string fromCity = null; string toCity = null; string flightTime = null; string arriveTime = null; string flightNumber = null; string flightCarrayCode = null; if (mOrder.SkyWays != null && mOrder.SkyWays.Count == 1) { //单程 fromCity = pnrResource.GetCityInfo(mOrder.SkyWays[0].FromCityCode).city.Name; toCity = pnrResource.GetCityInfo(mOrder.SkyWays[0].ToCityCode).city.Name; flightTime = mOrder.SkyWays[0].StartDateTime.ToString("yyyy-MM-dd HH:mm"); arriveTime = mOrder.SkyWays[0].ToDateTime.ToString("HH:mm"); flightNumber = mOrder.SkyWays[0].FlightNumber; flightCarrayCode = mOrder.SkyWays[0].CarrayCode; Content = Content.Replace("[航空公司航班号]", flightCarrayCode + flightNumber); Content = Content.Replace("[出发城市]", fromCity); Content = Content.Replace("[出发航站楼]", mOrder.SkyWays[0].FromTerminal); Content = Content.Replace("[到达城市]", toCity); Content = Content.Replace("[到达航站楼]", mOrder.SkyWays[0].ToTerminal); if (mafterOrder != null) { flightTime = DateTime.Parse(mafterOrder.SkyWay[0].FlyDate.ToString()).ToString("yyyy-MM-dd HH:mm"); } Content = Content.Replace("[起飞时间]", flightTime); Content = Content.Replace("[到达时间]", arriveTime); } else if (mOrder.SkyWays != null && mOrder.SkyWays.Count == 2) { //返程联程 var fromCity1 = pnrResource.GetCityInfo(mOrder.SkyWays[0].FromCityCode).city.Name; var fromCity2 = pnrResource.GetCityInfo(mOrder.SkyWays[1].FromCityCode).city.Name; var toCity1 = pnrResource.GetCityInfo(mOrder.SkyWays[0].ToCityCode).city.Name; var toCity2 = pnrResource.GetCityInfo(mOrder.SkyWays[1].ToCityCode).city.Name; flightCarrayCode = mOrder.SkyWays[0].CarrayCode; flightNumber = mOrder.SkyWays[0].FlightNumber; flightTime = mOrder.SkyWays[0].StartDateTime.ToString("yyyy-MM-dd HH:mm"); arriveTime = mOrder.SkyWays[0].ToDateTime.ToString("HH:mm"); var flightCarrayCodeBack = mOrder.SkyWays[1].CarrayCode; var flightNumberNameBack = mOrder.SkyWays[1].FlightNumber; var flightTimeBack = mOrder.SkyWays[1].StartDateTime.ToString("yyyy-MM-dd HH:mm"); var arriveTimeBack = mOrder.SkyWays[1].ToDateTime.ToString("HH:mm"); if (fromCity1 == toCity2 && toCity1 == fromCity2) { //往返 Content = Content.Replace("[航空公司航班号]", flightCarrayCode + flightNumber); Content = Content.Replace("[出发城市]", fromCity1); Content = Content.Replace("[出发航站楼]", mOrder.SkyWays[0].FromTerminal); Content = Content.Replace("[到达城市]", toCity1); Content = Content.Replace("[到达航站楼]", mOrder.SkyWays[0].ToTerminal); Content = Content.Replace("[起飞时间]", flightTime); Content = Content.Replace("[到达时间]", arriveTime); Content = Content.Replace("[回程航空公司航班号]", flightCarrayCodeBack + flightNumberNameBack); Content = Content.Replace("[回程出发城市]", fromCity2); Content = Content.Replace("[回程出发航站楼]", mOrder.SkyWays[1].FromTerminal); Content = Content.Replace("[回程到达城市]", toCity2); Content = Content.Replace("[回程到达航站楼]", mOrder.SkyWays[1].ToTerminal); Content = Content.Replace("[回程起飞时间]", flightTimeBack); Content = Content.Replace("[回程到达时间]", arriveTimeBack); } else { //中转 Content = Content.Replace("[航空公司航班号]", flightCarrayCode + flightNumber); Content = Content.Replace("[出发城市]", fromCity1); Content = Content.Replace("[出发航站楼]", mOrder.SkyWays[0].FromTerminal); Content = Content.Replace("[到达城市]", toCity1); Content = Content.Replace("[到达航站楼]", mOrder.SkyWays[0].ToTerminal); Content = Content.Replace("[起飞时间]", flightTime); Content = Content.Replace("[到达时间]", arriveTime); Content = Content.Replace("[中转航空公司航班号]", flightCarrayCodeBack + flightNumberNameBack); Content = Content.Replace("[中转出发城市]", fromCity2); Content = Content.Replace("[中转出发航站楼]", mOrder.SkyWays[1].FromTerminal); Content = Content.Replace("[中转到达城市]", toCity2); Content = Content.Replace("[中转到达航站楼]", mOrder.SkyWays[1].ToTerminal); Content = Content.Replace("[回程起飞时间]", flightTimeBack); Content = Content.Replace("[回程到达时间]", arriveTimeBack); } } for (int i = 0; i < mOrder.Passengers.Where(p => PassengerId.Contains(p.Id)).Count(); i++) { Content = Content.Replace("[乘客名称]", mOrder.Passengers[i].PassengerName); Content = Content.Replace("[证件号]", mOrder.Passengers[i].CardNo); if (Content.Length > 300) { throw new CustomException(400, "短信内容只能在300字数内!"); } int sendCount = Convert.ToInt32(Math.Ceiling((double)Content.Length / 64)); if (sendCount > businessman.SMS.RemainCount) { throw new CustomException(400, "你的短信不足,请充值购买!"); } businessman.SendMessage(currentUser.OperatorName, mOrder.Passengers[i].PassengerName, mOrder.Passengers[i].Mobile, Content); } unitOfWorkRepository.PersistUpdateOf(businessman); unitOfWork.Commit(); }
private bool SaleOrderRefund(int saleorderid, string money, string refundid) { var model = afterSaleOrderRepository.FindAll(p => p.Id == saleorderid).FirstOrDefault(); if (model == null) { WriteLog(string.Format("售后订单ID:{0}不存在", saleorderid), string.Empty); return(false); } if (model.ProcessStatus != EnumTfgProcessStatus.Refunding) { WriteLog(string.Format("当前订单状态不是可完成状态,订单ID:{0},当时订单状态{1}", saleorderid, model.ProcessStatus.ToEnumDesc()), string.Empty); return(false); } if (model is AnnulOrder || model is BounceOrder) { if (model is AnnulOrder) { AnnulOrder annulOrder = model as AnnulOrder; var list = annulOrder.BounceLines.ToList(); var bline = list.Where(p => p.ID == refundid).FirstOrDefault(); bline.RefundTime = DateTime.Now; bline.Status = EnumBoundRefundStatus.Refunded; if (list.All(p => p.Status == EnumBoundRefundStatus.Refunded)) { annulOrder.Passenger.ForEach(n => n.Status = EnumTfgPassengerStatus.AnnulTicketed); annulOrder.ProcessStatus = EnumTfgProcessStatus.Processed; annulOrder.CompletedTime = DateTime.Now; annulOrder.LockCurrentAccount = string.Empty; } } else if (model is BounceOrder) { BounceOrder bounceOrder = model as BounceOrder; var list = bounceOrder.BounceLines.ToList(); var bline = list.Where(p => p.ID == refundid).FirstOrDefault(); bline.RefundTime = DateTime.Now; bline.Status = EnumBoundRefundStatus.Refunded; if (list.All(p => p.Status == EnumBoundRefundStatus.Refunded)) { bounceOrder.Passenger.ForEach(n => n.Status = EnumTfgPassengerStatus.Refunded); bounceOrder.ProcessStatus = EnumTfgProcessStatus.Processed; bounceOrder.CompletedTime = DateTime.Now; bounceOrder.LockCurrentAccount = string.Empty; } } model.WriteLog(new OrderLog { IsShowLog = true, OperationContent = "订单退款完成,交易结束", OperationDatetime = DateTime.Now, OperationPerson = "系统" }); unitOfWorkRepository.PersistUpdateOf(model); unitOfWork.Commit(); if (model.ProcessStatus == EnumTfgProcessStatus.Processed) { MessageQueueManager.SendMessage(model.Id.ToString(), 1); } return(true); } WriteLog(string.Format("该订单不是退票单或者废票单"), string.Empty); return(false); }
public void Process(HttpRequest request, HttpResponse response) { Logger.WriteLog(LogType.INFO, request.Url.ToString()); string orderid = request.QueryString["orderId"]; string outPayNo = request.QueryString["payNo"]; string remark = request.QueryString["remark"]; string price = request.QueryString["price"]; //交易金额 string currentTime = request.QueryString["currentTime"]; string isRefund = request.QueryString["isRefund"]; //退款标志(0=支付1=退款) string signature = request.QueryString["signature"]; string payway = request.QueryString["payWay"]; //支付方式 int saleorderid = orderid.Substring(2).ToInt(); if (isRefund == "1") { int refundId = remark.ToInt(); /* * orderid:退款单ID * remark:退票单ID * price:金额 */ if (SaleOrderRefund(refundId, price, orderid)) { response.WriteLine("success"); } return; } var model = afterSaleOrderRepository.FindAll(p => p.Id == saleorderid).FirstOrDefault(); if (model == null) { Logger.WriteLog(LogType.INFO, string.Format("改签支付售后订单ID:{0}不存在", saleorderid)); return; } ChangeOrder changeOrder = null; if (model is ChangeOrder) { changeOrder = model as ChangeOrder; } if (changeOrder == null) { Logger.WriteLog(LogType.INFO, string.Format("售后订单ID:{0}不是改签类型", saleorderid)); return; } if (changeOrder.ProcessStatus != EnumTfgProcessStatus.ProcessingWaitPay) { return; } changeOrder.OutPayNo = outPayNo; changeOrder.PayTime = DateTime.Now; changeOrder.PayStatus = EnumChangePayStatus.Payed; changeOrder.ProcessStatus = EnumTfgProcessStatus.WaitIssue; changeOrder.PayWay = ExtHelper.GetPayMethod(payway); changeOrder.WriteLog(new OrderLog { IsShowLog = true, OperationContent = "订单改签支付完成,等待出票", OperationDatetime = DateTime.Now, OperationPerson = "系统" }); unitOfWorkRepository.PersistUpdateOf(changeOrder); unitOfWork.Commit(); response.WriteLine("success"); }