示例#1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Expires     = 0;
            string result = "false";

            try
            {
                if (bllUser.IsLogin)
                {
                    this.currentUserInfo = bll.GetCurrentUserInfo();
                }
                string action = context.Request["Action"];
                //利用反射找到未知的调用的方法
                if (!string.IsNullOrEmpty(action))
                {
                    MethodInfo method = this.GetType().GetMethod(action, BindingFlags.NonPublic | BindingFlags.Instance); //找到方法BindingFlags.NonPublic指定搜索非公有方法
                    result = Convert.ToString(method.Invoke(this, new[] { context }));                                    //调用方法
                }
                else
                {
                    resp.Status = 0;
                    resp.Msg    = "请联系管理员";
                    result      = Common.JSONHelper.ObjectToJson(resp);
                }
            }
            catch (Exception ex)
            {
                resp.Status = -1;
                resp.Msg    = ex.Message;
                result      = Common.JSONHelper.ObjectToJson(resp);
            }
            context.Response.Write(result);
        }
示例#2
0
文件: BLLUserScore.cs 项目: uvbs/mmp
        public BLLUserScore(string userId)
            : base(userId)
        {
            if (string.IsNullOrEmpty(userId))
            {
                throw new Exception("userid can not be empty");  //exception需要重组
            }

            userInfo = this.Get <ZentCloud.BLLJIMP.Model.UserInfo>(string.Format("UserID='{0}'", this.UserID));
            if (userInfo == null)
            {
                throw new Exception("user not exist");  //exception需要重组
            }
        }
示例#3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var CategoryList = bll.GetLit <WXMallCategory>(100, 1, string.Format("WebsiteOwner='{0}'", bll.WebsiteOwner));

            if (CategoryList.Count > 0)
            {
                sbCategory.Append("<div class=\"kindbox\"><ul class=\"kind\">");
                foreach (var item in CategoryList)
                {
                    sbCategory.AppendFormat("<li data-categoryid=\"{0}\"><a href=\"javascript:\">{1}<span class=\"icon\"></span></a></li>", item.AutoID, item.CategoryName);
                }
                sbCategory.Append("</ul>");
                sbCategory.Append("</div>");
            }
            currWebSiteInfo     = bll.GetWebsiteInfoModel();
            currWebSiteUserInfo = new BLLJIMP.BLLUser("").GetUserInfo(DataLoadTool.GetWebsiteInfoModel().WebsiteOwner);
        }
示例#4
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Expires     = 0;
            string result = "false";

            try
            {
                this.currentUserInfo = bllUser.GetCurrentUserInfo();
                string action = context.Request["Action"];
                switch (action)
                {
                case "QuerySignUpData":
                    result = QuerySignUpData(context);
                    break;

                case "UpdateApplyStatus":    //修改申请结果
                    result = UpdateApplyStatus(context);
                    break;

                case "UpdateApplyResult":    //修改
                    result = UpdateApplyResult(context);
                    break;

                case "DeleteSignUpData":    //删除
                    result = DeleteSignUpData(context);
                    break;

                case "GetApplyImageList":
                    result = GetApplyImageList(context);
                    break;
                }
            }
            catch (Exception ex)
            {
                resp.Status = -1;
                resp.Msg    = "异常:" + ex.Message;
                result      = Common.JSONHelper.ObjectToJson(resp);
            }

            context.Response.Write(result);
        }
示例#5
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            this.currentUserInfo         = bllUser.GetCurrentUserInfo();
            string action = context.Request["Action"];
            string result = "false";

            try
            {
                switch (action)
                {
                case "AddActivity":
                    result = AddActivity(context);
                    break;

                case "EditActivity":
                    result = EditActivity(context);
                    break;

                case "DeleteActivity":
                    result = DeleteActivity(context);
                    break;

                case "QueryActivity":
                    result = QueryActivity(context);
                    break;

                case "BatChangState":
                    result = BatChangState(context);
                    break;
                }
            }
            catch (Exception ex)
            {
                resp.Status = -1;
                resp.Msg    = ex.Message;
                result      = Common.JSONHelper.ObjectToJson(resp);
            }

            context.Response.Write(result);
        }
示例#6
0
        public bool UpdateTutorInfoByUserInfo(Model.UserInfo user)
        {
            Model.TutorInfo tutor         = GetTutorInfo(user.UserID);
            BLLUserExpand   bllUserExpand = new BLLUserExpand();
            BLLUser         bllUser       = new BLLUser();

            if (tutor == null)
            {
                tutor              = new Model.TutorInfo();
                tutor.UserId       = user.UserID;
                tutor.Email        = user.Email;
                tutor.TutorImg     = user.WXHeadimgurl;
                tutor.TutorName    = user.TrueName;
                tutor.Gender       = bllUser.GetSex(user);
                tutor.ProvinceCode = user.ProvinceCode;
                tutor.CityCode     = user.CityCode;
                tutor.City         = user.City;
                tutor.Digest       = bllUserExpand.GetUserExpandValue(BLLJIMP.Enums.UserExpandType.UserIntroduction, user.UserID);
                tutor.Company      = user.Company;
                tutor.Position     = user.Postion;
                tutor.WZNums       = GetCount <Model.JuActivityInfo>(string.Format(" UserId ='{0}' And IsDelete=0 And IsHide=0  And WebsiteOwner='{1}'", user.UserID, WebsiteOwner));
                var reviewTypeKey = CommonPlatform.Helper.EnumStringHelper.ToString(Enums.ReviewTypeKey.Answer);
                tutor.TutorAnswers = GetCount <Model.ReviewInfo>(string.Format(" UserId ='{0}' And ReviewType='{1}' AND WebsiteOwner='{2}'", user.UserID, reviewTypeKey, WebsiteOwner));
                tutor.RDataTime    = DateTime.Now;
                tutor.websiteOwner = WebsiteOwner;
                return(Add(tutor));
            }
            else
            {
                tutor.TutorImg     = user.WXHeadimgurl;
                tutor.TutorName    = user.TrueName;
                tutor.Gender       = bllUser.GetSex(user);
                tutor.ProvinceCode = user.ProvinceCode;
                tutor.CityCode     = user.CityCode;
                tutor.City         = user.City;
                tutor.Digest       = bllUserExpand.GetUserExpandValue(BLLJIMP.Enums.UserExpandType.UserIntroduction, user.UserID);
                tutor.Company      = user.Company;
                tutor.Position     = user.Postion;
                return(Update(tutor));
            }
        }
示例#7
0
        public void ProcessRequest(HttpContext context)
        {
            string result = "false";

            try
            {
                this.currentUserInfo         = bllWeixin.GetCurrentUserInfo();
                context.Response.ContentType = "text/plain";
                context.Response.Expires     = 0;
                string action = context.Request["Action"];
                switch (action)
                {
                case "AddWeixinMenu":
                    result = AddWeixinMenu(context);    //添加微信菜单
                    break;

                case "EditWeixinMenu":
                    result = EditWeixinMenu(context);    //编辑微信菜单
                    break;

                case "DeleteWeixinMenu":
                    result = DeleteWeixinMenu(context);    //删除微信菜单
                    break;

                case "QueryWeixinMenu":
                    result = QueryWeixinMenu(context);    //获取微信菜单
                    break;

                case "GetMenuSelectList":    //获取微信自定义菜单
                    result = GetMenuSelectList(context);
                    break;

                case "CreateWeixinClientMenu":
                    result = CreateWeixinClientMenu();    //生成微信客户端菜单
                    break;

                case "MoveMenu":
                    result = MoveMenu(context);    //调整菜单顺序
                    break;

                case "QueryJuActivity":
                    result = QueryJuActivity(context);    //查询聚活动数据
                    break;

                case "AddJuActivity":
                    result = AddJuActivity(context);    //添加聚活动
                    break;

                case "GetSingelJuActivity":
                    result = GetSingelJuActivity(context);    //获取单条聚活动
                    break;

                case "EditJuActivity":
                    result = EditJuActivity(context);    //编辑聚活动
                    break;

                case "DeleteJuActivity":
                    result = DeleteJuActivity(context);    //删除聚活动
                    break;

                case "QueryWXMember":
                    result = QueryWXMember(context);    //查询会员注册数据
                    break;

                case "EditWXMember":
                    result = EditWXMember(context);    //编辑会员注册数据
                    break;

                case "DeleteWXMember":
                    result = DeleteWXMember(context);    //删除会员注册数据
                    break;

                case "SetWXLogoImage":
                    result = SetWXLogoImage(context);    //设置微信公众号Logo
                    break;
                    //case "SynchronousAllFollowers":
                    //    result = SynchronousAllFollowers();
                    //    break;
                }
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }
            context.Response.Write(result);
        }
示例#8
0
        void context_AcquireRequestState(object sender, EventArgs e)
        {
            // 获取应用程序
            HttpApplication application = (HttpApplication)sender;

            CurrentPath = application.Request.FilePath == null ? "" : application.Request.FilePath.ToLower();

            #region 判断文件是否检查
            string        pageExtraName           = System.IO.Path.GetExtension(CurrentPath);
            List <string> pageExtraNameFilterList = new List <string>()
            {
                ".aspx",
                ".ashx",
                ".cn",
                ".com",
                ".net"
            };


            //只处理aspx、ashx页面
            if (!pageExtraNameFilterList.Contains(pageExtraName))
            {
                ToLog("后缀不检查:" + CurrentPath);
                return;
            }

            //前端页面排除掉
            if (CurrentPath.IndexOf("/wap/") > -1 || CurrentPath.IndexOf("/m/") > -1 || CurrentPath.IndexOf("/customize/") > -1 ||
                CurrentPath.IndexOf("/wxcallback.aspx") > -1 || CurrentPath.IndexOf("/ueditorcontroller.ashx") > -1)
            {
                ToLog("前端页面排除掉:" + CurrentPath);
                return;
            }

            #endregion

            #region 过滤页排除

            //不过滤列表
            List <string> noFilterList = new List <string>()
            {
                //"/serv/api/admin/"
            };
            //不过滤列表中特殊的链接
            List <string> filterList = new List <string>()
            {
                //"/serv/api/admin/user/islogin.ashx",
                //"/serv/api/admin/mall/statistics/chart.ashx",
                //"/serv/api/admin/mall/statistics/list.ashx",
                //"/serv/api/admin/dashboard/get.ashx",
                //"/serv/api/admin/log/selectactionlist.ashx",
                //"/serv/api/admin/log/list.ashx",
                //"/serv/api/admin/account/selectlist.ashx"
            };

            //获取过滤页面表数据
            if (!noFilterList.Exists(p => CurrentPath.StartsWith(p)) || filterList.Exists(p => CurrentPath.StartsWith(p)))
            {
                //List<BLLPermission.Model.ModuleFilterInfo> pathList = bllPer.GetList<BLLPermission.Model.ModuleFilterInfo>(string.Format("FilterType !='WXOAuth'"));
                List <BLLPermission.Model.ModuleFilterInfo> pathList = bllRedis.GetModuleFilterInfoList().Where(p => p.FilterType != "WXOAuth").ToList();
                if (pathList.Where(p =>
                                   (CurrentPath.Equals(p.PagePath, StringComparison.OrdinalIgnoreCase) && p.MatchType.Equals("all")) ||
                                   (CurrentPath.StartsWith(p.PagePath, StringComparison.OrdinalIgnoreCase) && p.MatchType.Equals("start")) ||
                                   (CurrentPath.EndsWith(p.PagePath, StringComparison.OrdinalIgnoreCase) && p.MatchType.Equals("end")) ||
                                   (CurrentPath.ToLower().Contains(p.PagePath.ToLower()) && p.MatchType.Equals("contains"))
                                   ).Count() > 0)
                {
                    ToLog("过滤页面:" + CurrentPath);
                    return;//匹配
                }
            }
            #endregion

            #region 检查是否登录
            //检查是否登录
            if (application.Session == null || application.Session[Common.SessionKey.LoginStatu] == null || application.Session[Common.SessionKey.UserID] == null)
            {
                this.GotoLoginPage(application, pageExtraName);
                return;
            }
            if (!application.Session[Common.SessionKey.LoginStatu].ToString().Equals("1"))
            {
                //未登录
                this.GotoLoginPage(application, pageExtraName);
                return;
            }
            userID          = application.Session[Common.SessionKey.UserID].ToString();//获取登录ID
            CurrentUserInfo = bllUser.GetUserInfo(userID, bllUser.WebsiteOwner);
            //判断用户是否已被禁用
            if (CurrentUserInfo.IsDisable == 1)
            {
                GotoIsDisable(application, pageExtraName);
                return;
            }
            if (CurrentUserInfo.UserType == 1)
            {
                ToLog("超级管理员排除:" + CurrentPath);
                return;
            }
            #endregion

            #region 站点验证,判断用户是否属于当前站点,系统超级管理员除外
            if (HttpContext.Current.Session["WebsiteInfoModel"] != null && this.CurrentUserInfo.UserType != 1)
            {
                BLLJIMP.Model.WebsiteInfo webSiteModel = (BLLJIMP.Model.WebsiteInfo)HttpContext.Current.Session["WebsiteInfoModel"];

                if (webSiteModel.WebsiteExpirationDate.HasValue && webSiteModel.WebsiteExpirationDate.Value.AddDays(1).AddSeconds(-1) < DateTime.Now)
                {
                    this.GotoIsExpirePage(application, pageExtraName);
                    return;
                }

                if (this.CurrentUserInfo.WebsiteOwner == null)
                {
                    this.CurrentUserInfo.WebsiteOwner = "";
                }

                if (!webSiteModel.WebsiteOwner.Equals(this.CurrentUserInfo.WebsiteOwner, StringComparison.OrdinalIgnoreCase))
                {
                    //ToLog(string.Format("不属于当前用户,网站所有者{0}当前用户{1}路径:{2}", webSiteModel.WebsiteOwner,userModel.WebsiteOwner,currAbsolutePath));
                    this.GotoNoPmsPage(application, pageExtraName);
                    return;
                }
            }
            #endregion

            #region 页面权限验证

            if (string.IsNullOrWhiteSpace(userID))
            {
                this.GotoNoPmsPage(application, pageExtraName);
                return;
            }
            BLLPermission.BLLMenuPermission bllMenuPer = new BLLPermission.BLLMenuPermission(userID);
            //if (bllPms.IsActionPermissionV2(bllMenuPer.WebsiteOwner))
            //{
            string nAction = GetAction(application);    //参数名不分大小写
            //检查用户是否有该页面权限V2
            if (CurrentUserInfo.PermissionGroupID.HasValue)
            {
                ZentCloud.BLLPermission.Model.PermissionGroupInfo perGroupInfo = bllPms.Get <ZentCloud.BLLPermission.Model.PermissionGroupInfo>(string.Format(" GroupID={0}", CurrentUserInfo.PermissionGroupID));
                if (perGroupInfo != null && perGroupInfo.GroupType == 3)   //管理员权限跟站点所有者一致
                {
                    userID = bllMenuPer.WebsiteOwner;
                }
            }
            if (!bllMenuPer.NewCheckUserAndPath(userID, bllMenuPer.WebsiteOwner, CurrentPath, nAction))
            {
                this.GotoNoPmsPage(application, pageExtraName);
                return;
            }
            ToLog("权限检查通过: userID:" + userID + ",WebsiteOwner:" + bllMenuPer.WebsiteOwner + "," + CurrentPath);
            //}
            //else
            //{
            //    //检查用户是否有该页面权限
            //    if (!bllMenuPer.CheckUserAndPath(userID, CurrentPath))
            //    {
            //        this.GotoNoPmsPage(application, pageExtraName);
            //        return;
            //    }
            //}
            #endregion
        }
示例#9
0
文件: Handler.ashx.cs 项目: uvbs/mmp
        /// <summary>
        /// 系统添加票数 指定选手编号
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string SysAddvoteCount(HttpContext context)
        {
            if (CurrentUserInfo.UserType.Equals(1))//超级管理员才可以操作
            {
                int number   = int.Parse(context.Request["Number"]);
                int addCount = int.Parse(context.Request["AddCount"]);
                int voteId   = int.Parse(context.Request["VoteId"]);
                //
                VoteObjectInfo voteObj = bllVote.Get <VoteObjectInfo>(string.Format(" Number={0} And VoteID={1} And Status=1 ", number, voteId));
                if (voteObj != null)
                {
                    for (int i = 0; i < addCount; i++)
                    {
                        Random rand = new Random();
                        //注册用户
                        DateTime regTime = DateTime.Now.AddMinutes(new Random().Next(1, 10));

                        #region 注册用户
                        //注册用户
                        UserInfo userInfo = new ZentCloud.BLLJIMP.Model.UserInfo();
                        userInfo.UserID          = string.Format("WXUser{0}{1}", ZentCloud.Common.StringHelper.GetDateTimeNum(), ZentCloud.Common.Rand.Str(5));//WXUser+时间字符串+随机5位数字
                        userInfo.Password        = ZentCloud.Common.Rand.Str_char(12);
                        userInfo.UserType        = 2;
                        userInfo.WebsiteOwner    = bllVote.WebsiteOwner;
                        userInfo.Regtime         = regTime;
                        userInfo.WXOpenId        = "zc" + ZentCloud.Common.Rand.Str_char(12) + "cl";
                        userInfo.WXScope         = "snsapi_base";
                        userInfo.RegIP           = bllVote.GetLit <UserInfo>(1, new Random().Next(1, 10000), "RegIP IS NOT NULL")[0].RegIP;
                        userInfo.LastLoginIP     = userInfo.RegIP;
                        userInfo.LastLoginDate   = regTime;
                        userInfo.LoginTotalCount = 1;
                        if (bllVote.Add(userInfo))
                        {
                            VoteLogInfo log = new VoteLogInfo();
                            log.UserID       = userInfo.UserID;
                            log.VoteID       = voteId;
                            log.VoteObjectID = voteObj.AutoID;
                            log.InsertDate   = ((DateTime)(userInfo.Regtime)).AddSeconds(rand.Next(2, 10));
                            log.CreateUserID = bllVote.WebsiteOwner;
                            log.WebsiteOwner = bllVote.WebsiteOwner;
                            log.VoteCount    = 1;
                            log.IP           = userInfo.RegIP;
                            log.IPLocation   = Common.MySpider.GetIPLocation(log.IP);
                            if (bllVote.Add(log))
                            {
                                if (bllVote.Update(new VoteObjectInfo(), "VoteCount+=1", string.Format(" AutoID={0}", voteObj.AutoID)) > 0)
                                {
                                    System.Threading.Thread.Sleep(100);
                                }
                            }
                        }

                        #endregion
                        //
                    }
                }
                else
                {
                    resp.errcode = 1;
                    resp.errmsg  = "选手编号不存在";
                }

                //
            }
            else
            {
                resp.errcode = 1;
            }
            return(Common.JSONHelper.ObjectToJson(resp));
        }
示例#10
0
        /// <summary>
        /// 返回投票内容
        /// </summary>
        /// <param name="tvInfo"></param>
        /// <returns></returns>
        private string ToHtml(BLLJIMP.Model.TheVoteInfo tvInfo)
        {
            StringBuilder htmlStr   = new StringBuilder();
            string        classStr  = "";
            string        selectStr = "";
            string        str       = "";

            BLLJIMP.Model.UserVoteInfo uvInfo = null;
            if (bll.IsLogin)
            {
                this.userInfo = DataLoadTool.GetCurrUserModel();
                string whereStr = string.Format(" UserId='{0}' and VoteId='{1}'", userInfo.UserID, tvInfo.AutoId);
                uvInfo = bll.Get <BLLJIMP.Model.UserVoteInfo>(whereStr);
            }
            //uvInfo = null;
            if (uvInfo != null)
            {
                classStr = "toupiaobox toupiaoover";
            }
            else
            {
                if (tvInfo.VoteSelect == "1")
                {
                    classStr  = "toupiaobox";
                    selectStr = "radio";
                    str       = "以下选项为单选";
                }
                else if (tvInfo.VoteSelect == "2")
                {
                    classStr  = "toupiaobox duoxuan";
                    selectStr = "checkbox";
                    str       = "以下选项为多选";
                }
            }
            htmlStr.AppendFormat("<link rel=\"stylesheet\" href=\"styles/css/style.css?v=0.0.1\">");
            htmlStr.AppendFormat("<div id=\"toupiao\" class=\"{0}\">", classStr);
            htmlStr.AppendFormat("<div><img src=\"{0}\"></div>", tvInfo.ThumbnailsPath);
            htmlStr.AppendFormat("<div class=\"title\">{0}</div>", tvInfo.VoteName);
            htmlStr.AppendFormat("<p class=\"note\">{0}</p>", str);
            htmlStr.AppendFormat("<input type=\"hidden\" id=\"SelectStr\"  value=\"{0}\" />", selectStr);
            htmlStr.AppendFormat("<input type=\"hidden\" id=\"AutoId\"  value=\"{0}\" />", tvInfo.AutoId);
            List <BLLJIMP.Model.DictionaryInfo> dInfos = bll.GetList <BLLJIMP.Model.DictionaryInfo>(" ForeignKey='" + tvInfo.AutoId + "'");

            foreach (var item in dInfos)
            {
                htmlStr.AppendFormat("<input name=\"radiocheck2\" type=\"{0}\" class=\"radioinput\" id=\"{1}\" value=\"\" v=\"{2}\">", selectStr, selectStr + item.AutoID, item.AutoID);
                htmlStr.AppendFormat("<div class=\"mainconcent\">");
                htmlStr.AppendFormat("<label class=\"inputlabel\" for=\"{0}\"></label>", selectStr + item.AutoID);
                htmlStr.AppendFormat("<span class=\"inputicon\"><span class=\"icon\"></span></span>");
                htmlStr.AppendFormat("<div class=\"inputtext\" >{0}</div>", item.ValueStr);
                htmlStr.AppendFormat("<div class=\"jindubar\">");
                double f = 0;
                if (tvInfo.VoteNumbers != 0)
                {
                    f = Math.Round((Convert.ToDouble(item.VoteNums) / Convert.ToDouble(tvInfo.VoteNumbers)) * 100, 0);
                }
                htmlStr.AppendFormat("<span class=\"jindu\" style=\"width:{0}%;\"></span>", f);
                htmlStr.AppendFormat("<span class=\"peoplenum\">{0}票数</span>", item.VoteNums);


                htmlStr.AppendFormat("<span class=\"pecent\">{0}%</span>", f);
                htmlStr.AppendFormat("</div></div>");
            }
            string dName = "";

            if (uvInfo != null)
            {
                dInfos = bll.GetList <BLLJIMP.Model.DictionaryInfo>(" AutoId in (" + uvInfo.DiInfoId + ")");

                if (dInfos != null)
                {
                    foreach (BLLJIMP.Model.DictionaryInfo item in dInfos)
                    {
                        dName += item.ValueStr + " ";
                    }
                }
            }

            htmlStr.AppendFormat("<span class=\"button\" id=\"btnSave\" onclick=\"SaveInfo()\">投票</span>");
            htmlStr.AppendFormat("<span class=\"toupiaoinfo\" >你已投过票,投票项为\"{0}\"</span>", dName);
            htmlStr.AppendFormat("</div>");
            return(htmlStr.ToString());
        }
示例#11
0
        public void ProcessRequest(HttpContext context)
        {
            useinfo = Comm.DataLoadTool.GetCurrUserModel();
            context.Response.ContentType = "text/plain";
            context.Response.Expires     = 0;
            string Action = context.Request["Action"];
            string result = "true";

            switch (Action)
            {
            case "AddCategory":
                result = AddCategory(context);
                break;

            case "EditCategory":
                result = EditCategory(context);
                break;

            case "DeleteCategory":
                result = DeleteCategory(context);
                break;

            case "QueryCategory":
                result = QueryCategory(context);
                break;

            case "GetMenuSelectList":
                result = GetMenuSelectList(context);
                break;



            case "QueryHelpContent":
                result = QueryHelpContent(context);
                break;

            case "AddHelpContent":
                result = AddHelpContent(context);
                break;

            case "GetSingleHelpContent":
                result = GetSingleHelpContent(context);
                break;


            case "EditHelpContent":
                result = EditHelpContent(context);
                break;

            case "DeleteHelpContent":
                result = DeleteHelpContent(context);
                break;


            //case "SubmitFeedBack":
            //    result = SubmitFeedBack(context);
            //    break;

            case "QueryFeedBack":
                result = QueryFeedBack(context);
                break;

            case "DeleteFeedBack":
                result = DeleteFeedBack(context);
                break;
            }
            context.Response.Write(result);
        }
示例#12
0
        public void ProcessRequest(HttpContext context)
        {
            BLLUser         userBll = new BLLUser();
            BLLSMS          smsBll  = new BLLSMS("");
            BLLDistribution bllDist = new BLLDistribution();

            try
            {
                var phone    = context.Request["phone"];
                var code     = context.Request["code"];
                var password = context.Request["password"];

                string openId = "";
                if (context.Session["currWXOpenId"] != null)
                {
                    openId = context.Session["currWXOpenId"].ToString();
                }

                //if (string.IsNullOrWhiteSpace(openId))
                //{
                //    apiResp.status = false;
                //    apiResp.code = (int)BLLJIMP.Enums.APIErrCode.PrimaryKeyIncomplete;
                //    apiResp.msg = "找不到微信OpenId";
                //    userBll.ContextResponse(context, apiResp);
                //    return;
                //}

                phone    = phone.Trim();
                code     = code.Trim();
                password = password.Trim();

                if (string.IsNullOrWhiteSpace(phone) || string.IsNullOrWhiteSpace(code))
                {
                    apiResp.status = false;
                    apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.PrimaryKeyIncomplete;
                    apiResp.msg    = "手机以及验证码必传";
                    userBll.ContextResponse(context, apiResp);
                    return;
                }


                if (!ZentCloud.Common.MyRegex.PhoneNumLogicJudge(phone))
                {
                    apiResp.status = false;
                    apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.PrimaryKeyIncomplete;
                    apiResp.msg    = "手机号码格式不正确";
                    userBll.ContextResponse(context, apiResp);
                    return;
                }

                var vCode = smsBll.GetLastSmsVerificationCode(phone);

                if (vCode == null)
                {
                    apiResp.status = false;
                    apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.PrimaryKeyIncomplete;
                    apiResp.msg    = "无效验证码";
                    userBll.ContextResponse(context, apiResp);
                    return;
                }

                if (vCode.VerificationCode != code)
                {
                    apiResp.status = false;
                    apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.PrimaryKeyIncomplete;
                    apiResp.msg    = "无效验证码";
                    userBll.ContextResponse(context, apiResp);
                    return;
                }

                UserInfo phoneUser  = userBll.GetUserInfoByPhone(phone);
                UserInfo openIdUser = null;
                if (!string.IsNullOrWhiteSpace(openId))
                {
                    openIdUser = userBll.GetUserInfoByOpenId(openId);
                }

                #region phoneUser != null
                if (phoneUser != null)
                {
                    if (openIdUser == null && string.IsNullOrWhiteSpace(phoneUser.WXOpenId) && !string.IsNullOrWhiteSpace(openId))
                    {
                        StringBuilder sbSQL = new StringBuilder();
                        sbSQL.AppendFormat(" WXOpenId = '{0}' ", openId);
                        if (!string.IsNullOrWhiteSpace(password))
                        {
                            sbSQL.AppendFormat(",Password = '******' ", password);
                        }
                        //绑定openid到手机号账户上
                        if (userBll.Update(phoneUser, sbSQL.ToString(), string.Format(" AutoID = {0} ", phoneUser.AutoID)) > 0)
                        {
                            //设置登陆状态成功
                            //设置用户会话ID
                            context.Session[ZentCloud.Common.SessionKey.UserID]     = phoneUser.UserID;
                            context.Session[ZentCloud.Common.SessionKey.LoginStatu] = 1; //设置登录状态

                            apiResp.status = true;
                            apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.IsSuccess;
                            apiResp.msg    = "绑定成功";
                            userBll.ContextResponse(context, apiResp);

                            bllDist.SetUserDistributionOwnerByTemp(phoneUser.UserID, phoneUser.WebsiteOwner);

                            return;
                        }
                        else
                        {
                            apiResp.status = false;
                            apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.OperateFail;
                            apiResp.msg    = "绑定失败";
                            userBll.ContextResponse(context, apiResp);
                            return;
                        }
                    }
                    else if (!string.IsNullOrWhiteSpace(password))
                    {
                        if (userBll.Update(phoneUser, string.Format(" Password = {0} ", password), string.Format(" AutoID = {0} ", phoneUser.AutoID)) > 0)
                        {
                            //设置登陆状态成功
                            //设置用户会话ID
                            context.Session[ZentCloud.Common.SessionKey.UserID]     = phoneUser.UserID;
                            context.Session[ZentCloud.Common.SessionKey.LoginStatu] = 1; //设置登录状态

                            apiResp.status = true;
                            apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.IsSuccess;
                            apiResp.msg    = "登录成功";
                            userBll.ContextResponse(context, apiResp);
                            return;
                        }
                        else
                        {
                            apiResp.status = false;
                            apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.OperateFail;
                            apiResp.msg    = "注册失败";
                            userBll.ContextResponse(context, apiResp);
                            return;
                        }
                    }
                    else
                    {
                        //设置登陆状态成功
                        //设置用户会话ID
                        context.Session[ZentCloud.Common.SessionKey.UserID]     = phoneUser.UserID;
                        context.Session[ZentCloud.Common.SessionKey.LoginStatu] = 1; //设置登录状态

                        apiResp.status = true;
                        apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.IsSuccess;
                        apiResp.msg    = "登录成功";
                        userBll.ContextResponse(context, apiResp);
                        return;
                    }
                }
                #endregion

                if (openIdUser == null)
                {
                    //构造新用户
                    var currentUserInfo = new ZentCloud.BLLJIMP.Model.UserInfo();
                    currentUserInfo.UserID = string.Format("WXUser{0}", Guid.NewGuid().ToString());//Guid
                    if (!string.IsNullOrWhiteSpace(password))
                    {
                        currentUserInfo.Password = password;
                    }
                    else
                    {
                        currentUserInfo.Password = ZentCloud.Common.Rand.Str_char(6);
                    }
                    currentUserInfo.UserType     = 2;
                    currentUserInfo.WebsiteOwner = userBll.WebsiteOwner;
                    currentUserInfo.Regtime      = DateTime.Now;
                    if (!string.IsNullOrWhiteSpace(openId))
                    {
                        currentUserInfo.WXOpenId = openId;
                    }
                    currentUserInfo.RegIP           = ZentCloud.Common.MySpider.GetClientIP();
                    currentUserInfo.LastLoginIP     = ZentCloud.Common.MySpider.GetClientIP();
                    currentUserInfo.LastLoginDate   = DateTime.Now;
                    currentUserInfo.LoginTotalCount = 1;
                    currentUserInfo.Phone           = phone;

                    if (userBll.Add(currentUserInfo))
                    {
                        //设置登陆状态成功
                        //设置用户会话ID
                        context.Session[ZentCloud.Common.SessionKey.UserID]     = currentUserInfo.UserID;
                        context.Session[ZentCloud.Common.SessionKey.LoginStatu] = 1; //设置登录状态

                        apiResp.status = true;
                        apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.IsSuccess;
                        apiResp.msg    = "注册成功";
                        userBll.ContextResponse(context, apiResp);

                        bllDist.SetUserDistributionOwnerByTemp(currentUserInfo.UserID, currentUserInfo.WebsiteOwner);

                        return;
                    }
                    else
                    {
                        apiResp.status = false;
                        apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.OperateFail;
                        apiResp.msg    = "注册失败";
                        userBll.ContextResponse(context, apiResp);
                        return;
                    }
                }
                else
                {
                    apiResp.status = false;
                    apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.OperateFail;
                    apiResp.msg    = "该微信已绑定其他账号";
                    userBll.ContextResponse(context, apiResp);
                    return;

                    StringBuilder sbSQL1 = new StringBuilder();
                    sbSQL1.AppendFormat(" Phone = '{0}' ", phone);
                    if (!string.IsNullOrWhiteSpace(password))
                    {
                        sbSQL1.AppendFormat(",Password = '******' ", password);
                    }
                    openIdUser.Phone = phone;
                    if (userBll.Update(openIdUser, sbSQL1.ToString(), string.Format(" AutoID = {0} ", openIdUser.AutoID)) > 0)
                    {
                        //设置登陆状态成功
                        //设置用户会话ID
                        context.Session[ZentCloud.Common.SessionKey.UserID]     = openIdUser.UserID;
                        context.Session[ZentCloud.Common.SessionKey.LoginStatu] = 1; //设置登录状态

                        apiResp.status = true;
                        apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.IsSuccess;
                        apiResp.msg    = "绑定成功";
                        userBll.ContextResponse(context, apiResp);

                        bllDist.SetUserDistributionOwnerByTemp(openIdUser.UserID, openIdUser.WebsiteOwner);
                        return;
                    }
                    else
                    {
                        apiResp.status = false;
                        apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.OperateFail;
                        apiResp.msg    = "绑定失败";
                        userBll.ContextResponse(context, apiResp);
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                apiResp.status = false;
                apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.OperateFail;
                apiResp.msg    = "绑定失败:" + ex.Message;
                userBll.ContextResponse(context, apiResp);
                return;
            }
        }
示例#13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            articleId = Request["articleId"];
            if (articleId == null)
            {
                Response.End();
            }
            int articleIdint;

            if (!int.TryParse(articleId, out articleIdint))
            {
                Response.End();
            }
            currentUserInfo     = DataLoadTool.GetCurrUserModel();
            currWebSiteUserInfo = bll.Get <UserInfo>(string.Format("UserID='{0}'", DataLoadTool.GetWebsiteInfoModel().WebsiteOwner));//
            JuActivityInfo articleInfo = bll.Get <JuActivityInfo>(string.Format("JuActivityID={0}", articleIdint));

            if (articleInfo == null)
            {
                Response.End();
            }
            if (!currentUserInfo.UserType.Equals(1))
            {
                if (!articleInfo.WebsiteOwner.Equals(currentUserInfo.WebsiteOwner))
                {
                    Response.End();
                }
            }

            var    articleIdHex = Convert.ToString(articleIdint, 16);                                                                                                                                                                                                                                                                                                                       //文章活动ID十六进制
            string pageUrl      = string.Format("http://{0}/{1}/details.chtml", Request.Url.Host, articleIdHex);
            var    rootList     = bll.GetList <WebAccessLogsInfo>(string.Format("(Ex_PreSpreadUserID is null or Ex_PreSpreadUserID='') And (Ex_PreShareTimestamp is null or Ex_PreShareTimestamp='') And Ex_SpreadUserID !='' And Ex_SpreadUserID is not null  And Ex_ShareTimestamp !=''  And Ex_ShareTimestamp is not null  And PageUrl like '{0}%'  Order by AccessDate ASC", pageUrl)); //根节点


            if (rootList.Count > 0)
            {
                rootList = rootList.DistinctBy(p => p.Ex_ShareTimestamp).ToList();
                System.Text.StringBuilder sbRoot = new System.Text.StringBuilder();
                for (int i = 0; i < rootList.Count; i++)
                {
                    var item = rootList[i];

                    //int count = bll.GetCount<WebAccessLogsInfo>(string.Format("Ex_PreSpreadUserID='{0}' And Ex_PreShareTimestamp='{1}' Order by AccessDate ASC", item.Ex_SpreadUserID, item.Ex_ShareTimestamp));
                    var subList = bll.GetList <WebAccessLogsInfo>(string.Format("Ex_PreSpreadUserID='{0}' And Ex_PreShareTimestamp='{1}' Order by AccessDate ASC ", item.Ex_SpreadUserID, item.Ex_ShareTimestamp));
                    subList = subList.DistinctBy(p => p.Ex_ShareTimestamp).ToList();
                    int count    = subList.Count;
                    var isParent = false;
                    if (count > 0)
                    {
                        isParent = true;
                    }
                    string wxNickName = "无昵称";
                    string wxHeadImg  = "/zTree/css/zTreeStyle/img/diy/user.png";
                    string icon       = "/zTree/css/zTreeStyle/img/diy/user.png";
                    var    userInfo   = bll.Get <UserInfo>(string.Format("UserID='{0}'", item.Ex_SpreadUserID));
                    if (userInfo != null)
                    {
                        if (!string.IsNullOrEmpty(userInfo.WXNickname))
                        {
                            wxNickName = userInfo.WXNickname;
                        }
                        if (!string.IsNullOrEmpty(userInfo.WXHeadimgurlLocal))
                        {
                            wxHeadImg = userInfo.WXHeadimgurlLocal;
                        }
                        else
                        {
                            if (!string.IsNullOrEmpty(userInfo.WXOpenId))
                            {
                                //拉取用户信息并更新数据库

                                ZentCloud.BLLJIMP.Model.Weixin.WeixinUserInfo weixinInfo = bllWeixin.GetWeixinUserInfo(currWebSiteUserInfo.UserID, currWebSiteUserInfo.WeixinAppId, currWebSiteUserInfo.WeixinAppSecret, userInfo.WXOpenId);
                                if (weixinInfo != null)
                                {
                                    if (!string.IsNullOrEmpty(weixinInfo.NickName))
                                    {
                                        userInfo.WXNickname = weixinInfo.NickName;
                                    }
                                    if (!string.IsNullOrEmpty(weixinInfo.HeadImgUrl))
                                    {
                                        userInfo.WXHeadimgurl = weixinInfo.HeadImgUrl;
                                    }
                                    //bll.Update(userInfo);
                                }
                            }
                        }
                    }
                    string tip   = string.Format("<img src='{0}' align='absmiddle' width='100px' height='100px'/><br/>{1}<br/>被<span style='color:red;'>{2}</span>次转发", wxHeadImg, wxNickName, count);
                    var    title = string.Format("<span style='color:blue;'>{0}</span>  <span style='color:red;'>{1}</span>转发 [{2}]", wxNickName, count, string.Format("{0:f}", item.AccessDate));
                    sbRoot.Append("{");
                    sbRoot.AppendFormat("name: \"{0}\", id: \"{1}\", count:{2}, times: 1, isParent:\"{3}\",Ex_SpreadUserID:\"{4}\",Ex_ShareTimestamp:\"{5}\",icon:\"{6}\",tip:\"{7}\"", title, item.AutoID, "1", isParent.ToString().ToLower(), item.Ex_SpreadUserID, item.Ex_ShareTimestamp, icon, tip);
                    sbRoot.Append("}");

                    if (i < rootList.Count - 1)//追加分隔符
                    {
                        sbRoot.Append(",");
                    }
                }
                RootNodes = sbRoot.ToString();
            }
            else
            {
                RootNodes = "{ name: \"暂时没有转发记录\", id: \"0\", count: 0, times: 1, isParent: false }";
            }
        }
示例#14
0
        /// <summary>
        /// 注册用户
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string SaveInfo(HttpContext context)
        {
            string name            = context.Request["Uname"];
            string phone           = context.Request["UPhone"];
            string email           = context.Request["UEmail"];
            string company         = context.Request["UCompanyl"];
            string recommendUserId = context.Request["UserId"];//推荐人用户名
            //string SmsVerCode = context.Request["SmsVerCode"];
            string position = context.Request["Postion"];

            if (string.IsNullOrEmpty(name) ||
                string.IsNullOrEmpty(phone) || string.IsNullOrEmpty(company))
            {
                resp.Status = -1;
                resp.Msg    = "请填写完整信息";
                goto outF;
            }

            if (name.Length >= 15)
            {
                resp.Status = -1;
                resp.Msg    = "姓名长度在15字内";
                goto outF;
            }
            if (bllUser.GetCount <UserInfo>(string.Format(" WebsiteOwner='{0}' And Phone='{1}'", bllUser.WebsiteOwner, phone)) > 0)
            {
                resp.Status = -1;
                resp.Msg    = "手机号已经注册过";
                goto outF;
            }

            //if (string.IsNullOrEmpty(SmsVerCode))
            //{
            //    resp.Status = -1;
            //    resp.Msg = "请输入通关密码";
            //    goto outF;

            //}
            //if (context.Session["SmsVerificationCode"] == null)
            //{
            //    resp.Status = -1;
            //    resp.Msg = "请输入通关密码";
            //    goto outF;

            //}
            //if (!context.Session["SmsVerificationCode"].ToString().Equals(SmsVerCode))
            //{
            //    resp.Status = -1;
            //    resp.Msg = "通关密码不正确";
            //    goto outF;
            //}

            //注册会员加积分
            BLLUserScore bllScore = new BLLUserScore(this.currentUserInfo.UserID);

            bllScore.UpdateUserScoreWithWXTMNotify(bllScore.GetDefinedUserScore(BLLUserScore.UserScoreType.RegistWebSite), bllWeixin.GetAccessToken());

            //转发人加积分
            if (!string.IsNullOrEmpty(recommendUserId))//有转发人
            {
                SavaForwardingRecord(recommendUserId);

                //转发人加积分
                bllScore = new BLLUserScore(recommendUserId);
                if (IsTutor(recommendUserId))
                {
                    bllScore.UpdateUserScoreWithWXTMNotify(bllScore.GetDefinedUserScore(BLLUserScore.UserScoreType.TutorInviteFriendRegister), new ZentCloud.BLLJIMP.BLLWeixin("").GetAccessToken());
                }
                else
                {
                    bllScore.UpdateUserScoreWithWXTMNotify(bllScore.GetDefinedUserScore(BLLUserScore.UserScoreType.InviteFriendRegister), new ZentCloud.BLLJIMP.BLLWeixin("").GetAccessToken());
                }

                //SaveCurrUser();//注册会员加积分
                //SaveRecordUser(UserId);  //转发人加积分
            }

            currentUserInfo          = bllUser.GetCurrentUserInfo();
            currentUserInfo.TrueName = name;
            currentUserInfo.Phone    = phone;
            currentUserInfo.Email    = email;
            currentUserInfo.Company  = company;
            currentUserInfo.Regtime  = DateTime.Now;
            currentUserInfo.Postion  = position;
            bool isSuccess = bllUser.Update(currentUserInfo);

            if (isSuccess)
            {
                resp.Status = 0;
                resp.Msg    = "添加成功";
            }
            else
            {
                resp.Status = -1;
                resp.Msg    = "添加失败";
            }

outF:
            return(Common.JSONHelper.ObjectToJson(resp));
        }
示例#15
0
        /// <summary>
        /// 获取传入的用户信息和微信会员信息
        /// </summary>
        /// <param name="context"></param>
        /// <param name="memberModel"></param>
        /// <param name="userInfo"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        private bool GetWeixinMemberInfo(HttpContext context, out WXMemberInfo memberModel, out ZentCloud.BLLJIMP.Model.UserInfo userInfo, out string msg)
        {
            //取得OpenID支持两种模式:传入模式,授权Session模式
            string openId        = context.Request[systemSet.WXCurrOpenerOpenIDKey];
            string userAutoIDHex = context.Request[systemSet.UserAutoIDHexKey];

            memberModel = new WXMemberInfo();
            msg         = "";

            //判断用户微信是否已认证,认证则根据Session取openId,否则根据Url取得
            userInfo = userBll.GetUserInfoByAutoIDHex(userAutoIDHex);

            if (userInfo == null)
            {
                msg = "用户不存在!";
                return(false);
            }

            if (userModel.IsWeixinVerify == 1 && context.Session[systemSet.WXCurrOpenerOpenIDKey] != null)
            {
                //如果是微信认证用户而且认证取到的openID也存在,则会忽略浏览器url上的openid
                openId = context.Session[systemSet.WXCurrOpenerOpenIDKey].ToString();
            }

            memberModel = weixinBll.GetWXMemberInfo(userModel.UserID, openId);

            if (memberModel == null)
            {
                msg = "会员不存在!";
                return(false);
            }

            return(true);
        }
示例#16
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            currentUserInfo = bllUser.GetCurrentUserInfo();
            string            data              = context.Request["data"];
            decimal           productFee        = 0;                       //商品总价格 不包含邮费
            OrderRequestModel orderRequestModel = new OrderRequestModel(); //订单模型

            try
            {
                orderRequestModel = ZentCloud.Common.JSONHelper.JsonToModel <OrderRequestModel>(data);
            }
            catch (Exception ex)
            {
                resp.errcode = 1;
                resp.errmsg  = "JSON格式错误,请检查。错误信息:" + ex.Message;
                context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
            }
            WXMallOrderInfo orderInfo = new WXMallOrderInfo();//订单表

            orderInfo.InsertDate     = DateTime.Now;
            orderInfo.OrderUserID    = currentUserInfo.UserID;
            orderInfo.WebsiteOwner   = bllMall.WebsiteOwner;
            orderInfo.Transport_Fee  = 0;
            orderInfo.OrderID        = bllMall.GetGUID(BLLJIMP.TransacType.AddMallOrder);
            orderInfo.OrderMemo      = orderRequestModel.buyer_memo;
            orderInfo.MyCouponCardId = orderRequestModel.cardcoupon_id.ToString();
            orderInfo.UseScore       = orderRequestModel.use_score;
            orderInfo.Status         = "待付款";
            orderInfo.OrderType      = 1;
            if (orderRequestModel.pay_type == "WEIXIN")//微信支付
            {
                orderInfo.PaymentType = 2;
            }
            else if (orderRequestModel.pay_type == "ALIPAY")//支付宝支付
            {
                orderInfo.PaymentType = 1;
            }

            #region 格式检查
            //相关检查
            if (orderRequestModel.skus == null)
            {
                resp.errcode = 1;
                resp.errmsg  = "参数skus 不能为空";
                context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                return;
            }
            //相关检查
            #endregion


            #region 商品检查 订单详情生成
            ///订单详情
            List <WXMallOrderDetailsInfo> detailList = new List <WXMallOrderDetailsInfo>();//订单详情
            orderRequestModel.skus = orderRequestModel.skus.Distinct().ToList();
            foreach (var sku in orderRequestModel.skus)
            {
                //先检查库存
                ProductSku productSku = bllMall.GetProductSku(sku.sku_id);
                if (productSku == null)
                {
                    resp.errcode = 1;
                    resp.errmsg  = "SKU不存在";
                    context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                    return;
                }

                WXMallProductInfo productInfo = bllMall.GetProduct(productSku.ProductId.ToString());
                if (productInfo.IsOnSale == "0")
                {
                    resp.errcode = 1;
                    resp.errmsg  = string.Format("{0}已下架", productInfo.PName);
                    context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                    return;
                }
                if (bllMall.GetSkuCount(productSku) < sku.count)
                {
                    resp.errcode = 1;
                    resp.errmsg  = string.Format("{0}{1}库存余量为{2},库存不足,请减少购买数量", productInfo.PName, bllMall.GetProductShowProperties(productSku.SkuId), productSku.Stock);
                    context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                    return;
                }
                if (bllMall.IsPromotionTime(productSku))
                {
                    if (sku.count > productSku.PromotionStock)
                    {
                        resp.errcode = 1;
                        resp.errmsg  = string.Format("{0}{1}特卖库存余量为{2},库存不足,请减少购买数量", productInfo.PName, bllMall.GetProductShowProperties(productSku.SkuId), productSku.PromotionStock);
                        context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                        return;
                    }
                }
                WXMallOrderDetailsInfo detailModel = new WXMallOrderDetailsInfo();
                detailModel.OrderID     = orderInfo.OrderID;
                detailModel.PID         = productInfo.PID;
                detailModel.TotalCount  = sku.count;
                detailModel.OrderPrice  = bllMall.GetSkuPrice(productSku);
                detailModel.ProductName = productInfo.PName;
                detailModel.SkuId       = productSku.SkuId;
                detailModel.SkuShowProp = bllMall.GetProductShowProperties(productSku.SkuId);
                detailList.Add(detailModel);
            }
            #endregion

            productFee = detailList.Sum(p => p.OrderPrice * p.TotalCount).Value;//商品费用

            //物流费用
            #region 运费计算
            FreightModel freightModel = new FreightModel();
            freightModel.skus = orderRequestModel.skus;
            decimal freight    = 0;//运费
            string  freightMsg = "";
            if (!bllMall.CalcFreight(freightModel, out freight, out freightMsg))
            {
                resp.errcode = 1;
                resp.errmsg  = freightMsg;
                context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                return;
            }
            orderInfo.Transport_Fee = freight;
            #endregion
            #region 优惠券计算
            decimal discountAmount   = 0;//优惠金额
            bool    canUseCardCoupon = false;
            string  msg = "";
            if (orderRequestModel.cardcoupon_id > 0)//有优惠券
            {
                discountAmount = bllMall.CalcDiscountAmount(orderRequestModel.cardcoupon_id.ToString(), data, currentUserInfo.UserID, out canUseCardCoupon, out msg);
                if (!canUseCardCoupon)
                {
                    resp.errcode = 1;
                    resp.errmsg  = msg;
                    context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                    return;
                }
                if (discountAmount > productFee + orderInfo.Transport_Fee)
                {
                    resp.errcode = 1;
                    resp.errmsg  = "优惠券可优惠金额超过了订单总金额";
                    context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                    return;
                }
            }
            //优惠券计算
            #endregion


            #region 积分计算
            decimal scoreExchangeAmount = 0;///积分抵扣的金额
            //积分计算
            if (orderRequestModel.use_score > 0)
            {
                if (currentUserInfo.TotalScore < orderRequestModel.use_score)
                {
                    resp.errcode = 1;
                    resp.errmsg  = "积分不足";
                    context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                    return;
                }
                ScoreConfig scoreConfig = bllScore.GetScoreConfig();
                scoreExchangeAmount = Math.Round(orderRequestModel.use_score / (scoreConfig.ExchangeScore / scoreConfig.ExchangeAmount), 2);
            }
            #region 驿氪积分同步



            #endregion


            //积分计算
            #endregion


            //合计计算
            orderInfo.Product_Fee   = productFee;
            orderInfo.TotalAmount   = orderInfo.Product_Fee + orderInfo.Transport_Fee;
            orderInfo.TotalAmount  -= discountAmount;                  //优惠券优惠金额
            orderInfo.TotalAmount  -= scoreExchangeAmount;             //积分优惠金额
            orderInfo.PayableAmount = orderInfo.TotalAmount - freight; //应付金额
            if ((productFee + orderInfo.Transport_Fee - discountAmount - scoreExchangeAmount) < orderInfo.TotalAmount)
            {
                resp.errcode = 1;
                resp.errmsg  = "积分兑换金额不能大于订单总金额,请减少积分兑换";
                context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                return;
            }



            ZentCloud.ZCBLLEngine.BLLTransaction tran = new ZCBLLEngine.BLLTransaction();
            try
            {
                if (!this.bllMall.Add(orderInfo, tran))
                {
                    tran.Rollback();
                    resp.errcode = 1;
                    resp.errmsg  = "提交失败";
                    context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                    return;
                }

                #region 更新优惠券使用状态
                //优惠券
                if (orderRequestModel.cardcoupon_id > 0 && (canUseCardCoupon == true))//有优惠券且已经成功使用
                {
                    MyCardCoupons myCardCoupon = bllCardCoupon.GetMyCardCoupon(orderRequestModel.cardcoupon_id, currentUserInfo.UserID);
                    myCardCoupon.UseDate = DateTime.Now;
                    myCardCoupon.Status  = 1;
                    if (!bllCardCoupon.Update(myCardCoupon, tran))
                    {
                        tran.Rollback();
                        resp.errcode = 1;
                        resp.errmsg  = "更新优惠券状态失败";
                        context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                        return;
                    }
                }
                //优惠券
                #endregion

                #region 积分抵扣
                //积分扣除
                if (orderRequestModel.use_score > 0)
                {
                    currentUserInfo.TotalScore -= orderRequestModel.use_score;
                    if (

                        bllMall.Update(currentUserInfo, string.Format(" TotalScore-={0}", orderRequestModel.use_score), string.Format(" AutoID={0}", currentUserInfo.AutoID)) < 0)
                    {
                        tran.Rollback();
                        resp.errcode = 1;
                        resp.errmsg  = "更新用户积分失败";
                        context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                        return;
                    }

                    //积分记录
                    WXMallScoreRecord scoreRecord = new WXMallScoreRecord();
                    scoreRecord.InsertDate   = DateTime.Now;
                    scoreRecord.OrderID      = orderInfo.OrderID;
                    scoreRecord.Score        = orderRequestModel.use_score;
                    scoreRecord.Type         = 1;
                    scoreRecord.UserId       = currentUserInfo.UserID;
                    scoreRecord.WebsiteOwner = bllMall.WebsiteOwner;
                    scoreRecord.Remark       = "积分抵扣";
                    if (!bllMall.Add(scoreRecord))
                    {
                        tran.Rollback();
                        resp.errcode = 1;
                        resp.errmsg  = "插入积分记录失败";
                        context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                        return;
                    }

                    //积分记录
                }

                //积分扣除
                #endregion

                #region 插入订单详情页及更新库存
                foreach (var item in detailList)
                {
                    ProductSku        productSku  = bllMall.GetProductSku((int)(item.SkuId));
                    WXMallProductInfo productInfo = bllMall.GetProduct(productSku.ProductId.ToString());
                    if (!this.bllMall.Add(item, tran))
                    {
                        tran.Rollback();
                        resp.errcode = 1;
                        resp.errmsg  = "提交失败";
                        context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                        return;
                    }
                    //更新 SKU库存
                    productSku.Stock -= item.TotalCount;
                    if (bllMall.IsPromotionTime(productSku))
                    {
                        productSku.PromotionStock -= item.TotalCount;
                    }
                    if (!bllMall.Update(productSku, tran))
                    {
                        tran.Rollback();
                        resp.errcode = 1;
                        resp.errmsg  = "更新SKU失败";
                        context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                        return;
                    }
                }
                #endregion
                tran.Commit();//提交订单事务
            }
            catch (Exception ex)
            {
                //回滚事物
                tran.Rollback();
                resp.errcode = 1;
                resp.errmsg  = ex.Message;
                context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                return;
            }
            context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(new
            {
                errcode  = 0,
                errmsg   = "ok",
                order_id = orderInfo.OrderID
            }));
        }
示例#17
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Expires     = 0;
            string action = context.Request["Action"];
            string result = string.Empty;

            try
            {
                this.currentUserInfo = userBll.GetCurrentUserInfo();
                switch (action)
                {
                //case "GetCodeListInfo":
                //    result = GetCodeListInfo(context);
                //    break;

                //case "GetUserInfoByOpenId":
                //    result = GetUserInfov(context);
                //    break;
                case "GetUserInfo":
                    result = GetUserInfo(context);
                    break;

                case "EditUserInfoByOpenId":
                    result = EditUserInfoV1(context);
                    break;

                case "EditUserInfo":
                    result = EditUserInfo(context);
                    break;

                case "EditUserInfoV1":
                    result = EditUserInfoV1(context);
                    break;

                //case "SendPhoneVerifyCode":
                //    result = SendPhoneVerifyCode(context);
                // break;
                case "VerifyPhone":
                    result = VerifyPhone(context);
                    break;

                //IsAllUserBaseInfo
                case "IsAllUserBaseInfo":
                    result = IsAllUserBaseInfo(context);
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                this.resp.Status = -1;
                this.resp.Msg    = "异常" + ex.Message;

                result = ZentCloud.Common.JSONHelper.ObjectToJson(this.resp);
            }

            context.Response.Write(result);
        }