public TraOrderCancelResponseModel RequestCancelOrder(int orderId) { TraInterFaceOrderEntity traInterFaceOrderEntity = _traInterFaceOrderDal.Query <TraInterFaceOrderEntity>(n => n.OrderId == orderId.ToString()) .FirstOrDefault(); if (traInterFaceOrderEntity == null) { return(null); } int status = traInterFaceOrderEntity.Status; if (status == (int)OrderTypeEnum.OrderCancel) { return(null); } TraOrderCancelResponseModel responseModel = null; string isServer = AppSettingsHelper.GetAppSettings(AppSettingsEnum.IsServer); if (isServer == "T") { responseModel = _requestCancelOrderBll.RequestCancelOrder(new TraOrderCancelModel() { orderid = orderId.ToString(), transactionid = traInterFaceOrderEntity.Transactionid }); } else { responseModel = new TraOrderCancelResponseModel() { success = true }; } if (responseModel.success) { traInterFaceOrderEntity.Status = (int)OrderTypeEnum.OrderCancel; _traInterFaceOrderDal.Update <TraInterFaceOrderEntity>(traInterFaceOrderEntity, new[] { "Status" }); _traOrderOperateDal.Insert <TraOrderOperateEntity>(new TraOrderOperateEntity() { AfterOperateStatus = (int)OrderTypeEnum.OrderCancel, InterfaceId = traInterFaceOrderEntity.InterfaceId, Operate = (int)OrderTypeEnum.OrderCancel, OperateTime = traInterFaceOrderEntity.CreateTime, BeforOperateStatus = status }); } return(responseModel); }
public TraOrderConfirmResponseModel RequestPrintTicket(int orderId) { TraInterFaceOrderEntity traInterFaceOrderEntity = _traInterFaceOrderDal.Query <TraInterFaceOrderEntity>(n => n.OrderId == orderId.ToString()) .FirstOrDefault(); if (traInterFaceOrderEntity == null) { return(null); } int status = traInterFaceOrderEntity.Status; if (traInterFaceOrderEntity.CreateTime.AddMinutes(30) < DateTime.Now) { return(new TraOrderConfirmResponseModel() { success = false, msg = "该订单已经超过出票时间范围" }); } if (status == (int)OrderTypeEnum.MakingTicket) { return(new TraOrderConfirmResponseModel() { success = false, msg = "该订单已经发起出票请求了" }); } if (status == (int)OrderTypeEnum.TicketSuccess) { return(new TraOrderConfirmResponseModel() { success = false, msg = "该订单已经出票了" }); } if (status == (int)OrderTypeEnum.OrderCancel) { return(new TraOrderConfirmResponseModel() { success = false, msg = "该订单已经取消了" }); } string isServer = AppSettingsHelper.GetAppSettings(AppSettingsEnum.IsServer); TraOrderConfirmResponseModel responseModel = null; if (isServer == "T") { responseModel = _requestPrintTicketBll.RequestPrintTicket(new TraOrderConfirmModel() { orderid = orderId.ToString(), transactionid = traInterFaceOrderEntity.Transactionid }); } else { responseModel = new TraOrderConfirmResponseModel() { success = true, ordernumber = "ETest" + DateTime.Now.ToString("yyyyMMdd") + new Random().Next(1000) }; } if (responseModel.success) { traInterFaceOrderEntity.Status = (int)OrderTypeEnum.MakingTicket; traInterFaceOrderEntity.OrderNumber = responseModel.ordernumber; _traInterFaceOrderDal.Update <TraInterFaceOrderEntity>(traInterFaceOrderEntity, new[] { "Status", "OrderNumber" }); _traOrderOperateDal.Insert <TraOrderOperateEntity>(new TraOrderOperateEntity() { AfterOperateStatus = (int)OrderTypeEnum.TicketSuccess, InterfaceId = traInterFaceOrderEntity.InterfaceId, Operate = (int)OrderTypeEnum.MakingTicket, OperateTime = traInterFaceOrderEntity.CreateTime, BeforOperateStatus = status }); } return(responseModel); }