Exemplo n.º 1
0
        /// <summary>
        /// taobao.tbk.dg.newuser.order.sum( 拉新活动汇总API--导购 )
        /// </summary>
        public static void GetDgNewuserOrderSum()
        {
            var client = GetClient();
            TbkDgNewuserOrderSumRequest req = new TbkDgNewuserOrderSumRequest();

            req.PageSize    = 20L;
            req.AdzoneId    = 123L;   //mm_xxx_xxx_xxx的第三位,Must
            req.PageNo      = 1L;
            req.SiteId      = 123L;   //mm_xxx_xxx_xxx的第二位
            req.ActivityId  = "sxxx"; //活动id, 活动名称与活动ID列表,请参见https://tbk.bbs.taobao.com/detail.html?appId=45301&postId=8599277,Must
            req.SettleMonth = "201807";
            TbkDgNewuserOrderSumResponse rsp = client.Execute(req);

            Console.WriteLine(rsp.Body);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Sum(int ActivityID, TaoBaoSumModel sumModel)
        {
            var activity = await _context.ActivityModel.FirstOrDefaultAsync(i => i.ID == ActivityID);

            if (activity == null)
            {
                return(NotFound());
            }
            var pageindex = 1;
            List <TaoBaoSumItem> ItemList = new List <TaoBaoSumItem>();

            while (true)
            {
                ITopClient client = new DefaultTopClient("http://gw.api.taobao.com/router/rest", Program.Websiteconfig.TaoBaoAppKey, Program.Websiteconfig.TaoBaoAppSecret, "json");
                TbkDgNewuserOrderSumRequest req = new TbkDgNewuserOrderSumRequest();
                req.PageSize   = 100L;
                req.PageNo     = pageindex;
                req.ActivityId = activity.ActivityApiID;
                TbkDgNewuserOrderSumResponse rsp        = client.Execute(req);
                DataContractJsonSerializer   serializer = new DataContractJsonSerializer(typeof(TaoBaoSumModelOrgin));
                MemoryStream ms         = new MemoryStream(Encoding.UTF8.GetBytes(rsp.Body));
                var          modelOrgin = (TaoBaoSumModelOrgin)serializer.ReadObject(ms);

                if (modelOrgin.taoBaoSumModelSecond.taoBaoSumModel.taoBaoSumModel.Results.taoBaoSumItems == null) //没有数据
                {
                    sumModel.NoData = true;
                    break;
                }
                ItemList.AddRange(modelOrgin.taoBaoSumModelSecond.taoBaoSumModel.taoBaoSumModel.Results.taoBaoSumItems);
                if (modelOrgin.taoBaoSumModelSecond.taoBaoSumModel.taoBaoSumModel.HasNext == false)
                {
                    break;
                }
                pageindex++;
            }
            sumModel.DataModels   = ItemList;
            sumModel.ActivityName = activity.ActivityName;
            sumModel.ActivityID   = activity.ID;
            return(View(sumModel));
        }