Example #1
0
        public void Delete(HttpContext context)
        {
            string text = context.Request["ids"];

            if (string.IsNullOrWhiteSpace(text))
            {
                throw new HidistroAshxException("请选要删除的订单");
            }
            string[] array = text.Split(',');
            int      num   = 0;
            int      num2  = array.Count();

            string[] array2 = array;
            foreach (string text2 in array2)
            {
                OrderInfo orderInfo = new OrderDao().GetOrderInfo(text2.TrimStart('\'').TrimEnd('\''));
                if (orderInfo != null && orderInfo.OrderStatus == OrderStatus.WaitBuyerPay)
                {
                    MemberInfo user = Users.GetUser(orderInfo.UserId);
                    ManageOrder.ReturnPointOnClosed(orderInfo.OrderId, orderInfo.DeductionPoints, user);
                    ManageOrder.ReturnNeedPointOnClosed(orderInfo.OrderId, orderInfo.ExchangePoints, user);
                    if (!string.IsNullOrEmpty(orderInfo.CouponCode))
                    {
                        OrderHelper.ReturnCoupon(orderInfo.OrderId, orderInfo.CouponCode);
                    }
                    if (orderInfo.FightGroupId > 0)
                    {
                        foreach (LineItemInfo value in orderInfo.LineItems.Values)
                        {
                            VShopHelper.CloseOrderToReduceFightGroup(orderInfo.FightGroupId, value.SkuId, orderInfo.GetSkuQuantity(value.SkuId));
                        }
                    }
                }
            }
            int num3 = OrderHelper.DeleteOrders(text);

            if (num3 > 0)
            {
                string[] array3 = array;
                foreach (string orderId in array3)
                {
                    ShoppingProcessor.ClearOrderItemImages(orderId);
                }
                if (num2 == 1)
                {
                    base.ReturnSuccessResult(context, "删除订单成功,只能删除历史订单、未付款订单、已关闭订单和已退款订单", 0, true);
                }
                else
                {
                    base.ReturnSuccessResult(context, $"成功删除了{num3}个订单,只能删除历史订单、未付款订单、已关闭订单和已退款订单", 0, true);
                }
                return;
            }
            throw new HidistroAshxException("删除订单失败,只能删除历史订单、未付款订单、已关闭订单和已退款订单");
        }