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

            if (orderInfo == null)
            {
                return(PromptView("订单不存在"));
            }
            if (orderInfo.StoreId != WorkContext.StoreId)
            {
                return(PromptView("不能操作其它店铺的订单"));
            }
            if (!(orderInfo.OrderState == (int)OrderState.WaitPaying || (orderInfo.OrderState == (int)OrderState.Confirming && orderInfo.PayMode == 0)))
            {
                return(PromptView(Url.Action("orderinfo", new { oid = oid }), "不能修改订单配送费用"));
            }

            if (ModelState.IsValid)
            {
                decimal change = model.ShipFee - orderInfo.ShipFee;
                Orders.UpdateOrderShipFee(orderInfo.Oid, model.ShipFee, orderInfo.OrderAmount + change, orderInfo.SurplusMoney + change);
                CreateOrderAction(oid, OrderActionType.UpdateShipFee, "您订单的配送费用已经修改");
                AddStoreAdminLog("更新订单配送费用", "更新订单配送费用,订单ID为:" + oid);

                if ((orderInfo.SurplusMoney + change) <= 0)
                {
                    AdminOrders.UpdateOrderState(oid, OrderState.Confirming);
                }

                return(PromptView(Url.Action("orderinfo", new { oid = oid }), "更新订单配送费用成功"));
            }

            ViewData["orderInfo"] = orderInfo;
            return(View(model));
        }
コード例 #2
0
        public ActionResult UpdateOrderDiscount(UpdateOrderDiscountModel model, int oid = -1)
        {
            OrderInfo orderInfo = AdminOrders.GetOrderByOid(oid);

            if (orderInfo == null)
            {
                return(PromptView("订单不存在"));
            }
            if (!(orderInfo.OrderState == (int)OrderState.WaitPaying || (orderInfo.OrderState == (int)OrderState.Confirming && orderInfo.PayMode == 0)))
            {
                return(PromptView(Url.Action("orderinfo", new { oid = oid }), "不能修改订单折扣"));
            }

            if (model.Discount > (orderInfo.SurplusMoney + orderInfo.Discount))
            {
                ModelState.AddModelError("Discount", "折扣不能大于需支付金额");
            }

            if (ModelState.IsValid)
            {
                decimal surplusMoney = orderInfo.SurplusMoney + orderInfo.Discount - model.Discount;
                Orders.UpdateOrderDiscount(orderInfo.Oid, model.Discount, surplusMoney);
                CreateOrderAction(oid, OrderActionType.UpdateDiscount, "您订单的折扣已经修改");
                AddMallAdminLog("更新订单折扣", "更新订单折扣,订单ID为:" + oid);

                if (surplusMoney <= 0)
                {
                    AdminOrders.UpdateOrderState(oid, OrderState.Confirming);
                }

                return(PromptView(Url.Action("orderinfo", new { oid = oid }), "更新订单折扣成功"));
            }
            ViewData["orderInfo"] = orderInfo;
            return(View(model));
        }