Ejemplo n.º 1
0
        public ActionResult Detail(long id)
        {
            OrderInfo       order          = ServiceHelper.Create <IOrderService>().GetOrder(id, base.CurrentUser.Id);
            IShopService    shopService    = ServiceHelper.Create <IShopService>();
            IProductService productService = ServiceHelper.Create <IProductService>();
            OrderDetail     orderDetail    = new OrderDetail()
            {
                ShopName   = shopService.GetShop(order.ShopId, false).ShopName,
                ShopId     = order.ShopId,
                OrderItems =
                    from item in order.OrderItemInfo
                    select new OrderItem()
                {
                    ProductId    = item.ProductId,
                    ProductName  = item.ProductName,
                    Count        = item.Quantity,
                    Price        = item.SalePrice,
                    ProductImage = productService.GetProduct(item.ProductId).GetImage(ProductInfo.ImageSize.Size_100, 1)
                }
            };

            ViewBag.Detail = orderDetail;
            ViewBag.Bonus  = (dynamic)null;
            if (base.PlatformType == ChemCloud.Core.PlatformType.WeiXin)
            {
                IShopBonusService  shopBonusService = ServiceHelper.Create <IShopBonusService>();
                ShopBonusGrantInfo grantByUserOrder = shopBonusService.GetGrantByUserOrder(id, base.CurrentUser.Id);

                if (grantByUserOrder != null)
                {
                    ViewBag.Bonus = grantByUserOrder;
                    dynamic  viewBag = base.ViewBag;
                    object[] host    = new object[] { "http://", base.Request.Url.Host, "/m-weixin/shopbonus/index/", shopBonusService.GetGrantIdByOrderId(id) };
                    viewBag.ShareHref = string.Concat(host);
                }
            }
            ViewBag.Logo = base.CurrentSiteSetting.Logo;
            return(View(order));
        }
Ejemplo n.º 2
0
        public ActionResult Index(string orderDate, string keywords, string orderids, DateTime?startDateTime, DateTime?endDateTime, int?orderStatus, int pageNo = 1, int pageSize = 10)
        {
            OrderInfo.OrderOperateStatus?nullable;
            ViewBag.Grant = (object)null;
            if (!string.IsNullOrEmpty(orderids) && orderids.IndexOf(',') <= 0)
            {
                ViewBag.Grant = ServiceHelper.Create <IShopBonusService>().GetByOrderId(long.Parse(orderids));
            }
            DateTime?nullable1 = startDateTime;
            DateTime?nullable2 = endDateTime;

            if (!string.IsNullOrEmpty(orderDate) && orderDate.ToLower() != "all")
            {
                string lower = orderDate.ToLower();
                string str   = lower;
                if (lower != null)
                {
                    if (str == "threemonth")
                    {
                        nullable1 = new DateTime?(DateTime.Now.AddMonths(-3));
                    }
                    else if (str == "halfyear")
                    {
                        nullable1 = new DateTime?(DateTime.Now.AddMonths(-6));
                    }
                    else if (str == "year")
                    {
                        nullable1 = new DateTime?(DateTime.Now.AddYears(-1));
                    }
                    else if (str == "yearago")
                    {
                        nullable2 = new DateTime?(DateTime.Now.AddYears(-1));
                    }
                }
            }
            if (orderStatus.HasValue)
            {
                int?nullable3 = orderStatus;
                if ((nullable3.GetValueOrDefault() != 0 ? false : nullable3.HasValue))
                {
                    orderStatus = null;
                }
            }
            OrderQuery orderQuery = new OrderQuery()
            {
                StartDate = nullable1,
                EndDate   = nullable2
            };
            OrderQuery orderQuery1 = orderQuery;
            int?       nullable4   = orderStatus;

            if (nullable4.HasValue)
            {
                nullable = new OrderInfo.OrderOperateStatus?((OrderInfo.OrderOperateStatus)nullable4.GetValueOrDefault());
            }
            else
            {
                nullable = null;
            }
            orderQuery1.Status        = nullable;
            orderQuery.UserId         = new long?(base.CurrentUser.Id);
            orderQuery.SearchKeyWords = keywords;
            orderQuery.PageSize       = pageSize;
            orderQuery.PageNo         = pageNo;
            PageModel <OrderInfo> orders     = ServiceHelper.Create <IOrderService>().GetOrders <OrderInfo>(orderQuery, null);
            PagingInfo            pagingInfo = new PagingInfo()
            {
                CurrentPage  = pageNo,
                ItemsPerPage = pageSize,
                TotalItems   = orders.Total
            };

            ViewBag.pageInfo = pagingInfo;
            ViewBag.UserId   = base.CurrentUser.Id;
            SiteSettingsInfo  siteSettings     = ServiceHelper.Create <ISiteSettingService>().GetSiteSettings();
            IShopBonusService shopBonusService = ServiceHelper.Create <IShopBonusService>();

            ViewBag.SalesRefundTimeout = siteSettings.SalesReturnTimeout;
            List <OrderInfo>             list           = orders.Models.ToList();
            ICashDepositsService         create         = Instance <ICashDepositsService> .Create;
            IEnumerable <OrderListModel> orderListModel =
                from item in list
                select new OrderListModel()
            {
                Id                 = item.Id,
                ActiveType         = item.ActiveType,
                OrderType          = item.OrderType,
                Address            = item.Address,
                CellPhone          = item.CellPhone,
                CloseReason        = item.CloseReason,
                CommisTotalAmount  = item.CommisAmount,
                DiscountAmount     = item.DiscountAmount,
                ExpressCompanyName = item.ExpressCompanyName,
                FinishDate         = item.FinishDate,
                Freight            = item.Freight,
                GatewayOrderId     = item.GatewayOrderId,
                IntegralDiscount   = item.IntegralDiscount,
                UserId             = item.UserId,
                ShopId             = item.ShopId,
                ShopName           = item.ShopName,
                ShipTo             = item.ShipTo,
                OrderTotalAmount   = item.OrderTotalAmount,
                PaymentTypeName    = item.PaymentTypeName,
                OrderStatus        = item.OrderStatus,
                RefundStats        = item.RefundStats,
                OrderCommentInfo   = item.OrderCommentInfo,
                OrderDate          = item.OrderDate,
                OrderItemList      =
                    from oItem in item.OrderItemInfo
                    select new OrderItemListModel()
                {
                    ProductId              = oItem.ProductId,
                    Color                  = oItem.Color,
                    Size                   = oItem.Size,
                    Version                = oItem.Version,
                    ProductName            = oItem.ProductName,
                    ThumbnailsUrl          = oItem.ThumbnailsUrl,
                    SalePrice              = oItem.SalePrice,
                    SkuId                  = oItem.SkuId,
                    Quantity               = oItem.Quantity,
                    CashDepositsObligation = create.GetCashDepositsObligation(oItem.ProductId)
                },
                ReceiveBonus = shopBonusService.GetGrantByUserOrder(item.Id, CurrentUser.Id)
            };
            List <long> nums = (
                from d in list
                select d.Id).ToList();

            if (nums.Count > 0)
            {
                RefundQuery refundQuery = new RefundQuery()
                {
                    OrderId     = new long?(nums[0]),
                    MoreOrderId = nums,
                    PageNo      = 1,
                    PageSize    = list.Count
                };
                List <OrderRefundInfo> orderRefundInfos = (
                    from d in ServiceHelper.Create <IRefundService>().GetOrderRefunds(refundQuery).Models
                    where (int)d.RefundMode == 1
                    select d).ToList();

                if (orderRefundInfos.Count > 0)
                {
                    foreach (OrderRefundInfo orderRefundInfo in orderRefundInfos)
                    {
                        OrderInfo orderInfo = list.FirstOrDefault((OrderInfo d) => d.Id == orderRefundInfo.OrderId);
                        if (orderInfo == null)
                        {
                            continue;
                        }
                        orderInfo.RefundStats = (int)(orderRefundInfo.SellerAuditStatus);
                    }
                }
            }
            return(View(orderListModel.ToList()));
        }
 public static ShopBonusGrantInfo GetGrantByUserOrder(long orderid, long userid)
 {
     return(_iShopBonusService.GetGrantByUserOrder(orderid, userid));
 }