/// <summary> /// 获取客服及客服未回复客户的数量 /// </summary> /// <param name="nick"></param> /// <param name="start"></param> /// <param name="end"></param> /// <returns></returns> public List <TopKefuTotalInfo> GetUnTalkCustomerList(string nick, DateTime start, DateTime end) { SqlParameter[] param = new[] { new SqlParameter("@start", start), new SqlParameter("@end", end), new SqlParameter("@nick", nick) }; List <TopKefuTotalInfo> list = new List <TopKefuTotalInfo>(); string sql = SQL_SELECT_UNTALKCUSTOMER.Replace("@tableName", DBHelper.GetRealTable("TalkContent", DataHelper.Encrypt(nick))); using (SqlDataReader dr = ServiceDBHelper.CreateReader(sql, param)) { if (dr != null) { if (dr.Read()) { TopKefuTotalInfo info = new TopKefuTotalInfo(); info.Nick = dr["FromId"].ToString(); info.UnTalkCustomerCount = dr["untalkcount"] == DBNull.Value ? 0 : int.Parse(dr["untalkcount"].ToString()); list.Add(info); } } } return(list); }
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); } } }