コード例 #1
0
        public ActionResult PayOrder(PayOrderModel model, int oid = -1)
        {
            OrderInfo orderInfo = AdminOrders.GetOrderByOid(oid);

            if (orderInfo == null)
            {
                return(PromptView("订单不存在"));
            }

            if (orderInfo.PayMode != 2)
            {
                return(PromptView(Url.Action("orderinfo", new { oid = oid }), "付款操作只适用于线下付款"));
            }
            if (orderInfo.OrderState != (int)OrderState.WaitPaying)
            {
                return(PromptView(Url.Action("orderinfo", new { oid = oid }), "当前不能支付订单"));
            }

            if (ModelState.IsValid)
            {
                AdminOrders.PayOrder(oid, OrderState.Confirming, model.PaySN, DateTime.Now);
                CreateOrderAction(oid, OrderActionType.Pay, "您的订单成功支付,请等待确认");
                AddMallAdminLog("支付订单", "支付订单,订单ID为:" + oid);
                return(PromptView(Url.Action("orderinfo", new { oid = oid }), "订单支付成功"));
            }
            ViewData["orderInfo"] = orderInfo;
            return(View(model));
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        public ActionResult OperateOrder(int oid = -1, int actionType = -1, string actionDes = "")
        {
            OrderInfo orderInfo = AdminOrders.GetOrderByOid(oid);

            if (orderInfo == null)
            {
                return(PromptView("订单不存在"));
            }

            if (actionDes.Length > 125)
            {
                OperateOrderModel model = new OperateOrderModel();
                model.Oid             = oid;
                model.OrderInfo       = orderInfo;
                model.OrderActionType = (OrderActionType)actionType;
                model.ActionDes       = actionDes;

                ModelState.AddModelError("actionDes", "最多只能输入125个字");
                return(View(model));
            }

            OrderActionType orderActionType = (OrderActionType)actionType;
            OrderState      orderState      = (OrderState)orderInfo.OrderState;

            if (orderActionType == OrderActionType.Pay)//支付订单
            {
                if (orderInfo.PayMode != 2)
                {
                    return(PromptView(Url.Action("orderinfo", new { oid = oid }), "付款操作只适用于线下付款"));
                }

                if (orderState != OrderState.WaitPaying)
                {
                    return(PromptView(Url.Action("orderinfo", new { oid = oid }), "当前不能支付订单"));
                }

                string paySN = WebHelper.GetFormString("paySN").Trim();
                if (paySN.Length < 1)
                {
                    OperateOrderModel model = new OperateOrderModel();
                    model.Oid             = oid;
                    model.OrderInfo       = orderInfo;
                    model.OrderActionType = orderActionType;
                    model.ActionDes       = actionDes;

                    ModelState.AddModelError("paySN", "请填写支付单号");
                    return(View(model));
                }
                AdminOrders.PayOrder(oid, OrderState.Confirming, paySN, DateTime.Now);
                CreateOrderAction(oid, orderActionType, actionDes.Length == 0 ? "您的订单成功支付" : actionDes);
            }
            else if (orderActionType == OrderActionType.Confirm)//确认订单
            {
                if (orderState != OrderState.Confirming)
                {
                    return(PromptView(Url.Action("orderinfo", new { oid = oid }), "买家还未付款,不能确认订单"));
                }

                AdminOrders.ConfirmOrder(orderInfo);
                CreateOrderAction(oid, orderActionType, actionDes.Length == 0 ? "您的订单已经确认" : actionDes);
            }
            else if (orderActionType == OrderActionType.PreProduct)//备货
            {
                if (orderState != OrderState.Confirmed)
                {
                    return(PromptView(Url.Action("orderinfo", new { oid = oid }), "订单还未确认,不能备货"));
                }

                AdminOrders.PreProduct(orderInfo);
                CreateOrderAction(oid, orderActionType, actionDes.Length == 0 ? "您的订单正在备货" : actionDes);
            }
            else if (orderActionType == OrderActionType.Send)//发货
            {
                if (orderState != OrderState.PreProducting)
                {
                    return(PromptView(Url.Action("orderinfo", new { oid = oid }), "订单还未备货,不能发货"));
                }

                string shipSN = WebHelper.GetFormString("shipSN").Trim();
                if (shipSN.Length < 1)
                {
                    OperateOrderModel model = new OperateOrderModel();
                    model.Oid             = oid;
                    model.OrderInfo       = orderInfo;
                    model.OrderActionType = orderActionType;
                    model.ActionDes       = actionDes;

                    ModelState.AddModelError("shipSN", "请填写配送单号");
                    return(View(model));
                }
                AdminOrders.SendOrder(oid, OrderState.Sended, shipSN, DateTime.Now);
                CreateOrderAction(oid, orderActionType, actionDes.Length == 0 ? "您的订单已经发货,单号为:" + shipSN : actionDes);
            }
            else if (orderActionType == OrderActionType.Complete)//完成订单
            {
                if (orderState != OrderState.Sended)
                {
                    return(PromptView(Url.Action("orderinfo", new { oid = oid }), "订单还未发货,不能完成订单"));
                }

                if (orderInfo.PayMode == 0)
                {
                    string paySN = WebHelper.GetFormString("paySN").Trim();
                    if (paySN.Length < 1)
                    {
                        OperateOrderModel model = new OperateOrderModel();
                        model.Oid             = oid;
                        model.OrderInfo       = orderInfo;
                        model.OrderActionType = orderActionType;
                        model.ActionDes       = actionDes;

                        ModelState.AddModelError("paySN", "请填写支付单号");
                        return(View(model));
                    }
                    else
                    {
                        AdminOrders.PayOrder(oid, OrderState.Sended, paySN, DateTime.Now);
                        CreateOrderAction(oid, orderActionType, actionDes.Length == 0 ? "您的订单成功支付" : actionDes);
                    }
                }

                PartUserInfo partUserInfo = Users.GetPartUserById(orderInfo.Uid);
                AdminOrders.CompleteOrder(ref partUserInfo, orderInfo, DateTime.Now, WorkContext.IP);
                CreateOrderAction(oid, orderActionType, actionDes.Length == 0 ? "已完成配送,感谢您在" + WorkContext.ShopConfig.ShopName + "购物,欢迎您再次光临" : actionDes);
            }
            else if (orderActionType == OrderActionType.Return)//退货
            {
                if (orderState != OrderState.Sended && orderState != OrderState.Completed)
                {
                    return(PromptView(Url.Action("orderinfo", new { oid = oid }), "订单当前不能退货"));
                }

                PartUserInfo partUserInfo = Users.GetPartUserById(orderInfo.Uid);
                AdminOrders.ReturnOrder(ref partUserInfo, orderInfo, WorkContext.Uid, DateTime.Now);
                CreateOrderAction(oid, orderActionType, actionDes.Length == 0 ? "订单已退货" : actionDes);
            }
            else if (orderActionType == OrderActionType.Lock)//锁定订单
            {
                if (!(orderState == OrderState.WaitPaying || (orderState == OrderState.Confirming && orderInfo.PayMode == 0)))
                {
                    return(PromptView(Url.Action("orderinfo", new { oid = oid }), "订单当前不能锁定"));
                }

                AdminOrders.LockOrder(orderInfo);
                CreateOrderAction(oid, orderActionType, "订单已锁定:" + actionDes);
            }
            else if (orderActionType == OrderActionType.Cancel)//取消订单
            {
                if (!(orderState == OrderState.WaitPaying || (orderState == OrderState.Confirming && orderInfo.PayMode == 0)))
                {
                    return(PromptView(Url.Action("orderinfo", new { oid = oid }), "订单当前不能取消"));
                }

                PartUserInfo partUserInfo = Users.GetPartUserById(orderInfo.Uid);
                AdminOrders.CancelOrder(ref partUserInfo, orderInfo, WorkContext.Uid, DateTime.Now);
                CreateOrderAction(oid, orderActionType, actionDes.Length == 0 ? "订单已取消" : actionDes);
            }
            else
            {
                return(PromptView(Url.Action("orderinfo", new { oid = oid }), "当前操作不存在"));
            }

            AddAdminOperateLog("操作订单", "操作订单,订单ID为:" + oid);
            return(PromptView(Url.Action("orderinfo", new { oid = oid }), "操作已完成"));
        }