Exemplo n.º 1
0
        /// <summary>
        /// 保存客户备注
        /// </summary>
        /// <param name="aid"></param>
        /// <param name="desc"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult SaveDesc(int aid = 0, string desc = "", string phoneDesc = "", int id = 0, int employeeId = 0)
        {
            Return_Msg   returnData = new Return_Msg();
            QiyeCustomer model      = QiyeCustomerBLL.SingleModel.GetModel(id);

            if (model == null)
            {
                returnData.Msg = "请刷新重试";
                return(Json(returnData));
            }
            if (model.Aid != aid)
            {
                returnData.Msg = "权限不足";
                return(Json(returnData));
            }
            if (employeeId > 0)
            {
                model.StaffId = employeeId;
            }
            else
            {
                model.StaffId = 0;
            }
            model.Desc       = desc;
            model.PhoneDesc  = phoneDesc;
            model.UpdateTime = DateTime.Now;
            returnData.isok  = QiyeCustomerBLL.SingleModel.Update(model, "StaffId,PhoneDesc,desc,updatetime");
            returnData.Msg   = returnData.isok ? "保存成功" : "保存失败";

            return(Json(returnData));
        }
Exemplo n.º 2
0
        public ActionResult GetImessageUser(int aid = 0, int customerId = 0)
        {
            Return_Msg returnData = new Return_Msg();

            if (customerId <= 0)
            {
                returnData.Msg = "无效参数";
                return(Json(returnData));
            }
            QiyeCustomer customer = QiyeCustomerBLL.SingleModel.GetModel(customerId);

            if (customer == null)
            {
                returnData.Msg = "无效客户,请刷新重试!";
                return(Json(returnData));
            }
            List <ImMessage> messageList = ImMessageBLL.SingleModel.GetListByTuserid(customer.UserId);

            if (messageList != null && messageList.Count > 0)
            {
                string userIds = string.Join(",", messageList.Where(w => w.tuserId != customer.UserId).Select(s => s.tuserId).Distinct());
                //List<C_UserInfo> userList = _userInfoBLL.GetListByIds(userIds);
                List <QiyeEmployee> employeeList = QiyeEmployeeBLL.SingleModel.GetListByUserIds(userIds);

                returnData.dataObj = new { data = employeeList, customer = customer };
                returnData.isok    = true;
            }
            return(Json(returnData));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 删除数据
        /// </summary>
        /// <param name="aid"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult DelData(int aid = 0, int id = 0)
        {
            Return_Msg   returnData = new Return_Msg();
            QiyeCustomer customer   = QiyeCustomerBLL.SingleModel.GetModel(id);

            if (customer == null)
            {
                returnData.Msg = "无效数据";
                return(Json(returnData));
            }
            if (customer.Aid != aid)
            {
                returnData.Msg = "权限不足";
                return(Json(returnData));
            }
            customer.State      = -1;
            customer.UpdateTime = DateTime.Now;
            returnData.isok     = QiyeCustomerBLL.SingleModel.Update(customer, "state,UpdateTime");
            returnData.Msg      = returnData.isok ? "删除成功" : "删除失败";

            return(Json(returnData));
        }
Exemplo n.º 4
0
        /// <summary>
        /// 企业智推版员工获取联系人
        /// </summary>
        /// <param name="fuserid"></param>
        /// <param name="appid"></param>
        /// <returns></returns>
        public List <ImMessage> GetListByQiye(int tuserId, string appid, int pageSize, int pageIndex, ref int count, string name)
        {
            string key = string.Format(redis_ListEmployeekey, tuserId);

            List <ImMessage> list      = new List <ImMessage>();
            List <ImMessage> redisList = RedisUtil.Get <List <ImMessage> >(key);

            if (redisList == null || redisList.Count <= 0 || pageIndex == 1)
            {
                redisList = new List <ImMessage>();

                string sql      = $"select {"{0}"} from ImContact im left join c_userinfo c on im.fuserid = c.id ";
                string sqlCount = string.Format(sql, "count(*)");
                string sqlList  = string.Format(sql, "im.*,c.NickName,c.HeadImgUrl");
                string sqlWhere = $" where im.appid = '{appid}' and im.tuserid={tuserId}";
                string sqlPage  = "";//$" limit {(pageIndex - 1) * pageSize},{pageSize}";

                List <MySqlParameter> parms = new List <MySqlParameter>();
                if (!string.IsNullOrEmpty(name))
                {
                    sqlWhere += $" and (c.NickName like @name or c.TelePhone like @name)";
                    parms.Add(new MySqlParameter("@name", $"%{name}%"));
                }

                count = base.GetCountBySql(sqlCount + sqlWhere, parms.ToArray());
                if (count <= 0)
                {
                    return(redisList);
                }

                using (MySqlDataReader dr = SqlMySql.ExecuteDataReaderMaster(connName, CommandType.Text, sqlList + sqlWhere + sqlPage, parms.ToArray()))
                {
                    while (dr.Read())
                    {
                        ImContact tempmodel = base.GetModel(dr);
                        ImMessage model     = new ImMessage();
                        model.fuserId            = tempmodel.fuserId;
                        model.tuserId            = tuserId;
                        model.NoReadMessageCount = ImMessageBLL.SingleModel.GetUserNoReadCount(tuserId, tempmodel.fuserId);
                        ImMessage imModel = ImMessageBLL.SingleModel.GetNewMessage(model.fuserId, tuserId, 0, 1);
                        if (imModel != null)
                        {
                            model.LastMsg  = imModel.msg;
                            model.msgType  = imModel.msgType;
                            model.sendDate = imModel.sendDate;
                        }
                        model.CardImgUrl = dr["HeadImgUrl"].ToString();
                        model.CardName   = dr["NickName"].ToString();

                        redisList.Add(model);
                    }
                }

                string userIds = string.Join(",", redisList.Select(s => s.fuserId).Distinct());
                List <QiyeCustomer> customerList = QiyeCustomerBLL.SingleModel.GetListByUserIds(userIds);
                if (customerList == null || customerList.Count <= 0)
                {
                    return(redisList);
                }

                string empIds = string.Join(",", customerList.Select(s => s.StaffId).Distinct());
                List <QiyeEmployee> employeeList = QiyeEmployeeBLL.SingleModel.GetListByIds(empIds);
                if (employeeList == null || employeeList.Count <= 0)
                {
                    return(redisList);
                }

                foreach (ImMessage item in redisList)
                {
                    QiyeCustomer customerModel = customerList.FirstOrDefault(f => f.UserId == item.fuserId);
                    if (customerModel == null)
                    {
                        continue;
                    }

                    QiyeEmployee empModel = employeeList.FirstOrDefault(f => f.Id == customerModel.StaffId);
                    if (empModel == null)
                    {
                        continue;
                    }

                    item.Desc         = customerModel.Desc;
                    item.EmployeeName = empModel.Name;
                }

                RedisUtil.Set <List <ImMessage> >(key, redisList);
                redisList = redisList.OrderByDescending(o => o.sendDate).ToList();
                //list = redisList.Skip((pageIndex-1)*pageSize).Take(pageSize).ToList();
            }

            list = redisList.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();

            return(list);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 企业智推版获取客户与员工私信记录
        /// </summary>
        /// <param name="tuserId"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <param name="count"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public List <ImMessage> GetListByTuserId(int tuserId, int pageSize, int pageIndex, ref int count, string name)
        {
            List <ImMessage> list = new List <ImMessage>();

            string sql      = $"select {"{0}"} from (select * from immessage where tuserid={tuserId} group by fuserid) i left join c_userinfo c on i.fuserid=c.id";
            string sqlCount = string.Format(sql, "count(*)");
            //(select count(*) from immessage where tuserid={tuserId} and fuserid=i.fuserid and isread=0) messagecount,(select msg from immessage where tuserid = {tuserId} and fuserid = i.fuserid  order by senddate DESC LIMIT 1) lastmsg,
            string sqlList  = string.Format(sql, $@"i.*,c.NickName, c.HeadImgUrl, c.TelePhone");
            string sqlWhere = $" where i.tuserid={tuserId}";
            string sqlPage  = $" limit {(pageIndex - 1) * pageSize},{pageSize}";

            List <MySqlParameter> parms = new List <MySqlParameter>();

            if (!string.IsNullOrEmpty(name))
            {
                sqlWhere += $" and (c.NickName like @name or c.TelePhone like @name)";
                parms.Add(new MySqlParameter("@name", $"%{name}%"));
            }

            count = base.GetCountBySql(sqlCount + sqlWhere, parms.ToArray());
            if (count <= 0)
            {
                return(list);
            }

            using (MySqlDataReader dr = SqlMySql.ExecuteDataReaderMaster(connName, CommandType.Text, sqlList + sqlWhere + sqlPage, parms.ToArray()))
            {
                while (dr.Read())
                {
                    ImMessage model = base.GetModel(dr);
                    model.NoReadMessageCount = GetNoReadCount(model.fuserId, tuserId);
                    ImMessage imModel = GetNewMessage(model.fuserId, tuserId, 0, 1);
                    if (imModel != null)
                    {
                        model.LastMsg = imModel.msg;
                        model.msgType = imModel.msgType;
                    }

                    if (dr["HeadImgUrl"] != DBNull.Value)
                    {
                        model.CardImgUrl = dr["HeadImgUrl"].ToString();
                    }
                    if (dr["NickName"] != DBNull.Value)
                    {
                        model.CardName = dr["NickName"].ToString();
                    }


                    list.Add(model);
                }
            }

            string userIds = string.Join(",", list.Select(s => s.fuserId).Distinct());
            List <QiyeCustomer> customerList = QiyeCustomerBLL.SingleModel.GetListByUserIds(userIds);

            if (customerList == null || customerList.Count <= 0)
            {
                return(list);
            }

            string empIds = string.Join(",", customerList.Select(s => s.StaffId).Distinct());
            List <QiyeEmployee> employeeList = QiyeEmployeeBLL.SingleModel.GetListByIds(empIds);

            if (employeeList == null || employeeList.Count <= 0)
            {
                return(list);
            }

            foreach (ImMessage item in list)
            {
                QiyeCustomer customerModel = customerList.FirstOrDefault(f => f.UserId == item.fuserId);
                if (customerModel == null)
                {
                    continue;
                }

                QiyeEmployee empModel = employeeList.FirstOrDefault(f => f.Id == customerModel.StaffId);
                if (empModel == null)
                {
                    continue;
                }

                item.Desc         = customerModel.Desc;
                item.EmployeeName = empModel.Name;
            }
            return(list);
        }