Exemplo n.º 1
0
        /// <summary>
        ///     删除单个SKU
        /// taobao.item.sku.delete 删除SKU 
        /// </summary>
        /// <param name="numId"></param>
        /// <param name="properties"></param>
        public void DeleteGoodsSku(long numId, string properties, string goodsSn = "")
        {
            _log.LogInfo(Resource.Log_DeleteGoodsSkuing.StringFormat(numId, properties, goodsSn));
            var tContext = InstanceLocator.Current.GetInstance<AuthorizedContext>();
            var req = new ItemSkuDeleteRequest { NumIid = numId, Properties = properties };

            ItemSkuDeleteResponse response = _client.Execute(req, tContext.SessionKey);

            if (response.IsError)
            {
                var ex = new TopResponseException(response.ErrCode, response.ErrMsg, response.SubErrCode,
                                                  response.SubErrMsg, response.TopForbiddenFields);

                _log.LogError(Resource.Log_DeleteGoodsSkuFailure.StringFormat(numId, properties, goodsSn), ex);
            }
            _log.LogInfo(Resource.Log_DeleteGoodsSkuSuccess.StringFormat(numId, properties, goodsSn));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 删除该商品的销售图片
        /// taobao.item.propimg.delete 删除属性图片
        /// </summary>
        /// <param name="imgId">图片ID</param>
        /// <param name="numId">商品编号</param>
        /// <returns></returns>
        public PropImg DeleteItemPropimg(long imgId, long numId, string goodsSn = "")
        {
            _log.LogInfo(Resource.Log_DeleteItemPropingimg, imgId, numId, goodsSn);

            var req = new ItemPropimgDeleteRequest { NumIid = numId, Id = imgId };
            var tContext = InstanceLocator.Current.GetInstance<AuthorizedContext>();
            var response = _client.Execute(req, tContext.SessionKey);

            if (response.IsError)
            {
                var ex = new TopResponseException(response.ErrCode, response.ErrMsg, response.SubErrCode,
                                                  response.SubErrMsg, response.TopForbiddenFields);

                _log.LogError(Resource.Log_DeleteItemPropimgFailure.StringFormat(imgId, numId, goodsSn), ex);
            }

            _log.LogInfo(Resource.Log_DeleteItemPropimgSuccess, imgId, numId, goodsSn);

            return response.PropImg;
        }
Exemplo n.º 3
0
        /// <summary>
        /// taobao.item.sku.update 更新SKU信息
        /// </summary>
        /// <returns></returns>
        public Sku UpdateSku(ItemSkuUpdateRequest req)
        {
            _log.LogInfo(Resource.Log_UpdateSkuing.StringFormat(req.NumIid, req.Properties, req.OuterId));

            req.ThrowIfNull(Resource.ExceptionTemplate_MethedParameterIsNullorEmpty.StringFormat(new StackTrace()));

            var tContext = InstanceLocator.Current.GetInstance<AuthorizedContext>();

            var response = _client.Execute(req, tContext.SessionKey);

            if (response.IsError)
            {
                var ex = new TopResponseException(response.ErrCode, response.ErrMsg, response.SubErrCode,
                                               response.SubErrMsg, response.TopForbiddenFields);
                _log.LogError(Resource.Log_UpdateSkuFailure.StringFormat(req.NumIid, req.Properties, req.OuterId), ex);

            }

            _log.LogInfo(Resource.Log_UpdateSkuSuccess.StringFormat(req.NumIid, req.Properties, req.OuterId));

            return response.Sku;
        }
Exemplo n.º 4
0
        /// <summary>
        /// taobao.picture.upload 上传单张图片
        /// </summary>
        /// <param name="req"></param>
        /// <example>
        ///example
        ///ITopClient client = new DefaultTopClient(url, appkey, appsecret);
        ///PictureUploadRequest req=new PictureUploadRequest();
        ///req.PictureCategoryId = 123L;
        ///FileItem fItem = new FileItem("fileLocation");
        ///req.Img = fItem;
        ///req.ImageInputTitle = "Bule.jpg";
        ///req.Title = "图片名称";
        ///req.ClientType = "client:computer";
        /// PictureUploadResponse response = client.Execute(req, sessionKey);
        /// </example>
        /// <returns></returns>
        public Picture PictureUpload(PictureUploadRequest req)
        {
            _log.LogError("正在上传商品描述图片....");
            var tContext = InstanceLocator.Current.GetInstance<AuthorizedContext>();

            PictureUploadResponse response = _client.Execute(req, tContext.SessionKey);

            if (response.IsError)
            {
                var ex = new TopResponseException(response.ErrCode, response.ErrMsg, response.SubErrCode,
                                                  response.SubErrMsg, response.TopForbiddenFields);

                _log.LogError("上传商品描述图片失败", ex);

                throw ex;
            }

            _log.LogError("上传商品描述图片成功");
            return response.Picture;
        }
Exemplo n.º 5
0
        /// <summary>
        ///     发布商品
        /// taobao.item.add 添加一个商品 
        /// </summary>
        /// <param name="product">商品</param>
        /// <returns>商品编号</returns>
        public Item PublishGoods(Product product)
        {
            _log.LogInfo(Resource.Log_PublishGoodsing.StringFormat(product.Title));

            var req = new ItemAddRequest();

            Util.CopyModel(product, req);

            var tContext = InstanceLocator.Current.GetInstance<AuthorizedContext>();
            ItemAddResponse response = _client.Execute(req, tContext.SessionKey);

            if (response.IsError)
            {
                var ex = new TopResponseException(response.ErrCode, response.ErrMsg, response.SubErrCode,
                                                  response.SubErrMsg, response.TopForbiddenFields);
                _log.LogError(Resource.Log_PublishGoodsFailure, product.Title, ex);
                throw ex;
            }

            Item item = response.Item;

            _log.LogInfo(Resource.Log_PublishGoodsSuccess, product.Title, item.NumIid);

            return item;
        }
Exemplo n.º 6
0
        /// <summary>
        ///     根据商品ID列表获取SKU信息
        /// taobao.item.skus.get 根据商品ID列表获取SKU信息 
        /// </summary>
        /// <param name="numIds">支持多个商品,用“,”号分割</param>
        /// <returns></returns>
        public IEnumerable<Sku> GetSkusByNumId(string numIds)
        {
            _log.LogInfo(Resource.Log_GetSkusing.StringFormat(numIds));
            var tContext = InstanceLocator.Current.GetInstance<AuthorizedContext>();

            var req = new ItemSkusGetRequest
            {
                Fields = "properties_name,sku_id,iid,num_iid,properties,quantity,price,outer_id",
                NumIids = numIds
            };

            ItemSkusGetResponse response = _client.Execute(req, tContext.SessionKey);

            if (response.IsError)
            {
                var ex = new TopResponseException(response.ErrCode, response.ErrMsg, response.SubErrCode,
                                                  response.SubErrMsg, response.TopForbiddenFields);
                _log.LogError(Resource.Log_GetSkusFailure.StringFormat(numIds), ex);
                throw ex;
            }
            _log.LogInfo(Resource.Log_GetSkusSuccess.StringFormat(numIds));

            return response.Skus.OrderBy(f => f.SkuId).ToList();
        }
Exemplo n.º 7
0
        /// <summary>
        ///     taobao.item.update.delisting 商品下架
        /// </summary>
        /// <param name="numId">商品编号</param>
        /// <returns></returns>
        public Item GoodsDelisting(long numId)
        {
            _log.LogInfo(Resource.Log_GoodsDelisting, numId);

            var req = new ItemUpdateDelistingRequest { NumIid = numId };
            var tContext = InstanceLocator.Current.GetInstance<AuthorizedContext>();
            ItemUpdateDelistingResponse response = _client.Execute(req, tContext.SessionKey);

            if (response.IsError)
            {
                var ex = new TopResponseException(response.ErrCode, response.ErrMsg, response.SubErrCode,
                                                  response.SubErrMsg, response.TopForbiddenFields);

                _log.LogError(Resource.Log_GoodsDelistingFailure.StringFormat(numId), ex);
            }

            _log.LogInfo(Resource.Log_GoodsDelistingSuccess, numId);

            return response.Item;
        }
Exemplo n.º 8
0
        /// <summary>
        ///     获取当前会话用户出售中的商品列表
        ///     taobao.items.onsale.get
        /// </summary>
        /// <param name="req">要查询传入的参数</param>
        public List<Item> GetOnSaleGoods(ItemsOnsaleGetRequest req)
        {
            _log.LogInfo(Resource.Log_GetOnSaleGoodsing.StringFormat(req.Q));
            var tContext = InstanceLocator.Current.GetInstance<AuthorizedContext>();

            ItemsOnsaleGetResponse response = _client.Execute(req, tContext.SessionKey);

            if (response.IsError)
            {
                var ex = new TopResponseException(response.ErrCode, response.ErrMsg, response.SubErrCode,
                                                  response.SubErrMsg, response.TopForbiddenFields);

                _log.LogError(Resource.Log_GetOnSaleGoodsFailure, ex);

                throw ex;
            }

            _log.LogInfo(Resource.Log_GetOnSaleGoodsSuccess.StringFormat(req.Q));
            return response.Items;
        }
Exemplo n.º 9
0
        //得到卖家仓库中的商品
        public List<Item> GetInventoryGoods(ItemsInventoryGetRequest req)
        {
            var tContext = InstanceLocator.Current.GetInstance<AuthorizedContext>();

            ItemsInventoryGetResponse response = _client.Execute(req, tContext.SessionKey);

            if (response.IsError)
            {
                var ex = new TopResponseException(response.ErrCode, response.ErrMsg, response.SubErrCode,
                                                  response.SubErrMsg, response.TopForbiddenFields);

                _log.LogError(Resource.Log_GetInventoryGoodsFailure, ex);

                throw ex;
            }

            return response.Items;
        }
Exemplo n.º 10
0
        /// <summary>
        ///     得到产品列表
        /// </summary>
        /// <param name="numIds">各ID以","号分割</param>
        /// <returns></returns>
        public List<Item> GetGoodsList(string numIds)
        {
            var tContext = InstanceLocator.Current.GetInstance<AuthorizedContext>();

            var req = new ItemsListGetRequest { Fields = "num_iid,cid,num,sku,title,price,outer_id", NumIids = numIds };

            ItemsListGetResponse response = _client.Execute(req, tContext.SessionKey);

            if (response.IsError)
            {
                var ex = new TopResponseException(response.ErrCode, response.ErrMsg, response.SubErrCode,
                                                  response.SubErrMsg, response.TopForbiddenFields);
                _log.LogError(Resource.Log_GetGoodsListFailure, ex);
                throw ex;
            }

            return response.Items;
        }
Exemplo n.º 11
0
        //taobao.item.propimg.upload 添加或修改属性图片
        private PropImg UploadItemPropimgInternal(long numId, string properties, FileItem fItem)
        {
            _log.LogInfo(Resource.Log_PublishSaleImging, numId);

            var req = new ItemPropimgUploadRequest {NumIid = numId, Image = fItem, Properties = properties};

            var tContext = InstanceLocator.Current.GetInstance<AuthorizedContext>();
            ItemPropimgUploadResponse response = _client.Execute(req, tContext.SessionKey);

            if (response.IsError)
            {
                var ex = new TopResponseException(response.ErrCode, response.ErrMsg, response.SubErrCode,
                                                  response.SubErrMsg, response.TopForbiddenFields);
                _log.LogError(Resource.Log_PublishSaleImgFailure, ex);
                throw ex;
            }

            _log.LogInfo(Resource.Log_PublishSaleImgSuccess, response.PropImg.Id, response.PropImg.Url);
            return response.PropImg;
        }
Exemplo n.º 12
0
        private Item UpdateGoodsBase(ItemUpdateRequest req, long? numiid, string outerId, string title)
        {
            _log.LogInfo(Resource.Log_UpdateGoodsing.StringFormat(numiid, outerId));

            var tContext = InstanceLocator.Current.GetInstance<AuthorizedContext>();
            ItemUpdateResponse response = _client.Execute(req, tContext.SessionKey);

            if (response.IsError)
            {
                var ex = new TopResponseException(response.ErrCode, response.ErrMsg, response.SubErrCode,
                                                  response.SubErrMsg, response.TopForbiddenFields);
                _log.LogError(Resource.Log_UpdateGoodsFailure.StringFormat(numiid, outerId), ex);
                throw ex;
            }

            Item item = response.Item;

            _log.LogInfo(Resource.Log_UpdateGoodsSuccess, title, item.NumIid);

            return item;
        }