Example #1
0
 /// <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);
     }
 }
Example #2
0
        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));
        }
Example #3
0
 /// <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);
     }
 }
Example #4
0
 /// <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);
     }
 }
Example #5
0
 /// <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;
            }
        }
Example #7
0
        /// <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();
        }
Example #9
0
        /// <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);
            }
        }
Example #10
0
 /// <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("");
     }
 }
 public static ITopClient GetTopClient()
 {
     if (itopclient == null)
     {
         itopclient = new DefaultTopClient(serverurl, appkey, appsecret);
     }
     return itopclient;
 }
Example #12
0
 /// <summary>
 /// 传入淘宝开发者配置信息
 /// </summary>
 /// <param name="url">参数:调用环境</param>
 /// <param name="appkey">参数:App Key</param>
 /// <param name="secret">参数:App Secret</param>
 /// <returns>返回:TOP客户端</returns>
 public static ITopClient Get(string url, string appkey, string secret)
 {
     if (client == null)
     {
         client = new Top.Api.DefaultTopClient(url, appkey, secret);
     }
     return(client);
 }
Example #13
0
 public TaobaoCatalogSearchImpl(Func <ICatalogRepository> catalogRepositoryFactory, ICacheManager <object> cacheManager, ICatalogSearchService catalogSearchService, ITopClient topClient, IItemService productService, ISearchQueryBuilder luceneQueryBuilder)
     : base(catalogRepositoryFactory, cacheManager)
 {
     _catalogSearchService = catalogSearchService;
     _topClient            = topClient;
     _productService       = productService;
     _luceneQueryBuilder   = luceneQueryBuilder;
 }
Example #14
0
        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);
            }
        }
Example #15
0
        public SecurityCore(ITopClient topClient, string randomNum)
        {
            this.topClient = topClient;
            this.randomNum = randomNum;
            // 初始化报表
            ApiReporter apiReporter = new ApiReporter();

            apiReporter.InitSecret(topClient);
        }
Example #16
0
 //授权开通物流提醒
 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);
 }
Example #17
0
        /// <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());;
        }
Example #18
0
        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);
        }
Example #19
0
        /// <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());
        }
Example #20
0
        /// <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));
        }
Example #21
0
        /// <summary>
        /// 在Web.config文件里获取淘宝开发者配置信息
        /// </summary>
        /// <returns>返回:TOP客户端</returns>
        public static ITopClient Get()
        {
            String taoke_url    = ConfigurationManager.AppSettings["taoke_url"].ToString();
            String taoke_appkey = ConfigurationManager.AppSettings["taoke_appkey"].ToString();
            String taoke_secret = ConfigurationManager.AppSettings["taoke_secret"].ToString();

            if (client == null)
            {
                client = new Top.Api.DefaultTopClient(taoke_url, taoke_appkey, taoke_secret);
            }
            return(client);
        }
Example #22
0
 public void InitSecret(ITopClient topClient)
 {
     this.topClient = topClient;
     lock (InitSecretLock)
     {
         if (!SecretTreadCreated)
         {
             InitSecretThread();
             SecretTreadCreated = true;
         }
     }
 }
Example #23
0
        /// <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)));
        }
Example #24
0
        /// <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));
        }
Example #25
0
        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);
        }
        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);
        }
Example #27
0
        /// <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 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);
        }
Example #29
0
 static OpenUserInfoService()
 {
     if (WebConfigurationManager.AppSettings["OpenIMAppKey"] != null && WebConfigurationManager.AppSettings["OpenIMAppSecret"] != null)
     {
         AppKey    = WebConfigurationManager.AppSettings["OpenIMAppKey"].ToString();
         AppSecret = WebConfigurationManager.AppSettings["OpenIMAppSecret"].ToString();
     }
     else
     {
         throw new Exception("OpenIMAppKey或OpenIMAppSecret没有进行配置");
     }
     client = new DefaultTopClient(Url, AppKey, AppSecret);
 }
Example #30
0
        public static void InitRefreshThread(ITopClient client)
        {
            if (refreshThread == null)
            {
                lock (initLock)
                {
                    if (refreshThread == null)
                    {
                        try
                        {
                            DnsConfig remoteConfig = GetDnsConfigFromTop(client);
                            if (dnsConfig == null)
                            {
                                dnsConfig = remoteConfig;
                            }
                            else if (remoteConfig != null && remoteConfig.GetVersion() > dnsConfig.GetVersion())
                            {
                                dnsConfig = remoteConfig;
                            }
                        }
                        catch (TopException e)
                        {
                            if ("22".Equals(e.ErrorCode))
                            {
                                return; // 如果HTTP DNS服务不存在,则退出守护线程
                            }
                        }

                        refreshThread = new Thread(o =>
                        {
                            while (true)
                            {
                                try
                                {
                                    Thread.Sleep(dnsConfig.GetRefreshInterval() * 60 * 1000);
                                    dnsConfig = GetDnsConfigFromTop(client);
                                }
                                catch (Exception e)
                                {
                                    Console.WriteLine(e.StackTrace);
                                    Thread.Sleep(3 * 1000); // 出错则过3秒重试
                                }
                            }
                        });
                        refreshThread.IsBackground = true;
                        refreshThread.Name         = "HTTP_DNS_REFRESH_THREAD";
                        refreshThread.Start();
                    }
                }
            }
        }
Example #31
0
        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);
            }
        }
Example #32
0
 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);
 }
Example #33
0
    //get trade detail information by trade ID(tid) which is got from Traderates result.
    private void GetUserAddress(ref ITopClient client, ref TraderatesGetRequest req, ref TraderatesGetResponse GetUserAddress_response)
    {
        ITopClient GetUserAddressclient = new DefaultTopClient(url, appkey, appsecret);
        TradeFullinfoGetRequest GetUserAddress_req = new TradeFullinfoGetRequest();
        GetUserAddress_req.Fields = "alipay_no,commission_fee,received_payment,buyer_alipay_no,receiver_name,receiver_state, receiver_city, receiver_district, receiver_address, receiver_zip, receiver_mobile, receiver_phone,seller_flag";
        GetUserAddress_req.Tid = GetUserAddress_response.TradeRates[0].Tid;

        TradeFullinfoGetResponse response = GetUserAddressclient.Execute(GetUserAddress_req, sessionKey);
        //买家信息.Text = response.Trade.ReceiverAddress;

        NamePhone.Text = response.Trade.ReceiverName + response.Trade.ReceiverPhone + response.Trade.ReceiverMobile;
        BuyerAddress.Text = response.Trade.ReceiverState + " " + response.Trade.ReceiverCity + " " + response.Trade.ReceiverDistrict + " " + response.Trade.ReceiverAddress;
    }
Example #34
0
 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
     }
 }
Example #35
0
        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;
        }
Example #36
0
        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());
                    }
                }
            }
        }
Example #37
0
 public TmallClient()
 {
     _client = new DefaultTopClient(Url, Appkey, AppSecret);
 }
Example #38
0
        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);
            }
        }
Example #39
0
 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);
 }
Example #40
0
 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 = "";
     }
 }
 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 = "生成采购单失败,可能您选择的淘宝订单在系统中没有找到对应的商品";
             }
         }
     }
 }
Example #42
0
        public void ProcessRequest(HttpContext context)
        {
            string appkey = context.Request.Form["appkey"];
            string appsecret = context.Request.Form["appsecret"];
            string sessionkey = context.Request.Form["sessionkey"];
            string productIds = context.Request.Form["productIds"];
            string approve_status = context.Request.Form["approve_status"];
            string morepic = context.Request.Form["morepic"];
            string repub = context.Request.Form["repub"];
            string chkdesc = context.Request.Form["chkdesc"];
            string chknormal = context.Request.Form["chknormal"];
            string chktitle = context.Request.Form["chktitle"];

            if (!string.IsNullOrEmpty(appkey) && !string.IsNullOrEmpty(appsecret))
            {
                this.client = new DefaultTopClient("http://gw.api.taobao.com/router/rest", appkey, appsecret, "json");
            }

            DataTable taobaoProducts = SubSiteProducthelper.GetTaobaoProducts(productIds);

            if (null != taobaoProducts && taobaoProducts.Rows.Count > 0)
            {
                Dictionary<int, long> taobaoReturnProductIds = new Dictionary<int, long>();

                StringBuilder builder = new StringBuilder();
                string pname = "";
                int num = 0;
                string imgurl = "";
                int stock = 0;
                decimal markprice = 0M;
                string issuccess = "true";
                string msg = "";
                string imgmsg = "";
                string proTitle = "";// (string)row["ProTitle"];

                foreach (DataRow row in taobaoProducts.Rows)
                {
                    proTitle = (string)row["ProTitle"];

                    ResponseData(row, out imgurl, out stock, out markprice);

                    if ((row["taobaoproductid"] != DBNull.Value) && (repub.ToLower() == "true"))
                    {
                        ItemUpdateRequest req = new ItemUpdateRequest();

                        req.NumIid = new long?(Convert.ToInt64(row["taobaoproductid"]));

                        req.ApproveStatus = approve_status;

                        if (!string.IsNullOrEmpty(chknormal) && (chknormal.ToLower() == "true"))
                        {
                            this.SetTaoBaoUpdateData(req, row);
                        }

                        if (!string.IsNullOrEmpty(chktitle) && (chktitle.ToLower() == "true"))
                        {
                            req.Title = (row["ProTitle"] == DBNull.Value) ? "请修改商品标题" : ((string)row["ProTitle"]);
                        }

                        if (!string.IsNullOrEmpty(chkdesc) && (chkdesc.ToLower() == "true"))
                        {
                            req.Desc = (row["Description"] == DBNull.Value) ? "暂无该商品的描述信息" : ((string)row["Description"]);
                        }

                        ItemUpdateResponse response = client.Execute<ItemUpdateResponse>(req, sessionkey);

                        if (response.IsError)
                        {

                            num = (int)row["ProductId"];

                            pname = string.Format("<a href='{0}' target=_blank>{1} </a>", Globals.GetSiteUrls().UrlData.FormatUrl("productDetails", new object[] { num }), proTitle);

                            imgurl = string.Format("<a href='{0}' target=_blank><img src={1} /></a>", Globals.GetSiteUrls().UrlData.FormatUrl("productDetails", new object[] { num }), imgurl);

                            msg = string.Format("商品更新失败<br/>({0})", ":" + response.ErrMsg + ":" + response.SubErrMsg);

                            issuccess = "false";

                        }
                        else
                        {
                            imgurl = string.Format("<a href='http://item.taobao.com/item.htm?id={0}' target=_blank><img src={1} /></a>", response.Item.NumIid, imgurl);

                            pname = string.Format("<a href='http://item.taobao.com/item.htm?id={0}'>{1}</a>", response.Item.NumIid, proTitle);

                            msg = "商品更新成功";

                            issuccess = "true";

                            taobaoReturnProductIds.Add((int)row["ProductId"], response.Item.NumIid);

                        }
                    }
                    else
                    {
                        ItemAddRequest req = new ItemAddRequest();

                        req.ApproveStatus = approve_status;

                        SetTaoBaoAddData(req, row);

                        ItemAddResponse response2 = client.Execute<ItemAddResponse>(req, sessionkey);

                        if (response2.IsError)
                        {
                            num = (int)row["ProductId"];

                            pname = string.Format("<a href='{0}' target=_blank>{1} </a>", Globals.GetSiteUrls().UrlData.FormatUrl("productDetails", new object[] { num }), proTitle);

                            imgurl = string.Format("<a href='{0}' target=_blank><img src={1} /></a>", Globals.GetSiteUrls().UrlData.FormatUrl("productDetails", new object[] { num }), imgurl);

                            msg = string.Format("发布失败<br/>({0})", response2.ErrMsg + ":" + response2.SubErrMsg);

                            issuccess = "false";

                        }
                        else
                        {
                            imgurl = string.Format("<a href='http://item.taobao.com/item.htm?id={0}' target=_blank><img src={1} /></a>", response2.Item.NumIid, imgurl);

                            pname = string.Format("<a href='http://item.taobao.com/item.htm?id={0}'>{1}</a>", response2.Item.NumIid, proTitle);

                            msg = "商品发布成功";

                            issuccess = "true";

                            taobaoReturnProductIds.Add((int)row["ProductId"], response2.Item.NumIid);

                            if (morepic == "true")
                            {
                                List<TbImage> productsImgs = this.GetProductsImgs(row, response2);

                                StringBuilder builder2 = new StringBuilder();

                                foreach (TbImage image in productsImgs)
                                {
                                    string path = Globals.ApplicationPath + image.Imgpath;

                                    if (File.Exists(Globals.MapPath(path)))
                                    {
                                        FileItem item = new FileItem(Globals.MapPath(path));

                                        ItemImgUploadRequest request = new ItemImgUploadRequest();

                                        request.Image = item;

                                        request.NumIid = new long?(image.TbProductId);

                                        request.IsMajor = false;

                                        ItemImgUploadResponse itemImgUploadResponse = this.client.Execute<ItemImgUploadResponse>(request, sessionkey);

                                        if (itemImgUploadResponse.IsError)
                                        {
                                            builder2.AppendFormat("[\"{0}发布图片错误,错误原因:{1}\"],", proTitle, itemImgUploadResponse.ErrMsg + ";" + itemImgUploadResponse.SubErrMsg);
                                        }

                                    }
                                }

                                if (builder2.Length > 0)
                                {

                                    imgmsg = builder2.ToString().Substring(0, builder2.ToString().Length - 1);

                                }

                            }
                        }
                    }

                    builder.Append(string.Concat(new object[] { "{\"pname\":\"", pname, "\",\"pimg\":\"", imgurl, "\",\"pmarkprice\":\"", markprice.ToString("F2"), "\",\"pstock\":\"", stock, "\",\"issuccess\":\"", issuccess, "\",\"msg\":\"", msg, "\",\"imgmsg\":[", imgmsg, "]}," }));

                }

                if (taobaoReturnProductIds.Count > 0)
                {
                    SubSiteProducthelper.AddTaobaoReturnProductIds(taobaoReturnProductIds, 0);
                }

                if (builder.ToString().Length > 0)
                {
                    builder.Remove(builder.Length - 1, 1);
                }

                context.Response.Write("{\"Status\":\"OK\",\"Result\":[" + builder.ToString() + "]}");
                context.Response.Flush();
                context.Response.End();
            }
            else
            {
                context.Response.Write("{\"Status\":\"Error\",\"Result\":\"发布商品到淘宝出错!\"}");
                context.Response.Flush();
                context.Response.End();
            }
        }
Example #43
0
 /// <summary>
 /// 淘宝 客户对象
 /// </summary>
 public ITopClient TopClient(ResultFormat resultFormat)
 {
     return _topClient ??
            (_topClient = new DefaultTopClient(TopUtility.TopApiUrl, AppKey, AppSecret, resultFormat.ToString()));
 }
Example #44
0
 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
     }
 }
 public static ITopClient GetTopClient()
 {
     return _itopclient ?? (_itopclient = new DefaultTopClient(ServerUrl, Appkey, Appsecret));
 }