/// <summary> /// 得到当前会话用户库存中的商品列表 /// </summary> public static ItemRsp ItemsInventoryGet(string session, ItemReq itemreq) { try { TopDictionary paramsTable = new TopDictionary(); paramsTable.Add("method", "taobao.items.inventory.get"); paramsTable.Add("fields", "approve_status,iid,num_iid,title,nick,type,cid,pic_url,num,props,valid_thru,list_time,price,has_discount,has_invoice,has_warranty,has_showcase,modified,delist_time,postage_id,seller_cids,outer_id"); paramsTable.Add("q", itemreq.Q); paramsTable.Add("cid", itemreq.Cid); paramsTable.Add("page_no", itemreq.PageNo); paramsTable.Add("page_size", itemreq.PageSize); paramsTable.Add("order_by", itemreq.OrderBy); paramsTable.Add("banner", itemreq.Banner); paramsTable.Add("seller_cids", itemreq.SellerCids); paramsTable.Add("has_discount", itemreq.HasDiscount); paramsTable.Add("is_taobao", itemreq.IsTaobao); paramsTable.Add("has_showcase", itemreq.HasShowcase); paramsTable.Add("is_ex", itemreq.IsExternal); paramsTable.Add("session", session); return(TopUtils.DeserializeObject <ItemRsp>(TopUtils.InvokeAPI(paramsTable, APIInvokeType.Private))); } catch (System.Exception ex) { throw ex; } }
public Rifles(Player player, string _room) { room = _room; Player = player; InventoryItems listItem = new InventoryItems(); ItemReq req = new ItemReq() { type = "weapons", subtype = "Винтовка" }; string post = JsonConvert.SerializeObject(req); listItem = JsonConvert.DeserializeObject <InventoryItems>(Methods.POST_request(post, "get-item-list-by-type")); Items = new List <Item>(); foreach (Item item in listItem.item) { Items.Add(new Item { id = item.id, name = item.name, caliber = item.caliber, cost = item.cost, country = item.country, accuracy = item.accuracy, damage = item.damage, type = item.type }); } this.BindingContext = this; InitializeComponent(); }
/// <summary> /// 添加一个商品 /// </summary> public static ItemRsp ItemAdd(string session, ItemReq itemreq) { try { TopDictionary paramsTable = new TopDictionary(); paramsTable.Add("method", "taobao.item.add"); paramsTable.Add("num", itemreq.Num); paramsTable.Add("price", itemreq.Price); paramsTable.Add("type", itemreq.Type); paramsTable.Add("stuff_status", itemreq.StuffStatus); paramsTable.Add("title", itemreq.Title); paramsTable.Add("desc", itemreq.Desc); if (itemreq.Location != null) { paramsTable.Add("location.state", itemreq.Location.State); paramsTable.Add("location.city", itemreq.Location.City); } paramsTable.Add("approve_status", itemreq.ApproveStatus); paramsTable.Add("cid", itemreq.Cid); paramsTable.Add("props", itemreq.Props); paramsTable.Add("freight_payer", itemreq.FreightPayer); paramsTable.Add("valid_thru", itemreq.ValidThru); paramsTable.Add("has_invoice", itemreq.HasInvoice); paramsTable.Add("has_warranty", itemreq.HasWarranty); paramsTable.Add("auto_repost", itemreq.AutoRepost); paramsTable.Add("has_showcase", itemreq.HasShowcase); paramsTable.Add("seller_cids", itemreq.SellerCids); paramsTable.Add("has_discount", itemreq.HasDiscount); paramsTable.Add("post_fee", itemreq.PostFee); paramsTable.Add("express_fee", itemreq.ExpressFee); paramsTable.Add("ems_fee", itemreq.EmsFee); paramsTable.Add("list_time", itemreq.ListTime); paramsTable.Add("increment", itemreq.Increment); paramsTable.Add("image", itemreq.Image); paramsTable.Add("postage_id", itemreq.PostageId); paramsTable.Add("auction_point", itemreq.AuctionPoint); paramsTable.Add("property_alias", itemreq.PropAlias); paramsTable.Add("input_pids", itemreq.InputPids); paramsTable.Add("input_str", itemreq.InputStrs); paramsTable.Add("sku_properties", itemreq.SkuProperties); paramsTable.Add("sku_quantities", itemreq.SkuQuantities); paramsTable.Add("sku_prices", itemreq.Skuprices); paramsTable.Add("sku_outer_ids", itemreq.SkuOuterIds); paramsTable.Add("lang", itemreq.Lang); paramsTable.Add("outer_id", itemreq.OuterId); paramsTable.Add("product_id", itemreq.ProductId); paramsTable.Add("pic_path", itemreq.PicUrl); paramsTable.Add("session", session); return(TopUtils.DeserializeObject <ItemRsp>(TopUtils.InvokeAPI(paramsTable, APIInvokeType.Private))); } catch (System.Exception ex) { throw ex; } }
/// <summary> /// 更新商家编码,返回失败的商品,同时置成功商品的IsUpdate为TRUE,标识已同步到淘宝 /// </summary> /// <param name="nick"></param> /// <param name="itemdic"></param> /// <returns></returns> private Dictionary <string, string> UpdateOuterId(string nick, Dictionary <string, string> itemdic, DoWorkEventArgs e) { Dictionary <string, string> failedItemsDic = new Dictionary <string, string>(); List <string> iidlist = itemdic.Keys.ToList(); ItemReq req = new ItemReq(); ItemRsp response = new ItemRsp(); string session = SystemHelper.GetSessionKey(nick); float n = iidlist.Count; int temp = 0;//作用是避免进度值propgress没有改变时得重复报告 for (int i = 0; i < n; i++) { if (workerUpdate.CancellationPending) { e.Cancel = true; break; } if (workerUpdate.CancellationPending) { e.Cancel = true; break; } string iid = iidlist[i]; req.Iid = iid; req.OuterId = itemdic.SingleOrDefault(it => it.Key == iid).Value; try { response = TopService.ItemUpdate(session, req); if (response.Item == null) { failedItemsDic.Add(req.Iid, req.OuterId); } else { ItemService.UpdateItemIsUpdate(iid, true); } } catch (System.Exception ex) { failedItemsDic.Add(req.Iid, req.OuterId); continue; } //进度报告 int propgress = (int)((float)(i + 1) / n * 100); if (propgress > temp) { workerUpdate.ReportProgress(propgress, null); } temp = propgress; } return(failedItemsDic); }
/// <summary> /// 将上架计划列表中的宝贝更新到淘宝,返回成功宝贝的iid /// </summary> /// <param name="itemdic"></param> /// <returns></returns> private Dictionary <string, string> UpdateListPlan(string nick, Dictionary <string, string> itemdic, BackgroundWorker backWorker, DoWorkEventArgs e) { Dictionary <string, string> successitems = new Dictionary <string, string>(); List <string> iidlist = itemdic.Keys.ToList(); ItemReq req = new ItemReq(); ItemRsp response = new ItemRsp(); string session = SystemHelper.GetSessionKey(nick); float n = iidlist.Count; int temp = 0;//作用是避免进度值propgress没有改变时得重复报告 for (int i = 0; i < n; i++) { if (backWorker.CancellationPending) { e.Cancel = true; break; } string iid = iidlist[i]; req.Iid = iid; req.ApproveStatus = "onsale"; req.ListTime = itemdic.SingleOrDefault(it => it.Key == iid).Value; try { response = TopService.ItemUpdate(session, req); if (response.Item != null) { successitems.Add(req.Iid, req.ListTime); } } catch (Exception) { continue; } //进度报告 int propgress = (int)((float)(i + 1) / n * 100); if (propgress > temp) { backWorker.ReportProgress(propgress, null); } temp = propgress; } return(successitems); }
/// <summary> /// 搜索商品信息 /// </summary> public static ItemRsp ItemsGet(ItemReq itemreq) { try { TopDictionary paramsTable = new TopDictionary(); paramsTable.Add("method", "taobao.items.get"); paramsTable.Add("fields", "iid,title,nick,pic_url,cid,price,type,delist_time,post_fee,score,volume,location.city,location.state"); paramsTable.Add("q", itemreq.Q); paramsTable.Add("nicks", itemreq.Nick); paramsTable.Add("cid", itemreq.Cid); paramsTable.Add("props", itemreq.Props); paramsTable.Add("product_id", itemreq.ProductId); paramsTable.Add("start_price", itemreq.StartPrice); paramsTable.Add("end_price", itemreq.EndPrice); paramsTable.Add("post_free", itemreq.PostFree); paramsTable.Add("ww_status", itemreq.WwStatus); paramsTable.Add("page_no", itemreq.PageNo); paramsTable.Add("page_size", itemreq.PageSize); paramsTable.Add("order_by", itemreq.OrderBy); paramsTable.Add("location.state", itemreq.Location.State); paramsTable.Add("location.city", itemreq.Location.City); paramsTable.Add("is_3D", itemreq.Is3D); paramsTable.Add("start_score", itemreq.StartScore); paramsTable.Add("end_score", itemreq.EndScore); paramsTable.Add("start_volume", itemreq.StartVolume); paramsTable.Add("end_volume", itemreq.EndVolume); paramsTable.Add("one_station", itemreq.OneStation); paramsTable.Add("is_cod", itemreq.IsCod); paramsTable.Add("is_mall", itemreq.IsMall); paramsTable.Add("is_prepay", itemreq.IsPrepay); paramsTable.Add("genuine_security", itemreq.GenuineSecurity); paramsTable.Add("promoted_service", itemreq.PromotedService); paramsTable.Add("stuff_status", itemreq.StuffStatus); return(TopUtils.DeserializeObject <ItemRsp>(TopUtils.InvokeAPI(paramsTable, APIInvokeType.Public))); } catch (System.Exception ex) { throw ex; } }
public ItemAdd(ItemReq req) { InitializeComponent(); this.itemreq = req; }