Пример #1
0
        /// <summary>
        /// 使用非芮卡家园APP扫码后打开该页下载APP
        /// </summary>
        ///<param name="typestr">1</param>
        /// <param name="codestr">二维码字符串</param>
        /// <returns></returns>
        public ActionResult App(string typestr, string codestr)
        {
            string showMsg   = ""; //提示信息
            int    typeId    = 0;  //类型;1学一学课件注册
            bool   typeIsInt = int.TryParse(typestr, out typeId);

            //-----------------------
            if (typeId == 1)
            {
                #region 判断并开通学一学电子书
                using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities())//数据库操作
                {
                    Sys_BookStudy_QRCode mySys_BookStudy_QRCode = new Sys_BookStudy_QRCode();
                    mySys_BookStudy_QRCode = myOperating.Sys_BookStudy_QRCode.FirstOrDefault(p => p.QRCode == codestr);
                    if (mySys_BookStudy_QRCode != null)
                    {
                        long myBookId = mySys_BookStudy_QRCode.BookStudyID;
                        if (mySys_BookStudy_QRCode.Used)
                        {//注册码已经使用过
                            showMsg = "该二维码已经使用过,不能再次使用,请核对准确。";
                        }
                        else
                        {
                            #region 要开通那本图书
                            Child_Book_Study myChild_Book_Study = new Child_Book_Study();
                            myChild_Book_Study = myOperating.Child_Book_Study.FirstOrDefault(p => p.BookID == myBookId);
                            if (myChild_Book_Study != null)
                            {
                                showMsg = "要开通:《" + myChild_Book_Study.BookName + "》点读";
                                if (!String.IsNullOrWhiteSpace(myChild_Book_Study.BookImage))
                                {
                                    ViewBag.CoverImage = StaticVarClass.BookStudyResourceUrl + myChild_Book_Study.BookImage;
                                }
                            }
                            else
                            {
                                showMsg = "该电子书不存在,请核实您的二维码。";
                            }
                            #endregion
                        }
                    }
                    else
                    {
                        showMsg = "该编码不存在,请核实您的二维码。";
                    }
                }
                #endregion
            }
            else
            {
                showMsg = "二维码错误。";
            }
            ViewBag.Message = showMsg;
            //========================
            return(View());
        }
Пример #2
0
        public JsonResult Scan(string codestr)
        {
            StatusData myStatusData = new StatusData();//返回状态

            //
            #region 检查授权
            string           myMobilePhone      = "";//手机号码
            AuthCodeInstance myAuthCodeInstance = new AuthCodeInstance();
            AuthCodeClass    myAuthCodeClass    = new AuthCodeClass();
            bool             checkAuthCodeBool  = myAuthCodeClass.checkAuthCode(out myAuthCodeInstance);
            #endregion
            //
            int    myTypeInt   = 0;  //类型;0注册开通课件;1学一学电子书注册
            string myCodeStr   = ""; //二维码
            string tempCodeStr = ""; //临时
            #region 解析二维码字符串
            if (!String.IsNullOrWhiteSpace(codestr))
            {
                tempCodeStr = codestr.ToUpper().Replace(StaticVarClass.QRCodeUrl.ToUpper(), "");
                tempCodeStr = tempCodeStr.Replace("\\", "/");
                string[] temCode = tempCodeStr.Split('/');
                if (temCode.Length > 1)
                {
                    bool isInt = int.TryParse(temCode[0], out myTypeInt);
                    if (isInt)
                    {
                        myCodeStr = temCode[1];//
                    }
                    else
                    {
                        if (myTypeInt < 1)
                        {
                            myStatusData.operateStatus = 400;
                            myStatusData.operateMsg    = "类型错误:" + codestr;
                            return(Json(myStatusData));
                        }
                    }
                }
                else
                {
                    myTypeInt = 0;
                    myCodeStr = codestr;
                }
            }
            else
            {
                myStatusData.operateStatus = 400;
                return(Json(myStatusData));
            }
            #endregion
            //
            if (checkAuthCodeBool)
            {
                myMobilePhone = myAuthCodeInstance.mobilePhone;
                //
                switch (myTypeInt)
                {
                case 0:
                    break;

                case 1:
                    #region 判断并开通学一学电子书
                    using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities())    //数据库操作
                    {
                        Sys_BookStudy_QRCode mySys_BookStudy_QRCode = new Sys_BookStudy_QRCode();
                        mySys_BookStudy_QRCode = myOperating.Sys_BookStudy_QRCode.FirstOrDefault(p => p.QRCode == myCodeStr);
                        if (mySys_BookStudy_QRCode != null)
                        {
                            if (mySys_BookStudy_QRCode.Used)
                            {    //注册码已经使用过
                                myStatusData.operateStatus = 500;
                            }
                            else
                            {
                                #region 判断是否已经开通该课程,否则开通
                                int TheBookIsReg = myOperating.User_RegBook_List.Count(p => p.MobilePhone == myMobilePhone && p.BookStudyID == mySys_BookStudy_QRCode.BookStudyID);
                                if (TheBookIsReg == 0)
                                {    //判断该用户是否已经开通该课件
                                    #region 注册开通
                                    User_RegBook_List newUser_RegBook_List = new User_RegBook_List();
                                    int isReg = myOperating.User_RegBook_List.Count(p => p.QRCode == myCodeStr);
                                    if (isReg == 0)
                                    {
                                        newUser_RegBook_List.QRCode      = myCodeStr;
                                        newUser_RegBook_List.MobilePhone = myMobilePhone;
                                        newUser_RegBook_List.BookStudyID = mySys_BookStudy_QRCode.BookStudyID;
                                        newUser_RegBook_List.RegDate     = DateTime.Now;
                                        myOperating.User_RegBook_List.Add(newUser_RegBook_List);
                                        //
                                        mySys_BookStudy_QRCode.MobilePhone = myMobilePhone;
                                        mySys_BookStudy_QRCode.Used        = true;
                                        mySys_BookStudy_QRCode.UsedDate    = DateTime.Now;
                                        //
                                        myOperating.SaveChanges();
                                        myStatusData.operateStatus = 200;
                                    }
                                    else
                                    {
                                        myStatusData.operateStatus = 500;
                                    }
                                    #endregion
                                }
                                else
                                {
                                    myStatusData.operateStatus = 400;
                                    myStatusData.operateMsg    = "已经开通,无需重新开通";
                                }
                                #endregion
                            }
                        }
                        else
                        {
                            myStatusData.operateStatus = 400;
                            myStatusData.operateMsg    = "不存在";
                        }
                    }
                    #endregion
                    break;
                }
                //
            }
            else
            {
                myStatusData.operateStatus = 5;
            }
            return(Json(myStatusData));
        }
Пример #3
0
        public ActionResult ItemList(int currentpage = 1, string del = "", long bookid = 0, int searchBatchNum = 0)
        {
            ViewBag.BookID = 0;//要生成那本书的二维码
            //
            #region 翻页定义
            ViewBag.CurrentPage = 0;  //当前页
            ViewBag.PPage       = 0;  //上一页
            ViewBag.NPage       = 0;  //下一页
            ViewBag.PageCount   = 0;  //总页数
            ViewBag.RecordCount = 0;  //记录总数
            ViewBag.IsFirstPage = ""; //第一条记录,禁用首页和上一页
            ViewBag.IsEndPage   = ""; //最后条记录,禁用首页和下一页
            #endregion
            //
            ViewBag.Headline = "二维码管理";//栏目主题
            //
            ViewBag.DataList   = null;
            ViewBag.RecordItem = null;
            //
            StatusData myStatusData = new StatusData();                           //返回状态
            //
            using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities()) //数据库操作
            {
                #region  除
                if (!String.IsNullOrWhiteSpace(del))
                {
                    Sys_BookStudy_QRCode myDelRecord = myOperating.Sys_BookStudy_QRCode.FirstOrDefault(p => p.QRCode == del);
                    if (myDelRecord != null)
                    {
                        myOperating.Sys_BookStudy_QRCode.Remove(myDelRecord);
                        myOperating.SaveChanges();
                    }
                }
                #endregion
                //
                #region 翻页属性
                int    recordCount  = 0;
                int    pageCount    = 0;
                string orderbyfiled = "AddDate";
                //
                //当前页
                int sqlCurrentpage = currentpage;
                if (sqlCurrentpage < 1)
                {
                    sqlCurrentpage = 1;
                }
                //页大小
                int sqlPagesize = 10;
                #endregion
                //
                #region 取出内容
                IQueryable <Sys_BookStudy_QRCode> myIQueryable = null;
                if (bookid > 0)
                {
                    if (searchBatchNum > 0)
                    {
                        ViewBag.BatchNum = searchBatchNum;
                        myIQueryable     = myOperating.Sys_BookStudy_QRCode.Where(p => p.BookStudyID == bookid && p.BatchNum == searchBatchNum);
                    }
                    else
                    {
                        myIQueryable = myOperating.Sys_BookStudy_QRCode.Where(p => p.BookStudyID == bookid);
                    }
                }
                else
                {
                    if (searchBatchNum > 0)
                    {
                        ViewBag.BatchNum = searchBatchNum;
                        myIQueryable     = myOperating.Sys_BookStudy_QRCode.Where(p => p.BatchNum == searchBatchNum);
                    }
                    else
                    {
                        myIQueryable = myOperating.Sys_BookStudy_QRCode;
                    }
                }

                //
                if (myIQueryable != null)
                {
                    List <Sys_BookStudy_QRCode> BookTable = QueryableExtensions.OrderBy(myIQueryable, orderbyfiled, out recordCount, out pageCount, ref sqlCurrentpage, sqlPagesize, true).ToList();
                    //
                    ViewBag.DataList = BookTable;
                    #region 页数取值
                    ViewBag.CurrentPage = sqlCurrentpage;
                    ViewBag.PageCount   = pageCount;
                    ViewBag.RecordCount = recordCount;
                    if (sqlCurrentpage > 1)
                    {
                        ViewBag.PPage = sqlCurrentpage - 1;
                    }
                    else
                    {
                        ViewBag.IsFirstPage = "disabled";
                        ViewBag.PPage       = 1;
                    }
                    if (sqlCurrentpage < pageCount)
                    {
                        ViewBag.NPage = sqlCurrentpage + 1;
                    }
                    else
                    {
                        ViewBag.NPage     = sqlCurrentpage;
                        ViewBag.IsEndPage = "disabled";
                    }
                    #endregion
                }
                #endregion
                //
                if (bookid > 0)
                {
                    #region 要开通那本图书
                    Child_Book_Study myChild_Book_Study = new Child_Book_Study();
                    myChild_Book_Study = myOperating.Child_Book_Study.FirstOrDefault(p => p.BookID == bookid);
                    if (myChild_Book_Study != null)
                    {
                        ViewBag.BookName = myChild_Book_Study.BookName;
                        ViewBag.BookID   = myChild_Book_Study.BookID;
                    }
                    #endregion
                }
            }
            return(View());
        }