/// <summary> /// 淘宝在线获取宝贝信息 /// </summary> public static string GetItemOnline(long item_id) { ItemGetRequest req = new ItemGetRequest(); req.Fields = "detail_url,num_iid,title,nick,props_name,price,cid,seller_cids,pic_url,num,location"; req.NumIid = item_id; ItemGetResponse response = client.Execute(req); return(response.Body); }
//得到淘宝的所有商品类目 /// <summary> /// 得到淘宝的所有商品类目 /// taobao.itemcats.get 获取后台供卖家发布商品的标准商品类目 /// </summary> /// <returns></returns> public List <ItemCat> GetAllItemCatByApi(long parentCid) { ItemcatsGetRequest req = new ItemcatsGetRequest(); req.Fields = "cid,parent_cid,name,is_parent"; req.ParentCid = parentCid; ItemcatsGetResponse response = client.Execute(req); return(response.ItemCats); }
/// <summary> /// 获取店铺等待发货的订单 /// </summary> /// <param name="param">条件参数</param> /// <param name="auth">授权参数</param> /// <returns>订单列表</returns> /// <reamrks>2014-04-08 黄波 创建</reamrks> private List <UpGradeOrder> GetShopWaitSendOrder(OrderParameters param, AuthorizationParameters auth) { var result = new List <UpGradeOrder>(); //增量查询今日订单请求 var req = new TradesSoldIncrementGetRequest { Fields = "seller_flag,seller_nick,buyer_nick,alipay_no,has_buyer_message,title,tid,status,payment,discount_fee,post_fee,adjust_fee,pay_time,receiver_name,receiver_state,receiver_city,receiver_district,receiver_address,receiver_zip,receiver_mobile,receiver_phone,orders.title,orders.price,orders.num,orders.iid,orders.num_iid,orders.sku_id,orders.payment,orders.discount_fee,orders.sku_properties_name,orders.outer_iid,orders.outer_sku_id,orders.oid,orders.refund_status", Status = "WAIT_SELLER_SEND_GOODS", StartModified = param.StartDate, EndModified = param.EndDate, PageSize = 20L, UseHasNext = true }; var nextPage = true; var pageNo = 1L; var response = new TradesSoldIncrementGetResponse(); while (nextPage) { try { req.PageNo = pageNo; response = client.Execute(req, auth.AuthorizationCode); if (!response.IsError) { if (response.HasNext) { pageNo++; } else { nextPage = false; } foreach (Trade trade in response.Trades) { var order = new UpGradeOrder(); Map(trade, order); order.MallOrderBuyer.SellerFlag = trade.SellerFlag.ToString(); result.Add(order); } } else { nextPage = false; } } catch { nextPage = false; } } return(result); }
/// <summary> /// 商品图片上传 /// </summary> /// <param name="numIid">商品数字ID</param> /// <param name="filePath">文件路径</param> /// <param name="isMagor">是否将图片设置为主图</param> public string ItemImgUpload(Int64 numIid, string filePath, Boolean isMagor, string sessionKey) { try { ITopClient client = TBManager.GetClient(); PictureUploadRequest req = new PictureUploadRequest(); //req.NumIid = numIid; req.ClientType = "client:phone"; var fileInfo = new FileInfo(filePath); FileItem fItem = new FileItem(fileInfo); req.ImageInputTitle = fileInfo.Name; req.PictureCategoryId = 0; req.Img = fItem; //req.IsMajor = true; //req.Position = 6; PictureUploadResponse response = client.Execute(req, sessionKey); //#if DEBUG // return filePath; //#else return(response.Picture.PicturePath); //#endif } catch (Exception ex) { ExceptionReporter.WriteLog(ex, ExceptionPostion.TopApi); return(null); } }
public ApiPagedResult <List <TopTrade> > GetSoldTrade(string status, int page, DateTime start) { ITopClient client = GetTopClient(); TradesSoldGetRequest request = new TradesSoldGetRequest { Fields = "tid,buyer_nick,num,num_iid,created,pay_time,payment,receiver_address,status,end_time,seller_rate,seller_can_rate" }; request.StartCreated = start; request.EndCreated = DateTime.Now; request.Status = status; request.Type = "guarantee_trade"; request.PageNo = page; request.PageSize = 50; request.UseHasNext = true; TradesSoldGetResponse response = client.Execute <TradesSoldGetResponse>(request, AccessToken); List <TopTrade> list = new List <TopTrade>(); if (!response.IsError) { list = response.Trades.Select(x => TopTrade.FromTrade(x)).ToList(); } return(response.AsApiPagedResult(list, response.HasNext)); }
/// <summary> /// 获取指定时间段内的交易信息和明细 /// TradesSoldGetRequest 获取单笔交易的详细信息 /// </summary> /// <param name="sellerNick">根据买家昵称获取交易信息</param> /// <returns></returns> public static List <Trade> GetBuyerTrade(string sellerNick, DateTime startDate, DateTime endDate, ref bool hasNextPage, string sessionKey, long pageNo) { try { ITopClient client = TBManager.GetClient(); TradesSoldGetRequest req = new TradesSoldGetRequest(); req.Fields = @"tid,seller_rate,orders.oid,orders.end_time,orders.buyer_rate,buyer_nick,end_time"; if (!String.IsNullOrEmpty(startDate.ToShortDateString())) { req.StartCreated = startDate; } if (!String.IsNullOrEmpty(endDate.ToShortDateString())) { req.EndCreated = endDate; } req.Status = "TRADE_FINISHED";//交易成功后才可以评价 req.PageNo = pageNo; req.PageSize = 100L; req.UseHasNext = true; TradesSoldGetResponse response = client.Execute(req, sessionKey); hasNextPage = response.HasNext; return(response.Trades); } catch (Exception ex) { CHENGTUAN.Components.ExceptionReporter.WriteLog(ex, CHENGTUAN.Entity.ExceptionPostion.TopApi); return(null); } }
/// <summary> /// 获取单笔交易的部分信息:查询该笔订单是否有退货 /// </summary> /// <param name="tid"></param> /// <returns></returns> public string GetBuyerTradeByTid(long tid) { try { ITopClient client = TBManager.GetClient(); TradeGetRequest req = new TradeGetRequest(); req.Fields = "orders.buyer_nick,orders.refund_status"; req.Tid = tid; TradeGetResponse response = client.Execute(req, Users.SessionKey); Trade trade = response.Trade; string buyerNick = ""; if (trade != null) { if (trade.Orders.Count > 0) { foreach (Order o in trade.Orders) {//查询该笔交易,如果有订单退款马上返回该买家 if (o.RefundStatus.Equals("SUCCESS")) { buyerNick = o.BuyerNick; } break; } } } return(buyerNick); } catch (Exception ex) { CHENGTUAN.Components.ExceptionReporter.WriteLog(ex, CHENGTUAN.Entity.ExceptionPostion.TopApi); return(""); } }
/// <summary> /// 订单按日期下载 /// </summary> /// <param name="strSessionKey"></param> /// <param name="startTime"></param> /// <param name="endTime"></param> /// <param name="pageNo"></param> /// <param name="pageSize"></param> /// <param name="hasNext"></param> /// <returns></returns> public static List <Trade> GetTradeByDate(string strSessionKey, string startTime, string endTime, string pageNo, string pageSize, string buyer_nick, string type, ref Boolean hasNext) { try { ITopClient client = TBManager.GetClient(); TradesSoldGetRequest req = new TradesSoldGetRequest(); req.Fields = @"tid,type,buyer_nick,receiver_name,receiver_state,receiver_city,receiver_district,receiver_address, receiver_mobile,receiver_phone,receiver_zip,buyer_area,post_fee,created,seller_nick,payment,status,shipping_type,pay_time,modified, orders.outer_iid,orders.discount_fee,orders.payment,orders.refund_status,orders.status,orders.pic_path,orders.sku_properties_name,orders.adjust_fee, orders.outer_sku_id,orders.cid,orders.refund_id,orders.item_meal_name,orders.num,orders.title,orders.price,orders.oid,orders.total_fee,orders.num_iid,orders.sku_id,orders.seller_type"; req.StartCreated = Convert.ToDateTime(startTime); req.EndCreated = Convert.ToDateTime(endTime); req.PageSize = Convert.ToInt64(pageSize); req.PageNo = Convert.ToInt64(pageNo); if (!string.IsNullOrEmpty(buyer_nick)) { req.BuyerNick = buyer_nick; } if (!string.IsNullOrEmpty(type)) { req.Type = type; } TradesSoldGetResponse rsp = client.Execute(req, strSessionKey); hasNext = rsp.HasNext; return(rsp.Trades); } catch (Exception ex) { ExceptionReporter.WriteLog(ex, ExceptionPostion.TopApi); return(null); } }
private void DisplayShop(Shop shop) { if (!string.IsNullOrEmpty(shop.LogoUrl)) { imgShop.Visible = true; imgShop.ImageUrl = string.Format(ShopLogUrlFormat, shop.LogoUrl); } else { imgShop.Visible = false; } lblNick.Text = shop.SellerNick; lblShopTitle.Text = shop.Title; ITopClient client = GetProductTopClient(); ItemsGetRequest reqItems = new ItemsGetRequest(); reqItems.Fields = TopFieldsHelper.GetItemFields_OnlyId(); reqItems.Nicks = shop.SellerNick; reqItems.PageNo = 1; reqItems.PageSize = 1; ResponseList <Item> rsp = client.Execute(reqItems, new ItemListJsonParser()); lblItemCount.Text = rsp.TotalResults.ToString(); lblImportCount.Text = (rsp.TotalResults - IgnoreList.Count).ToString(); }
/// <summary> /// 调用API获取会员数据 /// </summary> /// <param name="currentPage"></param> /// <param name="pagesize"></param> /// <returns></returns> public List <CrmMember> GetBuyer(string strSessionKey, Int64 currentPage, Int64 pagesize) { try { if (currentPage == 0) { currentPage = 1L; } if (pagesize == 0) { pagesize = 100; } ITopClient client = TBManager.GetClient(); CrmMembersSearchRequest req = new CrmMembersSearchRequest(); req.CurrentPage = currentPage; req.PageSize = pagesize; CrmMembersSearchResponse response = client.Execute(req, strSessionKey); if (response.IsError) { ExceptionReporter.WriteLog("GetBuyer:" + response.SubErrCode + ":" + response.SubErrMsg, null, ExceptionPostion.TopApi, ExceptionRank.important); } return(response.Members); } catch (Exception ex) { ExceptionReporter.WriteLog(ex, ExceptionPostion.TopApi); return(null); } }
/// <summary> /// 调用API获取会员数据 /// </summary> /// <param name="currentPage"></param> /// <param name="pagesize"></param> /// <param name="total"></param> /// <returns></returns> public List <CrmMember> GetBuyer(string strSessionKey, Int64 currentPage, Int64 pagesize, ref Int64 total) { try { if (currentPage == 0) { currentPage = 1L; } if (pagesize == 0) { pagesize = 100; } ITopClient client = TBManager.GetClient(); CrmMembersSearchRequest req = new CrmMembersSearchRequest(); //req.MaxLastTradeTime = DateTime.Now.AddMonths(-3); req.CurrentPage = currentPage; req.PageSize = pagesize; CrmMembersSearchResponse response = client.Execute(req, strSessionKey); if (response.IsError) { ExceptionReporter.WriteLog(response.SubErrMsg, ExceptionPostion.TopApi, ExceptionRank.important); } total = response.TotalResult; return(response.Members); } catch (Exception ex) { ExceptionReporter.WriteLog(ex, ExceptionPostion.TopApi); return(null); } }
private void ImportItem(Item item) { try { ITopClient client = GetProductTopClient(); ItemAddRequest req = new ItemAddRequest(); req.ApproveStatus = item.ApproveStatus; req.EnlistTime = DateTime.Parse(item.EnlistTime); req.Num = int.Parse(item.Num); req.Price = item.Price; req.Type = item.Type; req.StuffStatus = item.StuffStatus; req.Title = item.Title; req.Desc = item.Desc; req.Cid = item.Cid; req.Location = item.Location; req.AutoRepost = item.AutoRepost; req.PostFee = item.PostFee; req.ExpressFee = item.ExpressFee; req.EmsFee = item.EmsFee; req.OuterId = item.OuterId; req.Props = item.Props; // req.SkuProps = item.SkuList; req.HasShowcase = item.HasShowcase; // req.Image = TestUtils.GetResourceAsFileItem("item.jpg"); Item importedItem = client.Execute(req, new ItemJsonParser(), CurrentSessionKey); } catch (Exception e) { throw e; } }
/// <summary> /// 获取图片分类信息 /// </summary> /// <param name="currentPage"></param> /// <param name="pageSize"></param> /// <param name="picture_category_id"></param> /// <param name="total"></param> /// <returns></returns> public static List <Picture> GetPicsBySeller(long currentPage, long pageSize, long picture_category_id, ref long total) { try { if (currentPage == 0) { currentPage = 1L; } if (pageSize == 0) { pageSize = 100; } ITopClient client = TBManager.GetClient(); PictureGetRequest req = new PictureGetRequest(); req.PageNo = currentPage; req.PageSize = pageSize; if (picture_category_id != 0) { req.PictureCategoryId = picture_category_id; } req.Deleted = "unfroze"; PictureGetResponse response = client.Execute(req, Users.SessionKey); total = response.TotalResults; return(response.Pictures); } catch (Exception ex) { ExceptionReporter.WriteLog(ex, ExceptionPostion.TopApi); return(null); } }
/// <summary> /// 产品搜索 /// </summary> /// <param name="request"></param> /// <returns></returns> public Task <List <TbkProductInfo> > Search(ProductSearchRequest request) { return(Task.Factory.StartNew(() => { List <TbkProductInfo> result = new List <TbkProductInfo>(); TbkDgItemCouponGetRequest req = new TbkDgItemCouponGetRequest(); req.AdzoneId = ConstantsUtils.ADZONE_ID; req.Platform = ConstantsUtils.PLATFORM; req.PageSize = request.PageSize; req.PageNo = request.PageNo; if (!string.IsNullOrWhiteSpace(request.KeyWord)) { req.Q = request.KeyWord; } if (request.CategoryIds != null && request.CategoryIds.Count >= 1) { req.Cat = string.Join(",", request.CategoryIds); } var response = client.Execute(req); if (null != response && response.Results != null) { response.Results.ForEach(item => { Tuple <decimal, string> coupon = CouponInfoFomarter.GetCouponPrice(item.CouponInfo); if (coupon.Item1 <= 0 || item.ZkFinalPrice.ToDecimal() - coupon.Item1 < 0) { return; } result.Add(new TbkProductInfo() { CP = coupon.Item2, FP = (item.ZkFinalPrice.ToDouble() - coupon.Item2.ToDouble()).ToString(), PTLX = item.UserType.ToString(), SPID = item.NumIid, SPMC = item.Title, SPYHQTGLJ = item.CouponClickUrl, SPYXL = item.Volume, SPZT = ToolUtils.GetThumbnail(item.PictUrl), SPJG = item.ZkFinalPrice, Rate = item.CommissionRate.ToDouble(), Desc = item.ItemDescription, }); }); } return result; })); }
protected void btnAuothOpen_Click(object sender, ImageClickEventArgs e) { try { DataRow orderDate = SellersBLL.GetSelerOrderDate(Users.Nick); if (orderDate != null) { if (orderDate["OrderVersion"].Equals("体验版")) { Response.Redirect("http://crm.new9channel.com/version/versionTip.aspx"); return; } if (AppCusBLL.CheckAppCusIsExit(Users.Nick)) { ITopClient client = TBManager.GetClient(); TmcUserCancelRequest req = new TmcUserCancelRequest(); req.Nick = Users.Nick; TmcUserCancelResponse response = client.Execute(req); if (response.IsSuccess) { AppCusBLL.DeleteSellerNifty(Users.Nick); btnAuothOpen.ImageUrl = "~/Images/rate/closed.png"; } else { lberror.Text = response.ErrMsg; } } else { ITopClient client = TBManager.GetClient(); TmcUserPermitRequest req = new TmcUserPermitRequest(); TmcUserPermitResponse response = client.Execute(req, Users.SessionKey); AppCustomer appCus = null; if (response.IsSuccess) { appCus = new AppCustomer(); appCus.Status = "1"; appCus.Nick = Users.Nick; appCus.Created = DateTime.Now.ToShortDateString(); AppCusBLL.AddAppCus(appCus); btnAuothOpen.ImageUrl = "~/Images/rate/2open.png"; } else { lberror.Text = response.ErrMsg; } } btnAuothOpen.Width = Unit.Pixel(80); btnAuothOpen.Height = Unit.Pixel(25); } } catch (Exception ex) { ExceptionReporter.WriteLog(ex, ExceptionPostion.TBApply_Web_UI); } }
//授权开通物流提醒 public static void OpenLogistics(string sellerNick) { string key = SellersBLL.GetSellerSessionKey(sellerNick); ITopClient client = TBManager.GetClient(); TmcUserPermitRequest req = new TmcUserPermitRequest(); //req.Topics = "taobao_trade_TradeCreate,taobao_refund_RefundCreate"; 不需要设置 TmcUserPermitResponse rsp = client.Execute(req, key); //Console.WriteLine(rsp.Body); }
private void DisplayShop(Shop shop) { lblTitle.Text = "导入店铺 - " + shop.Title; if (!string.IsNullOrEmpty(shop.LogoUrl)) { imgShop.Visible = true; imgShop.ImageUrl = string.Format(ShopLogUrlFormat, shop.LogoUrl); } else { imgShop.Visible = false; } lblNick.Text = shop.SellerNick; lblShopTitle.Text = shop.Title; lblCreateDate.Text = shop.Created; lblUpdateDate.Text = shop.Modified; ITopClient client = GetProductTopClient(); UserGetRequest req = new UserGetRequest(); req.Fields = TopFieldsHelper.GetUserFields_All(); req.Nick = shop.SellerNick; User user = client.Execute(req, new UserJsonParser()); if (user != null) { ucCtrlCreditBuyer.CreditNum = user.BuyerCredit.GoodNum; ucCtrlCreditSeller.CreditNum = user.SellerCredit.GoodNum; } ItemsGetRequest reqItems = new ItemsGetRequest(); reqItems.Fields = TopFieldsHelper.GetItemFields_InList(); reqItems.Nicks = shop.SellerNick; reqItems.PageNo = ucCtrlPager.PageIndex + 1; reqItems.PageSize = ucCtrlPager.PageSize; ResponseList <Item> rsp = client.Execute(reqItems, new ItemListJsonParser()); ucCtrlPager.TotalCount = (int)rsp.TotalResults; rptItems.DataSource = rsp.Content; rptItems.DataBind(); lblItemCount.Text = rsp.TotalResults.ToString(); }
/// <summary> /// 下架商品 /// </summary> /// <param name="itemId"></param> /// <returns></returns> public ApiResult ItemUpdateDelist(long itemId) { ITopClient client = GetTopClient(); ItemUpdateDelistingRequest req = new ItemUpdateDelistingRequest(); req.NumIid = itemId; ItemUpdateDelistingResponse rsp = client.Execute(req, AccessToken); return(rsp.AsApiResult());; }
private string OrderPay(string FW_GOODS, string nick) { ITopClient client = TBManager.GetClient(); VasSubscribeGetRequest req = new VasSubscribeGetRequest(); req.ArticleCode = FW_GOODS; req.Nick = nick; VasSubscribeGetResponse rsp = client.Execute(req); return(rsp.Body); }
/// <summary> /// 卖家关闭一笔交易 /// </summary> /// <param name="tid"></param> /// <param name="closeReason"></param> /// <returns></returns> /// <remarks>关闭一笔订单,可以是主订单或子订单。当订单从创建到关闭时间小于10s的时候,会报“CLOSE_TRADE_TOO_FAST”错误。</remarks> public ApiResult <long> CloseTrade(long tid, string closeReason) { ITopClient client = GetTopClient(); TradeCloseRequest req = new TradeCloseRequest(); req.Tid = tid; req.CloseReason = closeReason; TradeCloseResponse rsp = client.Execute(req, AccessToken); return(rsp.AsApiResult(() => rsp.Trade.Tid)); }
/// <summary> /// 更新商品价格 /// </summary> /// <param name="itemId"></param> /// <param name="onePrice"></param> /// <returns></returns> public ApiResult ItemUpdatePrice(long itemId, double onePrice) { ITopClient client = GetTopClient(); ItemUpdateRequest req = new ItemUpdateRequest(); req.NumIid = itemId; req.Price = onePrice.ToString("f2"); ItemUpdateResponse rsp = client.Execute(req, AccessToken); return(rsp.AsApiResult()); }
static string OrderPay(string outOrderId) { ITopClient client = TBManager.GetClient(); FuwuPurchaseOrderPayRequest req = new FuwuPurchaseOrderPayRequest(); req.Appkey = "21088197"; req.OutOrderId = outOrderId; req.DeviceType = "pc"; FuwuPurchaseOrderPayResponse rsp = client.Execute(req); return(rsp.Body); }
/// <summary> /// 获取交易信息 /// </summary> /// <param name="tid"></param> /// <returns></returns> public ApiResult <TopTrade> GetTrade(long tid) { ITopClient client = GetTopClient(); TradeFullinfoGetRequest request = new TradeFullinfoGetRequest { Tid = tid, Fields = "tid,buyer_nick,num,num_iid,created,pay_time,payment,receiver_address,status,end_time,seller_rate,seller_can_rate" }; var rsp = client.Execute(request, AccessToken); return(rsp.AsApiResult <TopTrade>(() => TopTrade.FromTrade(rsp.Trade))); }
/// <summary> /// 获取订单状态 /// </summary> /// <param name="tid"></param> /// <returns></returns> public ApiResult <string> GetTradeStatus(long tid) { ITopClient client = GetTopClient(); TradeGetRequest request = new TradeGetRequest { Fields = "status", Tid = tid }; TradeGetResponse response = client.Execute <TradeGetResponse>(request, AccessToken); return(response.AsApiResult(() => response.Trade.Status)); }
/// <summary> /// 定时上架商品,未测试。 /// </summary> /// <param name="itemId"></param> /// <param name="num"></param> /// <param name="listTime"></param> /// <returns></returns> public ApiResult ItemUpdateListWhenTime(long itemId, long?num, DateTime?listTime = null) { ITopClient client = GetTopClient(); ItemUpdateRequest req = new ItemUpdateRequest(); req.NumIid = itemId; req.ApproveStatus = "onsale"; req.ListTime = listTime; req.Num = num; ItemUpdateResponse rsp = client.Execute(req, AccessToken); return(rsp.AsApiResult()); }
private int GetTotalImportCount(string nick) { ITopClient client = GetProductTopClient(); ItemsGetRequest reqItems = new ItemsGetRequest(); reqItems.Fields = TopFieldsHelper.GetItemFields_OnlyId(); reqItems.Nicks = nick; reqItems.PageNo = 1; reqItems.PageSize = 1; ResponseList <Item> rsp = client.Execute(reqItems, new ItemListJsonParser()); return((int)rsp.TotalResults); }
private List <Item> GetItemList(string nick, int pageIndex, int pageSize) { ITopClient client = GetProductTopClient(); ItemsGetRequest reqItems = new ItemsGetRequest(); reqItems.Fields = TopFieldsHelper.GetItemFields_InList(); reqItems.Nicks = nick; reqItems.PageNo = pageIndex; reqItems.PageSize = pageSize; ResponseList <Item> rsp = client.Execute(reqItems, new ItemListJsonParser()); return(rsp.Content); }
/// <summary> /// 淘宝联盟分类信息 /// </summary> /// <param name="req"></param> /// <returns></returns> public TbkUatmFavoritesGetResponse GetTaoBaoFavorites(TbkUatmFavoritesGetRequest req) { if (req == null) { return(null); } return(Client.Execute(req)); }
public SearchResult Search(SearchCriteria criteria) { var retVal = _catalogSearchService.Search(criteria); if (criteria.ResponseGroup.HasFlag(SearchResponseGroup.WithCatalogs)) { if (!retVal.Catalogs.Contains(_taobaoCatalog)) { retVal.Catalogs.Add(_taobaoCatalog); } } if (criteria.CatalogId.EqualsInvariant("Taobao") || criteria.CatalogIds.IsNullOrEmpty()) { var request = new ItemsSearchRequest() { Q = criteria.Keyword, PageNo = criteria.Skip / Math.Max(1, criteria.Take), PageSize = criteria.Take }; var itemsSearchResponse = _topClient.Execute <ItemsSearchResponse>(request); retVal.ProductsTotalCount += (int)itemsSearchResponse.TotalResults; foreach (var item in itemsSearchResponse.ItemSearch.Items) { var product = new CatalogProduct { Id = item.NumIid.ToString(), Catalog = _taobaoCatalog, CatalogId = _taobaoCatalog.Id, Code = item.NumIid.ToString(), Name = item.Title, Images = new Image[] { new Image { Url = item.PicUrl } } }; retVal.Products.Add(product); } } return(retVal); }
private static DnsConfig GetDnsConfigFromTop(ITopClient client) { HttpdnsGetRequest req = new HttpdnsGetRequest(); HttpdnsGetResponse rsp = client.Execute(req); if (!rsp.IsError) { return(DnsConfig.parse(rsp.Result)); } else { throw new TopException(rsp.ErrCode, rsp.ErrMsg); } }
private void AddUserOrUpdateUser(string nick) { tbClient = new DefaultTopClient(Config.ServerURL, Config.Appkey, Config.Secret); UserGetRequest userReq = new UserGetRequest(); userReq.Fields = "user_id,uid,nick,sex,buyer_credit,seller_credit,location,created,last_visit,birthday,type,status,alipay_no,alipay_account,alipay_account,email,consumer_protection,alipay_bind"; userReq.Nick = nick; UserGetResponse userResp = tbClient.Execute(userReq); if (userResp.IsError) { return;//userResp.ErrorMsg 读取用户信息失败,错误信息写入日志 } //用户信息保存或修改到数据库,并获取level tb_UserEntity userE = new tb_UserEntity(); userE.email = userResp.User.Email == null ? "" : userResp.User.Email; userE.nick = userResp.User.Nick; userE.type = userResp.User.Type; string authEndTime = GetAuthEndTime(nick);//到期会员时间获取 try { userE.authEndTime = authEndTime == "" ? DateTime.Now.AddDays(-1) : Convert.ToDateTime(authEndTime); if (userE.authEndTime < DateTime.Now) { userE.syslevel = ((int)Util.Enum.UserSysLevel.Experience).ToString(); } else { userE.syslevel = ((int)Util.Enum.UserSysLevel.Member).ToString(); } } catch (Exception ex) { //日期格式转换错误 return; } userE.SessionKey = Request.QueryString["top_session"]; loginAction.AddUserOrUpdateUser(userE); }
private void Rename(long itemid,string newName) { tbClient = new DefaultTopClient(Config.ServerURL, Config.Appkey, Config.Secret); ItemUpdateRequest itemUpdateReq = new ItemUpdateRequest(); itemUpdateReq.NumIid = itemid; itemUpdateReq.Title = newName; ItemUpdateResponse itemUpdateResp = tbClient.Execute(itemUpdateReq,base.sessionkey); if (itemUpdateResp.IsError) { Alert(this, itemUpdateResp.ErrMsg); //错误日志 //itemUpdateResp.Body } }
private void BindOnsaleItem(string searchTitle) { if (Request.QueryString["PageID"] != null) { PL.PageID = Convert.ToInt16(Request.QueryString["PageID"]); } PL.PageSize = 4; int total = 0; tbClient = new DefaultTopClient(Config.ServerURL, Config.Appkey, Config.Secret); ItemsOnsaleGetRequest itemOnsaleReq = new ItemsOnsaleGetRequest(); itemOnsaleReq.Fields = "num_iid,title,price"; itemOnsaleReq.PageNo = PL.PageID; itemOnsaleReq.PageSize = PL.PageSize; if (searchTitle != "") { itemOnsaleReq.Q = searchTitle; } ItemsOnsaleGetResponse itemOnsaleResp = tbClient.Execute(itemOnsaleReq, base.sessionkey); if (!itemOnsaleResp.IsError) { DataList1.DataSource = itemOnsaleResp.Items; DataList1.DataBind(); total = (int)itemOnsaleResp.TotalResults; PL.RecordCount = total; PageListLink = new PageListBll().GetPageList(PL); } }
static void GetSellerMemo(ITopClient client, Trade trade) { if (!String.IsNullOrEmpty(trade.SellerMemo)) return; TradeGetRequest req = new TradeGetRequest(); req.Fields = "seller_memo"; req.Tid = trade.Tid; TradeGetResponse response = client.Execute(req, Global.SessionKey); if (response.Trade != null && !String.IsNullOrEmpty(response.Trade.SellerMemo)) trade.SellerMemo = response.Trade.SellerMemo; }
protected void Page_Load(object sender, EventArgs e) { cookie = HiContext.Current.Context.Request.Cookies["TopSession_" + HiContext.Current.User.UserId.ToString()]; //if (!Page.IsPostBack && ((cookie == null) || string.IsNullOrEmpty(cookie.Value))) //{ // string str = "0"; // try // { // str = base.SendHttpRequest(); // } // catch (Exception) // { // content1.Visible = false; // content12.Visible = true; // txtMsg.Text = "SAAS分销平台请求失败,可能是网络原因,请刷新重试"; // return; // } // string str5 = str; // if (str5 != null) // { // if (!(str5 == "-1")) // { // if (str5 == "-2") // { // content1.Visible = false; // content12.Visible = true; // txtMsg.Text = "更新分销商信息出错"; // return; // } // if (str5 == "-3") // { // content1.Visible = false; // content12.Visible = true; // txtMsg.Text = "添加分销商记录出错"; // return; // } // if (str5 == "-99") // { // content1.Visible = false; // content12.Visible = true; // txtMsg.Text = "未知错误"; // return; // } // if (str5 == "0") // { // content1.Visible = false; // content12.Visible = true; // txtMsg.Text = "您提交的参数有误"; // return; // } // } // else // { // content1.Visible = false; // content12.Visible = true; // txtMsg.Text = "您的供货商(即主站管理员)并没有注册开通同步淘宝"; // return; // } // } //} LoadParameters(); shippingModeDropDownList.DataBind(); btnSearch.Click += new EventHandler(btnSearch_Click); //SiteSettings masterSettings = SettingsManager.GetMasterSettings(false); SiteSettings masterSettings = SettingsManager.GetSiteSettings(HiContext.Current.User.UserId); if ((cookie == null) || string.IsNullOrEmpty(cookie.Value)) { if (null != masterSettings) { if (!(string.IsNullOrEmpty(masterSettings.Topkey) || string.IsNullOrEmpty(masterSettings.TopSecret))) { HttpCookie TaobaoSessionReturnUrlCookies = new HttpCookie("TaobaoSessionReturnUrl_" + HiContext.Current.User.UserId.ToString()); TaobaoSessionReturnUrlCookies.Value = HttpContext.Current.Request.Url.AbsoluteUri; HttpContext.Current.Response.Cookies.Add(TaobaoSessionReturnUrlCookies); Response.Redirect("http://container.api.taobao.com/container?appkey=" + Cryptographer.Decrypt(masterSettings.Topkey), true); } } else { this.ShowMsg("请先申请开店铺,设置淘宝同步信息!", false); } } else { string serverUrl = "http://gw.api.taobao.com/router/rest"; string appKey = Cryptographer.Decrypt(masterSettings.Topkey); string appSecret = Cryptographer.Decrypt(masterSettings.TopSecret); client = new DefaultTopClient(serverUrl, appKey, appSecret, "json"); TradesSoldGetRequest request2 = new TradesSoldGetRequest(); request2.Fields = "tid,created,buyer_nick,receiver_name,price,num,payment,shipping_type,post_fee,status,seller_rate,orders"; TradesSoldGetRequest request = request2; if (startDate.HasValue) { request.StartCreated = new DateTime?(startDate.Value); } if (endDate.HasValue) { request.EndCreated = new DateTime?(endDate.Value); } request.Status = "WAIT_SELLER_SEND_GOODS"; if (!string.IsNullOrEmpty(buyerNick)) { request.BuyerNick = buyerNick; } request.PageNo = new long?((long)pager.PageIndex); request.PageSize = 40; TradesSoldGetResponse response = client.Execute<TradesSoldGetResponse>(request, cookie.Value); if (!response.IsError) { List<Trade> trades = response.Trades; if (trades != null) { foreach (Trade trade in trades) { trade.ShippingType = GetShippingType(trade.ShippingType); trade.Status = GetTradeStatus(trade.Status); foreach (Order order in trade.Orders) { if (!string.IsNullOrEmpty(order.OuterSkuId)) { order.OuterSkuId = "商家编码:" + order.OuterSkuId; } } } rptTrades.DataSource = trades; rptTrades.DataBind(); pager.TotalRecords = int.Parse(response.TotalResults.ToString()); pager1.TotalRecords = int.Parse(response.TotalResults.ToString()); } } } }
private void RePrice(long itemid, string newPrice) { tbClient = new DefaultTopClient(Config.ServerURL, Config.Appkey, Config.Secret); ItemPriceUpdateRequest req = new ItemPriceUpdateRequest(); req.NumIid = itemid; req.Price = newPrice; ItemPriceUpdateResponse response = tbClient.Execute(req,base.sessionkey); if (response.IsError) { if (response.ErrCode == "42") { Alert(this, "修改价格之前需要二次授权,授权后30分钟内操作可用!"); } else { Alert(this, response.ErrMsg); } //错误日志 //itemUpdateResp.Body } }
protected void Page_Load(object sender, EventArgs e) { orderIds = Page.Request.QueryString["orderIds"]; if (string.IsNullOrEmpty(orderIds)) { litmsg.Text = "没有要转换的订单"; } else { int result = 0; int.TryParse(Page.Request.QueryString["shippingModeId"], out result); shippingMode = SubsiteSalesHelper.GetShippingMode(result, true); if (shippingMode == null) { litmsg.Text = "没有选择配送方式"; } else { distributor = HiContext.Current.User as Hidistro.Membership.Context.Distributor; cookie = HiContext.Current.Context.Request.Cookies["TopSession_" + HiContext.Current.User.UserId.ToString()]; string serverUrl = "http://gw.api.taobao.com/router/rest"; SiteSettings masterSettings = SettingsManager.GetMasterSettings(false); string appKey = Cryptographer.Decrypt(masterSettings.Topkey); string appSecret = Cryptographer.Decrypt(masterSettings.TopSecret); client = new DefaultTopClient(serverUrl, appKey, appSecret, "json"); TradeFullinfoGetRequest request2 = new TradeFullinfoGetRequest(); request2.Fields = "tid,receiver_name,receiver_state,payment,receiver_district,receiver_city,receiver_address,receiver_phone,receiver_zip,receiver_mobile,post_fee,adjust_fee,total_fee,orders"; TradeFullinfoGetRequest request = request2; string[] strArray = orderIds.Split(new char[] { ',' }); int count = 0; decimal expenditure = 0M; foreach (string str4 in strArray) { request.Tid = new long?(long.Parse(str4)); TradeFullinfoGetResponse response = client.Execute<TradeFullinfoGetResponse>(request, cookie.Value); if (!response.IsError) { try { PurchaseOrderInfo purchaseOrder = GetPurchaseOrder(response.Trade); if ((purchaseOrder != null) && SubsiteSalesHelper.CreatePurchaseOrder(purchaseOrder)) { expenditure += purchaseOrder.OrderTotal; count++; } } catch { litmsg.Text = "生成采购单发生错误,请重新尝试"; } } } if (count > 0) { SendHttpRequest(count, expenditure); litmsg.Text = string.Format("你选择的{0}淘宝订单已经成功的转换了{1}个采购单", strArray.Length, count); } else { litmsg.Text = "生成采购单失败,可能您选择的淘宝订单在系统中没有找到对应的商品"; } } } }
private void BindRemainCount() { tbClient = new DefaultTopClient(Config.ServerURL, Config.Appkey, Config.Secret); ShopRemainshowcaseGetRequest req1 = new ShopRemainshowcaseGetRequest(); ShopRemainshowcaseGetResponse resp1 = tbClient.Execute(req1, base.sessionkey); if (!resp1.IsError) { this.lblRemainCount.Text = resp1.Shop.RemainCount.ToString(); if (resp1.Shop.RemainCount <= 0) { this.lblRemainCount.ForeColor = System.Drawing.Color.Red; } } else { //调用失败 ,可能是sessionkey过期 this.lblRemainCount.Text = ""; } }
private void Doupromoted() { foreach (DataListItem item in DataList1.Items) { CheckBox cbo = item.FindControl("cbolist") as CheckBox; if (cbo.Checked) { long iid = Convert.ToInt64((item.FindControl("item") as System.Web.UI.HtmlControls.HtmlInputText).Value); tbClient = new DefaultTopClient(Config.ServerURL, Config.Appkey, Config.Secret); ItemRecommendDeleteRequest req3 = new ItemRecommendDeleteRequest(); req3.NumIid = iid; ItemRecommendDeleteResponse resp3 = tbClient.Execute(req3, base.sessionkey); tb_RecommendResultEntity rre = new tb_RecommendResultEntity(); rre.nick = base.nick; rre.operatTime = DateTime.Now; rre.Result = resp3.Body; rre.type = "M"; if (resp3.IsError) { //取消橱窗失败,可能是sessionkey过期 rre.isSuccess = false; scheduleRecommendAction.ResultWrite(rre); } else { rre.isSuccess = true; scheduleRecommendAction.ResultWrite(rre); } } } BindRemainCount(); BindOnsaleItem(this.txtTitleSearch.Text); }