Exemplo n.º 1
0
        public JsonResult DoAdd(string channelName, string invitedcode, int status, string adminUserName, string adminUserPassword, string trueName, string channelType = "cps1")
        {
            var result = new { state = 1, msg = "渠道 " + channelName + " 增加成功!" };

            if (string.IsNullOrEmpty(channelName) || string.IsNullOrEmpty(invitedcode) ||
                string.IsNullOrEmpty(adminUserName) || string.IsNullOrEmpty(adminUserPassword))
            {
                result = new { state = 0, msg = "缺少增加的参数!" };
                return(Json(result));
            }

            var ckChannelNameList = ef.hx_Channel.Any(p => p.ChannelName == channelName);

            if (ckChannelNameList)
            {
                result = new { state = 0, msg = "渠道名称已经存在!" };
                return(Json(result));
            }

            var ckAdminNameList = ef.hx_Channel_AdminUser.Any(p => p.AdminUserName == adminUserName);

            if (ckAdminNameList)
            {
                result = new { state = 0, msg = "渠道使用者名称已存在!" };
                return(Json(result));
            }

            //写入 Channel 与  Channel_AdminUser 表
            hx_Channel channelEnitty = new hx_Channel();

            channelEnitty.ChannelName = channelName;
            channelEnitty.Invitedcode = invitedcode;
            channelEnitty.Status      = (byte)status;
            channelEnitty.Creator     = Utils.GetAdmUserID().ToString();
            channelEnitty.CreateTime  = DateTime.Now;
            channelEnitty.type        = channelType;//渠道类型
            channelEnitty.UpdateTime  = channelEnitty.CreateTime;

            hx_Channel_AdminUser cAdminUserEntity = new hx_Channel_AdminUser();

            cAdminUserEntity.CreateTime        = channelEnitty.CreateTime;
            cAdminUserEntity.AdminUserName     = adminUserName;
            cAdminUserEntity.AdminUserPassword = Utils.MD5(adminUserPassword);
            cAdminUserEntity.Status            = (byte)1;
            if (string.IsNullOrEmpty(trueName))
            {
                cAdminUserEntity.TrueName = adminUserName;
            }
            else
            {
                cAdminUserEntity.TrueName = trueName;
            }
            List <hx_Channel_AdminUser> cauList = new List <hx_Channel_AdminUser>();

            cauList.Add(cAdminUserEntity);
            channelEnitty.hx_Channel_AdminUser = cauList;
            ef.hx_Channel.Add(channelEnitty);
            ef.SaveChanges();
            return(Json(result));
        }
Exemplo n.º 2
0
        public JsonResult DoEditor(string channelName, int status, string adminUserName, string adminUserPassword, string trueName, int channelId = 0, string channelType = "cps1")
        {
            var result = new { state = 1, msg = "渠道 " + channelName + " 编辑完成!" };

            if (string.IsNullOrEmpty(channelName) || channelId == 0 ||
                string.IsNullOrEmpty(adminUserName) || string.IsNullOrEmpty(adminUserPassword))
            {
                result = new { state = 0, msg = "缺少编辑的参数!" };
                return(Json(result));
            }
            hx_Channel channelEnitty = ef.hx_Channel.Where(p => p.ChannelID == channelId).ToList().FirstOrDefault();

            var ckChannelNameList = ef.hx_Channel.Where(p => p.ChannelName == channelName && p.ChannelID != channelId).ToList();

            if (ckChannelNameList.Count() > 0)
            {
                result = new { state = 0, msg = "渠道名称已经存在!" };
                return(Json(result));
            }
            var cAdminuserId    = channelEnitty.hx_Channel_AdminUser.FirstOrDefault().AdminUserID;
            var ckAdminNameList = ef.hx_Channel_AdminUser.Where(p => p.AdminUserName == adminUserName && p.AdminUserID != cAdminuserId).ToList();

            if (ckAdminNameList.Count() > 0)
            {
                result = new { state = 0, msg = "渠道使用者名称已存在!" };
                return(Json(result));
            }

            //编辑 Channel 与  Channel_AdminUser 表

            channelEnitty.ChannelName = channelName;
            channelEnitty.Status      = (byte)status;
            channelEnitty.type        = channelType;
            channelEnitty.UpdateTime  = DateTime.Now;
            hx_Channel_AdminUser cAdminUserEntity = channelEnitty.hx_Channel_AdminUser.ToList().FirstOrDefault();

            cAdminUserEntity.AdminUserName = adminUserName;

            if (cAdminUserEntity.AdminUserPassword != adminUserPassword)
            {
                cAdminUserEntity.AdminUserPassword = Utils.MD5(adminUserPassword);
            }
            cAdminUserEntity.TrueName = trueName == "" || string.IsNullOrEmpty(trueName) ? cAdminUserEntity.TrueName : trueName;
            ef.SaveChanges();
            Utils.RemoveCache("hx_Channel_" + channelEnitty.Invitedcode);
            return(Json(result));
        }
Exemplo n.º 3
0
        public ActionResult AdminUserList(int page = 1, int pagesize = 10)
        {
            //渠道用户非,非后台登录用户
            hx_Channel_AdminUser adminUser = Session["Channel_AdminUser"] as hx_Channel_AdminUser;

            //判定用户
            if (adminUser == null)
            {
                return(RedirectToAction("LoginOut", "Channel"));
            }
            int    pageIndex = page / 1;
            string realname  = Utils.CheckSQLHtml(DNTRequest.GetString("RealName"));
            string username  = Utils.CheckSQLHtml(DNTRequest.GetString("UserName"));
            string startTime = DNTRequest.GetString("StartTime");
            string endTime   = DNTRequest.GetString("EndTime");

            Expression <Func <V_Channel_UserList, bool> > where = PredicateExtensionses.True <V_Channel_UserList>();
            where = where.And(p => p.AdminUserName == adminUser.AdminUserName);
            if (!string.IsNullOrEmpty(realname))
            {
                where = where.And(p => p.realname.Contains(realname.Trim()));
            }
            if (!string.IsNullOrEmpty(username))
            {
                where = where.And(p => p.username.Contains(username.Trim()));
            }
            if (!string.IsNullOrEmpty(startTime) && startTime != "")
            {
                DateTime stime = Convert.ToDateTime(startTime);
                where = where.And(p => DbFunctions.DiffDays(p.registration_time, stime) <= 0);
                DateTime etime = DateTime.Now;
                if (!string.IsNullOrEmpty(endTime) && endTime != "")
                {
                    etime = Convert.ToDateTime(endTime);
                }
                etime = etime.AddDays(1).AddSeconds(-1);
                where = where.And(p => DbFunctions.DiffDays(p.registration_time, etime) >= 0);
            }
            var list = ef.V_Channel_UserList.Where(where).OrderByDescending(p => p.registration_time).ToPagedList(pageIndex, pagesize);

            ViewBag.Username  = username;
            ViewBag.RealName  = realname;
            ViewBag.StartTime = startTime;
            ViewBag.EndTime   = endTime;
            return(View(list));
        }
Exemplo n.º 4
0
        public JsonResult AdminUserListExcel()
        {
            hx_Channel_AdminUser adminUser = Session["Channel_AdminUser"] as hx_Channel_AdminUser;
            var result = new { state = 0, msg = "用户没有权限!", data = string.Empty };

            //判定用户
            if (adminUser == null)
            {
                return(Json(result));
            }
            string realname  = Utils.CheckSQLHtml(DNTRequest.GetString("RealName"));
            string username  = Utils.CheckSQLHtml(DNTRequest.GetString("UserName"));
            string startTime = DNTRequest.GetString("StartTime");
            string endTime   = DNTRequest.GetString("EndTime");

            Expression <Func <V_Channel_UserList, bool> > where = PredicateExtensionses.True <V_Channel_UserList>();
            where = where.And(p => p.AdminUserName == adminUser.AdminUserName);
            if (!string.IsNullOrEmpty(realname))
            {
                where = where.And(p => p.realname.Contains(realname.Trim()));
            }
            if (!string.IsNullOrEmpty(username))
            {
                where = where.And(p => p.username.Contains(username.Trim()));
            }
            if (!string.IsNullOrEmpty(startTime) && startTime != "")
            {
                DateTime stime = Convert.ToDateTime(startTime);
                where = where.And(p => DbFunctions.DiffDays(p.registration_time, stime) <= 0);
                DateTime etime = DateTime.Now;
                if (!string.IsNullOrEmpty(endTime) && endTime != "")
                {
                    etime = Convert.ToDateTime(endTime);
                }
                etime = etime.AddDays(1).AddSeconds(-1);
                where = where.And(p => DbFunctions.DiffDays(p.registration_time, etime) >= 0);
            }
            var list = ef.V_Channel_UserList.Where(where).OrderByDescending(p => p.registration_time).ToList();

            var dt = new DataTable();

            #region List TO DataTable
            dt.Columns.Add("编号", typeof(string));
            dt.Columns.Add("渠道使用者", typeof(string));
            dt.Columns.Add("被邀请账号", typeof(string));
            dt.Columns.Add("被邀请真实姓名", typeof(string));
            dt.Columns.Add("注册时间", typeof(string));
            foreach (var item in list)
            {
                DataRow dr = dt.NewRow();
                dr[0] = item.ID.ToString();
                dr[1] = item.AdminUserName;
                dr[2] = Utils.ReplaceWithSpecialChar(item.username, 3, 4, '*');
                dr[3] = item.realname;
                dr[4] = item.registration_time.ToString();
                dt.Rows.Add(dr);
            }
            #endregion
            string url = Extensions.ExportExcel(dt);
            result = new { state = 1, msg = "投资列表导出完成!", data = url };
            if (string.IsNullOrEmpty(url))
            {
                result = new { state = 0, msg = "导出数据为空!", data = string.Empty };
            }
            return(Json(result));
        }
Exemplo n.º 5
0
        public JsonResult UListExcel()
        {
            //渠道用户,非后台登录用户
            hx_Channel_AdminUser adminUser = Session["Channel_AdminUser"] as hx_Channel_AdminUser;

            var result = new { state = 0, msg = "用户没有权限!", data = string.Empty };

            //判定用户
            if (adminUser == null)
            {
                return(Json(result));
            }
            string realname  = DNTRequest.GetString("Realname");
            string ordId     = Utils.CheckSQLHtml(DNTRequest.GetString("OrdId"));
            string startTime = DNTRequest.GetString("StartTime");
            string endTime   = DNTRequest.GetString("EndTime");
            string btitle    = Utils.CheckSQLHtml(DNTRequest.GetString("BTitle"));

            Expression <Func <V_Channel_Invite, bool> > where = PredicateExtensionses.True <V_Channel_Invite>();
            decimal orderid = 0;

            decimal.TryParse(ordId, out orderid);
            if (!string.IsNullOrEmpty(ordId) && orderid > 0)
            {
                where = where.And(p => p.OrdId.ToString().Contains(ordId.Trim()));
            }
            if (!string.IsNullOrEmpty(realname))
            {
                where = where.And(p => p.realname.Contains(realname));
            }
            if (!string.IsNullOrEmpty(btitle))
            {
                where = where.And(p => p.borrowing_title.Contains(btitle));
            }

            if (!string.IsNullOrEmpty(startTime) && startTime != "")
            {
                DateTime stime = Convert.ToDateTime(startTime);
                where = where.And(p => DbFunctions.DiffDays(p.invest_time, stime) <= 0);
                DateTime etime = DateTime.Now;
                if (!string.IsNullOrEmpty(endTime) && endTime != "")
                {
                    etime = Convert.ToDateTime(endTime);
                }
                etime = etime.AddDays(1).AddSeconds(-1);
                where = where.And(p => DbFunctions.DiffDays(p.invest_time, etime) >= 0);
            }
            where = where.And(p => p.AdminUserName == adminUser.AdminUserName);
            //查出此用户下所有的数据
            var list = ef.V_Channel_Invite.Where(where).OrderByDescending(p => p.invest_time).ToList();
            var dt   = new DataTable();

            #region List TO DataTable
            dt.Columns.Add("被邀请人ID", typeof(string));
            dt.Columns.Add("渠道名称", typeof(string));
            dt.Columns.Add("被邀请账号", typeof(string));
            dt.Columns.Add("被邀请真实姓名", typeof(string));
            dt.Columns.Add("注册时间", typeof(string));
            dt.Columns.Add("首投订单号", typeof(string));
            dt.Columns.Add("首投时间", typeof(string));
            dt.Columns.Add("首投金额", typeof(string));
            dt.Columns.Add("投标信息", typeof(string));
            dt.Columns.Add("投标期限", typeof(string));
            foreach (var item in list)
            {
                DataRow dr = dt.NewRow();
                dr[0] = item.ID.ToString();
                dr[1] = item.ChannelName.ToString();
                dr[2] = Utils.ReplaceWithSpecialChar(item.username, 3, 4, '*');
                dr[3] = item.realname;
                dr[4] = item.registration_time;
                dr[5] = item.OrdId.ToString();
                dr[6] = item.invest_time.ToString();
                dr[7] = item.investment_amount.ToString();
                dr[8] = item.borrowing_title.ToString();
                dr[9] = item.DeadLine.ToString();
                dt.Rows.Add(dr);
            }
            #endregion
            string url = Extensions.ExportExcel(dt);
            result = new { state = 1, msg = "投资列表导出完成!", data = url };
            if (string.IsNullOrEmpty(url))
            {
                result = new { state = 0, msg = "导出数据为空!", data = string.Empty };
            }
            return(Json(result));
        }
Exemplo n.º 6
0
        public ActionResult UserList(int page = 1, int pagesize = 10)
        {
            int    pageIndex = page / 1;
            string realname  = DNTRequest.GetString("Realname");
            string ordId     = Utils.CheckSQLHtml(DNTRequest.GetString("OrdId"));
            string btitle    = Utils.CheckSQLHtml(DNTRequest.GetString("BTitle"));
            string startTime = DNTRequest.GetString("StartTime");
            string endTime   = DNTRequest.GetString("EndTime");


            //渠道用户,非后台登录用户
            hx_Channel_AdminUser adminUser = Session["Channel_AdminUser"] as hx_Channel_AdminUser;

            //判定用户
            if (adminUser == null)
            {
                return(RedirectToAction("LoginOut", "Channel"));
            }
            Expression <Func <V_Channel_Invite, bool> > where = PredicateExtensionses.True <V_Channel_Invite>();
            decimal orderid = 0;

            decimal.TryParse(ordId, out orderid);
            if (!string.IsNullOrEmpty(ordId) && orderid > 0)
            {
                where = where.And(p => p.OrdId.ToString().Contains(ordId.Trim()));
            }
            if (!string.IsNullOrEmpty(realname))
            {
                where = where.And(p => p.realname.Contains(realname));
            }
            if (!string.IsNullOrEmpty(btitle))
            {
                where = where.And(p => p.borrowing_title.Contains(btitle));
            }

            if (!string.IsNullOrEmpty(startTime) && startTime != "")
            {
                DateTime stime = Convert.ToDateTime(startTime);
                where = where.And(p => DbFunctions.DiffDays(p.invest_time, stime) <= 0);
                DateTime etime = DateTime.Now;
                if (!string.IsNullOrEmpty(endTime) && endTime != "")
                {
                    etime = Convert.ToDateTime(endTime);
                }
                etime = etime.AddDays(1).AddSeconds(-1);
                where = where.And(p => DbFunctions.DiffDays(p.invest_time, etime) >= 0);
            }

            where = where.And(p => p.AdminUserName == adminUser.AdminUserName);
            //查出此用户下所有的数据
            var list = ef.V_Channel_Invite.Where(where).OrderByDescending(p => p.invest_time).ToPagedList(pageIndex, pagesize);

            ViewBag.AdminUserName = string.IsNullOrEmpty(adminUser.TrueName) == true || adminUser.TrueName == "" ? adminUser.AdminUserName: adminUser.TrueName;
            ViewBag.Invitedcode   = adminUser.hx_Channel.FirstOrDefault().Invitedcode;

            ViewBag.BTitle    = btitle;
            ViewBag.Realname  = realname;
            ViewBag.OrdId     = ordId;
            ViewBag.StartTime = startTime;
            ViewBag.EndTime   = endTime;

            return(View(list));
        }
Exemplo n.º 7
0
        public JsonResult DoLogin()
        {
            var    result   = new { state = 1, msg = "登录成功!" };
            string username = Utils.CheckSQLHtml(Request.Form["txtUserName"].ToString());
            string password = Utils.CheckSQLHtml(Request.Form["txtPassword"].ToString());
            string code     = Utils.CheckSQLHtml(Request.Form["txtCheckCode"].ToString());

            if (string.IsNullOrEmpty(username))
            {
                result = new { state = 0, msg = "渠道用户名不能为空!" };
                return(Json(result));
            }
            if (string.IsNullOrEmpty(password))
            {
                result = new { state = 0, msg = "密码不能为空!" };
                return(Json(result));
            }
            if (string.IsNullOrEmpty(username))
            {
                result = new { state = 0, msg = "验证码不能为空!" };
                return(Json(result));
            }
            password = Utils.MD5(password);
            if (Session["CheckCode"] != null)
            {
                string serverCode = Session["CheckCode"].ToString();
                if (code != serverCode)
                {
                    result = new { state = 0, msg = "验证码错误!" };
                    return(Json(result));
                }
            }
            else
            {
                result = new { state = 0, msg = "验证码过期!" };
                return(Json(result));
            }
            //渠道用户
            hx_Channel_AdminUser adminUser = ef.hx_Channel_AdminUser.Where(p => p.AdminUserName == username).FirstOrDefault();
            hx_Channel           channel   = null;

            if (adminUser == null)
            {
                result = new { state = 0, msg = "此渠道用户不存在!" };
                return(Json(result));
            }
            else
            {
                channel = adminUser.hx_Channel.Where(p => p.Status == 1).FirstOrDefault();
            }
            if (channel == null)
            {
                result = new { state = 0, msg = "渠道用户已禁用!" };
                return(Json(result));
            }
            else if (adminUser.AdminUserPassword != password)
            {
                result = new { state = 0, msg = "密码错误!" };
                return(Json(result));
            }
            else
            {
                Session["Channel_AdminUser"] = adminUser;
                Session["adminuserid"]       = adminUser.AdminUserID + 10000;//防止和后台管理帐号冲突,加1w偏移
            }
            return(Json(result));
        }