Ejemplo n.º 1
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);
    }
Ejemplo n.º 2
0
    public static void GetKfjxTotal(string nick, DateTime start, DateTime now)
    {
        TalkRecodService    trDal    = new TalkRecodService();
        GoodsService        goodsDal = new GoodsService();
        GoodsOrderService   goDal    = new GoodsOrderService();
        TopKefuTotalService kfDal    = new TopKefuTotalService();
        //所有商品
        List <TaoBaoAPIHelper.GoodsInfo> goodsNickList = goodsDal.GetAllGoods(nick);

        for (DateTime h = start; h < now; h = h.AddDays(1))
        {
            //所有订单
            List <TaoBaoAPIHelper.GoodsOrderInfo> orderList = goDal.GetGoodsOrderList(nick, h, h.AddDays(1));

            //得到回复次数和接待人数
            List <CustomerInfo> cuslist = trDal.GetReceiveList(nick, h, h.AddDays(1));

            //得到接待人和购买者信息
            IList <CustomerInfo> cusBuyList = trDal.GetCustomerList(h, h.AddDays(1), nick);

            //得到客服未回复的客户数量
            List <TopKefuTotalInfo> untalkList = trDal.GetUnTalkCustomerList(nick, h, h.AddDays(1));

            for (int i = 0; i < cusBuyList.Count; i++)
            {
                IList <TaoBaoAPIHelper.GoodsOrderInfo> thislist = orderList.Where(o => o.buyer_nick == cusBuyList[i].CustomerNick).ToList();
                if (thislist.Count > 0)
                {
                    cusBuyList[i].tid = thislist[0].tid;
                }
            }
            //得到成功下单
            List <CustomerInfo> orderCusList = cusBuyList.Where(o => !string.IsNullOrEmpty(o.tid)).ToList();
            foreach (CustomerInfo fromInfo in cuslist)
            {
                TopKefuTotalInfo kefutotalInfo = new TopKefuTotalInfo();
                kefutotalInfo.CustomerCount = int.Parse(fromInfo.CustomerNick);
                kefutotalInfo.ReceiveCount  = fromInfo.TalkCount;
                kefutotalInfo.Nick          = fromInfo.FromNick;
                kefutotalInfo.NickDate      = h.ToString("yyyyMMdd");
                //赋值未回复数量
                if (untalkList.Where(o => o.Nick == fromInfo.FromNick).ToList().Count > 0)
                {
                    kefutotalInfo.UnTalkCustomerCount = untalkList.Where(o => o.Nick == fromInfo.FromNick).ToList()[0].UnTalkCustomerCount;
                }

                List <CustomerInfo> mylist = orderCusList.Where(o => o.FromNick == fromInfo.FromNick).ToList();
                if (mylist.Count > 0)
                {
                    List <string> tids = new List <string>();
                    foreach (CustomerInfo inf in mylist)
                    {
                        tids.Add(inf.tid);
                    }

                    List <TaoBaoAPIHelper.GoodsOrderInfo> myolist = orderList.Where(o => tids.Contains(o.tid)).ToList();

                    kefutotalInfo.OrderCount = mylist.Count;

                    kefutotalInfo.PostFee = myolist.Sum(o => o.post_fee);
                    kefutotalInfo.Payment = myolist.Sum(o => o.payment);

                    List <TaoBaoAPIHelper.GoodsInfo> goodsList = goDal.GetGoodsCount(tids);
                    kefutotalInfo.GoodsCount = goodsList.Sum(o => o.Count);
                    decimal goodsPriceTotal = 0;
                    foreach (TaoBaoAPIHelper.GoodsInfo ginfo in goodsList)
                    {
                        List <TaoBaoAPIHelper.GoodsInfo> mygoodsList = goodsNickList.Where(o => o.num_iid == ginfo.num_iid).ToList();
                        if (mygoodsList.Count > 0)
                        {
                            goodsPriceTotal += mygoodsList[0].price * ginfo.Count;
                        }
                        else
                        {
                            TaoBaoAPIHelper.GoodsInfo newgoods = TaoBaoAPIHelper.TaoBaoAPI.GetGoodsInfoService(ginfo.num_iid);
                            if (newgoods != null)
                            {
                                goodsPriceTotal += newgoods.price * ginfo.Count;
                                //找到后添加到集合
                                goodsNickList.Add(newgoods);
                            }
                        }
                    }
                    kefutotalInfo.GoodsPay = goodsPriceTotal;
                }
                //添加或者更新
                kfDal.AddOrUp(kefutotalInfo);
            }
        }
    }
Ejemplo n.º 3
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);
                        }
                    }
                }
                //}
            }
        }