Beispiel #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("删除订单失败,只能删除历史订单、未付款订单、已关闭订单和已退款订单");
        }
Beispiel #2
0
        private void xlsContent(HttpContext context, List <OrderInfo> orderInfos)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("<table border='1'>");
            stringBuilder.Append("<thead><tr>");
            stringBuilder.Append("<th>订单编号</th>");
            stringBuilder.Append("<th>下单时间</th>");
            stringBuilder.Append("<th>付款时间</th>");
            stringBuilder.Append("<th>完成时间</th>");
            stringBuilder.Append("<th>用户名</th>");
            stringBuilder.Append("<th>等级</th>");
            stringBuilder.Append("<th>买家真实姓名</th>");
            stringBuilder.Append("<th>收货地址</th>");
            stringBuilder.Append("<th>详细地址</th>");
            stringBuilder.Append("<th>收货人姓名</th>");
            stringBuilder.Append("<th>电话号码</th>");
            stringBuilder.Append("<th>手机号码</th>");
            stringBuilder.Append("<th>发货时间</th>");
            stringBuilder.Append("<th>物流公司</th>");
            stringBuilder.Append("<th>发货单号</th>");
            stringBuilder.Append("<th>订单总金额</th>");
            stringBuilder.Append("<th>退款金额</th>");
            stringBuilder.Append("<th>运费</th>");
            stringBuilder.Append("<th>订单奖励积分</th>");
            stringBuilder.Append("<th>供货价</th>");
            stringBuilder.Append("<th>支付方式</th>");
            stringBuilder.Append("<th>订单状态</th>");
            stringBuilder.Append("<th>税金</th>");
            stringBuilder.Append("<th>积分抵扣</th>");
            stringBuilder.Append("<th>优惠券抵扣</th>");
            stringBuilder.Append("<th>优惠金额</th>");
            stringBuilder.Append("<th>优惠活动</th>");
            stringBuilder.Append("<th>购买件数</th>");
            stringBuilder.Append("<th>发货件数</th>");
            stringBuilder.Append("<th>用户备注</th>");
            stringBuilder.Append("<th>商品总价</th>");
            stringBuilder.Append("<th>商品明细</th>");
            stringBuilder.Append("<th>供应商</th>");
            stringBuilder.Append("</tr></thead>");
            StringBuilder stringBuilder2 = new StringBuilder();

            foreach (OrderInfo orderInfo in orderInfos)
            {
                stringBuilder2.Append("<tr>");
                stringBuilder2.Append(this.GetXLSFieldsTD(orderInfo.PayOrderId, true));
                stringBuilder2.Append(this.GetXLSFieldsTD(orderInfo.OrderDate, true));
                stringBuilder2.Append(this.GetXLSFieldsTD(orderInfo.PayDate, true));
                stringBuilder2.Append(this.GetXLSFieldsTD(orderInfo.FinishDate, true));
                stringBuilder2.Append(this.GetXLSFieldsTD(orderInfo.Username, true));
                stringBuilder2.Append(this.GetXLSFieldsTD(MemberHelper.GetMemberGradeName(orderInfo.UserId), true));
                stringBuilder2.Append(this.GetXLSFieldsTD(orderInfo.RealName, true));
                stringBuilder2.Append(this.GetXLSFieldsTD(orderInfo.ShippingRegion, true));
                stringBuilder2.Append(this.GetXLSFieldsTD(orderInfo.Address, true));
                stringBuilder2.Append(this.GetXLSFieldsTD(orderInfo.ShipTo, true));
                stringBuilder2.Append(this.GetXLSFieldsTD(orderInfo.TelPhone, true));
                stringBuilder2.Append(this.GetXLSFieldsTD(orderInfo.CellPhone, true));
                stringBuilder2.Append(this.GetXLSFieldsTD(orderInfo.ShipToDate, true));
                stringBuilder2.Append(this.GetXLSFieldsTD(orderInfo.ExpressCompanyName, true));
                stringBuilder2.Append(this.GetXLSFieldsTD(orderInfo.ShipOrderNumber, true));
                stringBuilder2.Append(this.GetXLSFieldsTD(orderInfo.GetTotal(false), false));
                stringBuilder2.Append(this.GetXLSFieldsTD(orderInfo.RefundAmount, false));
                stringBuilder2.Append(this.GetXLSFieldsTD(orderInfo.Freight, false));
                stringBuilder2.Append(this.GetXLSFieldsTD(orderInfo.Points, false));
                stringBuilder2.Append(this.GetXLSFieldsTD(orderInfo.GetCostPrice(), false));
                stringBuilder2.Append(this.GetXLSFieldsTD(orderInfo.PaymentType, true));
                stringBuilder2.Append(this.GetXLSFieldsTD(EnumDescription.GetEnumDescription((Enum)(object)orderInfo.OrderStatus, 0), true));
                stringBuilder2.Append(this.GetXLSFieldsTD(orderInfo.Tax, false));
                stringBuilder2.Append(this.GetXLSFieldsTD(orderInfo.DeductionMoney.HasValue ? orderInfo.DeductionMoney.Value : decimal.Zero, false));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(orderInfo.CouponValue, false));
                stringBuilder2.Append(this.GetXLSFieldsTD(orderInfo.ReducedPromotionAmount, false));
                string text = "";
                if (!string.IsNullOrEmpty(orderInfo.ReducedPromotionName))
                {
                    text = text + orderInfo.ReducedPromotionName + ";";
                }
                if (!string.IsNullOrEmpty(orderInfo.SentTimesPointPromotionName))
                {
                    text = text + orderInfo.SentTimesPointPromotionName + ";";
                }
                if (!string.IsNullOrEmpty(orderInfo.FreightFreePromotionName))
                {
                    text = text + orderInfo.FreightFreePromotionName + ";";
                }
                stringBuilder2.Append(this.GetXLSFieldsTD(text, true));
                stringBuilder2.Append(this.GetXLSFieldsTD(orderInfo.GetBuyQuantity(), false));
                int num = 0;
                if (orderInfo.LineItems != null && orderInfo.LineItems.Count > 0)
                {
                    num = orderInfo.LineItems.Values.Sum((LineItemInfo i) => i.ShipmentQuantity);
                }
                stringBuilder2.Append(this.GetXLSFieldsTD(num, false));
                stringBuilder2.Append(this.GetXLSFieldsTD(orderInfo.Remark, true));
                stringBuilder2.AppendFormat("<td>{0}</td>", orderInfo.GetAmount(false).F2ToString("f2"));
                StringBuilder stringBuilder3 = new StringBuilder();
                foreach (LineItemInfo value in orderInfo.LineItems.Values)
                {
                    stringBuilder3.Append(value.ItemDescription.ToNullString());
                    stringBuilder3.Append("[" + value.Quantity.ToNullString() + "]");
                    if (!string.IsNullOrEmpty(value.SKUContent))
                    {
                        stringBuilder3.Append("[" + value.SKUContent + "]");
                    }
                    if (!string.IsNullOrEmpty(value.PromotionName))
                    {
                        stringBuilder3.Append("(" + value.PromotionName + ")");
                    }
                    stringBuilder3.Append(";");
                }
                foreach (OrderGiftInfo gift in orderInfo.Gifts)
                {
                    stringBuilder3.Append(gift.GiftName.ToNullString());
                    stringBuilder3.Append("[" + gift.Quantity.ToNullString() + "]");
                    stringBuilder3.Append(";");
                }
                stringBuilder2.AppendFormat("<td>{0}</td>", stringBuilder3.ToString());
                UserInvoiceDataInfo invoiceInfo = orderInfo.InvoiceInfo;
                if (invoiceInfo == null)
                {
                    invoiceInfo = new UserInvoiceDataInfo
                    {
                        InvoiceType           = orderInfo.InvoiceType,
                        InvoiceTitle          = orderInfo.InvoiceTitle,
                        InvoiceTaxpayerNumber = orderInfo.InvoiceTaxpayerNumber
                    };
                }
                stringBuilder2.Append(this.GetXLSFieldsTD(orderInfo.ShipperName, false));
                stringBuilder2.Append("</tr>");
            }
            stringBuilder.AppendFormat("<tbody>{0}</tbody></table>", stringBuilder2.ToString());
            StringWriter stringWriter = new StringWriter();

            stringWriter.Write(stringBuilder);
            ManageOrder.DownloadFile(context.Response, stringWriter.GetStringBuilder(), "OrderList" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".xls");
            stringWriter.Close();
            context.Response.End();
        }