public ActionResult CompleteOrder(CompleteOrderModel model, int oid = -1) { OrderInfo orderInfo = AdminOrders.GetOrderByOid(oid); if (orderInfo == null) { return(PromptView("订单不存在")); } if (orderInfo.OrderState != (int)OrderState.Sended) { return(PromptView(Url.Action("orderinfo", new { oid = oid }), "订单还未发货,不能完成订单")); } if (orderInfo.PayMode != 0) { return(PromptView(Url.Action("orderinfo", new { oid = oid }), "只有货到付款订单才需要填写支付单号")); } if (string.IsNullOrWhiteSpace(model.PaySN)) { ModelState.AddModelError("PaySN", "请填写支付单号"); } if (ModelState.IsValid) { AdminOrders.PayOrder(oid, OrderState.Sended, model.PaySN, DateTime.Now); PartUserInfo partUserInfo = Users.GetPartUserById(orderInfo.Uid); AdminOrders.CompleteOrder(ref partUserInfo, orderInfo, DateTime.Now, WorkContext.IP); CreateOrderAction(oid, OrderActionType.Complete, "订单已完成,感谢您在" + WorkContext.MallConfig.MallName + "购物,欢迎您再次光临"); AddMallAdminLog("完成订单", "完成订单,订单ID为:" + oid); return(PromptView(Url.Action("orderinfo", new { oid = oid }), "完成订单成功")); } ViewData["orderInfo"] = orderInfo; return(View(model)); }
public ActionResult CompleteOrder(int oid = -1) { OrderInfo orderInfo = AdminOrders.GetOrderByOid(oid); if (orderInfo == null) { return(PromptView("订单不存在")); } if (orderInfo.OrderState != (int)OrderState.Sended) { return(PromptView(Url.Action("orderinfo", new { oid = oid }), "订单还未发货,不能完成订单")); } if (orderInfo.PayMode != 0) { PartUserInfo partUserInfo = Users.GetPartUserById(orderInfo.Uid); AdminOrders.CompleteOrder(ref partUserInfo, orderInfo, DateTime.Now, WorkContext.IP); CreateOrderAction(oid, OrderActionType.Complete, "订单已完成,感谢您在" + WorkContext.MallConfig.MallName + "购物,欢迎您再次光临"); AddMallAdminLog("完成订单", "完成订单,订单ID为:" + oid); return(PromptView(Url.Action("orderinfo", new { oid = oid }), "完成订单成功")); } else { CompleteOrderModel model = new CompleteOrderModel(); ViewData["orderInfo"] = orderInfo; return(View(model)); } }
public ActionResult ShowOrderAdmin(int orderId) { if (IsActiveSession()) { //Getting header data var headerData = OrderProcessor.GetOrderById(orderId); OrderModel orderHeader = new OrderModel { Id = headerData.Id, Name = headerData.Name, Address = headerData.Address, City = headerData.City, State = headerData.State, Zip = headerData.Zip, CompanyName = headerData.CompanyName, DateCreated = headerData.DateCreated }; //Getting details data var detailsData = OrderProcessor.GetOrderProducts(orderId); List <OrderProductsModel> orderDetails = new List <OrderProductsModel>(); float total = 0.0f; int index = 0; foreach (var row in detailsData) { index++; orderDetails.Add(new OrderProductsModel { Id = row.Id, ProductCode = index.ToString(), ProductId = row.ProductId, ProductDescription = row.ProductDescription, ProductPrice = row.ProductPrice, ProductQty = row.ProductQty, ProductImagePath = row.ProductImagePath, OrderId = row.OrderId }); total = total + (row.ProductQty * row.ProductPrice); } CompleteOrderModel completeOrderModel = new CompleteOrderModel { OrderHeader = orderHeader, OrderDetails = orderDetails }; StoreViewModel storeViewModel = new StoreViewModel { StoreProducts = null, CartProducts = new List <CartProductsModel>() }; ViewBag.total = total; ViewBag.taxTotal = total * 0.25; ViewBag.grandTotal = total - (total * 0.25); return(View(completeOrderModel)); } return(RedirectToAction("Login", "Login", null)); }
public IActionResult EndOrderByID([FromBody] CompleteOrderModel model) { try { var command = new CompleteOrderCommand(model.orderId); _commandDispatcher.DispatchCommand(command); return(new OkObjectResult("Order complete successfully!")); } catch (AppException ex) { return(BadRequest(ex.Message)); } }
public virtual ActionResult Submit(CompleteOrderModel model) { try { #region Checking var gatewayRep = _paymentGatewayBusiness.GetPaymentGateway(model.PaymentGatewayId); if (!gatewayRep.IsSuccessful) { return(Json(new { IsSuccessful = false, Message = LocalMessage.RecordsNotFound })); } if (model.AddressId != null) { var addrRep = _addressBusiness.Find((User as ICurrentUserPrincipal).UserId, model.AddressId ?? 0); if (!addrRep.IsSuccessful) { return(Json(new { IsSuccessful = false, Message = LocalMessage.RecordsNotFound })); } } #endregion #region Fill Some Props of Model model.UserId = (User as ICurrentUserPrincipal).UserId; #endregion var findOrder = _orderBusiness.UpdateBeforePayment(model); if (!findOrder.IsSuccessful) { return(Json(findOrder)); } var result = PaymentFactory.GetInstance(gatewayRep.Result.BankName).Do(gatewayRep.Result, new TransactionModel { OrderId = model.OrderId, PaymentGatewayId = model.PaymentGatewayId, Price = findOrder.Result.Item2, UserId = (User as ICurrentUserPrincipal).UserId }); return(Json(result)); } catch (Exception e) { FileLoger.Error(e); return(Json(new { IsSuccessful = false, Message = LocalMessage.Error })); } }
public virtual JsonResult SubmitCompleteOrder(CompleteOrderModel model) { #region Checking var gatewayRep = _paymentGatewayBusiness.GetPaymentGateway(model.PaymentGatewayId); if (!gatewayRep.IsSuccessful) { return(Json(new { IsSuccessful = false, Message = LocalMessage.RecordsNotFound })); } if (model.AddressId != null) { var addrRep = _addressBusiness.Find((User as ICurrentUserPrincipal).UserId, model.AddressId ?? 0); if (!addrRep.IsSuccessful) { return(Json(new { IsSuccessful = false, Message = LocalMessage.RecordsNotFound })); } } #endregion #region Fill Some Props of Model model.UserId = (User as ICurrentUserPrincipal).UserId; #endregion var rep = _orderBusiness.CompleteOrder(model); if (!rep.IsSuccessful) { return(Json(rep)); } if (model.PaymentType == PaymentType.InPerson) { return(Json(new { rep.IsSuccessful, Result = Url.Action(MVC.Attachment.ActionNames.UploadAfterTransacttion, MVC.Attachment.Name, new { rep.Result.OrderId }) })); } var result = PaymentFactory.GetInstance(gatewayRep.Result.BankName).Do(gatewayRep.Result, new TransactionModel { OrderId = model.OrderId, PaymentGatewayId = model.PaymentGatewayId, Price = rep.Result.TotalPrice(), UserId = (User as ICurrentUserPrincipal).UserId }); return(Json(result)); }