예제 #1
0
        public ActionResult AddHelpPost(hx_td_about_news p, int rootid, string context)
        {
            p            = (hx_td_about_news)Utils.ValidateModelClass(p);
            p.context    = context;
            p.createtime = DateTime.Now;
            p.newimg     = p.newimg.Replace("//", "/");

            p.comm        = 0;
            p.listcomm    = 0;
            p.adminuserid = 0;
            ef.hx_td_about_news.Add(p);
            //ef.SaveChanges();
            string str = "";
            int    i   = ef.SaveChanges();

            if (i > 0)
            {
                CacheRemove.RemoveWebCache("NewsList");

                str = StringAlert.Alert("添加成功!", "/admin/Help/Index?rootid=" + rootid);
            }
            else
            {
                str = StringAlert.Alert("添加失败!", "/admin/Help/Add?rootid=" + rootid);
            }
            return(Content(str, "text/html"));
        }
예제 #2
0
        public ActionResult Add(hx_td_adminuser t)
        {
            var userpass = t.userpass;

            t = (hx_td_adminuser)Utils.ValidateModelClass(t);

            //  t.userpass = DESEncrypt.Encrypt(userpass.Trim(), ConfigurationManager.AppSettings["KEYS"].ToString());

            t.userpass      = Utils.MD5(userpass.Trim());
            t.province      = "0";
            t.city          = "0";
            t.email         = "";
            t.datetime      = DateTime.Now;
            t.lastLoginTime = DateTime.Now;
            t.loginTimes    = 0;
            t.area_id       = 0;

            ef.hx_td_adminuser.Add(t);

            int id = ef.SaveChanges();

            if (id > 0)
            {
                return(Content(StringAlert.Alert("操作成功", "/admin/AdminUser/index"), "text/html"));
            }
            else
            {
                return(Content(StringAlert.Alert("操作失败"), "text/html"));
            }
        }
예제 #3
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));
        }
예제 #4
0
        public ActionResult EmailPost(hx_td_SMSEmail p, string SEContext = "")
        {
            string str = "";

            string[] proNames;

            proNames = new string[] { "SmsEmailId", "SEContext" };


            p = (hx_td_SMSEmail)Utils.ValidateModelClass(p);

            p.SEContext = SEContext;

            DbEntityEntry entry = ef.Entry <hx_td_SMSEmail>(p);

            entry.State = EntityState.Unchanged;

            foreach (string ProName in proNames)
            {
                entry.Property(ProName).IsModified = true;
            }

            int i = ef.SaveChanges();

            if (i > 0)
            {
                str = StringAlert.Alert("邮件模板修改成功!", "/Admin/Template/Email");
            }
            else
            {
                str = StringAlert.Alert("邮件模板修改失败!", "/Admin/Template/Email");
            }
            return(Content(str, "text/html"));
        }
예제 #5
0
        public ActionResult ProductImgTest(int targetid, int registerid, int tp, string fname, string rdm)
        {
            HttpFileCollection hfc          = System.Web.HttpContext.Current.Request.Files;
            string             imgPath      = "";
            string             PhysicalPath = "";
            string             json         = "{\"ret\":0,\"msg\":\"上传图片失败!\"}";
            string             path2        = "/ProductImg/UploadFiles/";
            string             fileName     = "";

            if (hfc.Count > 0)
            {
                var    httpfile = hfc[0];
                string suf      = "";
                if (!isImage(httpfile.FileName, out suf))
                {
                    json = "{\"ret\":0,\"msg\":\"图片只支持---gif|jpg|jpeg|bmp!\"}";
                    return(Content(json, "text/json"));
                }
                fileName = string.Format("{0}.{1}", sjname() + rdm, suf);
                imgPath  = @"/ProductImg/UploadFiles/";
                var ss = httpfile.ContentType;
                PhysicalPath = Server.MapPath(imgPath);
                if (!System.IO.Directory.Exists(PhysicalPath))
                {
                    System.IO.Directory.CreateDirectory(PhysicalPath);
                }

                PhysicalPath = PhysicalPath + fileName;
                httpfile.SaveAs(PhysicalPath);



                imgPath = imgPath + fileName;

                if (Utils.CheckPictureSafe(PhysicalPath))
                {
                    if (!string.IsNullOrEmpty(imgPath))
                    {
                        hx_borrower_guarantor_picture p = new hx_borrower_guarantor_picture();
                        p.targetid            = targetid;
                        p.borrower_registerid = registerid;
                        p.picture_name        = Utils.CheckSQLHtml(fname);
                        p.type_picture        = tp;
                        p.picture_path        = path2 + fileName;
                        p.uploadtime          = DateTime.Now;
                        ef.hx_borrower_guarantor_picture.Add(p);
                        ef.SaveChanges();

                        imgPath = imgPath.Replace("/", "//");
                        json    = "{\"ret\":1,\"path\":\"" + imgPath + "\",\"key\":" + p.borrower_guarantor_picture_id + "}";
                    }
                }
                else
                {   //图片安全提醒,您试除上传非法文件
                    json = "{\"ret\":0,\"path\":\"图片中含有非法文件\"}";
                }
            }
            return(Content(json, "text/json"));
        }
예제 #6
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        private bool Add(hx_Contract_template t)
        {
            t = (hx_Contract_template)Utils.ValidateModelClass(t);
            ef.hx_Contract_template.Add(t);
            ef.SaveChanges();

            return(true);
        }
예제 #7
0
 public int Add(Holiday model)
 {
     if (model != null)
     {
         ef.Holidays.Add(model);
         return(ef.SaveChanges());
     }
     return(0);
 }
예제 #8
0
 public int Add(hx_AppUpdatePackage model)
 {
     if (string.IsNullOrWhiteSpace(model.Code))
     {
         model.Code = Guid.NewGuid().ToString().Replace("-", "");
     }
     ef.hx_AppUpdatePackage.Add(model);
     return(ef.SaveChanges());
 }
예제 #9
0
        public ActionResult AddAdpost(hx_td_Ad p)
        {
            p              = (hx_td_Ad)Utils.ValidateModelClass(p);
            p.AdPath       = p.AdPath.Replace("//", "/");
            p.Adcreatetime = DateTime.Now;
            ef.hx_td_Ad.Add(p);
            ef.SaveChanges();

            CacheRemove.RemoveWebAdtype(); //请除广告位缓存
            return(RedirectToAction("index", "Ad"));
        }
예제 #10
0
        public ActionResult AddLinkpost(hx_td_Links p)
        {
            p = (hx_td_Links)Utils.ValidateModelClass(p);
            p.LinkLogo.Replace("//", "/");
            p.createtime = DateTime.Now;
            ef.hx_td_Links.Add(p);
            ef.SaveChanges();
            CacheRemove.ReMovetd_web_Links();

            return(RedirectToAction("index", "Link"));
        }
예제 #11
0
        public ActionResult SaveEditor(int key, int parendid, string name)
        {
            name = Utils.CheckSQLHtml(HttpUtility.UrlDecode(name));
            var list = (from a in ef.hx_td_department where a.department_name == name && a.department_id != key select a).SingleOrDefault();

            if (list != null && list.department_id > 0)
            {
                return(Content("{\"ret\":-1,\"msg\":\"部门名称已经存在\"}", "text/json"));
            }

            hx_td_department model = new hx_td_department();

            model.department_name = name;
            model.parentid        = parendid;
            model.department_id   = key;

            if (parendid != 0)
            {
                var parent = (from a in ef.hx_td_department where a.department_id == parendid select a).SingleOrDefault();
                if (parent != null)
                {
                    model.rootid     = parent.rootid;
                    model.parentpath = parent.parentpath + "," + model.department_id + ",";
                    model.depath     = parent.depath + 1;
                }
            }

            string[] proNames;
            proNames = new string[] { "department_name", "parentid", "parentpath", "rootid", "depath" };

            DbEntityEntry entry = ef.Entry <hx_td_department>(model);

            entry.State = EntityState.Unchanged;

            foreach (string ProName in proNames)
            {
                entry.Property(ProName).IsModified = true;
            }
            int result = ef.SaveChanges();

            if (result > 0)
            {
                new SelectListByEF().ClearDepartmentInfo();
                return(Content("{\"ret\":1,\"msg\":\"保存成功!\"}", "text/json"));
            }
            else
            {
                return(Content("{\"ret\":0,\"msg\":\"保存失败!\"}", "text/json"));
            }
        }
예제 #12
0
        public ActionResult AppUpdateAdd(FormCollection Form)
        {
            hx_AppUpdatePackage model = new hx_AppUpdatePackage();

            if (Form.Count < 1)
            {
                ViewBag.UpdateLevelList = GetUpdateLevel();
                ViewBag.PlatformList    = GetPlatformList();
                return(View(model));
            }

            model.Code        = Guid.NewGuid().ToString().Replace("-", "");
            model.Channel     = Form["channel"] ?? string.Empty;
            model.CreateTime  = DateTime.Now;
            model.DependCode  = Form["DependCode"] ?? string.Empty;
            model.Description = Form["Description"] ?? string.Empty;
            var canUse = Form["canUse"] ?? "否";

            if (canUse == "是")
            {
                model.IsEnable = 1;
            }
            else
            {
                model.IsEnable = 0;
            }
            model.DownloadCount = 0;
            model.Platform      = Form["Platform"] ?? string.Empty;
            string updateLevel = Form["UpdateLevel"];

            model.UpdateLevel = Convert.ToInt32(updateLevel);
            model.ValideCode  = string.Empty;
            model.Version     = Form["version"];
            model.VirtualPath = "";
            if (model.Platform == "IOS")
            {
                model.Channel     = "CLT";
                model.Ways        = "Apple Store";
                model.ValideCode  = "XxxxXxxxXxxxXxxxXxxxXxxxXxxxXxxx";
                model.VirtualPath = "";
            }
            else
            {
                model.Ways = "Http";
                var    uploadFile    = HttpContext.Request.Files[0];
                string directoryPath = Utils.GetPhysicalPath("Static/AppUpdate");
                if (!Directory.Exists(directoryPath))
                {
                    Directory.CreateDirectory(directoryPath);
                }
                string fileName = directoryPath + "/" + model.Code;
                uploadFile.SaveAs(fileName);
                string md5 = EncryptHelper.GetMD5HashFromFile(fileName);
                model.ValideCode  = md5;
                model.VirtualPath = "Static/AppUpdate/" + model.Code;
            }
            ef.hx_AppUpdatePackage.Add(model);
            ef.SaveChanges();
            return(Redirect("AppUpdateList"));
        }
예제 #13
0
        public ActionResult Waitverify(int id, decimal borrowing_balance, decimal consultingAMT, decimal guaranteeAMT, int tender_state, string reviewremarks)
        {
            var userid         = Utils.GetAdmUserID();
            var controllerName = this.RouteData.Values["controller"].ToString();
            var actionName     = this.RouteData.Values["action"].ToString();

            if (!new UserLimitByEF().CheckAdminLimit(userid, controllerName, actionName))
            {   //无权限
                return(Content("<script>alert('您没有操作权限');closewindows();</script>", "text/html"));
            }
            var result = ef.hx_borrowing_target.Where(p => p.targetid == id).Update(p => new hx_borrowing_target {
                consultingAMT = consultingAMT, guaranteeAMT = guaranteeAMT, tender_state = tender_state
            });

            string str = string.Format("<script>alert('审核操作失败');closewindows();</script>");

            if (result > 0)
            {
                hx_td_reviewremarks model = new hx_td_reviewremarks();
                model.targetid       = id;
                model.tender_state   = tender_state;
                model.reviewremarks  = reviewremarks;
                model.reviewtime     = DateTime.Now;
                model.admin_operator = Utils.GetAdmUserID();

                ef.hx_td_reviewremarks.Add(model);

                if (ef.SaveChanges() > 0)
                {
                    str = string.Format("<script>alert('审核操作成功');closewindows();</script>");
                }
            }
            return(Content(str, "text/html"));
        }
예제 #14
0
        public ActionResult AddPost(hx_Activity_schedule p)
        {
            p = (hx_Activity_schedule)Utils.ValidateModelClass(p);
            ef.hx_Activity_schedule.Add(p);
            //ef.SaveChanges();
            string str = "";
            int    i   = ef.SaveChanges();

            if (i > 0)
            {
                str = StringAlert.Alert("活动计划添加成功!", "/admin/ActivitySchedule/Index");
            }
            else
            {
                str = StringAlert.Alert("活动计划添加失败!", "/admin/ActivitySchedule/Add/");
            }
            return(Content(str, "text/html"));
        }
예제 #15
0
        public ActionResult AddPost(hx_Mention_charges p)
        {
            p = (hx_Mention_charges)Utils.ValidateModelClass(p);
            ef.hx_Mention_charges.Add(p);
            //ef.SaveChanges();
            string str = "";
            int    i   = ef.SaveChanges();

            if (i > 0)
            {
                str = StringAlert.Alert("提现费用添加成功!", "/admin/MentionCharges/Index");
            }
            else
            {
                str = StringAlert.Alert("提现费用添加失败!", "/admin/MentionCharges/Add/");
            }
            return(Content(str, "text/html"));
        }
예제 #16
0
        public ActionResult AddPost(hx_bonding_company p, string company_profile)
        {
            p = (hx_bonding_company)Utils.ValidateModelClass(p);
            p.company_profile = company_profile;
            ef.hx_bonding_company.Add(p);
            //ef.SaveChanges();
            string str = "";
            int    i   = ef.SaveChanges();

            if (i > 0)
            {
                str = StringAlert.Alert("担保公司添加成功!", "/admin/BondingCompany/Index");
            }
            else
            {
                str = StringAlert.Alert("担保公司添加失败!", "/admin/BondingCompany/Add/");
            }
            return(Content(str, "text/html"));
        }
예제 #17
0
        public ActionResult AddPost(hx_Project_type p)
        {
            p = (hx_Project_type)Utils.ValidateModelClass(p);

            ef.hx_Project_type.Add(p);
            //ef.SaveChanges();
            string str = "";
            int    i   = ef.SaveChanges();

            if (i > 0)
            {
                str = StringAlert.Alert("项目类型添加成功!", "/admin/ProjectType/Index");
            }
            else
            {
                str = StringAlert.Alert("项目类型添加失败!", "/admin/ProjectType/Add/");
            }
            return(Content(str, "text/html"));
        }
예제 #18
0
        public ActionResult AddPost(guarantee_way p)
        {
            p            = (guarantee_way)Utils.ValidateModelClass(p);
            p.createtime = DateTime.Now;
            ef.guarantee_way.Add(p);
            //ef.SaveChanges();
            string str = "";
            int    i   = ef.SaveChanges();

            if (i > 0)
            {
                str = StringAlert.Alert("担保方式添加成功!", "/admin/GuaranteeWay/Index");
            }
            else
            {
                str = StringAlert.Alert("担保方式添加失败!", "/admin/GuaranteeWay/Add/");
            }
            return(Content(str, "text/html"));
        }
예제 #19
0
        /// <summary>
        /// 保存部门权限
        /// </summary>
        /// <param name="departmentid"></param>
        /// <param name="limitids"></param>
        /// <returns></returns>
        public ActionResult SaveUserLimit(int userid, int departmentid, string limitids)
        {
            var json = "{\"ret\":-1,\"msg\":\"参数错误\"}";

            if (userid > 0)
            {
                var result   = ef.hx_DepUserLimit1.Where(a => a.adminUserId == userid).Delete();
                var errorNum = 0;
                if (!string.IsNullOrEmpty(limitids))
                {
                    var arrLimitId = limitids.Split('|');
                    foreach (var item in arrLimitId)
                    {
                        hx_DepUserLimit1 l = new hx_DepUserLimit1();
                        l.adminUserId  = Utils.GetAdmUserID();
                        l.createTime   = DateTime.Now;
                        l.departmentId = departmentid;
                        l.adminUserId  = userid;
                        l.limitId      = int.Parse(item);
                        l.limitType    = 2;

                        ef.hx_DepUserLimit1.Add(l);
                        int id = ef.SaveChanges();
                        if (id < 1)
                        {
                            errorNum += 1;
                        }
                    }
                }
                if (errorNum > 0)
                {
                    json = "{\"ret\":0,\"msg\":\"保存失败\"}";
                }
                else
                {
                    new UserLimitByEF().ClearUserCache(userid);
                    json = "{\"ret\":1,\"msg\":\"保存成功\"}";
                }
            }

            return(Content(json, "text/json"));
        }
예제 #20
0
        public ActionResult UploadExcelData(HttpPostedFileBase file)
        {
            if (file == null)
            {
                return(Content("没有文件!", "text/plain"));
            }
            List <hx_QuanmamaRecord> data = GetDataFromExcel(file.InputStream);

            if (data == null)
            {
                return(Content("请检查Excel文件内容!", "text/plain"));
            }
            var mobileData   = data.Select(c => c.RegisterMobile).ToList();
            var existMobiles = (from item in ef.hx_member_table
                                where mobileData.Contains(item.mobile)
                                select new { mobile = item.mobile, usrCustID = item.UsrCustId }).ToList();

            data = (from item in data
                    join dr in existMobiles
                    on item.RegisterMobile equals dr.mobile
                    //on new { mobile = item.RegisterMobile, usrCustID = item.UsrCustID } equals new { mobile = dr.mobile, usrCustID = dr.usrCustID }
                    select item).ToList();
            var noNeedInsertData = (from item in ef.hx_QuanmamaRecord
                                    where mobileData.Contains(item.RegisterMobile) //|| usrCustIDData.Contains(item.UsrCustID)
                                    select item).ToList();
            var dataInsert = (from item in data
                              where !noNeedInsertData.Select(c => c.RegisterMobile).Contains(item.RegisterMobile) //&& !noNeedInsertData.Select(c => c.UsrCustID).Contains(item.UsrCustID)
                              select item).ToList();

            dataInsert.ForEach(c =>
            {
                var usrCustID = existMobiles.Where(d => d.mobile == c.RegisterMobile).First().usrCustID;
                c.UsrCustID   = usrCustID;
            });
            //var usrCustIDData = data.Select(c => c.UsrCustID).ToList();
            ef.hx_QuanmamaRecord.AddRange(dataInsert);
            ef.SaveChanges();
            return(RedirectToAction("QuanmamaList"));
        }
예제 #21
0
        /// 增加文章点击量
        public void ProcessRequest(HttpContext context)
        {
            int id = Convert.ToInt32(context.Request.QueryString["id"]);

            if (id != 0)
            {
                chuangtouEntities TF = new chuangtouEntities();
                hx_td_about_news  ha = TF.hx_td_about_news.Where(p => p.newid == id).FirstOrDefault();
                if (ha != null)
                {
                    ha.ClickCount = (ha.ClickCount == null ? 0 : ha.ClickCount) + 1;
                    TF.SaveChanges();
                }
            }
        }
예제 #22
0
        public bool InserXiCaiUser(hx_member_table user, string userid = "0", string display = "pc")
        {
            XiCaiUser xiCaiUser = new XiCaiUser()
            {
                Mobile         = user.mobile,
                XiCaiUserID    = int.Parse(userid),
                RegisterUserID = user.registerid,
                Display        = display
            };

            if (!ef.XiCaiUsers.Any(c => c.Mobile == user.mobile))
            {
                ef.XiCaiUsers.Add(xiCaiUser);
                if (ef.SaveChanges() < 1)
                {
                    LogInfo.WriteLog("注册成功,插入希财数据失败");
                    return(false); //("操作失败,请重新操作");
                }
            }
            return(true);
        }
예제 #23
0
        public ActionResult PayMoney(string norid = "", string username = "", int OrdIdState = -1, int ddlType = 4)
        {
            if (string.IsNullOrEmpty(norid))
            {
                return(Content(StringAlert.Alert("参数错误!"), "text/html"));
            }

            var list = ef.hx_td_LL_cash.Where(p => p.no_order == norid && p.paystate == 0);

            if (list != null && list.Count() > 0)
            {
                hx_td_LL_cash llc = list.ToList <hx_td_LL_cash>()[0];
                llc.paystate = 3;
                llc.OperTime = DateTime.Now;

                ef.hx_td_LL_cash.Add(llc);
                ef.SaveChanges();
            }

            return(RedirectToAction("index", new { username = username, OrdIdState = OrdIdState, ddlType = ddlType }));
        }
예제 #24
0
        public ActionResult DelById(int id, int rootid = 0)
        {
            string str = "";

            hx_td_web_type pDel = new hx_td_web_type()
            {
                menu_id = id
            };

            ef.hx_td_web_type.Attach(pDel);
            ef.hx_td_web_type.Remove(pDel);

            int i = ef.SaveChanges();

            if (i > 0)
            {
                str = StringAlert.Alert("网站分类删除成功!", "/admin/WebType/Index?rootid=" + rootid.ToString());
            }
            else
            {
                str = StringAlert.Alert("网站分类删除失败!", "/admin/WebType/Index?rootid=" + rootid.ToString());
            }
            return(Content(str, "text/html"));
        }
예제 #25
0
        /// <summary>
        /// 按照投资金额进行红包或加息券奖励发放(常规投资 红包或加息券) 未记录系统信息及奖励流水
        /// 返回用户活动表hx_UserAct 对象
        /// </summary>
        /// <param name="mcp">规则对象</param>
        ///  <param name="hua">活动项目表</param>
        ///  <param name="Registerid">用户id</param>
        ///  <param name="investAmt">投资金额</param>
        protected List <hx_UserAct> OPMcoupon(Mcoupon mcp, hx_ActivityTable hat, int Registerid, decimal investAmt)
        {
            List <hx_UserAct>    t   = new List <hx_UserAct>();
            List <Msplitarr>     msp = new List <Msplitarr>();
            List <MAmtList>      mat = new List <MAmtList>();
            JavaScriptSerializer js  = new JavaScriptSerializer();

            if (mcp.rule == 1) //统一赠送
            {
                #region 统一赠送
                t.Clear();
                string msplitarrc = "";
                //经过比对拆分不拆分代码逻辑一样,所以合并处理
                //if (mcp.ISsplit == 1)
                try
                {
                    msplitarrc = mcp.Msplitarr.SerializeJSON();
                    msp        = js.Deserialize <List <Msplitarr> >(msplitarrc);
                }
                catch
                {
                    msp = null;
                }
                foreach (var item in msp)
                {
                    hx_UserAct hua = new hx_UserAct();
                    hua.ActTypeId  = hat.ActTypeId;
                    hua.registerid = Registerid;
                    hua.RewTypeID  = hat.RewTypeID;
                    hua.ActID      = hat.ActID;
                    hua.Amt        = item.cashAmt;
                    hua.Uselower   = item.startAmt;
                    hua.Usehight   = item.endAmt;
                    if (item.validity > 0) //有效天数大于0
                    {
                        hua.AmtEndtime = DateTime.Now.Date.AddDays(item.validity + 1).AddSeconds(-1);
                    }
                    else
                    {
                        hua.AmtEndtime = item.endTime;
                    }

                    hua.AmtUses      = mcp.Uses; //没指定情况下默认为单独使用
                    hua.UseState     = 0;        //现金未转账
                    hua.AmtProid     = 0;        //未使用默认为0
                    hua.ISSmsOne     = 0;
                    hua.IsSmsThree   = 0;
                    hua.isSmsFifteen = 0;
                    hua.IsSmsSeven   = 0;
                    hua.isSmsSixteen = 0;
                    hua.Createtime   = DateTime.Now;
                    hua.Title        = hat.ActName;
                    hua.UseLifeLoan  = string.IsNullOrWhiteSpace(item.UseLifeLoan) ? "" : item.UseLifeLoan;
                    ef.hx_UserAct.Add(hua);
                    int i = ef.SaveChanges();
                    t.Add(hua);
                }
                #endregion
            }
            else if (mcp.rule == 2)//按投资赠送,需要判断投资金额区间,不支持拆分 只赠送一张代金券或加息券,使用限制按照金额在拆分中匹配
            {
                #region  投资赠送
                hx_UserAct hua = new hx_UserAct();
                t.Clear();
                string msplitarrc = "";
                hua.ActTypeId  = hat.ActTypeId;
                hua.registerid = Registerid;
                hua.RewTypeID  = hat.RewTypeID;
                hua.ActID      = hat.ActID;
                try
                {
                    msplitarrc = mcp.Msplitarr.SerializeJSON();
                    msp        = js.Deserialize <List <Msplitarr> >(msplitarrc);
                }
                catch
                {
                    msp = null;
                }
                hua.Amt          = GetCouponAmtByInvestAmt(mcp, investAmt);
                hua.Uselower     = GetCouponUseConByAmt(msp, decimal.Parse(hua.Amt.ToString()), 0);
                hua.Usehight     = GetCouponUseConByAmt(msp, decimal.Parse(hua.Amt.ToString()), 1);
                hua.AmtEndtime   = GetCouponEndTimeByAmt(msp, decimal.Parse(hua.Amt.ToString()));
                hua.AmtUses      = mcp.Uses; //没指定情况下默认为单独使用
                hua.UseState     = 0;        //现金未转账
                hua.AmtProid     = 0;        //未使用默认为0
                hua.ISSmsOne     = 0;
                hua.IsSmsThree   = 0;
                hua.isSmsFifteen = 0;
                hua.IsSmsSeven   = 0;
                hua.isSmsSixteen = 0;
                hua.Createtime   = DateTime.Now;
                hua.Title        = hat.ActName;
                hua.UseLifeLoan  = msp == null ? "" : msp[0].UseLifeLoan;
                if (hua.Uselower >= 0 || hua.Usehight >= 0 || hua.Amt <= 0)
                {
                    ef.hx_UserAct.Add(hua);
                    int i = ef.SaveChanges();
                    if (i > 0)
                    {
                        t.Add(hua);
                    }
                }
                #endregion
            }

            else if (mcp.rule == 3) //随机赠送,需要判断投资金额区间,不支持拆分 只赠送一张代金券或加息券,使用限制按照金额在拆分中匹配
            {
                #region 随机赠送
                t.Clear();
                foreach (var item in mcp.MAmtList)
                {
                    if (item.startAmt <= investAmt && (item.endAmt == 0 || item.endAmt >= investAmt))
                    {
                        for (int i = 0; i < item.num; i++)
                        {
                            hx_UserAct hua        = new hx_UserAct();
                            string     msplitarrc = "";
                            hua.ActTypeId  = hat.ActTypeId;
                            hua.registerid = Registerid;
                            hua.RewTypeID  = hat.RewTypeID;
                            hua.ActID      = hat.ActID;
                            try
                            {
                                msplitarrc = mcp.Msplitarr.SerializeJSON();
                                msp        = js.Deserialize <List <Msplitarr> >(msplitarrc);
                            }
                            catch
                            {
                                msp = null;
                            }
                            hua.Amt        = Utils.GetActRandom(item.Amtstr);
                            hua.Uselower   = GetCouponUseConByAmt(msp, decimal.Parse(hua.Amt.ToString()), 0);
                            hua.Usehight   = GetCouponUseConByAmt(msp, decimal.Parse(hua.Amt.ToString()), 1);
                            hua.AmtEndtime = GetCouponEndTimeByAmt(msp, decimal.Parse(hua.Amt.ToString()));

                            hua.AmtUses      = mcp.Uses; //没指定情况下默认为单独使用
                            hua.UseState     = 0;        //现金未转账
                            hua.AmtProid     = 0;        //未使用默认为0
                            hua.ISSmsOne     = 0;
                            hua.IsSmsThree   = 0;
                            hua.isSmsFifteen = 0;
                            hua.IsSmsSeven   = 0;
                            hua.isSmsSixteen = 0;
                            hua.Createtime   = DateTime.Now;
                            hua.Title        = hat.ActName;
                            hua.UseLifeLoan  = msp == null ? "" : msp[0].UseLifeLoan;
                            if (hua.Uselower >= 0 || hua.Usehight >= 0 || hua.Amt <= 0)
                            {
                                ef.hx_UserAct.Add(hua);
                                int c1 = ef.SaveChanges();
                                if (c1 > 0)
                                {
                                    t.Add(hua);
                                }
                            }
                        }
                        break;
                    }
                }
                #endregion
            }
            return(t);
        }
예제 #26
0
        public bool SendCash(int actID, int Registerid)
        {
            bool t = false;
            chuangtouEntities ef  = new chuangtouEntities();
            hx_ActivityTable  hat = new ActFacade().GetActivityModel(actID); //GetActTableInfo(ActTypeId, ActUser, 1);

            if (hat != null)
            {
                //判是否过期
                if (hat.ActStarttime <= DateTime.Now && DateTime.Now <= hat.ActEndtime)
                {
                    string               ActRule = hat.ActRule;
                    List <MAmtList>      mlist   = new List <MAmtList>();
                    JavaScriptSerializer js      = new JavaScriptSerializer();
                    //MActCash mc = new MActCash();
                    Mcoupon mcp = new Mcoupon();
                    mcp = js.Deserialize <Mcoupon>(ActRule);
                    //mlist = js.Deserialize<List<MAmtList>>(ActRule);

                    //检查分发奖励是否超过顶限,如果超过直接跳过
                    //int TopNum = B_usercenter.GetTopNum(hat.ActID);
                    //项目已经发放的金额
                    //decimal totalAmt = B_usercenter.GetTopAmtCount(hat.ActID);
                    //第一次投资获取对应奖励
                    decimal actamt = mcp.cash;//GetActAmt(mc, InvestAmt, TopNum);

                    //if (mc.TopAmt > totalAmt && mc.TopNum > TopNum)
                    //{

                    t = true;
                    if (actamt > 0)//大于 0里写入对应的奖励数据
                    {
                        hx_UserAct hua = new hx_UserAct();
                        hua.ActTypeId    = hat.ActTypeId;
                        hua.registerid   = Registerid;
                        hua.RewTypeID    = hat.RewTypeID;
                        hua.ActID        = hat.ActID;
                        hua.Amt          = actamt;
                        hua.Uselower     = 0.00M;
                        hua.Usehight     = 0.00M;
                        hua.AmtEndtime   = DateTime.Parse(hat.ActEndtime.ToString()).AddMonths(1);
                        hua.AmtUses      = 1; //没指定情况下默认为单独使用
                        hua.UseState     = 5; //现金未转账
                        hua.UseTime      = DateTime.Now;
                        hua.AmtProid     = 0; //未使用默认为0
                        hua.ISSmsOne     = 0;
                        hua.IsSmsThree   = 0;
                        hua.isSmsFifteen = 0;
                        hua.IsSmsSeven   = 0;
                        hua.isSmsSixteen = 0;
                        hua.OrderID      = decimal.Parse(Utils.Createcode());
                        hua.Createtime   = DateTime.Now;
                        hua.Title        = hat.ActName;
                        hua.UseLifeLoan  = "";
                        ef.hx_UserAct.Add(hua);
                        int i = ef.SaveChanges();
                        if (i > 0)
                        {
                            //录入成功,后进行转账操作
                            //1.获取用户对向
                            M_member_table p = new M_member_table();
                            B_member_table o = new B_member_table();
                            p = o.GetModel(Registerid);

                            if (p != null)
                            {
                                //2.调用商户向用户转账接口
                                Transfer   tf   = new Transfer();
                                ReTransfer retf = tf.ToUserTransfer(p.UsrCustId, actamt, hua.OrderID.ToString(), hua.ActID.ToString(), "/Thirdparty/ToUserTransfer");
                                if (retf != null)
                                {
                                    if (retf.RespCode == "000")
                                    {
                                        //3.事务处理操作账户及插入流水

                                        #region 验签缓存处理
                                        string cachename = retf.OrdId + "ToUserTransfer" + retf.InCustId;

                                        if (Utils.GeTThirdCache(cachename) == 0)
                                        {
                                            Utils.SetThirdCache(cachename);
                                            B_usercenter BUC = new B_usercenter();
                                            int          ic  = BUC.UpateActToUserTransfer(retf, 0); //用户余更新
                                            if (ic > 0)
                                            {
                                                string    sql = "SELECT registerid,username,mobile  from hx_member_table where UsrCustId='" + retf.InCustId + "'";
                                                DataTable dt  = DbHelperSQL.GET_DataTable_List(sql);
                                                if (dt.Rows.Count > 0)
                                                {
                                                    /*短信接口*/


                                                    #region 流水信息
                                                    B_usercenter ors = new B_usercenter();
                                                    decimal      di  = ors.GetUsridAvailable_balance(int.Parse(dt.Rows[0]["registerid"].ToString()));
                                                    // di = di + decimal.Parse(hua.Amt.ToString());
                                                    StringBuilder strSql = new StringBuilder();
                                                    strSql.Append("insert into hx_Capital_account_water(");
                                                    strSql.Append("membertable_registerid,income,expenditure,time_of_occurrence,account_balance,types_Finance,createtime,keyid,remarks)");
                                                    strSql.Append(" values (");
                                                    strSql.Append("" + int.Parse(dt.Rows[0]["registerid"].ToString()) + "," + decimal.Parse(hua.Amt.ToString()) + ",0,'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "'," + di + "," + (int)Enum.Parse(typeof(EnumTypesFinance), EnumTypesFinance.现金奖励.ToString()) + ",'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',0,'" + "现金奖励" + "')");

                                                    DbHelperSQL.RunSql(strSql.ToString());

                                                    strSql.Clear();
                                                    #endregion

                                                    #region 奖励流水
                                                    M_bonus_account_water mbaw = new M_bonus_account_water();
                                                    B_bonus_account_water bbaw = new B_bonus_account_water();
                                                    DateTime dte = DateTime.Now;
                                                    mbaw.bonus_account_id       = int.Parse(hua.ActID.ToString());
                                                    mbaw.membertable_registerid = int.Parse(dt.Rows[0]["registerid"].ToString());
                                                    mbaw.income             = decimal.Parse(retf.TransAmt);
                                                    mbaw.expenditure        = 0.00M;
                                                    mbaw.time_of_occurrence = DateTime.Now;

                                                    mbaw.award_description = hat.ActName + "奖励已汇入个人账户";
                                                    mbaw.water_type        = 0;
                                                    bbaw.Add(mbaw);

                                                    #endregion


                                                    #region MyRegion  系统消息
                                                    DateTime            dti = DateTime.Now;
                                                    M_td_System_message pm  = new M_td_System_message();
                                                    pm.MReg     = int.Parse(dt.Rows[0]["registerid"].ToString());
                                                    pm.Mstate   = 0;
                                                    pm.MTitle   = hat.ActName;
                                                    pm.MContext = "尊敬的用户" + dt.Rows[0]["username"].ToString() + ":您好!恭喜您成功" + hat.ActName + ",现金奖励 " + retf.TransAmt + "元。如有问题可咨询创利投的客服!";
                                                    pm.PubTime  = dti;
                                                    B_usercenter.AddMessage(pm);
                                                    #endregion
                                                }
                                            }

                                            t = true;
                                        }
                                        #endregion
                                    }
                                }
                            }
                        }
                    }
                    //}
                }
            }


            return(t);
        }
예제 #27
0
        /// <summary>
        /// 发放奖励
        /// </summary>
        /// <param name="activity"></param>
        /// <param name="registerID"></param>
        private void DrawBonus(hx_ActivityTable activity, int registerID)
        {
            chuangtouEntities ef = new chuangtouEntities();

            B_bonus_account bb = new B_bonus_account();
            M_bonus_account mb = new M_bonus_account();

            M_bonus_account_water mbaw = new M_bonus_account_water();
            B_bonus_account_water bbaw = new B_bonus_account_water();

            DateTime dte = DateTime.Now;//当前时间截点

            //hx_ActivityTable act = ef.hx_ActivityTable.Where(c => c.ActID == activity.ActID).FirstOrDefault();//添加奖励类型
            if (activity.ActEndtime >= dte && activity.ActStarttime <= dte)
            {
                Mcoupon mcp             = new Mcoupon();
                JavaScriptSerializer js = new JavaScriptSerializer();
                mcp = js.Deserialize <Mcoupon>(activity.ActRule);
                hx_UserAct hua = new hx_UserAct();
                hua.ActTypeId    = activity.ActTypeId;
                hua.registerid   = registerID;
                hua.RewTypeID    = activity.RewTypeID;
                hua.ActID        = activity.ActID;
                hua.Amt          = mcp.cash;
                hua.Uselower     = mcp.Msplitarr == null || mcp.Msplitarr.Count <= 0 ? 0 : mcp.Msplitarr[0].startAmt;
                hua.Usehight     = mcp.Msplitarr == null || mcp.Msplitarr.Count <= 0 ? 0 : mcp.Msplitarr[0].endAmt;
                hua.AmtEndtime   = activity.ActEndtime;
                hua.AmtUses      = mcp.Uses; //没指定情况下默认为单独使用
                hua.UseState     = 0;        //现金未转账
                hua.AmtProid     = 0;        //未使用默认为0
                hua.ISSmsOne     = 0;
                hua.IsSmsThree   = 0;
                hua.isSmsFifteen = 0;
                hua.IsSmsSeven   = 0;
                hua.isSmsSixteen = 0;
                hua.Createtime   = DateTime.Now;

                ef.hx_UserAct.Add(hua);
                int i = ef.SaveChanges();

                mb.activity_schedule_id   = activity.ActID;
                mb.membertable_registerid = registerID;
                mb.activity_schedule_name = activity.ActName;
                mb.amount_of_reward       = decimal.Parse(hua.Amt.ToString());

                mb.use_lower_limit = Convert.ToDecimal(hua.Uselower);
                mb.reward          = 0;
                mb.start_date      = Convert.ToDateTime(hua.Createtime);
                mb.end_date        = Convert.ToDateTime(hua.AmtEndtime);
                mb.entry_time      = dte;
                int bbid = bb.Add(mb);
                if (bbid > 0) //奖励记录成功后插入明细记录
                {
                    mbaw.bonus_account_id       = bbid;
                    mbaw.membertable_registerid = registerID;
                    mbaw.income             = decimal.Parse(hua.Amt.ToString());
                    mbaw.expenditure        = 0.00M;
                    mbaw.time_of_occurrence = DateTime.Now;
                    mbaw.award_description  = activity.ActName;
                    mbaw.water_type         = 0;

                    bbaw.Add(mbaw);
                }
            }
        }
예제 #28
0
        /// <summary>
        /// 发放奖励
        /// </summary>
        /// <param name="activity"></param>
        /// <param name="registerID"></param>
        public static void DrawBonus(hx_ActivityTable activity, int registerID, int effectiveDays)
        {
            //chuangtouEntities ef = new chuangtouEntities();
            M_bonus_account_water mbaw = new M_bonus_account_water();
            B_bonus_account_water bbaw = new B_bonus_account_water();

            DateTime dte = DateTime.Now;//当前时间截点

            //if (activity.ActEndtime >= dte && activity.ActStarttime <= dte)   //发布的时候要释放
            if (true)
            {
                Mcoupon mcp             = new Mcoupon();
                JavaScriptSerializer js = new JavaScriptSerializer();
                mcp = js.Deserialize <Mcoupon>(activity.ActRule);
                hx_UserAct hua = new hx_UserAct();
                hua.ActTypeId  = activity.ActTypeId;
                hua.registerid = registerID;
                hua.RewTypeID  = activity.RewTypeID;
                if (activity.RewTypeID == 3)
                {
                    hua.UseLifeLoan = "3-0";
                }
                hua.ActID        = activity.ActID;
                hua.Amt          = mcp.cash;
                hua.Uselower     = mcp.Msplitarr == null || mcp.Msplitarr.Count <= 0 ? 0 : mcp.Msplitarr[0].startAmt;
                hua.Usehight     = mcp.Msplitarr == null || mcp.Msplitarr.Count <= 0 ? 0 : mcp.Msplitarr[0].endAmt;
                hua.AmtEndtime   = Convert.ToDateTime(dte.AddDays(effectiveDays).ToShortDateString() + " 23:59:59"); //有效期为10天
                hua.AmtUses      = 1;                                                                                //没指定情况下默认为单独使用
                hua.UseState     = activity.RewTypeID == 1 ? 5 : 0;
                hua.AmtProid     = 0;                                                                                //未使用默认为0
                hua.ISSmsOne     = 0;
                hua.IsSmsThree   = 0;
                hua.isSmsFifteen = 0;
                hua.IsSmsSeven   = 0;
                hua.isSmsSixteen = 0;
                hua.Title        = activity.ActName;
                hua.Createtime   = dte;
                hua.OrderID      = decimal.Parse(Utils.Createcode());//根据日期生成单号
                ef.hx_UserAct.Add(hua);
                ef.SaveChanges();


                if (activity.RewTypeID == 1)  //当奖品为现金时
                {
                    Transfer       tf = new Transfer();
                    M_member_table p  = new M_member_table();
                    B_member_table o  = new B_member_table();
                    p = o.GetModel(registerID);
                    ReTransfer retf = tf.ToUserTransfer(p.UsrCustId, mcp.cash, hua.OrderID.ToString(), hua.ActID.ToString(), "/Thirdparty/ToUserTransfer");
                    if (retf != null)
                    {
                        if (retf.RespCode == "000")
                        {
                            //3.事务处理操作账户及插入流水
                            #region 验签缓存处理
                            string cachename = retf.OrdId + "ToUserTransfer" + retf.InCustId;
                            if (Utils.GeTThirdCache(cachename) == 0)
                            {
                                Utils.SetThirdCache(cachename);
                                B_usercenter BUC = new B_usercenter();
                                BUC.UpateActToUserTransfer(retf, 0);

                                //增加账户资金流水
                                hx_Capital_account_water Caw = new hx_Capital_account_water();

                                Caw.membertable_registerid = registerID;
                                Caw.income             = mcp.cash;
                                Caw.expenditure        = 0;
                                Caw.time_of_occurrence = dte;
                                Caw.account_balance    = p.available_balance + mcp.cash;
                                Caw.types_Finance      = 43;
                                Caw.createtime         = dte;
                                Caw.keyid   = 0;
                                Caw.remarks = "现金奖励";
                                ef.hx_Capital_account_water.Add(Caw);
                                ef.SaveChanges();
                            }
                            #endregion
                        }
                    }
                }
            }
        }
예제 #29
0
        public string LoginIN(string username, string userpassword, string Validatecode, int remember, bool realMobileUser = false)
        {
            string         ip          = Utils.GetRealIP();
            string         json        = "";
            B_member_table o           = new B_member_table();
            string         strIdentify = "LoginValidateCode"; //随机字串存储键值,以便存储到Session中

            var ts = true;

            if (Settings.Instance.SiteDomain.IndexOf(PublicURL.NewPCUrl) >= 0)
            {
                ts = false;
            }


            if (realMobileUser || Session[strIdentify] != null)
            {
                if (realMobileUser && ts == false)
                {
                    if (Session[strIdentify].ToString() != Validatecode)
                    {
                        json = @" {""rs""    : ""n"", ""error""      :  ""验证码不对!""}";
                        return(json);
                    }
                }
                if (realMobileUser || Session[strIdentify].ToString() == Validatecode)
                {
                    int userid = o.CheckLogin(username, userpassword);

                    if (userid > 0)
                    {
                        M_login mlogin = new M_login();
                        mlogin.userid   = userid;
                        mlogin.username = username;
                        mlogin.codeno   = Utils.SetSessioncode();
                        Utils.AddLoginCache(username, mlogin);

                        string sql = "update hx_member_table set lastlogintime='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',lastloginIP='" + Utils.GetRealIP() + "' where registerid=" + userid.ToString();

                        LogInfo.WriteLog("登录信息更新" + sql);
                        DbHelperSQL.ExecuteSql(sql);

                        #region 登录成功
                        try
                        {
                            hx_td_usrlogininfo usrmode = new hx_td_usrlogininfo();
                            usrmode.logintime    = DateTime.Now;
                            usrmode.Loginusrname = username;
                            usrmode.loginusrpass = "******";
                            usrmode.registerid   = userid;
                            usrmode.loginIP      = ip;
                            usrmode.logincity    = GetIpToCity.GetAddressByIp(ip);
                            usrmode.loginsource  = 1;
                            usrmode.loginstate   = 0;
                            ef.hx_td_usrlogininfo.Add(usrmode);
                            int ie = ef.SaveChanges();

                            //登录发送1580奖励(活动时间:2017.1.9-1.24)
                            using (ChuanglitouP2P.BLL.EF.ActFacade actFacade = new ChuanglitouP2P.BLL.EF.ActFacade())
                            {
                                actFacade.LoginSendDKQ(userid);
                            }
                        }
                        catch (Exception tx)
                        {
                            throw (tx);
                        }
                        #endregion
                        var jmpUrl = DNTRequest.GetString("jmpUrl");
                        if (!string.IsNullOrEmpty(jmpUrl))
                        {
                            return(Newtonsoft.Json.JsonConvert.SerializeObject(new { rs = "y", url = jmpUrl }));
                        }

                        return(Newtonsoft.Json.JsonConvert.SerializeObject(new { rs = "y", url = "/" }));
                    }
                    else if (userid == -100)
                    {
                        #region 登录失败
                        try
                        {
                            hx_td_usrlogininfo usrmode = new hx_td_usrlogininfo();
                            usrmode.logintime    = DateTime.Now;
                            usrmode.Loginusrname = username;
                            usrmode.loginusrpass = "******";
                            usrmode.registerid   = userid;
                            usrmode.loginIP      = ip;
                            usrmode.logincity    = GetIpToCity.GetAddressByIp(ip);
                            usrmode.loginsource  = 1;
                            usrmode.loginstate   = 2;
                            ef.hx_td_usrlogininfo.Add(usrmode);
                            int ie = ef.SaveChanges();
                        }
                        catch { }
                        #endregion


                        return(Newtonsoft.Json.JsonConvert.SerializeObject(new { rs = "n", error = "禁止登录!" }));
                    }
                    else
                    {
                        #region 登录失败
                        try
                        {
                            hx_td_usrlogininfo usrmode = new hx_td_usrlogininfo();
                            usrmode.logintime    = DateTime.Now;
                            usrmode.Loginusrname = username;
                            usrmode.loginusrpass = "******";
                            usrmode.registerid   = userid;
                            usrmode.loginIP      = ip;
                            usrmode.logincity    = GetIpToCity.GetAddressByIp(ip);
                            usrmode.loginsource  = 1;
                            usrmode.loginstate   = 1;
                            ef.hx_td_usrlogininfo.Add(usrmode);
                            int ie = ef.SaveChanges();
                        }
                        catch { }
                        #endregion



                        return(Newtonsoft.Json.JsonConvert.SerializeObject(new { rs = "n", error = "用户名或密码错误!" }));
                    }
                }

                return(Newtonsoft.Json.JsonConvert.SerializeObject(new { rs = "n", error = "验证码不对!" }));
            }

            return(Newtonsoft.Json.JsonConvert.SerializeObject(new { rs = "n", error = "验证码过期!" }));
        }
예제 #30
0
        public string loginIn(string username, string userpassword, string Validatecode, int remember, bool realMobileUser = false)
        {
            string         json        = string.Empty;
            B_member_table o           = new B_member_table();
            string         strIdentify = "LoginValidateCode"; //随机字串存储键值,以便存储到Session中
            string         ip          = Utils.GetRealIP();

            if (realMobileUser || Session[strIdentify] != null)
            {
                if (!realMobileUser)
                {
                    var ts = true;
                    if (Settings.Instance.SiteDomain.IndexOf(PublicURL.NewPCUrl) >= 0)
                    {
                        ts = false;
                    }
                    if (ts == false)
                    {
                        if (Session[strIdentify].ToString() != Validatecode)
                        {
                            json = @" {""rs""    : ""n"", ""error""      :  ""验证码过期!""}";
                            return(json);
                        }
                    }
                }

                int userid = 0;
                // int userid = o.CheckLogin(username, userpassword);
                M_member_table mtb = o.CheckUsrLogin(username);
                if (mtb == null)
                {
                    json = @" {""rs""    : ""n"", ""error""      :  ""该手机号未注册用户!""}";
                    return(json);
                }

                if (mtb.password != userpassword)
                {
                    #region 登录失败
                    try
                    {
                        hx_td_usrlogininfo usrmode = new hx_td_usrlogininfo();
                        usrmode.logintime    = DateTime.Now;
                        usrmode.Loginusrname = mtb.username;
                        usrmode.loginusrpass = "******";
                        usrmode.registerid   = mtb.registerid;
                        usrmode.loginIP      = ip;
                        usrmode.logincity    = GetIpToCity.GetAddressByIp(ip);
                        usrmode.loginsource  = 0;
                        usrmode.loginstate   = 1;
                        ef.hx_td_usrlogininfo.Add(usrmode);
                        int ie = ef.SaveChanges();
                    }
                    catch { }
                    #endregion

                    json = @" {""rs""    : ""n"", ""error""      :  ""用户名或密码错误!""}";
                    return(json);
                }

                userid = mtb.registerid;


                if (userid > 0)
                {
                    M_login mlogin = new M_login();
                    mlogin.userid   = userid;
                    mlogin.username = username;
                    mlogin.codeno   = Utils.SetSessioncode();
                    mlogin.UsrName  = mtb.realname;

                    if (Utils.LoginWriteSession(mlogin, remember) > 0)
                    {
                        string sql = "update hx_member_table set  LoginNum=LoginNum+1,lastlogintime='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',lastloginIP='" + ip + "' where registerid=" + userid.ToString();

                        LogInfo.WriteLog("登录信息更新" + sql);


                        DbHelperSQL.ExecuteSql(sql);

                        #region 登录成功
                        try
                        {
                            hx_td_usrlogininfo usrmode = new hx_td_usrlogininfo();
                            usrmode.logintime    = DateTime.Now;
                            usrmode.Loginusrname = mtb.username;
                            usrmode.loginusrpass = "******";
                            usrmode.registerid   = mtb.registerid;
                            usrmode.loginIP      = ip;
                            usrmode.logincity    = GetIpToCity.GetAddressByIp(ip);
                            usrmode.loginsource  = 0;
                            usrmode.loginstate   = 0;
                            ef.hx_td_usrlogininfo.Add(usrmode);
                            int ie = ef.SaveChanges();

                            //登录发送1580奖励(活动时间:2017.1.9-1.24)
                            ActFacade actFacade = new ActFacade();
                            {
                                actFacade.LoginSendDKQ(userid);
                            }
                        }
                        catch (Exception tx)
                        {
                            throw (tx);
                        }
                        #endregion

                        if (realMobileUser)
                        {
                            json = @"{""rs""    : ""y"", ""url""      :  ""/""}";
                            return(json);
                        }

                        if (Session["returnpage"] != null)
                        {
                            json = @"{""rs""    : ""y"", ""url""      :  ""/""}";
                            json = json.Replace("/", Session["returnpage"].ToString());
                            Session["returnpage"] = null;
                        }
                        else
                        {
                            json = @" {""rs""    : ""y"", ""url""      :  ""/""}";
                        }
                        return(json);
                    }
                }
                else if (userid == -100)
                {
                    #region 登录失败
                    try
                    {
                        hx_td_usrlogininfo usrmode = new hx_td_usrlogininfo();
                        usrmode.logintime    = DateTime.Now;
                        usrmode.Loginusrname = mtb.username;
                        usrmode.loginusrpass = "******";
                        usrmode.registerid   = mtb.registerid;
                        usrmode.loginIP      = ip;
                        usrmode.logincity    = GetIpToCity.GetAddressByIp(ip);
                        usrmode.loginsource  = 1;
                        usrmode.loginstate   = 2;
                        ef.hx_td_usrlogininfo.Add(usrmode);
                        int ie = ef.SaveChanges();
                    }
                    catch { }
                    #endregion

                    json = @" {""rs""    : ""n"", ""error""      :  ""禁止登录!""}";
                    return(json);
                }
                else
                {
                    #region 登录失败
                    try
                    {
                        hx_td_usrlogininfo usrmode = new hx_td_usrlogininfo();
                        usrmode.logintime    = DateTime.Now;
                        usrmode.Loginusrname = mtb.username;
                        usrmode.loginusrpass = "******";
                        usrmode.registerid   = mtb.registerid;
                        usrmode.loginIP      = ip;
                        usrmode.logincity    = GetIpToCity.GetAddressByIp(ip);
                        usrmode.loginsource  = 0;
                        usrmode.loginstate   = 1;
                        ef.hx_td_usrlogininfo.Add(usrmode);
                        int ie = ef.SaveChanges();
                    }
                    catch { }
                    #endregion

                    json = @" {""rs""    : ""n"", ""error""      :  ""用户名或密码错误!""}";
                    return(json);
                }
            }
            else
            {
                json = @" {""rs""    : ""y"", ""error""      :  ""验证码过期!""}";
            }
            return(json);
        }