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   = 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 num2 = OrderHelper.DeleteOrders(text);

            if (num2 > 0)
            {
                string[] array3 = array;
                foreach (string orderId in array3)
                {
                    ShoppingProcessor.ClearOrderItemImages(orderId);
                }
                if (num == 1)
                {
                    base.ReturnSuccessResult(context, "删除订单成功,只能删除历史订单、未付款订单、已关闭订单和已退款订单", 0, true);
                }
                else
                {
                    base.ReturnSuccessResult(context, $"成功删除了{num2}个订单,只能删除历史订单、未付款订单、已关闭订单和已退款订单", 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("<th>用户备注</th>");
            stringBuilder.Append("<th>商品明细</th>");
            if (HiContext.Current.SiteSettings.IsOpenCertification)
            {
                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.OrderId, 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.ZipCode, 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.AdjustedFreight, false));
                stringBuilder2.Append(this.GetXLSFieldsTD(orderInfo.Points, false));
                stringBuilder2.Append(this.GetXLSFieldsTD(orderInfo.GetAmount(false), false));
                stringBuilder2.Append(this.GetXLSFieldsTD(orderInfo.GetCostPrice(), false));
                decimal profit = orderInfo.GetProfit();
                stringBuilder2.Append(this.GetXLSFieldsTD(profit, false));
                stringBuilder2.Append(this.GetXLSFieldsTD(orderInfo.PaymentType, true));
                stringBuilder2.Append(this.GetXLSFieldsTD(string.IsNullOrEmpty(orderInfo.StoreName) ? "平台店" : orderInfo.StoreName, 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));
                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());
                if (HiContext.Current.SiteSettings.IsOpenCertification)
                {
                    string argFields = string.Empty;
                    if (!string.IsNullOrWhiteSpace(orderInfo.IDNumber) && orderInfo.IsincludeCrossBorderGoods)
                    {
                        try
                        {
                            argFields = HiCryptographer.Decrypt(orderInfo.IDNumber);
                        }
                        catch
                        {
                        }
                    }
                    stringBuilder2.Append(this.GetXLSFieldsTD(argFields, true));
                }
                UserInvoiceDataInfo userInvoiceDataInfo = orderInfo.InvoiceInfo;
                if (userInvoiceDataInfo == null)
                {
                    userInvoiceDataInfo = new UserInvoiceDataInfo
                    {
                        InvoiceType           = orderInfo.InvoiceType,
                        InvoiceTitle          = orderInfo.InvoiceTitle,
                        InvoiceTaxpayerNumber = orderInfo.InvoiceTaxpayerNumber
                    };
                }
                stringBuilder2.Append(this.GetXLSFieldsTD(string.IsNullOrEmpty(userInvoiceDataInfo.InvoiceTitle.ToNullString()) ? "" : userInvoiceDataInfo.InvoceTypeText.ToNullString(), true));
                stringBuilder2.Append(this.GetXLSFieldsTD(userInvoiceDataInfo.InvoiceTitle.ToNullString(), true));
                stringBuilder2.Append(this.GetXLSFieldsTD(userInvoiceDataInfo.InvoiceTaxpayerNumber.ToNullString(), true));
                stringBuilder2.Append(this.GetXLSFieldsTD(userInvoiceDataInfo.RegisterAddress.ToNullString(), true));
                stringBuilder2.Append(this.GetXLSFieldsTD(userInvoiceDataInfo.RegisterTel.ToNullString(), true));
                stringBuilder2.Append(this.GetXLSFieldsTD(userInvoiceDataInfo.OpenBank.ToNullString(), true));
                stringBuilder2.Append(this.GetXLSFieldsTD(userInvoiceDataInfo.BankAccount.ToNullString(), true));
                stringBuilder2.Append(this.GetXLSFieldsTD(userInvoiceDataInfo.ReceiveName.ToNullString(), true));
                stringBuilder2.Append(this.GetXLSFieldsTD(userInvoiceDataInfo.ReceivePhone.ToNullString(), true));
                stringBuilder2.Append(this.GetXLSFieldsTD(userInvoiceDataInfo.ReceiveEmail.ToNullString(), true));
                stringBuilder2.Append(this.GetXLSFieldsTD(userInvoiceDataInfo.ReceiveRegionName.ToNullString(), true));
                stringBuilder2.Append(this.GetXLSFieldsTD(userInvoiceDataInfo.ReceiveAddress.ToNullString(), true));
                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();
        }