Пример #1
0
        public void LockBatch(IUnitOfWork db,
                              long batchId,
                              DateTime?when)
        {
            _log.Info("Lock batch, batchId=" + batchId);

            var orderIds = db.OrderBatches.GetOrderIdsForBatch(
                batchId,
                OrderStatusEnumEx.AllUnshippedWithShipped);

            var shippingList = db.OrderShippingInfos
                               .GetOrderInfoWithItems(_weightService,
                                                      orderIds.ToList(),
                                                      SortMode.ByLocation,
                                                      unmaskReferenceStyle: false,
                                                      includeSourceItems: false)
                               .ToList();

            shippingList = SortHelper.Sort(shippingList, SortMode.ByShippingMethodThenLocation).ToList();

            for (int i = 0; i < shippingList.Count; i++)
            {
                var mapping = new OrderToBatch()
                {
                    BatchId        = batchId,
                    ShippingInfoId = shippingList[i].Id,
                    SortIndex1     = ShippingUtils.GetShippingMethodIndex(shippingList[i].ShippingMethodId),
                    SortIndex2     = LocationHelper.GetLocationIndex(shippingList[i].SortIsle, shippingList[i].SortSection, shippingList[i].SortShelf),
                    SortIndex3     = SortHelper.GetStringIndex(shippingList[i].SortStyleString),
                    SortIndex4     = (decimal)SizeHelper.GetSizeIndex(shippingList[i].SortSize),
                    SortIndex5     = SortHelper.GetStringIndex(shippingList[i].SortColor),
                    //SortIndex6 = SortHelper.GetStringIndex(shippingList[i].FirstItemName),
                    CreateDate = when,
                };
                db.OrderToBatches.Add(mapping);
            }
            db.Commit();

            db.OrderBatches.LockBatch(batchId, when);
        }
Пример #2
0
        /// <summary>
        /// For Named List
        /// </summary>
        /// <param name="item"></param>
        /// <param name="market"></param>
        /// <param name="isOrderOnHold"></param>
        /// <param name="isOrderPartial"></param>
        public OrderItemViewModel(ListingOrderDTO item, bool isOrderOnHold, bool isOrderPartial)
        {
            Market        = item.Market;
            MarketplaceId = item.MarketplaceId;

            ListingEntityId = item.Id;

            ItemOrderId  = item.ItemOrderId;
            RecordNumber = item.RecordNumber;
            ParentASIN   = item.ParentASIN;
            ASIN         = item.ASIN;

            ListingCreateDate = item.ListingCreateDate;

            SourceMarketId = item.SourceMarketId;

            OnHold = isOrderOnHold;

            StyleID     = item.StyleID;
            StyleSize   = item.StyleSize;
            Size        = item.Size;
            Color       = item.Color;
            StyleItemId = item.StyleItemId;


            SourceStyleString = item.SourceStyleString;
            SourceStyleSize   = item.SourceStyleSize;
            SourceStyleColor  = item.SourceStyleColor;

            Title    = item.Title;
            Quantity = isOrderPartial
                ? item.QuantityShipped.ToString("G") + "/" + item.QuantityOrdered.ToString("G")
                : item.QuantityOrdered.ToString("G");
            QuantityOrdered = item.QuantityOrdered;
            QuantityShipped = item.QuantityShipped;

            if (item.ItemPaid.HasValue && item.ItemPaid > 0)
            {
                ItemPrice = item.ItemPaid.Value - (item.ItemTax ?? 0);
            }
            else if (Market == (int)MarketType.eBay)
            {
                ItemPrice = item.ItemPrice * item.QuantityOrdered;
            }
            else
            {
                ItemPrice = item.ItemPrice;
            }
            RefundItemPrice     = item.RefundItemPrice;
            ItemDiscount        = item.PromotionDiscount;
            ItemTax             = item.ItemTax;
            ShippingPrice       = item.ShippingPrice;
            RefundShippingPrice = item.RefundShippingPrice;
            ShippingDiscount    = item.ShippingDiscount;
            ItemPriceInUSD      = item.ItemPriceInUSD;

            ExcessiveShipmentThreshold = StringHelper.TryGetDecimal(item.ExcessiveShipmentThreshold);

            FBAFee = item.FBAPerOrderFulfillmentFee + item.FBAPerUnitFulfillmentFee + item.FBAWeightBasedFee;
            FBAAvailableQuantity = item.AvailableQuantity;
            SimilarNonFBASKU     = item.SimilarNonFBASKU;
            SimilarNonFBAPrice   = item.SimilarNonFBAPrice;

            var image = item.ItemPicture;

            if (String.IsNullOrEmpty(image))
            {
                image = item.StyleImage;
            }
            if (item.ReplaceType == (int)ItemReplaceTypes.Combined)
            {
                image = item.StyleImage;
            }
            if (item.UseStyleImage)
            {
                image = item.StyleImage;
            }

            PictureUrl = ImageHelper.GetFirstOrDefaultPicture(image);

            Weight = item.Weight;

            BayNumber     = StringHelper.Substring(item.SortIsle.ToString(), 1);
            LocationIndex = LocationHelper.GetLocationIndex(item.SortIsle, item.SortSection, item.SortShelf);
        }