Example #1
0
 public void GetOrderDetailsDataStatus(Tbl_OrderDetail tbl_OrderDetail, OrderQueryTicketInfo orderQueryTicketInfo)
 {
     if (tbl_OrderDetail.OrderStatus == (int)OrderDetailsDataStatus.Success || tbl_OrderDetail.OrderStatus == (int)OrderDetailsDataStatus.Activate)
     {
         orderQueryTicketInfo.Status      = "OREDER_SUCCESS"; //已支付未消费
         orderQueryTicketInfo.OrderStatus = (int)TicketOrderStatus.Success;
     }
     else if (tbl_OrderDetail.OrderStatus == (int)OrderDetailsDataStatus.Canncel || tbl_OrderDetail.OrderStatus == (int)OrderDetailsDataStatus.Refund)
     {
         orderQueryTicketInfo.Status      = "OREDER_CANCEL";//已取消
         orderQueryTicketInfo.OrderStatus = (int)TicketOrderStatus.Canncel;
     }
     else if (tbl_OrderDetail.OrderStatus == (int)OrderDetailsDataStatus.Consume || tbl_OrderDetail.OrderStatus == (int)OrderDetailsDataStatus.IsTaken)
     {
         orderQueryTicketInfo.Status      = "OREDER_CONSUMED";//已消费
         orderQueryTicketInfo.OrderStatus = (int)TicketOrderStatus.Consume;
     }
     else if (tbl_OrderDetail.CanRefundTime < DateTime.Now.Date)
     {
         orderQueryTicketInfo.Status      = "OREDER_OVERDUE";//已过期
         orderQueryTicketInfo.OrderStatus = (int)TicketOrderStatus.Expired;
     }
 }
        private PageResult QueryOrder(OrderQueryRequest request, Tbl_OTABusiness business)
        {
            string             orderId = request.Body.OrderId;
            OrderQueryResponse result  = new OrderQueryResponse
            {
                Head = HeadResult.V1,
                Body = new OrderQueryBody()
            };
            var validResult = _orderService.ValidDataForOrderQueryRequest(request);

            if (!validResult.Status)
            {
                result.Head.Code     = validResult.Code;
                result.Head.Describe = validResult.Message;
                return(PageDataResult.Data(result, business.Saltcode.ToString()));
            }
            var tbl_Order = _orderService.Get(orderId, request.Body.OtaOrderId);

            if (tbl_Order == null)
            {
                result.Head.Code     = "115002";
                result.Head.Describe = "查询订单异常,订单不存在";
                return(PageDataResult.Data(result, business.Saltcode.ToString()));
            }
            result.Body.OrderInfo = new OrderQueryInfo
            {
                OrderId       = tbl_Order.OrderNo,
                OrderQuantity = tbl_Order.BookCount,
                OrderPrice    = tbl_Order.TotalAmount,
                VisitDate     = tbl_Order.ValidityDateEnd.ToString("yyyy-MM-dd"),
                ContactPerson = new OrderQueryContactPerson
                {
                    Name     = tbl_Order.Linkman,
                    Mobile   = tbl_Order.Mobile,
                    CardNo   = tbl_Order.IDCard,
                    CardType = ((CredentialsStatus)tbl_Order.IDType).GetDescriptionByName()
                },
                EticketInfo = new List <OrderQueryTicketInfo>()
            };
            var orderDetails = _orderDetailService.GetList(tbl_Order.OrderNo);
            var tickets      = _ticketService.GetTickets(orderDetails.Select(a => a.TicketId).ToList());

            foreach (var row in orderDetails)
            {
                var ticket = tickets.FirstOrDefault(a => a.TicketId == row.TicketId);
                var orderQueryTicketInfo = new OrderQueryTicketInfo
                {
                    OtaOrderDetailId = row.OtaOrderDetailId,
                    EticektNo        = row.CertificateNO,
                    SellPrice        = row.Price,
                    MarketPrice      = ticket == null ? 0 : ticket.MarkPrice.Value,
                    EticektSend      = 1,
                    ProductId        = row.TicketId,
                    ProductName      = row.TicketName,
                    EticketQuantity  = row.Quantity,
                    UseQuantity      = row.UsedQuantity == null ? 0 : row.UsedQuantity.Value,
                    CreateTime       = row.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"),
                    CancelTime       = row.CancelTime.HasValue ? row.CancelTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
                    DelayCheckTime   = row.DelayCheckTime.HasValue ? row.DelayCheckTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
                    UseEndDate       = row.ValidityDateStart.ToString("yyyy-MM-dd"),
                    UseStartDate     = row.ValidityDateEnd.ToString("yyyy-MM-dd"),
                };
                _orderDetailService.GetOrderDetailsDataStatus(row, orderQueryTicketInfo);
                result.Body.OrderInfo.EticketInfo.Add(orderQueryTicketInfo);
            }
            result.Head.Code     = "000000";
            result.Head.Describe = "成功";
            return(PageDataResult.Data(result, business.Saltcode.ToString()));
        }