예제 #1
0
        /// <summary>
        /// 发送奖励金
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public IActionResult OnPostSendReward(long invitelogId, string invitedOpenId, string ownOpenId)
        {
            ResultNormal result = new ResultNormal();

            try
            {
                AmountTransType amountTransType = AmountTransType.Invited_TrialReward;
                EUserAccount    ownAccount;
                bool            needWx = _SalesSrv.CreateRewardTrans(invitelogId, ownOpenId, amountTransType, out ownAccount);

                if (ownAccount != null)
                {
                    var ui = _UserSrv.GetUserInfo(invitedOpenId);
                    NLogHelper.InfoTxt($"wxMessage:OpenId-{ownOpenId}");
                    //微信提醒
                    UserAccountChangeTemplate wxMessage = new UserAccountChangeTemplate();
                    wxMessage.data = wxMessage.GenerateData(ownOpenId,
                                                            ui.Name,
                                                            amountTransType,
                                                            DateTime.Now,
                                                            ownAccount.InviteRewards,
                                                            GlobalSrv.GetRewardAmount(amountTransType)
                                                            );
                    WXApi.SendTemplateMessage <UserAccountChangeTemplate>(wxMessage);
                }
            }
            catch (Exception ex)
            {
                result.ErrorMsg = ex.Message;
            }

            return(new JsonResult(result));
        }
예제 #2
0
        public AlipayTradePrecreateResponse BuildNew(EAliPayApplication app, EStoreInfo store, EUserInfo AgentUI, string TotalAmt, bool needNotifyUrl = true, bool needControl = true)
        {
            string NotifyUrl = ConfigurationManager.AppSettings["Main_SiteUrl"] + "AliPay/PayNotify";

            _OrderNo = StringHelper.GenerateOrderNo();

            IAopClient aliyapClient = new DefaultAopClient("https://openapi.alipay.com/gateway.do", app.AppId,
                                                           app.Merchant_Private_Key, "json", "1.0", "RSA2", app.Merchant_Public_key, "GBK", false);

            AlipayTradePrecreateRequest request = new AlipayTradePrecreateRequest();
            AlipayTradePrecreateModel   model   = new AlipayTradePrecreateModel();

            model.SellerId = store.AliPayAccount;
            NLogHelper.InfoTxt("当面付OrderNo:" + _OrderNo);
            model.OutTradeNo   = _OrderNo;
            model.TotalAmount  = TotalAmt;
            model.Subject      = "#" + AgentUI.Name + " 收银台";
            model.Body         = app.AppName + "-商品";
            model.ExtendParams = new Aop.Api.Domain.ExtendParams();
            model.ExtendParams.SysServiceProviderId = app.AppId;
            if (needControl)
            {
                model.DisablePayChannels = "balance,moneyFund,creditCard,creditCardExpress,creditCardCartoon,debitCardExpress,point,bankPay";
            }

            request.SetBizModel(model);
            if (needNotifyUrl)
            {
                request.SetNotifyUrl(NotifyUrl);
            }

            AlipayTradePrecreateResponse response = aliyapClient.Execute(request, null, store.AliPayAuthToke);

            return(response);
        }
예제 #3
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));
        }
예제 #4
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};");
                    }
                }
            }
        }
예제 #5
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));
        }
예제 #6
0
        public NResult <EUserInfo> Login(string loginName,
                                         string pwd,
                                         string DeviceIdentify       = "",
                                         string DeviceToken          = "",
                                         DeviceChannel DeviceChannel = DeviceChannel.IOS)
        {
            NResult <EUserInfo> result = new NResult <EUserInfo>();

            try
            {
                NLogHelper.InfoTxt(string.Format("用户{0}登陆,密码:{1},DeviceIdentify:{2}", loginName, pwd, DeviceIdentify));
                using (OOContent db = new OOContent())
                {
                    EUserInfo ui = db.DBUserInfo.Where(a => a.LoginName == loginName && a.Pwd == pwd).FirstOrDefault();
                    //var sql = @"select ui.Id,ui.NickName,
                    //                   ui.Phone,ui.UserRole,
                    //                   ui.HeaderImgUrl,
                    //                   ui.RecordStatus
                    //            from UserInfo as ui
                    //            where ui.LoginName = @LoginName and ui.Pwd = @Pwd";
                    //sql = string.Format(sql, loginName, pwd);
                    //List<SqlParameter> pList = new List<SqlParameter>();
                    //pList.Add(new SqlParameter("@LoginName", loginName));
                    //pList.Add(new SqlParameter("@Pwd", pwd));

                    //RUserInfo ui = db.Database.SqlQuery<RUserInfo>(sql, pList.ToArray()).FirstOrDefault();
                    if (ui == null)
                    {
                        result.ErrorMsg = "用户名或密码错误";
                        return(result);
                    }
                    else
                    {
                        ui.LastLoginDateTime = DateTime.Now;
                        //更新设备对应的手机
                        UpdateDevice(DeviceIdentify, loginName, db);
                        db.SaveChanges();
                    }
                    result.resultObj = ui;
                }
            }
            catch (Exception ex)
            {
                result.ErrorMsg = ex.Message;
                ErrorToDb(ex.Message);
            }
            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);
        }
예제 #8
0
        public static WXUserInfo GetWXUserInfo(string OpenId, AccessToken accessToken = null)
        {
            if (accessToken == null)
            {
                accessToken = getAccessToken();
            }

            NLogHelper.InfoTxt($"[WXApi]GetWXUserInfo -- accesstoken:{accessToken}.openid:{OpenId}");
            string url_userInfo = string.Format("https://api.weixin.qq.com/cgi-bin/user/info?access_token={0}&openid={1}",
                                                accessToken.access_token, OpenId);


            WXUserInfo wxUser = HttpHelper.Get <WXUserInfo>(url_userInfo);

            return(wxUser);
        }
예제 #9
0
        /// <summary>
        /// 关注
        /// </summary>
        private void SubscribeHandler()
        {
            NLogHelper.InfoTxt("SubscribeHandler In");
            EUserInfo ui = _UserSrv.GetUserInfo(_wxMessage.FromUserName);

            if (ui == null)
            {
                var wxUser = WXApi.GetWXUserInfo(_wxMessage.FromUserName);
                ui = _UserSrv.AddOrUpdateFromWXUser(wxUser);

                _ResultMsg = _wxMessage.toText(WXReplyContent.NewUserAdd(ui.wx_Name));
            }
            else
            {
                _ResultMsg = _wxMessage.toText(WXReplyContent.UserComing(ui.wx_Name));
            }
        }
예제 #10
0
        public void OnGet()
        {
            var code = Convert.ToString(Request.Query["code"]);

            NLogHelper.InfoTxt($"LessonQR Scan Code:{code}");
            var qr = _ToolsSrv.GetQR(code);

            if (qr != null)
            {
                if (!string.IsNullOrEmpty(qr.Url))
                {
                    if (!qr.Url.StartsWith("http"))
                    {
                        qr.Url = "http://" + qr.Url;
                    }
                    HttpContext.Response.Redirect(qr.Url);
                }
            }
        }
예제 #11
0
        public ResultNormal SendComment(InArtComment indata)
        {
            NLogHelper.InfoTxt($"[SendComment]unionId: {indata.unionId}");
            ResultNormal result = new ResultNormal();

            try
            {
                var checkRes = WXApi.CheckContentSec(indata.Content);
                if (checkRes.errcode == 0)
                {
                    EArtComment artComment = new EArtComment
                    {
                        ArtId          = indata.ArtId,
                        Content        = indata.Content,
                        Praize         = 0,
                        UnionId        = indata.unionId,
                        CreateDateTime = DateTime.Now,
                        RefId          = 0,
                    };
                    _WxMiniSrv.AddComment(artComment);
                    var artInfo = _WxMiniSrv.GetArtInfo(indata.ArtId);
                    artInfo.Comments++;

                    _WxMiniSrv.SaveChanges();
                }
                else
                {
                    if (checkRes.errcode == 87014)
                    {
                        result.ErrorMsg = "请注意您的言论,请勿发布包含色情、违法等有害信息";
                    }
                    else
                    {
                        result.ErrorMsg = checkRes.errMsg;
                    }
                }
            }
            catch (Exception ex)
            {
                result.ErrorMsg = "发布评论失败";
            }
            return(result);
        }
예제 #12
0
        /// <summary>
        /// 菜单点击
        /// </summary>
        private void MenuClickHandler()
        {
            string key = _wxMessage.EventKey;

            NLogHelper.InfoTxt("MenuClickHandler:" + key);
            switch (key)
            {
            case "intro_100":
                IntroduceYunYi();
                break;

            case "ApplyTrial":
                menu_ApplyTrial();
                break;

            case "SalesInvite":
                menu_SalesInvite();
                break;
            }
        }
예제 #13
0
        public OutAPIResult SetNickName()
        {
            OutAPIResult result   = new OutAPIResult();
            string       NickName = HttpContext.Current.Request["NickName"];
            string       phone    = HttpContext.Current.Request["Phone"];

            NLogHelper.InfoTxt(string.Format("Set Nick Name:{0}.Phone:{1}", NickName, phone));
            try
            {
                if (string.IsNullOrEmpty(phone))
                {
                    result.ErrorMsg = "【B】手机号没有获取";
                    return(result);
                }
                if (string.IsNullOrEmpty(NickName))
                {
                    result.ErrorMsg = "【B】昵称没有获取";
                    return(result);
                }
                using (OOContent db = new OOContent())
                {
                    var pList = new List <SqlParameter>();
                    pList.Add(new SqlParameter("@NickName", NickName));
                    pList.Add(new SqlParameter("@Phone", phone));
                    var sql = @"update UserInfo
                                    set NickName = @NickName
                                    where Phone = @Phone
                                    ";
                    result.IntMsg = db.Database.ExecuteSqlCommand(sql, pList.ToArray());
                    if (result.IntMsg <= 0)
                    {
                        result.ErrorMsg = "没有找到对应的用户更新";
                    }
                }
            }
            catch (Exception ex)
            {
                result.ErrorMsg = ex.Message;
            }
            return(result);
        }
예제 #14
0
        public OutAPIResult UpdateHeaderImage()
        {
            OutAPIResult result = new OutAPIResult();
            Stream       stream;
            int          maxSize = 10;
            string       phone   = HttpContext.Current.Request["UserPhone"];

            try
            {
                if (string.IsNullOrEmpty(phone))
                {
                    result.ErrorMsg = "【B】手机号没有获取";
                    return(result);
                }

                HttpPostedFile file0 = HttpContext.Current.Request.Files[0];

                int size = file0.ContentLength / 1024; //文件大小KB
                if (size > maxSize * 1024)
                {
                    result.ErrorMsg = string.Format("文件过大,不能超过{0}M", maxSize);
                    return(result);
                }
                byte[] fileByte = new byte[2]; //contentLength,这里我们只读取文件长度的前两位用于判断就好了,这样速度比较快,剩下的也用不到。
                stream = file0.InputStream;
                stream.Read(fileByte, 0, 2);   //contentLength,还是取前两位

                string fileFlag = "";
                if (fileByte != null || fileByte.Length <= 0)//图片数据是否为空
                {
                    fileFlag = fileByte[0].ToString() + fileByte[1].ToString();
                }
                //extDir.Add("255216", "jpg");
                if (fileFlag != "255216")
                {
                    result.ErrorMsg = "图片格式不正确";
                    return(result);
                }

                string fileName     = "user_" + phone + ".jpg";
                string saveFullPath = SysConfig.ImageSaveDir + "\\" + fileName;
                NLogHelper.InfoTxt("Save Paht:" + saveFullPath);

                OutAPIResult updateResult = ImgHelper.UploadImg(saveFullPath);
                if (updateResult.IsSuccess)
                {
                    using (OOContent db = new OOContent())
                    {
                        var dbImgUrl = SysConfig.ImageSaveDBRoot + fileName;
                        var pList    = new List <SqlParameter>();
                        pList.Add(new SqlParameter("@imgUrl", dbImgUrl));
                        pList.Add(new SqlParameter("@Phone", phone));
                        var sql = @"update UserInfo
                                    set HeaderImgUrl = @imgUrl
                                    where Phone = @Phone
                                    ";
                        db.Database.ExecuteSqlCommand(sql, pList.ToArray());
                    }
                }
                else
                {
                    result.ErrorMsg = result.ErrorMsg;
                }
            }
            catch (Exception ex)
            {
                result.ErrorMsg = ex.Message;
            }
            return(result);
        }
예제 #15
0
        public void LoginWX()
        {
            if (!string.IsNullOrEmpty(HttpContext.Request.Query["code"]))
            {
                //获取code码,以获取openid和access_token
                string code = HttpContext.Request.Query["code"];
                NLogHelper.InfoTxt($"LoginWX-Query:{HttpContext.Request.QueryString}");
                var accessToken = WXApi.GetOAuth2AccessTokenFromCode(code);
                if (!string.IsNullOrEmpty(accessToken.openid))
                {
                    string     url_userInfo = string.Format("https://api.weixin.qq.com/sns/userinfo?access_token={0}&openid={1}&lang=zh_CN", accessToken.access_token, accessToken.openid);
                    WXUserInfo wxUser       = HttpHelper.Get <WXUserInfo>(url_userInfo, false);

                    EUserInfo ui = TryInvitedUserComing(accessToken.openid, wxUser);
                    if (ui == null)
                    {
                        ui = _UserSrv.AddOrUpdateFromWXUser(wxUser);
                    }


                    WXLoginCallBack(ui);

                    string toPage = HttpContext.Request.Query["toPage"];
                    if (!string.IsNullOrEmpty(toPage))
                    {
                        if (toPage.Contains("/User/MyCourse") && ui.UserRole == UserRole.Teacher)
                        {
                            //  HttpContext.Response.Redirect("/Teacher/DayCourse");
                            return;
                        }
                        //微信QR支付页面
                        string amt = HttpContext.Request.Query["amt"];
                        if (!string.IsNullOrEmpty(amt))
                        {
                            var ct = HttpContext.Request.Query["ct"];
                            toPage += $"?amt={amt}&ct={ct}";
                        }
                        HttpContext.Response.Redirect(toPage);
                    }
                }
            }
            else
            {
                try
                {
                    var reUrl = $"https://edu.iqianba.cn/User/Login{Request.QueryString}";
                    //   NLogHelper.InfoTxt($"Login-reUrl:{reUrl}");
                    var       redirect_uri = System.Web.HttpUtility.UrlEncode(reUrl, System.Text.Encoding.UTF8);
                    WxPayData data         = new WxPayData();
                    data.SetValue("appid", WxConfig.APPID);
                    data.SetValue("redirect_uri", redirect_uri);
                    data.SetValue("response_type", "code");
                    data.SetValue("scope", "snsapi_userinfo");
                    data.SetValue("state", "1" + "#wechat_redirect");
                    string url = "https://open.weixin.qq.com/connect/oauth2/authorize?" + data.ToUrl();

                    HttpContext.Response.Redirect(url);
                }
                catch (Exception ex)
                {
                    NLogHelper.ErrorTxt($"LoginWX:{ex.Message}");
                }

                return;
            }
        }
예제 #16
0
 public NResult <EUserTask> Test(long UserId)
 {
     ErrorToDb("aaa");
     NLogHelper.InfoTxt("prod 1");
     return(null);
 }
예제 #17
0
 public void Test()
 {
     NLogHelper.InfoTxt("==============WXPayNotify=================");
 }