/// <summary> /// /// </summary> /// <param name="outer_id"></param> /// <param name="mall_sku_id"></param> /// <returns></returns> public bool MappingSku(string outer_id, string mall_sku_id, string mall_item_id, string properities) { bool ret = false; TB.Sku sku = null; if (string.IsNullOrEmpty(properities)) { sku = this.GetSku(mall_sku_id); if (sku != null) { properities = sku.Properties; } } ItemSkuUpdateRequest req = new ItemSkuUpdateRequest(); req.NumIid = long.Parse(mall_item_id); req.Properties = properities; req.OuterId = outer_id; ItemSkuUpdateResponse response = this.client.Execute(req, this.Access_Token.Access_Token1); if (response.IsError) { throw new KMJXCTaobaoException(response.ErrCode, response.SubErrMsg); } ret = true; return(ret); }
/// <summary> /// /// </summary> /// <param name="skuCode">商品SKUid 商品SKU条形码</param> /// <param name="balance">需要修改的库存</param> /// <param name="num_id">淘宝商品编号 .</param> /// <param name="Scode">商品Scode 需要改成</param> /// <param name="Price">需要修改目标价格 </param> /// <param name="properties"></param> /// <returns></returns> public bool UpdateTao(string skuCode, long balance, long num_id, string Scode, string Price, string properties) { ITopClient client = new DefaultTopClient(Url, Appkey, Appsecret); ItemSkuUpdateRequest req = new ItemSkuUpdateRequest(); req.NumIid = num_id; //淘宝商品编号 必填 req.Properties = properties; //SKU属性 必填 req.Quantity = balance; //库存 req.Barcode = skuCode; //SKUiD 必填 req.ItemPrice = Price; //价格 req.OuterId = Scode; //货号 ItemSkuUpdateResponse response = client.Execute(req, Sessionkey); return(true); }
/// <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); }
/// <summary> /// taobao.item.sku.update /// 更新SKU信息 /// </summary> /// <param name="numid">必填 Sku所属商品数字id,可通过 taobao.item.get 获取 </param> /// <param name="properties">必填 Sku属性串。格式:pid:vid;pid:vid,如: 1627207:3232483;1630696:3284570,表示机身颜色:军绿色;手机套餐:一电一充。 /// 如果包含自定义属性,则格式为pid:vid;pid2:vid2;$pText:vText , 其中$pText:vText为自定义属性。限制:其中$pText的’$’前缀不能少,且pText和vText文本中不可以存在 冒号:和分号;以及逗号, </param> /// <param name="quantity">Sku的库存数量。sku的总数量应该小于等于商品总数量(Item的NUM),sku数量变化后item的总数量也会随着变化。取值范围:大于等于零的整数 </param> /// <param name="price">Sku的销售价格。精确到2位小数;单位:元。如:200.07,表示:200元7分。修改后的sku价格要保证商品的价格在所有sku价格所形成的价格区间内 /// (例如:商品价格为6元,sku价格有5元、10元两种,如果要修改5元sku的价格,那么修改的范围只能是0-6元之间;如果要修改10元的sku,那么修改的范围只能是6到无穷大的区间中)</param> /// <param name="outerid">Sku的商家外部id </param> /// <param name="itemprice">sku所属商品的价格。当用户更新sku,使商品价格不属于sku价格之间的时候,用于修改商品的价格,使sku能够更新成功 </param> /// <param name="lang">Sku文字的版本。可选值:zh_HK(繁体),zh_CN(简体);默认值:zh_CN </param> /// <param name="specid">产品的规格信息。 </param> /// <returns></returns> public static Sku UpdateItemSku(long? numid, string properties, long? quantity, string price, string outerid, string itemprice, string lang, string specid) { ITopClient client = TopClientService.GetTopClient(); ItemSkuUpdateRequest req = new ItemSkuUpdateRequest(); req.NumIid = numid; req.Properties = properties; req.Quantity = quantity; req.Price = price; req.OuterId = outerid; req.ItemPrice = itemprice; req.Lang = lang; req.SpecId = specid; ItemSkuUpdateResponse response = client.Execute(req, SessionKey); return response.Sku; }
public void UpdateGoodsSkuInfo( IRequest reqSource, IEnumerable <string> lstSearch, //要为款号 double discountRatio = 0.68, int stock = 3, string originalTitle = "xx", string newTitle = "xx", bool isModifyPrice = true) { foreach (var search in lstSearch) { if (search.IsEmptyString()) { continue; } List <Item> lstItem = GetOnSaleGoods(search); if (lstItem != null && lstItem.Count > 0) { #region 更新SKU信息 foreach (var item in lstItem) { Thread.Sleep(100); //获取产品原价 var oPrice = item.Title.GetNumberInt(); var req = new ItemUpdateRequest(); req.NumIid = item.NumIid; req.Title = item.Title.Replace(originalTitle, newTitle); req.LocationState = SysConst.LocationState; req.LocationCity = SysConst.LocationCity; if (isModifyPrice) { req.Price = (oPrice * discountRatio).ToType <int>().ToString(); } var skus = GetSkusByNumId(item.NumIid.ToString()).ToArray(); var lastSku = skus[skus.Count() - 1]; for (int i = 0; i < skus.Count() - 1; i++) { Thread.Sleep(100); var skuReq = new ItemSkuUpdateRequest() { NumIid = item.NumIid, Properties = skus[i].Properties, Quantity = stock, OuterId = item.OuterId }; if (isModifyPrice) { skuReq.Price = req.Price; } UpdateSku(skuReq); Thread.Sleep(100); } UpdateGoodsBase(req, item.NumIid, item.OuterId, req.Title); var skuLastReq = new ItemSkuUpdateRequest() { NumIid = item.NumIid, Properties = lastSku.Properties, Quantity = stock, OuterId = item.OuterId }; if (isModifyPrice) { skuLastReq.Price = req.Price; } UpdateSku(skuLastReq); } #endregion } else { PublishGoodsMain( reqSource, new RequestModel { GoodsSn = search, Referer = reqSource.GetGoodsUrl(search) }); } } }
/// <summary> /// /// </summary> /// <param name="outer_id"></param> /// <param name="mall_sku_id"></param> /// <returns></returns> public bool MappingSku(string outer_id, string mall_sku_id,string mall_item_id,string properities) { bool ret = false; TB.Sku sku = null; if (string.IsNullOrEmpty(properities)) { sku = this.GetSku(mall_sku_id); if (sku != null) { properities = sku.Properties; } } ItemSkuUpdateRequest req = new ItemSkuUpdateRequest(); req.NumIid = long.Parse(mall_item_id); req.Properties = properities; req.OuterId = outer_id; ItemSkuUpdateResponse response= this.client.Execute(req,this.Access_Token.Access_Token1); if (response.IsError) { throw new KMJXCTaobaoException(response.ErrCode, response.SubErrMsg); } ret = true; return ret; }
/// <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; }
public void UpdateGoodsSkuInfo( IRequest reqSource, IEnumerable<string> lstSearch, //要为款号 double discountRatio = 0.68, int stock = 3, string originalTitle = "xx", string newTitle = "xx", bool isModifyPrice = true) { foreach (var search in lstSearch) { if (search.IsEmptyString()) continue; List<Item> lstItem = GetOnSaleGoods(search); if (lstItem != null && lstItem.Count > 0) { #region 更新SKU信息 foreach (var item in lstItem) { Thread.Sleep(100); //获取产品原价 var oPrice = item.Title.GetNumberInt(); var req = new ItemUpdateRequest(); req.NumIid = item.NumIid; req.Title = item.Title.Replace(originalTitle, newTitle); req.LocationState = SysConst.LocationState; req.LocationCity = SysConst.LocationCity; if (isModifyPrice) { req.Price = (oPrice * discountRatio).ToType<int>().ToString(); } var skus = GetSkusByNumId(item.NumIid.ToString()).ToArray(); var lastSku = skus[skus.Count() - 1]; for (int i = 0; i < skus.Count() - 1; i++) { Thread.Sleep(100); var skuReq = new ItemSkuUpdateRequest() { NumIid = item.NumIid, Properties = skus[i].Properties, Quantity = stock, OuterId = item.OuterId }; if (isModifyPrice) { skuReq.Price = req.Price; } UpdateSku(skuReq); Thread.Sleep(100); } UpdateGoodsBase(req, item.NumIid, item.OuterId, req.Title); var skuLastReq = new ItemSkuUpdateRequest() { NumIid = item.NumIid, Properties = lastSku.Properties, Quantity = stock, OuterId = item.OuterId }; if (isModifyPrice) { skuLastReq.Price = req.Price; } UpdateSku(skuLastReq); } #endregion } else { PublishGoodsMain( reqSource, new RequestModel { GoodsSn = search, Referer = reqSource.GetGoodsUrl(search) }); } } }