Пример #1
0
        private DataGridViewModel <Dictionary <string, object> > GetDataList(OrderQuery query)
        {
            DateTime now  = DateTime.Now;
            DateTime now2 = DateTime.Now;
            PageModel <OrderModel> pageModel = null;
            DataGridViewModel <Dictionary <string, object> > dataGridViewModel = new DataGridViewModel <Dictionary <string, object> >();
            TimeSpan timeSpan;
            double   totalMilliseconds;

            if (query != null)
            {
                now               = DateTime.Now;
                pageModel         = OrderHelper.GetOrderList(query);
                now2              = DateTime.Now;
                timeSpan          = now2 - now;
                totalMilliseconds = timeSpan.TotalMilliseconds;
                Globals.AppendLog("数据库查询花费时间", totalMilliseconds.ToString(), "", "GetDataList");
                now = DateTime.Now;
                string[] orderIds = (from d in pageModel.Models
                                     select d.OrderId).ToArray();
                List <RefundInfo> refundInfos = TradeHelper.GetRefundInfos(orderIds);
                dataGridViewModel.rows = DataHelper.ListToDictionary(pageModel.rows);
                now2 = DateTime.Now;
                dataGridViewModel.total = pageModel.total;
                int num = 0;
                now = DateTime.Now;
                foreach (Dictionary <string, object> row in dataGridViewModel.rows)
                {
                    OrderModel order = (from o in pageModel.rows
                                        where o.OrderId == row["OrderId"].ToNullString()
                                        select o).FirstOrDefault();
                    row.Add("OrderStatusText", OrderHelper.GetOrderStatusText(order.OrderStatus, order.ShippingModeId, order.IsConfirm, order.Gateway, 0, order.PreSaleId, order.DepositDate, false, order.ItemStatus, order.OrderType));
                    row.Add("canCheckTake", order.CanConfirmTakeCode());
                    row.Add("canCloseOrder", order.CanClose(base.CurrentSiteSetting.OpenMultStore, false));
                    row.Add("canOfflineReceipt", this.CanConfirmOfflineReceipt(order, false));
                    row.Add("CanEditPrice", this.CanEditPrice(order));
                    row.Add("canCancelSendGoods", order.OrderStatus == OrderStatus.SellerAlreadySent && (order.DadaStatus == DadaStatus.WaitOrder || order.DadaStatus == DadaStatus.WaitTake));
                    row.Add("dadaState", (order.DadaStatus != 0) ? ((Enum)(object)order.DadaStatus).ToDescription() : "");
                    row.Add("InvoiceTypeText", string.IsNullOrEmpty(order.InvoiceTitle) ? "" : EnumDescription.GetEnumDescription((Enum)(object)order.InvoiceType, 0));
                    bool flag = this.CanSendGoods(order, base.CurrentSiteSetting.OpenMultStore);
                    if (base.CurrentSiteSetting.OpenMultStore && order.StoreId != 0)
                    {
                        flag = false;
                    }
                    row.Add("canFinishTrade", order.OrderStatus == OrderStatus.SellerAlreadySent && order.ItemStatus == OrderItemStatus.Nomarl);
                    bool flag2 = false;
                    if (base.CurrentSiteSetting.OpenMultStore && order.CountDownBuyId == 0 && order.BundlingId == 0 && order.GroupBuyId == 0 && order.FightGroupId == 0 && order.PreSaleId == 0 && order.ItemStatus == OrderItemStatus.Nomarl && (order.OrderStatus == OrderStatus.BuyerAlreadyPaid || (order.OrderStatus == OrderStatus.WaitBuyerPay && order.Gateway == "hishop.plugins.payment.podrequest")))
                    {
                        if (order.StoreId == -1)
                        {
                            flag2 = (order.BuyQuantity > 0);
                        }
                        else if (order.StoreId > 0)
                        {
                            flag2 = !order.IsConfirm;
                        }
                        else if (order.StoreId == 0)
                        {
                            flag2 = (order.ShippingModeId != -2 && order.BuyQuantity > 0);
                        }
                    }
                    row.Add("CanAllotStore", flag2);
                    RefundInfo refundInfo = refundInfos.FirstOrDefault((RefundInfo d) => d.OrderId == order.OrderId);
                    if (refundInfo != null)
                    {
                        row.Add("IsCheckRefund", order.OrderStatus == OrderStatus.ApplyForRefund && !order.IsStoreCollect);
                        row.Add("RefundId", refundInfo.RefundId);
                    }
                    bool   flag3  = false;
                    string value  = string.Empty;
                    string value2 = string.Empty;
                    if (order.ItemStatus != 0 || order.OrderStatus == OrderStatus.ApplyForRefund)
                    {
                        if (refundInfo != null && order.OrderStatus == OrderStatus.ApplyForRefund)
                        {
                            flag3  = true;
                            value2 = "订单已申请退款";
                            value  = "RefundApplyDetail?RefundId=" + refundInfo.RefundId;
                        }
                        else
                        {
                            if (order.ItemStatus == OrderItemStatus.HasReturnOrReplace)
                            {
                                value2 = "订单中有商品正在退货/换货中";
                            }
                            else if (order.ReturnedCount > 0)
                            {
                                value2 = "订单中有商品已退货完成";
                            }
                            else if (order.ItemStatus == OrderItemStatus.HasReplace)
                            {
                                value2 = "订单中有商品正在进行换货操作";
                            }
                            else if (order.ItemStatus == OrderItemStatus.HasReturn)
                            {
                                value2 = "订单中有商品正在进行退货操作";
                            }
                            if (order.AfterSaleCount > 0)
                            {
                                flag3 = true;
                                value = ((order.ReturnId <= 0) ? ("ReplaceApplyDetail?ReplaceId=" + order.ReplaceId) : ("ReturnApplyDetail?ReturnId=" + order.ReturnId));
                            }
                        }
                    }
                    row.Add("IsShowRefundIcon", flag3);
                    row.Add("RefundOperUrl", value);
                    row.Add("RefundTips", value2);
                    bool flag4 = false;
                    if (order.FightGroupId > 0)
                    {
                        FightGroupInfo fightGroup = VShopHelper.GetFightGroup(order.FightGroupId);
                        if (fightGroup != null)
                        {
                            row["FightGroupActivityId"] = fightGroup.FightGroupActivityId;
                            if (fightGroup.Status == FightGroupStatus.FightGroupIn && order.OrderStatus != OrderStatus.WaitBuyerPay && order.OrderStatus != OrderStatus.Closed)
                            {
                                flag4 = true;
                            }
                        }
                    }
                    row.Add("FightGrouping", flag4);
                    row.Add("canSendGoods", flag);
                    if (order.BuyQuantity <= 0)
                    {
                        if (order.UserAwardRecordsId > 0)
                        {
                            row.Add("IsAwardOrder", true);
                        }
                        else
                        {
                            row.Add("IsGiftOrder", true);
                        }
                    }
                    if (order.PreSaleId > 0 && order.OrderStatus == OrderStatus.BuyerAlreadyPaid)
                    {
                        ProductPreSaleInfo productPreSaleInfo = ProductPreSaleHelper.GetProductPreSaleInfo(order.PreSaleId);
                        if (productPreSaleInfo != null)
                        {
                            string   value3 = "";
                            DateTime dateTime;
                            if (productPreSaleInfo.DeliveryDate.HasValue)
                            {
                                dateTime = productPreSaleInfo.DeliveryDate.Value;
                                value3   = "<span>预计发货时间:" + dateTime.ToString("yyyy-MM-dd") + "</span>";
                            }
                            else
                            {
                                DateTime payDate = order.PayDate;
                                if (order.PayDate != DateTime.MinValue)
                                {
                                    dateTime = order.PayDate;
                                    dateTime = dateTime.AddDays((double)productPreSaleInfo.DeliveryDays);
                                    value3   = "<span>预计发货时间:" + dateTime.ToString("yyyy-MM-dd") + "</span>";
                                }
                            }
                            row.Add("SendGoodsTips", value3);
                        }
                    }
                    row.Add("IsOpenCertification", HiContext.Current.SiteSettings.IsOpenCertification && order.IsincludeCrossBorderGoods);
                    if (row["IDStatus"] != null)
                    {
                        row["IDStatus"] = order.IDStatus;
                    }
                    num++;
                }
            }
            now2              = DateTime.Now;
            timeSpan          = now2 - now;
            totalMilliseconds = timeSpan.TotalMilliseconds;
            Globals.AppendLog("数据计算花费时间", totalMilliseconds.ToString(), "", "GetDataList2");
            return(dataGridViewModel);
        }