/// <summary> /// 创建订单并支付 /// </summary> /// <param name="orderInfo"></param> private PageResult PayOrder(OrderCreateRequest request, Tbl_OTABusiness business) { OrderInfo orderInfo = request.Body.OrderInfo; OrderCreateResponse result = new OrderCreateResponse { Head = HeadResult.V1 }; var validResult = _orderService.ValidDataForOrderCreateRequest(request, result); if (!validResult.Status) { result.Head.Code = validResult.Code; result.Head.Describe = validResult.Message; return(PageDataResult.Data(result, business.Saltcode.ToString())); } List <int> productIds = orderInfo.TicketList.Select(a => a.ProductId).ToList(); var ticketIds = _otaTicketRelationService.GetTicketIds(business.Id, productIds); var tbl_Tickets = _ticketService.CheckIsTicketIds(ticketIds, business.ScenicId, orderInfo.VisitDate.ToDataTime()); var validDataResult = _orderService.ValidDataForOrderCreateRequest(request, tbl_Tickets); if (!validDataResult.Status) { result.Head.Code = validDataResult.Code; result.Head.Describe = validDataResult.Message; return(PageDataResult.Data(result, business.Saltcode.ToString())); } var tbl_Order = _orderService.AddOrder(orderInfo, business); var tbl_OrderDetails = _orderDetailService.AddOrderDetail(orderInfo, tbl_Order); _orderService.UpdateOrder(tbl_Order, tbl_OrderDetails); var tbl_Ticket_Testing = _ticketTestingService.addTicketTestings(tbl_Order, tbl_OrderDetails); _ticketService.UpdateTicketBySellCount(tbl_Tickets, tbl_OrderDetails); var tbl_SaleLog = _saleLogService.addSaleLog(tbl_Order); try { _orderService.BeginTran(); _orderService.Add(tbl_Order); _orderDetailService.Add(tbl_OrderDetails); _ticketTestingService.Add(tbl_Ticket_Testing); _ticketService.Update(tbl_Tickets); _noticeOrderConsumedService.Add(tbl_Order, tbl_OrderDetails, business); _orderTravelNoticeService.Add(tbl_Order, business); _saleLogService.Add(tbl_Order); _orderService.CommitTran(); } catch (Exception ex) { _orderService.RollbackTran(); result.Head.Code = "113021"; result.Head.Describe = "订单创建异常,订单创建失败"; return(PageDataResult.Data(result, business.Saltcode.ToString())); } result.Body = new OrderCreateInfo { OtaOrderId = tbl_Order.OTAOrderNo, OrderId = tbl_Order.OrderNo, OrderStatus = "OREDER_SUCCESS", Item = new List <OrderCreateItem>() }; tbl_OrderDetails = _orderDetailService.GetList(tbl_Order.OrderNo); foreach (var row in tbl_OrderDetails) { result.Body.Item.Add(new OrderCreateItem { OtaOrderDetailId = row.OtaOrderDetailId, ProductId = row.TicketId.ToString(), useDate = row.ValidityDateStart.ToString("yyyy-MM-dd"), CertificateNo = row.CertificateNO, quantity = 500000 }); } result.Head.Code = "000000"; result.Head.Describe = "成功"; return(PageDataResult.Data(result, business.Saltcode.ToString())); }
/// <summary> /// 创建单个产品订单并支付 /// </summary> /// <param name="request"></param> /// <param name="business"></param> /// <returns></returns> private PageResult PaySingleOrder(OrderSingleCreateRequest request, Tbl_OTABusiness business) { var orderInfo = request.Body.OrderInfo; OrderSingleCreateResponse result = new OrderSingleCreateResponse { Head = HeadResult.V1, Body = new OrderSingleCreateInfo { Inventory = 0 } }; var validResult = _orderService.ValidDataForOrderSingleCreateRequest(request, result); if (!validResult.Status) { result.Head.Code = validResult.Code; result.Head.Describe = validResult.Message; return(PageDataResult.Data(result, business.Saltcode.ToString())); } var tbl_Ticket = _ticketService.GetTicket(orderInfo.Ticket.ProductId, business.ScenicId, orderInfo.VisitDate.ToDataTime()); var validDataResult = _ticketService.ValidDataForOrderSingleCreateRequest(request, business, tbl_Ticket, result); if (!validDataResult.Status) { result.Head.Code = validDataResult.Code; result.Head.Describe = validDataResult.Message; return(PageDataResult.Data(result, business.Saltcode.ToString())); } var tbl_Order = _orderService.AddOrder(orderInfo, business); var tbl_OrderDetail = _orderDetailService.AddOrderDetail(orderInfo, tbl_Order, tbl_Ticket); _orderService.UpdateOrder(tbl_Order, tbl_OrderDetail); var tbl_Ticket_Testing = _ticketTestingService.AddTicketTesting(tbl_Order, tbl_OrderDetail); try { _orderService.BeginTran(); _orderService.Add(tbl_Order); _orderDetailService.Add(tbl_OrderDetail); _ticketTestingService.Add(tbl_Ticket_Testing); _ticketService.UpdateTicketBySellCount(tbl_Ticket, tbl_OrderDetail); _noticeOrderConsumedService.Add(tbl_Order, tbl_OrderDetail, business); _saleLogService.Add(tbl_Order); _orderService.CommitTran(); } catch (Exception ex) { _orderService.RollbackTran(); result.Head.Code = "113021"; result.Head.Describe = "订单创建异常,订单创建失败"; return(PageDataResult.Data(result, business.Saltcode.ToString())); } result.Head.Code = "000000"; result.Head.Describe = "成功"; result.Body.OrderId = tbl_Order.OrderNo; result.Body.OtaOrderId = tbl_Order.OTAOrderNo; result.Body.CertificateNo = tbl_OrderDetail.CertificateNO; result.Body.Code = tbl_OrderDetail.QRcode; result.Body.OrderStatus = "OREDER_SUCCESS"; return(PageDataResult.Data(result, business.Saltcode.ToString())); }