Beispiel #1
0
        private void SynInvnetoryQty(List <InventoryQtyEntity> inventoryQtyList)
        {
            TaoBaoRequest request = new TaoBaoRequest();

            request.TaoBaoSKUList = new List <TaoBaoSKUMsg>();

            foreach (InventoryQtyEntity entity in inventoryQtyList)
            {
                TaoBaoSKUMsg skuMsg = new TaoBaoSKUMsg();
                skuMsg.Quantity = entity.SynInventoryQty.ToString();
                skuMsg.Type     = "2";
                skuMsg.SKU      = entity.SKU;
                request.TaoBaoSKUList.Add(skuMsg);
            }
            request.Header = Util.CreateServiceHeader();
            ITaoBaoMaintain service = ServiceBroker.FindService <ITaoBaoMaintain>();

            try
            {
                TaoBaoResponse response = service.TaoBaoItemQantityUpdate(request);

                if (response != null && response.Faults != null && response.Faults.Count > 0)
                {
                    MessageFault      msg = response.Faults[0];
                    BusinessException ex  = new BusinessException(msg.ErrorCode, string.Format("{0}\r\n{1}", msg.ErrorDescription, msg.ErrorDetail), true);

                    throw ex;
                }
            }
            catch (Exception ex)
            {
                ExceptionHelper.HandleException(ex);
                throw ex;
            }
            finally
            {
                ServiceBroker.DisposeService <ITaoBaoMaintain>(service);
            }
        }
Beispiel #2
0
        protected override void On_Running(object sender, ThirdPartInventoryArgs args)
        {
            List <ThirdPartInventoryEntity> qtyList = args.ThirdPartInventoryList;
            List <TaoBaoSKUMsg>             list    = new List <TaoBaoSKUMsg>();

            foreach (ThirdPartInventoryEntity entity in qtyList)
            {
                TaoBaoSKUMsg skuMsg = new TaoBaoSKUMsg();
                int          qty    = Addapter.CalculateInventoryQty.CalculateSynQty(entity);

                #region 2011-10-26 Midify by Kilin 新商品同步库存时,淘宝库存默认为一个
                if (!entity.InventoryAlamQty.HasValue)
                {
                    qty -= 1;
                }
                #endregion
                skuMsg.Quantity = qty.ToString();
                skuMsg.Type     = "2";
                skuMsg.SKU      = entity.SKU;
                list.Add(skuMsg);
            }

            SynInvnetoryQty(list);
        }