Example #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (!string.IsNullOrEmpty(Request.QueryString["visitip"]))
            {
                DateTime[] darray = DataHelper.GetDateTime(DateTime.Now, 1);
                try
                {
                    string start = HttpUtility.UrlDecode(Request.QueryString["start"]);
                    string end   = HttpUtility.UrlDecode(Request.QueryString["end"]);
                    darray[0] = DateTime.Parse(start.Substring(0, start.LastIndexOf('-')) + " " + start.Substring(start.LastIndexOf('-') + 1, 2) + ":0:0");
                    darray[1] = DateTime.Parse(end.Substring(0, end.LastIndexOf('-')) + " " + end.Substring(end.LastIndexOf('-') + 1, 2) + ":0:0");
                }
                catch
                {
                }

                string nick    = HttpUtility.UrlDecode(Request.Cookies["nick"].Value);
                string session = Request.Cookies["nicksession"].Value;
                if (ViewState["GoodsClassList"] == null)
                {
                    GoodsClassList = TaoBaoAPI.GetGoodsClassInfoList(nick, Request.Cookies["nicksession"].Value);
                }
                Bind(nick, session, darray[0], darray[1]);
            }
        }
    }
Example #2
0
        public void GetTaoBaoGoods()
        {
            NickSessionService nsDal = new NickSessionService();
            IList <Model.TopNickSessionInfo> list = nsDal.GetAllNickSession(new[] { TopTaoBaoService.Temporary, TopTaoBaoService.YingXiaoJueCe });

            GoodsService goodsDal = new GoodsService();

            for (int i = 0; i < list.Count; i++)
            {
                string shopId = TaoBaoAPI.GetShopInfo(list[i].Nick, list[i].Session);
                list[i].ShopId = shopId;
                nsDal.UpdateNickShop(list[i].Nick, shopId);
            }

            foreach (Model.TopNickSessionInfo info in list)
            {
                List <GoodsInfo> goodsList = TaoBaoAPIService.GetGoodsInfoListByNick(info.Nick, info.Session, info.ServiceId);

                List <GoodsInfo> allGoods = goodsDal.GetAllGoods(info.Nick);

                foreach (GoodsInfo ginfo in goodsList)
                {
                    if (allGoods.Contains(ginfo))
                    {
                        goodsDal.UpdateGoodsInfo(ginfo);
                    }
                    else
                    {
                        goodsDal.InsertGoods(ginfo, info.Nick);
                    }
                }
            }
        }
    private static void ActionGoods(string nick, string session, TeteShopInfo info)
    {
        TeteShopItemService itemDal = new TeteShopItemService();

        List <GoodsInfo>         glist    = TaoBaoAPI.GetGoodsInfoListByNick(info.Short, session, info.Appkey, info.Appsecret);
        IList <TeteShopItemInfo> itemList = itemDal.GetAllTeteShopItem(Encrypt(nick));

        List <TeteShopItemInfo> addList = new List <TeteShopItemInfo>();
        List <TeteShopItemInfo> upList  = new List <TeteShopItemInfo>();

        foreach (GoodsInfo cinfo in glist)
        {
            List <TeteShopItemInfo> clist = itemList.Where(o => o.Itemid == cinfo.num_iid).ToList();
            if (clist.Count > 0)
            {
                InitItem(nick, cinfo, clist[0]);
                upList.Add(clist[0]);
            }

            else
            {
                TeteShopItemInfo ainfo = new TeteShopItemInfo();
                InitItem(nick, cinfo, ainfo);

                addList.Add(ainfo);
            }
        }

        //添加
        foreach (TeteShopItemInfo cinfo in addList)
        {
            itemDal.AddTeteShopItem(cinfo);
        }

        //修改
        foreach (TeteShopItemInfo cinfo in upList)
        {
            itemDal.ModifyTeteShopItem(cinfo);
        }

        //删除
        //List<TeteShopItemInfo> delList = new List<TeteShopItemInfo>();
        //foreach (TeteShopItemInfo cinfo in itemList)
        //{
        //    if (upList.Where(o => o.Itemid == cinfo.Itemid).ToList().Count == 0)
        //    {
        //        delList.Add(cinfo);
        //    }
        //}

        //foreach (TeteShopItemInfo cinfo in upList)
        //{
        //    itemDal.DeleteTeteShopItem(cinfo.Id);
        //}
    }
Example #4
0
 protected void Btn_AddCId_Click(object sender, EventArgs e)
 {
     if (TaoBaoAPI.AddCID(HttpUtility.UrlDecode(Request.Cookies["nick"].Value), Request.Cookies["nicksession"].Value))
     {
         Page.RegisterStartupScript("恭喜", "<script>alert('添加成功!');</script>");
     }
     else
     {
         Page.RegisterStartupScript("抱歉", "<script>alert('添加失败!');</script>");
     }
 }
Example #5
0
    /// <summary>
    /// 插入session
    /// </summary>
    private void InsertSession()
    {
        TopNickSessionInfo info = new TopNickSessionInfo();

        info.Nick      = nick;
        info.Session   = top_session;
        info.NickState = true;
        DateTime now = DateTime.Now;

        info.JoinDate         = now;
        info.LastGetOrderTime = now;
        info.ShopId           = "";//先赋空值
        info.ServiceId        = Enum.TopTaoBaoService.YingXiaoJueCe;
        //有则不添加
        if (CacheCollection.GetNickSessionList().Where(o => o.Nick == nick && o.ServiceId == Enum.TopTaoBaoService.YingXiaoJueCe).ToList().Count == 0)
        {
            //先添加后删除缓存
            new NickSessionService().InsertSerssionNew(info);
            CacheCollection.RemoveCacheByKey(CacheCollection.KEY_ALLNICKSESSIONINFO);
        }
        else
        {
            //新session赋值
            CacheCollection.GetNickSessionList().Where(o => o.Nick == nick && o.ServiceId == Enum.TopTaoBaoService.YingXiaoJueCe).ToList()[0].Session = top_session;
        }
        //修改缓存后读取店铺信息
        info.ShopId = TaoBaoAPI.GetShopInfo(nick, top_session);
        //更新店铺信息
        new NickSessionService().UpdateSession(info);
        //更新缓存
        CacheCollection.GetNickSessionList().Where(o => o.Nick == nick && o.ServiceId == Enum.TopTaoBaoService.YingXiaoJueCe).ToList()[0].ShopId = info.ShopId;

        HttpCookie cookie       = new HttpCookie("nick", HttpUtility.UrlEncode(nick));
        HttpCookie cooksession  = new HttpCookie("nicksession", top_session);
        HttpCookie cookietongji = new HttpCookie("istongji", "1");

        cookie.Expires       = DateTime.Now.AddDays(1);
        cooksession.Expires  = DateTime.Now.AddDays(1);
        cookietongji.Expires = DateTime.Now.AddDays(1);

        Response.Cookies.Add(cookie);
        Response.Cookies.Add(cooksession);
        Response.Cookies.Add(cookietongji);
    }
Example #6
0
    public static void GetAllGoods(string nick, string session)
    {
        GoodsService     goodsDal  = new GoodsService();
        List <GoodsInfo> goodsList = TaoBaoAPI.GetGoodsInfoListByNick(nick, session);

        List <GoodsInfo> allGoods = goodsDal.GetAllGoods(nick);

        foreach (GoodsInfo ginfo in goodsList)
        {
            if (allGoods.Contains(ginfo))
            {
                goodsDal.UpdateGoodsInfo(ginfo);
            }
            else
            {
                goodsDal.InsertGoods(ginfo, nick);
            }
        }
    }
Example #7
0
    protected void Btn_AddCa_Click(object sender, EventArgs e)
    {
        string       nick = HttpUtility.UrlDecode(Request.Cookies["nick"].Value);
        TeteShopInfo info = new TeteShopService().GetShopInfo(Encrypt(nick));

        if (info == null)
        {
            Page.RegisterStartupScript("抱歉", "<script>alert('您还未购买!');</script>");
            return;
        }

        if (TaoBaoAPI.AddCID(nick, Request.Cookies["nicksession"].Value, info.Appkey, info.Appsecret, "http://iphone.7fshop.com/apkimg/" + nick + "_s.jpg"))
        {
            Page.RegisterStartupScript("恭喜", "<script>alert('添加成功!');</script>");

            Lbl_Over.Visible = true;
        }
        else
        {
            Page.RegisterStartupScript("抱歉", "<script>alert('添加失败!');</script>");
        }
    }
Example #8
0
    private static void InsertGoodsOrderByState(DateTime start, DateTime end, string orderState, string session, string nick, TaoBaoGoodsOrderService tbgoDal, List <string> tids)
    {
        IList <GoodsOrderInfo> goodsOrderList = TaoBaoAPI.GetGoodsOrderInfoList(nick, start, end, session, orderState);

        if (goodsOrderList == null)
        {
            LogInfo.WriteLog("订购时获取订单错误", "参数错误");
        }
        else
        {
            for (int i = 0; i < goodsOrderList.Count; i++)
            {
                //判断是否已经添加
                if (tids.Contains(goodsOrderList[i].tid))
                {
                    continue;
                }

                goodsOrderList[i].UsePromotion = TaoBaoAPI.GetPromotion(nick, session, goodsOrderList[i].tid, "店铺优惠券");
                goodsOrderList[i].PingInfo     = TaoBaoAPI.GetPingjia(nick, session, goodsOrderList[i].tid);
                if (goodsOrderList[i].PingInfo == null)
                {
                    goodsOrderList[i].PingInfo = new PingJiaInfo
                    {
                        content = "",
                        created = DateTime.Parse("1990-1-1"),
                        result  = ""
                    };
                }
                tbgoDal.InsertTaoBaoGoodsOrder(goodsOrderList[i]);
                tbgoDal.InsertChildOrderInfo(goodsOrderList[i].orders, goodsOrderList[i].tid);
                //添加进集合
                tids.Add(goodsOrderList[i].tid);
            }
        }
    }
Example #9
0
    public static DateTime GetTalkContent(string nick, string session, DateTime now)
    {
        TalkRecodService trDal   = new TalkRecodService();
        SubUserService   userDal = new SubUserService();

        DateTime max = DateTime.Parse(now.AddDays(-6).ToShortDateString());

        trDal.CreateTable(DBHelp.DataHelper.Encrypt(nick));

        List <string> childNicks = new List <string>();
        //try
        //{
        IList <TaoBaoAPIHelper.SubUserInfo> userList    = TaoBaoAPI.GetChildNick(nick, session);
        List <TaoBaoAPIHelper.SubUserInfo>  hasuserList = userDal.GetAllChildNick(nick);

        foreach (TaoBaoAPIHelper.SubUserInfo uinfo in userList)
        {
            childNicks.Add(uinfo.nick);
            if (hasuserList.Where(o => o.nick == uinfo.nick).ToList().Count == 0)
            {
                userDal.InsertSubUserInfo(uinfo);
            }
        }

        foreach (string fromNick in childNicks)
        {
            max = trDal.GetMaxTime(nick, fromNick);

            //获取聊天对象列表,查询时间段<=7天,只支持xml返回
            if (max.AddDays(7) <= now)
            {
                max = now.AddDays(-6);
            }

            List <TaoBaoAPIHelper.TalkContent> allcontent = trDal.GetAllContent(max.AddHours(-16), max, nick, fromNick);

            List <TaoBaoAPIHelper.TalkObj> objList = TaoBaoAPIHelper.TaoBaoAPI.GetTalkObjList(fromNick.Replace("cntaobao", ""), session, max, now);
            foreach (TaoBaoAPIHelper.TalkObj obj in objList)
            {
                List <TaoBaoAPIHelper.TalkContent> contents = TaoBaoAPIHelper.TaoBaoAPI.GetTalkContentNow(session, fromNick.Replace("cntaobao", ""), obj.uid.Replace("cntaobao", ""), max, now);

                for (int i = 0; i < contents.Count; i++)
                {
                    contents[i].FromNick = fromNick.Replace("cntaobao", "");
                    contents[i].ToNick   = obj.uid.Replace("cntaobao", "");

                    if (allcontent.Contains(contents[i]))
                    {
                        continue;
                    }
                    trDal.InsertContent(contents[i], nick);
                }
            }
        }
        //}
        //catch (Exception ex)
        //{
        //    LogInfo.WriteLog("首次加载失败了", ex.Message);
        //}

        //返回获取聊天记录的开始时间
        return(max);
    }
Example #10
0
    public static void UpdateSiteTotal(string nick, string session, DateTime now, SiteTotalService taoDal)
    {
        RefundService           refDal  = new RefundService();
        TaoBaoGoodsOrderService tbgoDal = new TaoBaoGoodsOrderService();

        List <RefundInfo> refundList = (List <RefundInfo>)TaoBaoAPI.GetRefundInfoList(now.AddDays(-2), now, nick, session, "SUCCESS");
        //所有有订单的用户
        TopSiteTotalInfo stinfo = taoDal.GetOrderTotalPay(DateTime.Parse(now.ToShortDateString()), DateTime.Parse(now.AddDays(1).ToShortDateString()), nick);
        //所有表名(添加过统计代码到网页的)
        List <string> tableList   = taoDal.GetTableName();
        string        tablename   = GetTableName(nick);
        List <string> mytablelist = tableList.Where(o => o == tablename).ToList();

        TopSiteTotalInfo addup = new TopSiteTotalInfo();

        addup.SiteNick      = nick;
        addup.SiteTotalDate = now.ToString("yyyyMMdd");
        //给询单数赋值
        addup.AskOrder = new TalkRecodService().GetCustomerList(DateTime.Parse(now.ToShortDateString()), DateTime.Parse(now.AddDays(1).ToShortDateString()), nick).Count;

        //有添加统计代码
        if (mytablelist.Count > 0)
        {
            //有订单
            if (stinfo != null)
            {
                addup.SiteOrderCount     = stinfo.SiteOrderCount;
                addup.SiteOrderPay       = stinfo.SiteOrderPay;
                addup.PostFee            = stinfo.PostFee;
                addup.SiteBuyCustomTotal = stinfo.SiteBuyCustomTotal;
                addup.SiteSecondBuy      = taoDal.GetSecondBuyTotal(DateTime.Parse(now.ToShortDateString()), DateTime.Parse(now.AddDays(1).ToShortDateString()), nick);
            }
            TopSiteTotalInfo puvinfo = taoDal.GetPvUvTotal(DateTime.Parse(now.ToShortDateString()), DateTime.Parse(now.AddDays(1).ToShortDateString()), tablename);
            addup.SiteUVCount  = puvinfo.SiteUVCount;
            addup.SitePVCount  = puvinfo.SitePVCount;
            addup.ZhiTongFlow  = taoDal.GetZhiTongTotal(now, now.AddDays(1), tablename);
            addup.SiteZuanZhan = taoDal.GetZuanZhanTotal(now, now.AddDays(1), tablename);

            addup.SiteUVBack = taoDal.GetBackTotal(DateTime.Parse(now.ToShortDateString()), DateTime.Parse(now.AddDays(1).ToShortDateString()), tablename);
        }
        else
        {
            //有订单
            if (stinfo != null)
            {
                addup.SiteOrderCount     = stinfo.SiteOrderCount;
                addup.SiteOrderPay       = stinfo.SiteOrderPay;
                addup.PostFee            = stinfo.PostFee;
                addup.SiteBuyCustomTotal = stinfo.SiteBuyCustomTotal;
                addup.SiteSecondBuy      = taoDal.GetSecondBuyTotal(DateTime.Parse(now.ToShortDateString()), DateTime.Parse(now.AddDays(1).ToShortDateString()), nick);
            }
        }

        IList <string> tidList = taoDal.GetOrderIds(DateTime.Parse(now.ToShortDateString()), DateTime.Parse(now.AddDays(1).ToShortDateString()), nick);

        if (tidList.Count > 0)
        {
            addup.GoodsCount = taoDal.GetGoodsCount(tidList);
        }
        List <RefundInfo> hadReList = refDal.GetAllRefund(nick, now.AddDays(-2), now);

        //退款情况
        List <RefundInfo> trefundList = refundList.Where(o => o.modified.ToShortDateString() == now.ToShortDateString()).ToList();

        if (trefundList.Count > 0)
        {
            int     rorderCount = 0;
            decimal rpay        = 0;
            foreach (RefundInfo refund in new List <RefundInfo>(trefundList))
            {
                if (!tidList.Contains(refund.tid))
                {
                    GoodsOrderInfo roinfo = tbgoDal.GetGoodsOrderInfo(refund.tid);
                    if (roinfo == null)
                    {
                        continue;
                    }
                    else
                    {
                        if (hadReList.Where(o => o.tid == refund.tid).ToList().Count > 0)
                        {
                            continue;
                        }
                        if (roinfo.pay_time != DateTime.Parse("1990-1-1"))
                        {
                            refund.OrderTime = roinfo.pay_time;
                        }
                        else
                        {
                            refund.OrderTime = roinfo.created;
                        }
                        refund.seller_nick = nick;
                        refDal.AddRefund(refund);
                        //需要查询这一天有多少订单
                        RefundInfo newrefund = refDal.GetRefundTotal(nick, DateTime.Parse(refund.OrderTime.ToShortDateString()), DateTime.Parse(refund.OrderTime.ToShortDateString()).AddDays(1));

                        taoDal.UpdateGoodsOrderInfo(nick, refund.OrderTime.ToString("yyyyMMdd"), newrefund.total_fee, newrefund.num);
                    }
                    continue;
                }
                rorderCount++;
                rpay += (refund.total_fee - refund.payment);
            }
            addup.RefundOrderCount = rorderCount;
            addup.RefundMoney      = rpay;
        }

        taoDal.AddOrUp(addup);
    }
    private void Bind(string nick, string session, DateTime start, DateTime end, int totalCount, int recordCount)
    {
        int TotalPage = totalCount % recordCount != 0 ? (totalCount / recordCount) + 1 : totalCount / recordCount; //总页数

        int page = 1;

        try
        {
            page = int.Parse(Request.QueryString["Page"]);
            if (ViewState["page"] != null)
            {
                page = int.Parse(ViewState["page"].ToString());
                ViewState["page"] = null;
            }
        }
        catch { }

        IList <GoodsInfo> list = taoGoodsService.GetTopBuyGoods(HttpUtility.UrlDecode(Request.Cookies["nick"].Value), start, end, page, recordCount);

        if (list.Count > 0)
        {
            string           pids       = "";
            List <GoodsInfo> cachegoods = new List <GoodsInfo>();
            if (Cache["taobaogoodslist"] != null)
            {
                cachegoods = (List <GoodsInfo>)Cache["taobaogoodslist"];
            }
            foreach (GoodsInfo info in list)
            {
                if (!cachegoods.Contains(info))
                {
                    pids += info.num_iid + ",";
                }
            }

            if (pids != "")
            {
                List <GoodsInfo> goodsinfoList = TaoBaoAPI.GetGoodsInfoList(nick, session, pids.Substring(0, pids.Length - 1));

                if (Cache["taobaogoodslist"] == null)
                {
                    Cache.Insert("taobaogoodslist", goodsinfoList, null, DateTime.Now.AddHours(12), System.Web.Caching.Cache.NoSlidingExpiration);
                }
                else
                {
                    cachegoods.AddRange(goodsinfoList);
                }
            }
            for (int i = 0; i < list.Count; i++)
            {
                IList <GoodsInfo> thislist = ((List <GoodsInfo>)Cache["taobaogoodslist"]).Where(o => o.num_iid == list[i].num_iid).ToList();
                if (thislist.Count > 0)
                {
                    list[i].title   = thislist[0].title;
                    list[i].price   = thislist[0].price;
                    list[i].pic_url = thislist[0].pic_url;
                }
            }
        }

        //for (int i = 0; i < list.Count; i++)
        //{
        //    GoodsInfo rinfo = TaoBaoAPI.GetGoodsInfo(list[i].num_iid);
        //    list[i].title = rinfo.title;
        //    list[i].price = rinfo.price;
        //}

        lblCurrentPage.Text = "共" + totalCount.ToString() + "条记录 当前页:" + page + "/" + (TotalPage == 0 ? 1 : TotalPage);

        lnkFrist.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=1&" + "start=" + start.ToShortDateString() + "&end=" + end.ToShortDateString();
        if (page > 1)
        {
            lnkPrev.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(page - 1) + "&" + "start=" + start.ToShortDateString() + "&end=" + end.ToShortDateString();
        }

        if (page != TotalPage && TotalPage != 0)
        {
            lnkNext.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(page + 1) + "&" + "start=" + start.ToShortDateString() + "&end=" + end.ToShortDateString();
        }
        lnkEnd.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + (TotalPage == 0 ? 1 : TotalPage) + "&" + "start=" + start.ToShortDateString() + "&end=" + end.ToShortDateString();

        Rpt_PageVisit.DataSource = list;
        Rpt_PageVisit.DataBind();
        TB_Start.Text = start.ToString("yyyy-MM-dd");
        TB_End.Text   = end.ToString("yyyy-MM-dd");
    }
Example #12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.Cookies["nick"] == null)
            {
                System.Threading.Thread.Sleep(1000 * 6);
            }
            string       nickNo    = DataHelper.Encrypt(HttpUtility.UrlDecode(Request.Cookies["nick"].Value));
            VisitService vistitDal = new VisitService();
            DateTime[]   darray    = DataHelper.GetDateTime(DateTime.Now, 1);
            Rpt_IpPV.DataSource = vistitDal.GetIndexTotalInfoList(nickNo, darray[0], darray[1]).OrderByDescending(o => o.Value).ToList();
            Rpt_IpPV.DataBind();

            Rpt_OnlineCustomer.DataSource = vistitDal.GetIndexOnlineCustomer(nickNo, 3, darray[0], darray[1]);
            Rpt_OnlineCustomer.DataBind();

            TaoBaoGoodsServive taoGoodsService = new TaoBaoGoodsServive();

            IList <GoodsInfo> list = taoGoodsService.GetTopBuyGoods(HttpUtility.UrlDecode(Request.Cookies["nick"].Value), darray[0], darray[1], 1, 3);

            if (list.Count > 0)
            {
                string           pids       = "";
                List <GoodsInfo> cachegoods = new List <GoodsInfo>();
                if (Cache["taobaogoodslist"] != null)
                {
                    cachegoods = (List <GoodsInfo>)Cache["taobaogoodslist"];
                }
                foreach (GoodsInfo info in list)
                {
                    if (!cachegoods.Contains(info))
                    {
                        pids += info.num_iid + ",";
                    }
                }

                if (pids != "")
                {
                    List <GoodsInfo> goodsinfoList = TaoBaoAPI.GetGoodsInfoList(HttpUtility.UrlDecode(Request.Cookies["nick"].Value), Request.Cookies["nicksession"].Value, pids.Substring(0, pids.Length - 1));

                    if (Cache["taobaogoodslist"] == null)
                    {
                        Cache.Insert("taobaogoodslist", goodsinfoList, null, DateTime.Now.AddHours(12), System.Web.Caching.Cache.NoSlidingExpiration);
                    }
                    else
                    {
                        cachegoods.AddRange(goodsinfoList);
                    }
                }
                for (int i = 0; i < list.Count; i++)
                {
                    IList <GoodsInfo> thislist = ((List <GoodsInfo>)Cache["taobaogoodslist"]).Where(o => o.num_iid == list[i].num_iid).ToList();
                    if (thislist.Count > 0)
                    {
                        list[i].title   = thislist[0].title;
                        list[i].price   = thislist[0].price;
                        list[i].pic_url = thislist[0].pic_url;
                    }
                }
            }

            Rpt_GoodsSellTop.DataSource = list;
            Rpt_GoodsSellTop.DataBind();

            SiteTotalService siteTotalDal = new SiteTotalService();
            BindRpt_OrderTotal(siteTotalDal);
            TopSiteTotalInfo lastweek  = siteTotalDal.GetOrderTotalInfo(DateTime.Now.AddDays(-7), DateTime.Now, HttpUtility.UrlDecode(Request.Cookies["nick"].Value));
            TopSiteTotalInfo llastweek = siteTotalDal.GetOrderTotalInfo(DateTime.Now.AddDays(-14), DateTime.Now.AddDays(-8), HttpUtility.UrlDecode(Request.Cookies["nick"].Value));
            ViewState["lastweek"]  = lastweek;
            ViewState["llastweek"] = llastweek;
        }
    }
Example #13
0
    private void Bind(string nick, string session, DateTime start, DateTime end)
    {
        int    TotalCount = 0; //总记录数
        int    TotalPage  = 1; //总页数
        string ip         = Request.QueryString["visitip"];
        int    page       = 1;

        try
        {
            page = int.Parse(Request.QueryString["Page"]);
            if (ViewState["page"] != null)
            {
                page = int.Parse(ViewState["page"].ToString());
                ViewState["page"] = null;
            }
        }
        catch { }

        IList <TopVisitInfo> list       = visitDal.GetVisitInfoByIp(DataHelper.Encrypt(HttpUtility.UrlDecode(Request.Cookies["nick"].Value)), ip, start, end);
        List <GoodsInfo>     cachegoods = new List <GoodsInfo>();

        if (Cache["taobaogoodslist"] != null)
        {
            cachegoods = (List <GoodsInfo>)Cache["taobaogoodslist"];
        }
        for (int i = 0; i < list.Count; i++)
        {
            if (!string.IsNullOrEmpty(list[i].GoodsId))
            {
                List <GoodsInfo> mylist = cachegoods.Where(o => o.num_iid == list[i].GoodsId).ToList();
                if (mylist.Count == 0)
                {
                    GoodsInfo rinfo = TaoBaoAPI.GetGoodsInfo(nick, session, list[i].GoodsId);
                    list[i].GoodsName = rinfo.title;
                    cachegoods.Add(rinfo);
                    if (Cache["taobaogoodslist"] == null)
                    {
                        Cache.Insert("taobaogoodslist", cachegoods, null, DateTime.Now.AddHours(12), System.Web.Caching.Cache.NoSlidingExpiration);
                    }
                }
                else
                {
                    list[i].GoodsName = mylist[0].title;
                }
            }

            if (!string.IsNullOrEmpty(list[i].GoodsClassId))
            {
                IList <GoodsClassInfo> cList = GoodsClassList.Where(o => o.cid == list[i].GoodsClassId).ToList();
                if (cList.Count > 0)
                {
                    list[i].GoodsClassName = cList[0].name;
                }
            }
        }

        TotalCount      = list.Count;
        pds.DataSource  = list;
        pds.AllowPaging = true;
        pds.PageSize    = 20;

        if (TotalCount == 0)
        {
            TotalPage = 1;
        }
        else
        {
            if (TotalCount % pds.PageSize == 0)
            {
                TotalPage = TotalCount / pds.PageSize;
            }
            else
            {
                TotalPage = TotalCount / pds.PageSize + 1;
            }
        }

        string startstr = HttpUtility.UrlEncode(start.ToString("yyyy-MM-dd-HH"));
        string endstr   = HttpUtility.UrlEncode(end.ToString("yyyy-MM-dd-HH"));

        pds.CurrentPageIndex = page - 1;
        lblCurrentPage.Text  = "共" + TotalCount.ToString() + "条记录 当前页:" + page + "/" + TotalPage;

        lnkFrist.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=1&visitip=" + ip + "&start=" + startstr + "&end=" + endstr;
        if (!pds.IsFirstPage)
        {
            lnkPrev.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + (page - 1) + "&visitip=" + ip + "&start=" + startstr + "&end=" + endstr;
        }

        if (!pds.IsLastPage)
        {
            lnkNext.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + (page + 1) + "&visitip=" + ip + "&start=" + startstr + "&end=" + endstr;
        }
        lnkEnd.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + TotalPage + "&visitip=" + ip + "&start=" + startstr + "&end=" + endstr;

        Rpt_PageVisit.DataSource = pds;
        Rpt_PageVisit.DataBind();
        TB_Start.Text = start.ToString("yyyy-MM-dd HH");
        TB_End.Text   = end.ToString("yyyy-MM-dd HH");
    }
Example #14
0
    public static void UpdateSiteTotal(string nick, string session, DateTime now, SiteTotalService taoDal)
    {
        List <RefundInfo> refundList = (List <RefundInfo>)TaoBaoAPI.GetRefundInfoList(now.AddDays(-2), now, nick, session, "SUCCESS");
        //所有有订单的用户
        TopSiteTotalInfo stinfo = taoDal.GetOrderTotalPay(DateTime.Parse(now.ToShortDateString()), DateTime.Parse(now.AddDays(1).ToShortDateString()), nick);
        //所有表名(添加过统计代码到网页的)
        //List<string> tableList = taoDal.GetTableName();
        //string tablename = GetTableName(nick);
        List <string> mytablelist = new List <string>();//tableList.Where(o => o == tablename).ToList();

        TopSiteTotalInfo addup = new TopSiteTotalInfo();

        addup.SiteNick      = nick;
        addup.SiteTotalDate = now.ToString("yyyyMMdd");
        //给询单数赋值
        addup.AskOrder = new TalkRecodService().GetCustomerList(DateTime.Parse(now.ToShortDateString()), DateTime.Parse(now.AddDays(1).ToShortDateString()), nick).Count;

        //有添加统计代码
        if (mytablelist.Count > 0)
        {
            //有订单
            if (stinfo != null)
            {
                addup.SiteOrderCount     = stinfo.SiteOrderCount;
                addup.SiteOrderPay       = stinfo.SiteOrderPay;
                addup.PostFee            = stinfo.PostFee;
                addup.SiteBuyCustomTotal = stinfo.SiteBuyCustomTotal;
                addup.SiteSecondBuy      = taoDal.GetSecondBuyTotal(DateTime.Parse(now.ToShortDateString()), DateTime.Parse(now.AddDays(1).ToShortDateString()), nick);
            }
            //TopSiteTotalInfo puvinfo = taoDal.GetPvUvTotal(DateTime.Parse(now.ToShortDateString()), DateTime.Parse(now.AddDays(1).ToShortDateString()), tablename);
            addup.SiteUVCount  = 0; //puvinfo.SiteUVCount;
            addup.SitePVCount  = 0; // puvinfo.SitePVCount;
            addup.ZhiTongFlow  = 0; // taoDal.GetZhiTongTotal(now, now.AddDays(1), tablename);
            addup.SiteZuanZhan = 0; // taoDal.GetZuanZhanTotal(now, now.AddDays(1), tablename);

            addup.SiteUVBack = 0;   // taoDal.GetBackTotal(DateTime.Parse(now.ToShortDateString()), DateTime.Parse(now.AddDays(1).ToShortDateString()), tablename);
        }
        else
        {
            //有订单
            if (stinfo != null)
            {
                addup.SiteOrderCount     = stinfo.SiteOrderCount;
                addup.SiteOrderPay       = stinfo.SiteOrderPay;
                addup.PostFee            = stinfo.PostFee;
                addup.SiteBuyCustomTotal = stinfo.SiteBuyCustomTotal;
                addup.SiteSecondBuy      = taoDal.GetSecondBuyTotal(DateTime.Parse(now.ToShortDateString()), DateTime.Parse(now.AddDays(1).ToShortDateString()), nick);
            }
        }

        IList <string> tidList = taoDal.GetOrderIds(DateTime.Parse(now.ToShortDateString()), DateTime.Parse(now.AddDays(1).ToShortDateString()), nick);

        if (tidList.Count > 0)
        {
            addup.GoodsCount = taoDal.GetGoodsCount(tidList);
        }

        //退款情况
        List <RefundInfo> trefundList = refundList.Where(o => o.modified.ToShortDateString() == now.ToShortDateString()).ToList();

        if (trefundList.Count > 0)
        {
            int     rorderCount = 0;
            decimal rpay        = 0;
            foreach (RefundInfo refund in trefundList)
            {
                if (!tidList.Contains(refund.tid))
                {
                    continue;
                }
                rorderCount++;
                rpay += (refund.total_fee - refund.payment);
            }
            addup.RefundOrderCount = rorderCount;
            addup.RefundMoney      = rpay;
        }

        taoDal.AddOrUp(addup);
    }
    protected void Btn_Update_Click(object sender, EventArgs e)
    {
        string nick    = HttpUtility.UrlDecode(Request.Cookies["nick"].Value);
        string session = Request.Cookies["nicksession"].Value;

        TeteShopCategoryService cateDal = new TeteShopCategoryService();

        IList <TeteShopInfo> list = CacheCollection.GetNickSessionList().Where(o => o.Short == nick && o.Session == session).ToList();

        TeteShopInfo info = null;

        if (list.Count > 0)
        {
            info = list[0];
        }
        if (info == null)
        {
            Page.RegisterStartupScript("错误", "<script>alert('您的身份不合法,请确定您已购买!');</script>");
            return;
        }

        IList <TeteShopCategoryInfo> cateList  = cateDal.GetAllTeteShopCategory(Encrypt(nick));
        IList <GoodsClassInfo>       classList = TaoBaoAPI.GetGoodsClassInfoList(info.Short, session, info.Appkey, info.Appsecret);

        if (classList == null)
        {
            Page.RegisterStartupScript("错误", "<script>alert('获取店铺分类出错!');</script>");
            return;
        }

        List <TeteShopCategoryInfo> addList = new List <TeteShopCategoryInfo>();

        List <TeteShopCategoryInfo> upList = new List <TeteShopCategoryInfo>();

        foreach (GoodsClassInfo cinfo in classList)
        {
            List <TeteShopCategoryInfo> clist = cateList.Where(o => o.Cateid == cinfo.cid).ToList();
            if (clist.Count > 0)
            {
                InitCate(nick, cinfo, clist[0]);
                clist[0].Catecount = classList.Count(o => o.parent_cid == cinfo.cid);
                upList.Add(clist[0]);
            }

            else
            {
                TeteShopCategoryInfo ainfo = new TeteShopCategoryInfo();
                InitCate(nick, cinfo, ainfo);
                ainfo.Catecount = classList.Count(o => o.parent_cid == cinfo.cid);

                addList.Add(ainfo);
            }
        }

        //添加
        foreach (TeteShopCategoryInfo cinfo in addList)
        {
            cateDal.AddTeteShopCategory(cinfo);
        }

        //修改
        foreach (TeteShopCategoryInfo cinfo in upList)
        {
            cateDal.ModifyTeteShopCategory(cinfo);
        }

        //删除
        //List<TeteShopCategoryInfo> delList = new List<TeteShopCategoryInfo>();
        //foreach (TeteShopCategoryInfo cinfo in cateList)
        //{
        //    if (upList.Where(o => o.Cateid == cinfo.Cateid).ToList().Count == 0)
        //    {
        //        delList.Add(cinfo);
        //    }
        //}

        //foreach (TeteShopCategoryInfo cinfo in upList)
        //{
        //    cateDal.DeleteTeteShopCategory(cinfo.Id);
        //}

        //更新商品
        ActionGoods(nick, session, info);
        //更新商品分类包含商品数量
        IList <TeteShopCategoryInfo> nowCateList = cateDal.GetAllTeteShopCategory(Encrypt(nick));
        TeteShopItemService          itemDal     = new TeteShopItemService();

        for (int i = 0; i < nowCateList.Count; i++)
        {
            int count = itemDal.GetItemCountByCId(nowCateList[i].Cateid);
            nowCateList[i].Catecount = count;
        }

        //修改
        foreach (TeteShopCategoryInfo cinfo in nowCateList)
        {
            cateDal.ModifyTeteShopCategory(cinfo);
        }

        Page.RegisterStartupScript("更新提示", "<script>alert('更新成功!');</script>");
    }
Example #16
0
        public void GetTalkRecordContent()
        {
            IList <TopNickSessionInfo> list    = new NickSessionService().GetAllNickSession(Enum.TopTaoBaoService.Temporary);
            TalkRecodService           trDal   = new TalkRecodService();
            SubUserService             userDal = new SubUserService();

            foreach (TopNickSessionInfo info in list)
            {
                DateTime now = trDal.GetMaxTime(info.Nick);

                ServiceLog.RecodeLog(info.Nick + "开始获取时间" + now);

                trDal.CreateTable(DBHelp.DataHelper.Encrypt(info.Nick));
                //List<GroupMember> memberList = TaoBaoAPI.GetNickGroupList(info.Nick, info.Session);

                List <SubUserInfo> hasuserList = userDal.GetAllChildNick(info.Nick);
                List <string>      childNicks  = new List <string>();

                //直接获取子帐号列表
                //if (memberList.Count == 0)
                //{
                IList <SubUserInfo> userList = TaoBaoAPI.GetChildNick(info.Nick, info.Session);

                foreach (SubUserInfo uinfo in userList)
                {
                    childNicks.Add(uinfo.nick);
                    if (hasuserList.Where(o => o.nick == uinfo.nick).ToList().Count == 0)
                    {
                        userDal.InsertSubUserInfo(uinfo);
                    }
                }
                //}
                //else
                //{
                //    foreach (GroupMember minfo in memberList)
                //    {
                //        foreach (string cnick in minfo.MemberIdList)
                //        {
                //            if (childNicks.Contains(cnick))
                //                continue;
                //            childNicks.Add(cnick);
                //        }
                //    }
                //}

                //foreach (GroupMember minfo in memberList)
                //{

                DateTime rnow = DateTime.Now;

                List <TalkContent> allcontent = trDal.GetAllContent(now.AddHours(-16), now, info.Nick);

                foreach (string fromNick in childNicks)
                {
                    List <TalkObj> objList = TaoBaoAPI.GetTalkObjList(fromNick.Replace("cntaobao", ""), info.Session, now, rnow);
                    foreach (TalkObj obj in objList)
                    {
                        List <TalkContent> contents = TaoBaoAPI.GetTalkContentNow(info.Session, fromNick.Replace("cntaobao", ""), obj.uid.Replace("cntaobao", ""), now, rnow);

                        for (int i = 0; i < contents.Count; i++)
                        {
                            contents[i].FromNick = fromNick.Replace("cntaobao", "");
                            contents[i].ToNick   = obj.uid.Replace("cntaobao", "");
                            if (allcontent.Contains(contents[i]))
                            {
                                continue;
                            }
                            trDal.InsertContent(contents[i], info.Nick);
                        }
                    }
                }
                //}
            }
        }