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 static ResponseBounceOrder ToResponseBounceOrder(this BounceOrder p) { return(Mapper.Map <BounceOrder, ResponseBounceOrder>(p)); }