Esempio n. 1
0
        public IActionResult OnPostGetCourseByDate(string date)
        {
            ResultList <RUserCourseLog> result = new ResultList <RUserCourseLog>();
            var us = base.GetUserSession(false);

            try
            {
                date = DateTime.Parse(date).ToString("yyyy-MM-dd");

                if (us != null)
                {
                    result.List = _UserSrv.GetUserCourseByDate(us.OpenId, date, us.CurrentScheduleType);
                }
                else
                {
                    result.IntMsg   = -1;
                    result.ErrorMsg = "请重新登陆!";
                }
            }
            catch (Exception ex)
            {
                result.ErrorMsg = "数据获取失败,请联系工作人员";
                if (us != null)
                {
                    NLogHelper.ErrorTxt($"用户请假OpenId:{us.OpenId}");
                }
                NLogHelper.ErrorTxt($"MyLeaveModel[OnPostGetCourseByDate]:{ex.Message}");
            }
            return(new JsonResult(result));
        }
Esempio n. 2
0
        /**
         *
         * 通过code换取网页授权access_token和openid的返回数据,正确时返回的JSON数据包如下:
         * {
         *  "access_token":"ACCESS_TOKEN",
         *  "expires_in":7200,
         *  "refresh_token":"REFRESH_TOKEN",
         *  "openid":"OPENID",
         *  "scope":"SCOPE",
         *  "unionid": "o6_bmasdasdsad6_2sgVt7hMZOPfL"
         * }
         * 其中access_token可用于获取共享收货地址
         * openid是微信支付jsapi支付接口统一下单时必须的参数
         * 更详细的说明请参考网页授权获取用户基本信息:http://mp.weixin.qq.com/wiki/17/c0f37d5704f0b64713d5d2c37b468d75.html
         * @失败时抛异常WxPayException
         */
        public void GetOpenidAndAccessTokenFromCode(string code)
        {
            try
            {
                //构造获取openid及access_token的url
                WxPayData data = new WxPayData();
                data.SetValue("appid", WxPayConfig.APPID);
                data.SetValue("secret", WxPayConfig.APPSECRET);
                data.SetValue("code", code);
                data.SetValue("grant_type", "authorization_code");
                string url = "https://api.weixin.qq.com/sns/oauth2/access_token?" + data.ToUrl();

                //请求url以获取数据
                string result = HttpService.Get(url);

                //保存access_token,用于收货地址获取
                JsonData jd = JsonMapper.ToObject(result);
                access_token = (string)jd["access_token"];

                //获取用户openid
                openid = (string)jd["openid"];
            }
            catch (Exception ex)
            {
                NLogHelper.ErrorTxt("GetOpenidAndAccessTokenFromCode:" + ex.Message);
                throw new WxPayException(ex.ToString());
            }
        }
Esempio n. 3
0
        public static AccessToken GetOAuth2AccessTokenFromCode(string code)
        {
            try
            {
                //构造获取openid及access_token的url
                WxPayData data = new WxPayData();
                data.SetValue("appid", WxConfig.APPID);
                data.SetValue("secret", WxConfig.APPSECRET);

                //data.SetValue("appid", EduConfig.WXAppId);
                //data.SetValue("secret", EduConfig.WXSecret);

                data.SetValue("code", code);
                data.SetValue("grant_type", "authorization_code");
                string url = "https://api.weixin.qq.com/sns/oauth2/access_token?" + data.ToUrl();

                AccessToken token = HttpHelper.Get <AccessToken>(url);

                return(token);
            }
            catch (Exception ex)
            {
                NLogHelper.ErrorTxt("GetOAuth2AccessTokenFromCode:" + ex.Message);
                throw new WxPayException(ex.ToString());
            }
        }
Esempio n. 4
0
        public IActionResult OnPostQueryList(int pageIndex, int pageSize)
        {
            ResultList <RUserCourseLog> result = new ResultList <RUserCourseLog>();

            try
            {
                var us = base.GetUserSession(false);
                if (us != null)
                {
                    int totalPages;

                    result.List      = _UserSrv.GetUserCourseLogList(us.OpenId, UserCourseLogStatus.SignIn, out totalPages, pageIndex, pageSize);
                    result.TotlaPage = totalPages;
                }
                else
                {
                    result.IntMsg   = -1;
                    result.ErrorMsg = "需要您重新登录!";
                }
            }
            catch (Exception ex)
            {
                result.ErrorMsg = "获取数据失败!";
                NLogHelper.ErrorTxt($"签到列表[OnPostQueryList]:{ex.Message}");
            }
            return(new JsonResult(result));
        }
Esempio n. 5
0
        /// <summary>
        /// 邀请码进入
        /// </summary>
        private void InviteQRHandler()
        {
            try
            {
                //教师邀请
                if (_EventKey.StartsWith(WxConfig.QR_Invite_TecPre))
                {
                    var wxUser = WXApi.GetWXUserInfo(_wxMessage.FromUserName);
                    var user   = _UserSrv.AddOrUpdateFromWXUser(wxUser);
                    _TecSrv.NewTecFromUser(user);
                    _ResultMsg = _wxMessage.toText(WXReplyContent.NewTec(user.Name));
                }
                else if (_EventKey.StartsWith(WxConfig.QR_Invite_User))
                {
                    var ownOpenId = _EventKey.Split("_")[2];

                    var user = _BusinessSrv.InvitedUserComing(_wxMessage.FromUserName, ownOpenId);

                    _ResultMsg = _wxMessage.toText(WXReplyContent.NewUserAdd(user.Name));
                }
            }
            catch (Exception ex)
            {
                NLogHelper.ErrorTxt($"[InviteQRHandler]-FromUserName:{_wxMessage.FromUserName}| 信息:{ex.Message}");
            }
        }
        public IActionResult OnPostQRGen(double payAmount, int courseTime = 0)
        {
            ResultNormal result = new ResultNormal();

            try
            {
                var           url      = $"{Request.Scheme}://{Request.Host}/WX/PayQRMoney?amt={payAmount}&ct={courseTime}";
                var           fileName = $"{payAmount}_{DateTime.Now.ToString("yyyyMMdd_hhmmss")}.png";
                var           savePath = EduEnviroment.DicPath_QRPay + fileName;
                List <string> desc     = new List <string>();
                desc.Add($"请用户扫码付款,支付金额【{payAmount}】元");
                if (courseTime > 0)
                {
                    desc.Add($"共计: 【{courseTime}】节课时");
                }
                QRHelper.GenQR(url, savePath, desc);
                result.SuccessMsg = EduEnviroment.VirPath_QRPay + fileName;
            }
            catch (Exception ex)
            {
                result.ErrorMsg = "生成失败:" + ex.Message;
                NLogHelper.ErrorTxt($"二维码生成失败:{ex.Message}");
            }
            return(new JsonResult(result));
        }
Esempio n. 7
0
        public static EQRStoreAuth CreateStoreAuthUrlById(EQRStoreAuth qr)
        {
            try
            {
                string site = ConfigurationManager.AppSettings["Main_SiteUrl"];
                string url  = site + "Wap/Auth_Store?Id=" + qr.ID;

                string filePath = ConfigurationManager.AppSettings["QR_AuthStore_FP"];
                string filename = "QRAS" + System.DateTime.Now.ToString("yyyyMMddHHmmss") + (new Random()).Next(1, 100).ToString()
                                  + ".jpg";

                filePath    += filename;
                qr.FilePath  = filePath;
                qr.TargetUrl = url;

                //Create QR
                // filePath = PageController.Server.MapPath(filePath);
                filePath = System.Web.HttpContext.Current.Server.MapPath(filePath);
                QRManager.CreateQR(url, filePath, null);
            }
            catch (Exception ex)
            {
                NLogHelper.ErrorTxt(ex.Message);
                throw ex;
            }
            return(qr);
        }
Esempio n. 8
0
        public IActionResult OnPostInitPage()
        {
            ResultList <RUserSign> result = new ResultList <RUserSign>();

            try
            {
                var us = base.GetUserSession(false);
                if (us != null)
                {
                    if (us.UserRole == UserRole.Visitor)
                    {
                        result.ErrorMsg = "您还没有购买课程,请先去购买吧";
                        result.IntMsg   = -2;
                        return(new JsonResult(result));
                    }
                    result.List = _UserSrv.GetCurrentUserSign(us.OpenId, us.CurrentScheduleType);
                }
                else
                {
                    result.IntMsg   = -1;
                    result.ErrorMsg = "请重新登陆!";
                }
            }
            catch (EduException eex)
            {
                result.ErrorMsg = eex.Message;
            }
            catch (Exception ex)
            {
                result.ErrorMsg = "页面加载失败,请联系工作人员";
                NLogHelper.ErrorTxt($"签到页面[OnPostInitPage]:{ex.Message}");
            }
            return(new JsonResult(result));
        }
        public IActionResult OnPostBuyCourse(string priceCode)
        {
            ResultObject <ECoursePrice> result = new ResultObject <ECoursePrice>();

            try
            {
                var us = GetUserSession(false);
                if (us != null)
                {
                    if (string.IsNullOrEmpty(us.Phone))
                    {
                        result.IntMsg   = -2;
                        result.ErrorMsg = "请先绑定您的手机号";
                        return(new JsonResult(result));
                    }
                    ECoursePrice eCoursePrice = _CourseSrv.GetCoursePrice(priceCode);
                    result.Entity = eCoursePrice;
                }
                else
                {
                    result.IntMsg   = -1;
                    result.ErrorMsg = "请先重新登录";
                }
            }
            catch (EduException eex)
            {
                result.ErrorMsg = eex.Message;
            }
            catch (Exception ex)
            {
                result.ErrorMsg = "购买失败,请联系客服!";
                NLogHelper.ErrorTxt($"购买课时[OnPostBuyCourse]:{ex.Message}");
            }
            return(new JsonResult(result));
        }
        public IActionResult OnPostCheckUserAccount()
        {
            ResultObject <EUserAccount> result = new ResultObject <EUserAccount>();

            try
            {
                var us = base.GetUserSession(false);
                if (us != null)
                {
                    var userAccount = _UserSrv.GetUserAccount(us.OpenId);
                    if (string.IsNullOrEmpty(userAccount.AliPayAccount))
                    {
                        result.IntMsg   = -2;
                        result.ErrorMsg = "请设置转账支付宝账户";
                    }
                    else
                    {
                        result.Entity = userAccount;
                    }
                }
                else
                {
                    result.IntMsg   = -1;
                    result.ErrorMsg = "需要您重新登录!";
                }
            }
            catch (Exception ex)
            {
                result.ErrorMsg = "没有获取数据";
                NLogHelper.ErrorTxt(ex.Message);
            }
            return(new JsonResult(result));
        }
Esempio n. 11
0
        public IActionResult OnPostQueryTecDayCourse(string date)
        {
            ResultList <RTecCourse> result = new ResultList <RTecCourse>();

            try
            {
                var us = GetUserSession(false);
                if (us != null)
                {
                    NLogHelper.InfoTxt($"QueryTecDayCourse TecCode:{us.TecCode}");
                    result.List = _TecSrv.GetOneDayCourse(us.TecCode, date);
                }
                else
                {
                    result.IntMsg   = -1;
                    result.ErrorMsg = "请重新登陆";
                }
            }
            catch (Exception ex)
            {
                result.ErrorMsg = "未能获取数据!请联系管理员或稍后再试";
                NLogHelper.ErrorTxt(ex.Message);
            }
            return(new JsonResult(result));
        }
Esempio n. 12
0
        public IActionResult OnPostSave(List <EUserChild> list)
        {
            ResultNormal result = new ResultNormal();

            try
            {
                var us = GetUserSession(false);
                if (us != null)
                {
                    foreach (var c in list)
                    {
                        c.UserOpenId = us.OpenId;
                    }
                    _UserSrv.SaveChildList(list);
                }
                else
                {
                    result.IntMsg   = -1;
                    result.ErrorMsg = "超时,请重新登陆!";
                }
            }
            catch (Exception ex)
            {
                result.ErrorMsg = "保存数据错误!请联系管理员或稍后再试";
                NLogHelper.ErrorTxt(ex.Message);
            }
            return(new JsonResult(result));
        }
Esempio n. 13
0
        public void SetUserDeviceToken(string DeviceToken, string IDFV, DeviceChannel DeviceChannel, string appName = "YJOO")
        {
            try
            {
                if (!string.IsNullOrEmpty(DeviceToken) && !string.IsNullOrEmpty(IDFV))
                {
                    using (OOContent db = new OOContent())
                    {
                        EUserDevice userDevice = db.DBUserDevice.Where(a => a.IDFV == IDFV).FirstOrDefault();
                        if (userDevice == null)
                        {
                            userDevice = new EUserDevice();
                            userDevice.CreateDateTime = DateTime.Now;
                            db.DBUserDevice.Add(userDevice);
                        }


                        userDevice.DeviceToken = DeviceToken;
                        userDevice.IDFV        = IDFV;

                        userDevice.DeviceChannel     = DeviceChannel;
                        userDevice.AppName           = appName;
                        userDevice.LastLoginDateTime = DateTime.Now;
                        userDevice.LoginCount++;

                        db.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                NLogHelper.ErrorTxt("GetUserDeviceToken Error:" + ex.Message);
            }
        }
Esempio n. 14
0
        public IActionResult OnPostCourseLeave(List <EUserCourseLog> list)
        {
            ResultNormal result = new ResultNormal();
            var          us     = base.GetUserSession(false);

            try
            {
                if (us != null)
                {
                    _UserSrv.UpdateCourseLogToLeave(list, us.OpenId);


                    //wx通知
                    var time = StaticDataSrv.CourseTime;
                    UserLeaveTemplate wxMessage = new UserLeaveTemplate();
                    foreach (var c in list)
                    {
                        var ui   = _UserSrv.GetUserInfo(us.OpenId);
                        var cs   = _CourseSrv.GetCourseSchedule(c.LessonCode);
                        var desc = $"{cs.CourseName} | [{time[cs.Lesson].TimeRange}]";

                        var tec = _TecSrv.GetOpenIdByLessonCode(c.LessonCode, c.CourseDateTime);

                        if (!string.IsNullOrEmpty(ui.SalesOpenId))
                        {
                            wxMessage.data = wxMessage.GenerateData(ui.SalesOpenId, ui.ChildName, DateTime.Parse(c.CourseDateTime), desc);
                            WXApi.SendTemplateMessage <UserLeaveTemplate>(wxMessage);
                        }
                        if (tec != null)
                        {
                            wxMessage.data = wxMessage.GenerateData(tec.UserOpenId, ui.ChildName, DateTime.Parse(c.CourseDateTime), desc, true);
                            WXApi.SendTemplateMessage <UserLeaveTemplate>(wxMessage);
                        }
                    }
                }
                else
                {
                    result.IntMsg   = -1;
                    result.ErrorMsg = "请重新登陆!";
                }
            }
            catch (EduException eex)
            {
                result.ErrorMsg = eex.Message;
            }
            catch (Exception ex)
            {
                result.ErrorMsg = "请假失败,请联系工作人员";
                if (us != null)
                {
                    NLogHelper.ErrorTxt($"用户请假OpenId:{us.OpenId}");
                }
                NLogHelper.ErrorTxt($"MyLeaveModel[OnPostCourseLeave]:{ex.Message}");
            }
            return(new JsonResult(result));
        }
Esempio n. 15
0
        //晚上跑Job修复用户上课
        public void RunJob_FixUserCourse()
        {
            //Job第二天凌晨运行,所以-1;
            var signDate = DateTime.Now.AddDays(-1);
            //     signDate = DateTime.Parse("2019-07-27");

            UserSrv     userSrv     = new UserSrv(_dbContext);
            BusinessSrv businessSrv = new BusinessSrv(_dbContext);

            var day = DateSrv.GetDayOfWeek(signDate);


            var sql = from uc in _dbContext.DBUserCoures
                      join cs in _dbContext.DbCourseSchedule on uc.LessonCode equals cs.LessonCode
                      join ui in _dbContext.DBUserInfo on uc.UserOpenId equals ui.OpenId
                      where cs.Day == day
                      orderby uc.UserOpenId
                      select new FixUserCourse
            {
                UserOpenId = uc.UserOpenId,
                LessonCode = uc.LessonCode,
                MemberType = ui.MemberType,
                UserName   = ui.Name
            };

            var userCourseList = sql.ToList();

            foreach (var uc in userCourseList)
            {
                if (!userSrv.IsSkipTodayUserCourse(uc.UserOpenId))
                {
                    try
                    {
                        uc.CurrentCourseSchedule = userSrv.GetCurrentCourseScheduleType(uc.UserOpenId, uc.MemberType);

                        var log = businessSrv.UpdateCourseLogToSigned(uc.UserOpenId, uc.MemberType,
                                                                      uc.CurrentCourseSchedule,
                                                                      uc.LessonCode,
                                                                      signDate,
                                                                      "",
                                                                      false,
                                                                      false);
                        log.SignName          = "系统签到";
                        log.IsFixedByAuto     = true;
                        log.AutoFixedDatetime = DateTime.Now;
                        NLogHelper.InfoTxt($"修复用户:{uc.UserName}[OpenId]{uc.UserOpenId},课程:{log.LessonCode}");
                        _dbContext.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                        NLogHelper.ErrorTxt($"Error OpenId:{uc.UserOpenId};");
                    }
                }
            }
        }
Esempio n. 16
0
        public IActionResult OnPostSubmitTrial(string courseCode, int Lesson, string date)
        {
            ResultNormal result = new ResultNormal();
            var          times  = StaticDataSrv.TrialTime;

            try
            {
                var us = base.GetUserSession(false);
                if (us != null)
                {
                    var cls = _CourseSrv.GetCourseInfoClass(courseCode);

                    var errorMsg = _CourseSrv.VerifyUserTrial(us.OpenId, (int)cls.CourseType, date, Lesson);
                    if (errorMsg == EduErrorMessage.ApplyTrial_OverSingleLimit)
                    {
                        result.ErrorMsg = "同类型课不能试听超过2次";
                    }
                    else if (errorMsg == EduErrorMessage.ApplyTrial_SameTypeExist)
                    {
                        result.ErrorMsg = "同时段已经有申请试听";
                    }
                    else
                    {
                        ETrialLog log = new ETrialLog
                        {
                            OpenId = us.OpenId,
                            //UserName = us.UserName,
                            TecCode        = cls.TecCode,
                            TecName        = cls.TecName,
                            CourseCode     = cls.CourseCode,
                            CourseName     = cls.CourseName,
                            CourseType     = (int)cls.CourseType,
                            ApplyDateTime  = DateTime.Now,
                            Lesson         = Lesson,
                            TrialDateTime  = DateTime.Parse(date),
                            TrialLogStatus = (int)TrialLogStatus.UserApply,
                        };
                        _CourseSrv.AddTrial(log);
                        _CourseSrv.SaveChanges();
                    }
                }
                else
                {
                    result.IntMsg   = -1;
                    result.ErrorMsg = "需要您重新登录!";
                }
            }
            catch (Exception ex)
            {
                result.ErrorMsg = "提交申请失败,请联系工作人员";
                NLogHelper.ErrorTxt($"ApplyTrialModel[OnPostSubmitTrial]:{ex.Message}");
            }
            return(new JsonResult(result));
        }
Esempio n. 17
0
        public IActionResult OnPostSubmit(List <string> lessonCodeList, bool useRightNow = false)
        {
            ResultNormal result = new ResultNormal();

            try
            {
                var us = base.GetUserSession(false);
                if (us != null)
                {
                    var needRecharge = UserSession.NeedRecharge(us, CourseScheduleType.Standard);
                    if (needRecharge < 0)
                    {
                        string errorMsg = $"您的余额不足,请去充值";
                        result.ErrorMsg = errorMsg;
                        result.IntMsg   = -2;
                        return(new JsonResult(result));
                    }
                    List <EUserCourse> ucList = new List <EUserCourse>();
                    foreach (var lc in lessonCodeList)
                    {
                        EUserCourse uc = new EUserCourse
                        {
                            CourseScheduleType = CourseScheduleType.Standard,
                            CreateDateTime     = DateTime.Now,
                            LessonCode         = lc,
                            UseRightNow        = useRightNow,
                            UserOpenId         = us.OpenId
                        };
                        ucList.Add(uc);
                    }
                    _BusinessSrv.UserSelectNewCourses(us.OpenId, ucList, CourseScheduleType.Standard, useRightNow);

                    //更新Session是否跳过当天
                    us.CourseSkipToday = useRightNow;

                    SetUserSesion(us);
                }
                else
                {
                    result.IntMsg   = -1;
                    result.ErrorMsg = "请重新登陆";
                }
            }
            catch (EduException ex)
            {
                result.ErrorMsg = ex.Message;
            }
            catch (Exception ex)
            {
                result.ErrorMsg = "提交数据错误!请联系管理员或稍后再试";
                NLogHelper.ErrorTxt($"标准班课程选择[OnPostSubmit]:{ex.Message}");
            }
            return(new JsonResult(result));
        }
Esempio n. 18
0
        public EUserAccount PayCourseSuccess(WXPaySuccess wXPaySuccess)
        {
            EUserAccount eUserAccount = null;

            try
            {
                string orderId = wXPaySuccess.OrderId;
                //    NLogHelper.InfoTxt($"PayCourseSuccess OrderId:{orderId}");
                BeginTrans();
                //跟新订单状态
                var order = _dbContext.DBOrder.Where(a => a.OrderId == orderId && a.OrderStatus == OrderStatus.Created).FirstOrDefault();
                if (order == null)
                {
                    throw new Exception($"没有找到状态为[{ OrderStatus.Created}]的[{orderId}]订单,");
                }
                order.OrderStatus = OrderStatus.PaySuccess;

                //获取订单行,更新课时
                var line = _dbContext.DBOrderLine.Where(a => a.OrderId == orderId).FirstOrDefault();
                eUserAccount = UpdateUserAccountByOrderLine(order.CustOpenId, line);

                var ui = _dbContext.DBUserInfo.Where(a => a.OpenId == order.CustOpenId).FirstOrDefault();
                if (ui.UserRole == UserRole.Visitor)
                {
                    ui.UserRole = UserRole.Member;
                }
                //如果是JSPay
                if (wXPaySuccess.IsJSPay)
                {
                    ui.MemberType          = MemberType.VIP;
                    eUserAccount.VIPPrice1 = Math.Round(line.Price / line.Qty, 2);
                }
                //查看用户是否有邀请人

                SalesSrv salesSrv  = new SalesSrv(_dbContext);
                var      inviteLog = salesSrv.GetInviteLogByInvitedOpenId(ui.OpenId);
                if (inviteLog != null)
                {
                    salesSrv.CreateRewardTrans(inviteLog.Id, inviteLog.OwnOpenId, AmountTransType.Invited_Paied, out eUserAccount, false);
                }

                _dbContext.SaveChanges();
                CommitTrans();
            }
            catch (Exception ex)
            {
                RollBackTrans();
                NLogHelper.ErrorTxt($"[PayCourseSuccess] {ex.Message}");
                throw ex;
            }
            return(eUserAccount);
        }
Esempio n. 19
0
        /// <summary>
        /// 页面登陆按钮点击
        /// </summary>
        /// <returns></returns>
        public IActionResult OnPostUserLogin()
        {
            ResultNormal result      = new ResultNormal();
            UserSession  userSession = null;

            try
            {
                if (!EduConfig.IsTest)
                {
                    userSession = GetUserSession(false);
                    if (userSession == null)
                    {
                        result.ErrorMsg = "登陆失败,请联系客服";
                    }
                }
                else
                {
                    //oh6cV1dh0hjoGEizCoKH1KU70UwQ 童老师
                    //oh6cV1UUH2cg1p3--SPVnJdDpgbM 电子商务
                    //oh6cV1QhPLj6XPesheYUQ4XtuGTs jacky
                    var ui = _UserSrv.GetUserInfo("oh6cV1QhPLj6XPesheYUQ4XtuGTs");
                    WXLoginCallBack(ui);
                    userSession   = GetUserSession(false);
                    result.IntMsg = (int)ui.UserRole;
                }

                if (result.IsSuccess)
                {
                    if (userSession.UserRole == UserRole.Teacher)
                    {
                        NLogHelper.InfoTxt($"User OpenId:{userSession.OpenId}");

                        var tec = _TecSrv.GetByOpenId(userSession.OpenId);
                        NLogHelper.InfoTxt($"TecCode:{tec.Code}");
                        if (tec != null)
                        {
                            userSession.TecCode = tec.Code;
                            SetUserSesion(userSession);
                            result.IntMsg = (int)UserRole.Teacher;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                result.ErrorMsg = "登陆失败";

                NLogHelper.ErrorTxt(ex.Message);
            }
            return(new JsonResult(result));
        }
Esempio n. 20
0
        /// <summary>
        /// 被邀请用户首次进入公众号,绑定关系
        /// wxUser 因为获取方式不同
        /// </summary>
        /// <param name="wxMessage"></param>
        /// <param name="ownOpenId"></param>
        /// <returns></returns>
        public EUserInfo InvitedUserComing(string InvitedOpenId, string ownOpenId, WXUserInfo wxUser = null)
        {
            UserSrv   userSrv  = new UserSrv(_dbContext);
            SalesSrv  salesSrv = new SalesSrv(_dbContext);
            EUserInfo user     = null;

            try
            {
                if (wxUser == null)
                {
                    wxUser = WXApi.GetWXUserInfo(InvitedOpenId);
                }
            }
            catch (Exception ex)
            {
                NLogHelper.ErrorTxt($"businessSrv-[InvitedUserComing] -GetWXUserInfo Error:{ex.Message}");
                throw ex;
            }


            EUserInfo owner = null;

            try
            {
                //如果是老用户,不能绑定邀请
                if (!userSrv.IsExistUser(InvitedOpenId))
                {
                    owner = salesSrv.BindUser(ownOpenId, InvitedOpenId);
                }
            }
            catch (Exception ex)
            {
                NLogHelper.ErrorTxt($"businessSrv-[InvitedUserComing] -BindUser Error:{ex.Message}");
                throw ex;
            }

            try
            {
                user = userSrv.AddOrUpdateFromWXUser(wxUser, owner, false);
            }
            catch (Exception ex)
            {
                NLogHelper.ErrorTxt($"businessSrv-[InvitedUserComing] -AddOrUpdateFromWXUser Error:{ex.Message}");
                throw ex;
            }


            _dbContext.SaveChanges();
            return(user);
        }
Esempio n. 21
0
 private void IntroduceYunYi()
 {
     try
     {
         string url    = @"http://mp.weixin.qq.com/s?__biz=MzU3NDk2NjE1MQ==&mid=100000013&idx=1&sn=1b9b19525f6a60329e1e4315f5c40ec5&chksm=7d2b11e54a5c98f3485c9a6ff1394b9397f90b06c72e41d919473cba592d8cb05e6832d3b233#rd";
         string picUrl = @"http://mmbiz.qpic.cn/mmbiz_jpg/Ct0QBXEFiaJkACbLKbpDy8ql5rBoDUHBS0SOic6bHQ0gUYagFibCdYykZeibHGG9LiaJ2JgWTtGOAx0mH8FZfKL3CyA/0?wx_fmt=jpeg";
         _ResultMsg = _wxMessage.toPicText(picUrl, url, "欢饮光临云艺国学教育", "云艺国学教育");
         // NLogHelper.InfoTxt("Menu:" + _ResultMsg);
     }
     catch (Exception ex)
     {
         NLogHelper.ErrorTxt("Menu:" + ex.Message);
     }
 }
Esempio n. 22
0
        public IActionResult OnPostSave(List <EUserChild> list)
        {
            ResultNormal result = new ResultNormal();

            try
            {
                _UserSrv.SaveChildList(list);
            }
            catch (Exception ex)
            {
                result.ErrorMsg = ex.Message;
                NLogHelper.ErrorTxt(ex.Message);
            }
            return(new JsonResult(result));
        }
Esempio n. 23
0
        public ResultObject <OutSMS> SmsVerifyCode(string mobilePhone, string Code)
        {
            ResultObject <OutSMS> result = new ResultObject <OutSMS>();

            try
            {
                result.Entity = _smsSrv.SubmitUserVerifyCode(mobilePhone, Code);
            }
            catch (Exception ex)
            {
                result.ErrorMsg = "系统错误。请联系客服!";
                NLogHelper.ErrorTxt($"验证校验码[SmsVerifyCode]:{ex.Message}");
            }
            return(result);
        }
Esempio n. 24
0
        public IActionResult OnPostInitChildList(string openId)
        {
            ResultList <EUserChild> result = new ResultList <EUserChild>();

            try
            {
                result.List = _UserSrv.GetAllChild(openId);
            }
            catch (Exception ex)
            {
                result.ErrorMsg = ex.Message;
                NLogHelper.ErrorTxt(ex.Message);
            }
            return(new JsonResult(result));
        }
Esempio n. 25
0
        public string Post()
        {
            try
            {
                var memoryStream = new MemoryStream();
                Request.Body.CopyTo(memoryStream);
                string strXml = System.Text.Encoding.Default.GetString(memoryStream.ToArray());
                //       NLogHelper.InfoTxt($"WXEntry Message:{strXml}");

                if (!string.IsNullOrEmpty(strXml))
                {
                    _ResultMsg = "";

                    _wxMessage = new WXMessage();
                    _wxMessage.LoadXml(strXml);

                    _EventKey = _wxMessage.EventKey;
                    if (!string.IsNullOrEmpty(_EventKey))
                    {
                        //邀请码微信消息规则
                        if (_EventKey.StartsWith("qrscene_"))
                        {
                            _EventKey = _EventKey.Substring(8);
                        }
                        //邀请码
                        if (_EventKey.StartsWith(WxConfig.QR_Invite))
                        {
                            InviteQRHandler();
                        }
                        else
                        {
                            //Click 菜单
                            HandlerStdMessage();
                        }
                    }
                    else
                    {
                        HandlerStdMessage();
                    }
                }
            }
            catch (Exception ex)
            {
                NLogHelper.ErrorTxt($"[WX Home Post]:{ex.Message};");
            }

            return(_ResultMsg);
        }
Esempio n. 26
0
        public IActionResult OnPostInitChildList()
        {
            ResultList <EUserChild> result = new ResultList <EUserChild>();
            var us = GetUserSession(false);

            try
            {
                result.List = _UserSrv.GetAllChild(us.OpenId);
            }
            catch (Exception ex)
            {
                result.ErrorMsg = "查询数据异常!请联系管理员或稍后再试";
                NLogHelper.ErrorTxt(ex.Message);
            }
            return(new JsonResult(result));
        }
Esempio n. 27
0
        public ResultNormal DelArt(long artId)
        {
            ResultNormal result = new ResultNormal();

            try
            {
                _WxMiniSrv.DelArtInfo(artId);
            }
            catch (Exception ex)
            {
                NLogHelper.ErrorTxt($"DelArt:{ex.Message}");

                result.ErrorMsg = "删除作品失败,请联系客服!";
            }
            return(result);
        }
        public ResultObject <AppInitData> GetInitData()
        {
            NLogHelper.InfoTxt("Invoke GetInitData");
            ResultObject <AppInitData> result = new ResultObject <AppInitData>();

            try
            {
                result.Entity = _MemoryCache.GetOrCreate(Cache_AppFrameworkData, e => { return(_appEduSrv.InitData(_resSrv)); });
            }
            catch (Exception ex)
            {
                NLogHelper.ErrorTxt($"[AppEdu]GetInitData:{ex.Message}");
                result.ErrorMsg = ex.Message;
            }
            return(result);
        }
Esempio n. 29
0
        public IActionResult OnPostSubmitTecLeave(List <long> list, ETecLeave tecLeave)
        {
            ResultNormal result = new ResultNormal();

            try
            {
                _TecSrv.SubmitLeave(list, tecLeave);
            }
            catch (Exception ex)
            {
                result.ErrorMsg = "请假失败,请联系管理员";
                NLogHelper.ErrorTxt($"后台新增请假[OnPostSubmitTecLeave]:{ex.Message}");
            }

            return(new JsonResult(result));
        }
Esempio n. 30
0
        public IActionResult OnPostInitData()
        {
            ResultObject <PUserApply> result = new ResultObject <PUserApply>();

            try
            {
                result.Entity.CourseTimeList    = StaticDataSrv.CourseTime;
                result.Entity.CourseMaxApplyNum = StaticDataSrv.CourseMaxApplyNum;
            }
            catch (Exception ex)
            {
                result.ErrorMsg = "未能获取数据!请联系管理员或稍后再试";
                NLogHelper.ErrorTxt(ex.Message);
            }
            return(new JsonResult(result));
        }