private void DisplaySubmitOrderResults(SubmitOrderResult result) { if (result.HasException) { // TODO: Display exception info. MessageBox.Show(@"Exception Occurred."); return; } var lineItems = result.OrderItems; textOrderResultOrderLineItemID1.Text = lineItems[0].OrderLineItemId; textOrderResultProductID1.Text = lineItems[0].ProductIdentifier; textOrderResultQty1.Text = Convert.ToString(lineItems[0].QtyReserved); if (lineItems.Count < 2) { return; } textOrderResultOrderLineItemID2.Text = lineItems[1].OrderLineItemId; textOrderResultProductID2.Text = lineItems[1].ProductIdentifier; textOrderResultQty2.Text = Convert.ToString(lineItems[1].QtyReserved); if (lineItems.Count < 3) { return; } textOrderResultOrderLineItemID3.Text = lineItems[2].OrderLineItemId; textOrderResultProductID3.Text = lineItems[2].ProductIdentifier; textOrderResultQty3.Text = Convert.ToString(lineItems[2].QtyReserved); if (lineItems.Count < 4) { return; } textOrderResultOrderLineItemID4.Text = lineItems[3].OrderLineItemId; textOrderResultProductID4.Text = lineItems[3].ProductIdentifier; textOrderResultQty4.Text = Convert.ToString(lineItems[3].QtyReserved); if (lineItems.Count < 5) { return; } textOrderResultOrderLineItemID5.Text = lineItems[4].OrderLineItemId; textOrderResultProductID5.Text = lineItems[4].ProductIdentifier; textOrderResultQty5.Text = Convert.ToString(lineItems[4].QtyReserved); }
private SubmitOrderResult GetOrderResults() { var result = new SubmitOrderResult(); var lineItems = new List <LineItemStatus>(); try { using (var cmd = new SqlCommand("usp_GetOrderLineItems", cn)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@OrderID", SqlDbType.Int) { Value = id }); var reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { var lineItem = new LineItemStatus { OrderLineItemId = reader.GetString(OrderLineItemIdOrdinal), ProductIdentifier = reader.GetString(ProductIdentifierOrdinal), QtyReserved = reader.GetInt32(QtyReservedOrdinal) }; lineItems.Add(lineItem); } } else { throw new NoLineItemsFoundException(orderNumber); } } result.HasException = false; result.Exception = null; result.OrderItems = lineItems; } catch (SqlException ex) { result.HasException = true; result.Exception = ExceptionFactory.BuildSqlException(ex); } catch (Exception ex) { result.HasException = true; result.Exception = ExceptionFactory.BuildSystemException(ex); } return(result); }
public SubmitOrderResult SaveOrder(SubmitOrderRequest request) { var result = new SubmitOrderResult(); orderNumber = request.OrderNumber; try { trans = cn.BeginTransaction(); var orderId = InsertOrderRecord(request); foreach (var orderLineItem in request.LineItems) { InsertLineItems(orderId, orderLineItem); } trans.Commit(); trans.Dispose(); trans = null; result = GetOrderResults(); } catch (SqlException ex) { result.HasException = true; result.Exception = ExceptionFactory.BuildSqlException(ex); } catch (Exception ex) { result.HasException = true; result.Exception = ExceptionFactory.BuildSystemException(ex); } finally { if (trans != null) { trans.Rollback(); trans.Dispose(); } cn.Close(); cn.Dispose(); } return(result); }
public SubmitOrderResult SaveOrder(SubmitOrderRequest request) { var result = new SubmitOrderResult(); orderNumber = request.OrderNumber; try { trans = cn.BeginTransaction(); var orderId = InsertOrderRecord(request); foreach (var orderLineItem in request.LineItems) { InsertLineItems(orderId, orderLineItem); } trans.Commit(); trans.Dispose(); trans = null; result = GetOrderResults(); } catch (SqlException ex) { result.HasException = true; result.Exception = ExceptionFactory.BuildSqlException(ex); } catch (Exception ex) { result.HasException = true; result.Exception = ExceptionFactory.BuildSystemException(ex); } finally { if (trans != null) { trans.Rollback(); trans.Dispose(); } cn.Close(); cn.Dispose(); } return result; }
public JsonResult SubmitLimitOrder(CommonModel.OrderPostModel model) { model.CurrentUser = CurrentUser; model.PlatformType = (int)PlatformType.PC; var result = OrderApplication.GetLimitOrder(model); if (LimitOrderHelper.IsRedisCache()) { string id = ""; SubmitOrderResult r = LimitOrderHelper.SubmitOrder(result, out id); if (r == SubmitOrderResult.SoldOut) { throw new HimallException("已售空"); } else if (r == SubmitOrderResult.NoSkuId) { throw new InvalidPropertyException("创建订单的时候,SKU为空,或者数量为0"); } else if (r == SubmitOrderResult.NoData) { throw new InvalidPropertyException("参数错误"); } else if (r == SubmitOrderResult.NoLimit) { throw new InvalidPropertyException("没有限时购活动"); } else if (string.IsNullOrEmpty(id)) { throw new InvalidPropertyException("参数错误"); } else { OrderApplication.UpdateDistributionUserLink(GetDistributionUserLinkId().ToArray(), UserId); return(Json(new { success = true, Id = id })); } } else { var orderIds = OrderApplication.OrderSubmit(result); return(Json(new { success = true, orderIds = orderIds })); } }
/// <summary> /// submitOrder(提交订单) /// </summary> /// <returns></returns> private string SubmitOrder() { MessageInfo messageInfo = new MessageInfo() { Status = 1 }; try { if (CurrentMemberWeiXinDTO == null) { messageInfo.Message = "未获取到微信用户信息"; WCFClient.LoggerService.Error(string.Format("未获取到微信用户信息")); return(XMS.Core.Json.JsonSerializer.Serialize(messageInfo)); } string submitOrderInfo = Request["orderInfo"]; if (string.IsNullOrEmpty(submitOrderInfo)) { messageInfo.Message = "网络异常,稍后再试"; WCFClient.LoggerService.Error(string.Format("未获取到提交的订单信息")); return(XMS.Core.Json.JsonSerializer.Serialize(messageInfo)); } //bool outOfTime = Request["outOfTime"] == "0" ? false : true; XMS.Core.Container.LogService.Info("orderInfo:" + submitOrderInfo); SubmitOrderDTO submitOrderDTO = XMS.Core.Json.JsonSerializer.Deserialize <SubmitOrderDTO>(submitOrderInfo); if (submitOrderDTO == null) { messageInfo.Message = "网络异常,稍后再试"; WCFClient.LoggerService.Error(string.Format("未获取到提交的订单信息")); return(XMS.Core.Json.JsonSerializer.Serialize(messageInfo)); } DateTime?deliveryMaxTimeDate = null; DateTime?deliveryMinTimeDate = null; if (submitOrderDTO.deliveryMaxTime > 0) { deliveryMaxTimeDate = submitOrderDTO.deliveryMaxTime.MilliSecondsFrom1970ToDateTime(); } if (submitOrderDTO.deliveryMinTime > 0) { deliveryMinTimeDate = submitOrderDTO.deliveryMinTime.MilliSecondsFrom1970ToDateTime(); } List <AddOrderDTO> listOrder = new List <AddOrderDTO>(); submitOrderDTO.commodity.ForEach(item => { AddOrderDTO addOrder = new AddOrderDTO() { cityId = "上海", memberId = CurrentMemberWeiXinDTO.Id, commodityId = item.commodityId, couponId = submitOrderDTO.couponId.HasValue ? submitOrderDTO.couponId.Value : 0, deliveryMaxTime = deliveryMaxTimeDate, deliveryMinTime = deliveryMinTimeDate, memberAddressId = submitOrderDTO.addrssId, remark = submitOrderDTO.remark, serverFee = submitOrderDTO.serverFee, skuList = item.skuList == null ? null : item.skuList.ToArray(), resId = submitOrderDTO.resId, quantity = item.quantity, deliveryType = submitOrderDTO.deliveryType, isOutOfTime = !submitOrderDTO.outOfTime.HasValue ? false : (submitOrderDTO.outOfTime.Value == 0 ? false : true) }; listOrder.Add(addOrder); }); XMS.Core.ReturnValue <AddOrderResultDTO> addOrderResult = WCFClient.CoffeeService.AddOrder(listOrder.ToArray()); if (addOrderResult.Code != 200 || addOrderResult.Value == null) { messageInfo.Message = "网络异常稍后再试"; WCFClient.LoggerService.Error(string.Format(addOrderResult.RawMessage)); return(XMS.Core.Json.JsonSerializer.Serialize(messageInfo)); } if (addOrderResult.Value.order == null) { messageInfo.Message = "网络异常稍后再试"; WCFClient.LoggerService.Error(string.Format("提交订单失败")); return(XMS.Core.Json.JsonSerializer.Serialize(messageInfo)); } if (addOrderResult.Value.payInfo == null) { messageInfo.Message = "网络异常稍后再试"; WCFClient.LoggerService.Error(string.Format("获取支付信息失败")); return(XMS.Core.Json.JsonSerializer.Serialize(messageInfo)); } SubmitOrderResult submitOrderResult = new SubmitOrderResult() { id = addOrderResult.Value.order.id, payInfo = addOrderResult.Value.payInfo.payUrl }; messageInfo.Status = 0; messageInfo.Message = "success"; messageInfo.Data = submitOrderResult; } catch (Exception ex) { messageInfo.Status = 1; messageInfo.Message = "网络异常,稍后重试"; WCFClient.LoggerService.Error(string.Format("提交订单错误,详细情况:{0}", ex.Message)); } return(XMS.Core.Json.JsonSerializer.Serialize(messageInfo)); }
private string ContinuePay() { MessageInfo messageInfo = new MessageInfo() { Status = 1, Data = false }; try { if (CurrentMemberWeiXinDTO == null) { messageInfo.Message = "未获取到微信用户信息"; WCFClient.LoggerService.Error(string.Format("未获取到微信用户信息")); return(XMS.Core.Json.JsonSerializer.Serialize(messageInfo)); } int orderId = int.Parse(Request["orderId"]); XMS.Core.ReturnValue <AddOrderResultDTO> getOrderResult = WCFClient.CoffeeService.GetPayInfo(orderId, CurrentMemberWeiXinDTO.Id); if (getOrderResult.Code == 1000) { messageInfo.Message = getOrderResult.Message; WCFClient.LoggerService.Error(string.Format(getOrderResult.RawMessage)); return(XMS.Core.Json.JsonSerializer.Serialize(messageInfo)); } if (getOrderResult.Code != 200 || getOrderResult.Value == null) { messageInfo.Message = "网络异常稍后再试"; WCFClient.LoggerService.Error(string.Format(getOrderResult.RawMessage)); return(XMS.Core.Json.JsonSerializer.Serialize(messageInfo)); } if (getOrderResult.Value.order == null) { messageInfo.Message = "网络异常稍后再试"; WCFClient.LoggerService.Error(string.Format("获取订单失败")); return(XMS.Core.Json.JsonSerializer.Serialize(messageInfo)); } if (getOrderResult.Value.payInfo == null) { messageInfo.Message = "网络异常稍后再试"; WCFClient.LoggerService.Error(string.Format("获取支付信息失败")); return(XMS.Core.Json.JsonSerializer.Serialize(messageInfo)); } SubmitOrderResult submitOrderResult = new SubmitOrderResult() { id = getOrderResult.Value.order.id, payInfo = getOrderResult.Value.payInfo.payUrl }; messageInfo.Status = 0; messageInfo.Message = "success"; messageInfo.Data = submitOrderResult; } catch (Exception ex) { messageInfo.Status = 1; messageInfo.Message = "网络异常,稍后重试"; WCFClient.LoggerService.Error(string.Format("获取验证码错误,详细情况:{0}", ex.Message)); } return(XMS.Core.Json.JsonSerializer.Serialize(messageInfo)); }
private SubmitOrderResult GetOrderResults() { var result = new SubmitOrderResult(); var lineItems = new List<LineItemStatus>(); try { using (var cmd = new SqlCommand("usp_GetOrderLineItems", cn)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@OrderID", SqlDbType.Int) { Value = id }); var reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { var lineItem = new LineItemStatus { OrderLineItemId = reader.GetString(OrderLineItemIdOrdinal), ProductIdentifier = reader.GetString(ProductIdentifierOrdinal), QtyReserved = reader.GetInt32(QtyReservedOrdinal) }; lineItems.Add(lineItem); } } else { throw new NoLineItemsFoundException(orderNumber); } } result.HasException = false; result.Exception = null; result.OrderItems = lineItems; } catch (SqlException ex) { result.HasException = true; result.Exception = ExceptionFactory.BuildSqlException(ex); } catch (Exception ex) { result.HasException = true; result.Exception = ExceptionFactory.BuildSystemException(ex); } return result; }