예제 #1
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string DelArticle(HttpContext context)
        {
            string        ids    = context.Request["ids"];
            List <string> IdList = ids.Split(',').ToList();

            for (int i = 0; i < IdList.Count; i++)
            {
                if (string.IsNullOrWhiteSpace(IdList[i]))
                {
                    continue;
                }
                JuActivityInfo act = bll.GetJuActivity(int.Parse(IdList[i]));
                if (bll.DelArticle(IdList[i]))
                {
                    if (act.ArticleType == "Question")
                    {
                        bllUser.AddUserScoreDetail(act.UserID, EnumStringHelper.ToString(ScoreDefineType.DelQuestions), bll.WebsiteOwner, null, null);
                    }
                    else if (act.ArticleType == "Article")
                    {
                        bllUser.AddUserScoreDetail(act.UserID, EnumStringHelper.ToString(ScoreDefineType.DelArticle), bll.WebsiteOwner, null, null);
                    }
                }
            }
            resp.Status = 1;
            resp.Msg    = "删除完成";
            return(Common.JSONHelper.ObjectToJson(resp));
        }
예제 #2
0
        /// <summary>
        /// 删除回复
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string DelReview(HttpContext context)
        {
            string        ids    = context.Request["ids"];
            List <string> IdList = ids.Split(',').Distinct().ToList();

            for (int i = 0; i < IdList.Count; i++)
            {
                if (string.IsNullOrWhiteSpace(IdList[i]))
                {
                    continue;
                }
                ReviewInfo re = bllReview.GetReviewInfo(int.Parse(IdList[i]));
                if (bllReview.DelReview(IdList[i]))
                {
                    if (re.ReviewType == "Answer")
                    {
                        bllUser.AddUserScoreDetail(re.UserId, EnumStringHelper.ToString(ScoreDefineType.DelAnswer), bll.WebsiteOwner, null, null);
                    }
                    else if (re.ReviewType == "ArticleComment" || re.ReviewType == "CommentReply")
                    {
                        bllUser.AddUserScoreDetail(re.UserId, EnumStringHelper.ToString(ScoreDefineType.DelReview), bll.WebsiteOwner, null, null);
                    }
                }
            }
            resp.Status = 1;
            resp.Msg    = "删除完成";
            return(Common.JSONHelper.ObjectToJson(resp));
        }
예제 #3
0
파일: Delete.ashx.cs 프로젝트: uvbs/mmp
        public void ProcessRequest(HttpContext context)
        {
            string ids = context.Request["ids"];

            if (string.IsNullOrWhiteSpace(ids))
            {
                resp.errcode = (int)APIErrCode.OperateFail;
                resp.errmsg  = "ids不能为空";
                bllKeyValueData.ContextResponse(context, resp);
                return;
            }
            List <KeyVauleDataInfo> dataList = bllKeyValueData.GetListByKey <KeyVauleDataInfo>("AutoId", ids);

            try
            {
                foreach (var item in dataList)
                {
                    bllKeyValueData.DeleteDataVaule(EnumStringHelper.ToString(KeyVauleDataType.WXTmplmsgData), null, item.DataKey, item.WebsiteOwner);
                    bllKeyValueData.DeleteDataVaule(EnumStringHelper.ToString(KeyVauleDataType.WXTmplmsg), item.DataKey, item.WebsiteOwner);
                }
                resp.errcode   = (int)APIErrCode.IsSuccess;
                resp.isSuccess = true;
            }
            catch (Exception ex)
            {
                resp.errcode = (int)APIErrCode.OperateFail;
                resp.errmsg  = ex.Message;
            }
            bllKeyValueData.ContextResponse(context, resp);
        }
예제 #4
0
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string Login(HttpContext context)
        {
            Login  apiResult = new Login();
            string userName  = context.Request["userid"];
            string pwd       = context.Request["pwd"];
            string msg;

            string hasCheckCode    = context.Request["hascheckcode"];
            string checkCode       = context.Request["checkcode"];
            object serverCheckCode = context.Session["CheckCode"];

            if (!string.IsNullOrWhiteSpace(hasCheckCode) && hasCheckCode == "1" && serverCheckCode != null)
            {
                if (
                    string.IsNullOrWhiteSpace(checkCode)
                    ||
                    !checkCode.Equals(serverCheckCode.ToString(), StringComparison.OrdinalIgnoreCase)
                    )
                {
                    apiResult.message = "验证码错误";
                    apiResult.errcode = (int)BLLJIMP.Enums.APIErrCode.CheckCodeErr;
                    return(Common.JSONHelper.ObjectToJson(apiResult));
                }
            }

            UserInfo userInfo = new UserInfo();

            if (bllUser.Login(userName, pwd, out userInfo, out msg, this.webSiteOwner))
            {
                if (DateTime.Now.ToString("yyyy-MM-dd") != userInfo.LastLoginDate.ToString("yyyy-MM-dd"))
                {
                    bllUser.AddUserScoreDetail(userInfo.UserID, EnumStringHelper.ToString(ScoreDefineType.DayLogin), this.webSiteOwner, null, null);
                }
                bllUser.UpdateLoginInfo(userInfo);

                context.Session[SessionKey.LoginStatu] = 1;
                context.Session[SessionKey.UserID]     = userInfo.UserID;

                //绑定微信
                BindWXUser(context, userInfo.UserID);

                apiResult.issuccess = true;
                apiResult.userid    = userInfo.UserID;
                apiResult.headimg   = this.bllUser.GetUserDispalyAvatar(userInfo);
                apiResult.userName  = this.bllUser.GetUserDispalyName(userInfo);
                apiResult.avatar    = this.bllUser.GetUserDispalyAvatar(userInfo);
                apiResult.phone     = userInfo.Phone;
                apiResult.id        = userInfo.AutoID;
                apiResult.score     = userInfo.TotalScore;
                apiResult.im_token  = userInfo.IMToken;
            }
            else
            {
                apiResult.errcode = (int)BLLJIMP.Enums.APIErrCode.OperateFail;
                apiResult.message = msg;
            }
            return(Common.JSONHelper.ObjectToJson(apiResult));
        }
예제 #5
0
        public static void Add(SqlConnection connection, object param)
        {
            var sqlparams  = (object[])param;
            var parameters = new[]
            {
                new SqlParameter("@SubjectType", sqlparams[0].ToString()),
                new SqlParameter("@SubjectId", sqlparams[1].ToString()),
                new SqlParameter("@ErrorMessage", sqlparams[2].ToString()),
                new SqlParameter("@OperationUser", sqlparams[3].ToString()),
                new SqlParameter("@OperationName", sqlparams[4].ToString()),
                new SqlParameter("@MonitorLevel", (int)sqlparams[5]),
                new SqlParameter("@MonitorModule", EnumStringHelper.GetEnumDescription(sqlparams[6])),
                new SqlParameter("@OperationTime", DateTime.Now)
            };

            SqlHelper.ExecuteNonQuery(connection, CommandType.StoredProcedure, "procMonitoringOperationsAdd_V2", parameters);
        }
예제 #6
0
        private string AddScore(HttpContext context)
        {
            string userId = context.Request["UserId"];
            string type   = context.Request["Type"];
            int    score  = int.Parse(context.Request["Score"]);
            string rmk    = context.Request["Rmk"];

            score = type == "-"?0 - score:score;
            if (!bllUser.AddUserScoreDetail(userId, EnumStringHelper.ToString(ScoreDefineType.ManageUpdate), bllUser.WebsiteOwner, score, rmk))
            {
                resp.Status = -1;
                resp.Msg    = "设置失败";
                return(Common.JSONHelper.ObjectToJson(resp));
            }

            resp.Status = 1;
            resp.Msg    = "设置完成";
            return(Common.JSONHelper.ObjectToJson(resp));
        }
예제 #7
0
 public RepositoryManager(ConnectionStrings name)
 {
     connectionString = EnumStringHelper.GetEnumDescription(name);
 }
예제 #8
0
        /// <summary>
        /// 律师注册
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string LawyerRegister(HttpContext context)
        {
            string pId     = context.Request["pId"];
            string name    = context.Request["name"];
            string email   = context.Request["email"];
            string pwd     = context.Request["pwd"];
            string verCode = context.Request["vercode"];

            object serverCheckCode = context.Session["CheckCode"];

            if (!CheckRegister(name, email, pwd, verCode, serverCheckCode))
            {
                return(Common.JSONHelper.ObjectToJson(resp));
            }
            string company        = context.Request["company"];
            string position       = context.Request["postion"];
            string idCardNo       = context.Request["idCardNo"];//身份证
            string phone          = context.Request["phone"];
            string tel            = context.Request["tel"];
            string province       = context.Request["province"];
            string city           = context.Request["city"];
            string avatar         = context.Request["avatar"];
            string licensePhoto   = context.Request["licensePhoto"];
            string companyAddress = context.Request["companyaddress"];

            string IDPhoto1        = context.Request["IDPhoto1"];
            string IDPhoto2        = context.Request["IDPhoto2"];
            string IsSHowInfo      = context.Request["IsSHowInfo"];
            string LawyerLicenseNo = context.Request["LawyerLicenseNo"];


            if (!CheckLawyerRegister(company, idCardNo, position, phone, tel, province, city, licensePhoto, companyAddress))
            {
                return(Common.JSONHelper.ObjectToJson(resp));
            }
            if (string.IsNullOrWhiteSpace(IDPhoto1))
            {
                resp.errcode = 20;
                resp.errmsg  = "请上传身份证照片!";
                return(Common.JSONHelper.ObjectToJson(resp));
            }
            if (string.IsNullOrWhiteSpace(IDPhoto2))
            {
                resp.errcode = 21;
                resp.errmsg  = "请上传身份证照片!";
                return(Common.JSONHelper.ObjectToJson(resp));
            }
            if (string.IsNullOrWhiteSpace(avatar))
            {
                resp.errcode = 22;
                resp.errmsg  = "请上传您的免冠照!";
                return(Common.JSONHelper.ObjectToJson(resp));
            }
            UserInfo regUser = new UserInfo();

            regUser.UserID       = string.Format("WebPC{0}{1}", ZentCloud.Common.StringHelper.GetDateTimeNum(), ZentCloud.Common.Rand.Str(5));//WXUser+时间字符串+随机5位数字
            regUser.TrueName     = name;
            regUser.Email        = email;
            regUser.Password     = pwd;
            regUser.Company      = company;
            regUser.Postion      = position;
            regUser.Phone        = phone;
            regUser.WXHeadimgurl = avatar;

            regUser.ProvinceCode = province;
            if (!string.IsNullOrWhiteSpace(province))
            {
                regUser.Province = bllKeyValueData.GetDataDefVaule("Province", province);
            }
            regUser.CityCode = city;
            if (!string.IsNullOrWhiteSpace(city))
            {
                regUser.City = bllKeyValueData.GetDataDefVaule("City", city);
            }

            regUser.WebsiteOwner = this.webSiteOwner;
            regUser.UserType     = 4;
            regUser.Regtime      = DateTime.Now;
            string ip = ZentCloud.Common.MySpider.GetClientIP();

            regUser.RegIP           = ip;
            regUser.LastLoginIP     = ip;
            regUser.LastLoginDate   = DateTime.Now;
            regUser.LoginTotalCount = 1;

            if (bllUser.Add(regUser))
            {
                bllUser.AddUserScoreDetail(regUser.UserID, EnumStringHelper.ToString(ScoreDefineType.Register), this.webSiteOwner, null, null);
                if (!string.IsNullOrWhiteSpace(pId))
                {
                    string   pUserId   = MySpider.Base64Change.DecodeBase64(pId);
                    UserInfo shareUser = bllUser.GetUserInfo(pUserId);
                    if (shareUser != null)
                    {
                        bllUser.AddUserScoreDetail(regUser.UserID, EnumStringHelper.ToString(ScoreDefineType.RegisterFromShare), this.webSiteOwner, null, null);
                        bllUser.AddUserScoreDetail(shareUser.UserID, EnumStringHelper.ToString(ScoreDefineType.ShareRegister), this.webSiteOwner, null, null);
                    }
                }
                bllUserExpand.AddUserExpand(UserExpandType.IdCardNo, regUser.UserID, idCardNo);
                bllUserExpand.AddUserExpand(UserExpandType.UserTel, regUser.UserID, tel);
                bllUserExpand.AddUserExpand(UserExpandType.UserCompanyAddress, regUser.UserID, companyAddress);
                bllUserExpand.AddUserExpand(UserExpandType.LawyerLicensePhoto, regUser.UserID, licensePhoto);
                bllUserExpand.AddUserExpand(UserExpandType.IDPhoto1, regUser.UserID, IDPhoto1);
                bllUserExpand.AddUserExpand(UserExpandType.IDPhoto2, regUser.UserID, IDPhoto2);
                bllUserExpand.AddUserExpand(UserExpandType.IsSHowInfo, regUser.UserID, IsSHowInfo);
                bllUserExpand.AddUserExpand(UserExpandType.LawyerLicenseNo, regUser.UserID, LawyerLicenseNo);

                context.Session[SessionKey.LoginStatu] = 1;
                context.Session[SessionKey.UserID]     = regUser.UserID;

                //绑定微信
                BindWXUser(context, regUser.UserID);

                return(Common.JSONHelper.ObjectToJson(new
                {
                    isSuccess = true,
                    user = new
                    {
                        id = bllUser.GetUserAutoID(regUser.UserID),
                        userid = regUser.UserID,
                        userName = this.bllUser.GetUserDispalyName(regUser),
                        avatar = this.bllUser.GetUserDispalyAvatar(regUser)
                    }
                }));
            }
            else
            {
                resp.errcode = 999;
                resp.errmsg  = "注册失败";
            }
            return(Common.JSONHelper.ObjectToJson(resp));
        }
예제 #9
0
        /// <summary>
        /// 用户注册
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string UserRegister(HttpContext context)
        {
            string pId             = context.Request["pId"];
            string name            = context.Request["name"];
            string email           = context.Request["email"];
            string pwd             = context.Request["pwd"];
            string verCode         = context.Request["vercode"];
            object serverCheckCode = context.Session["CheckCode"];
            string IsSHowInfo      = context.Request["IsSHowInfo"];

            if (!CheckRegister(name, email, pwd, verCode, serverCheckCode))
            {
                return(Common.JSONHelper.ObjectToJson(resp));
            }
            UserInfo regUser = new UserInfo();

            regUser.UserID       = string.Format("WebPC{0}{1}", ZentCloud.Common.StringHelper.GetDateTimeNum(), ZentCloud.Common.Rand.Str(5));//WXUser+时间字符串+随机5位数字
            regUser.TrueName     = name;
            regUser.Email        = email;
            regUser.Password     = pwd;
            regUser.WebsiteOwner = this.webSiteOwner;
            regUser.UserType     = 2;
            regUser.Regtime      = DateTime.Now;
            string ip = ZentCloud.Common.MySpider.GetClientIP();

            regUser.RegIP           = ip;
            regUser.LastLoginIP     = ip;
            regUser.LastLoginDate   = DateTime.Now;
            regUser.LoginTotalCount = 1;

            if (bllUser.Add(regUser))
            {
                context.Session[SessionKey.LoginStatu] = 1;
                context.Session[SessionKey.UserID]     = regUser.UserID;
                bllUser.AddUserScoreDetail(regUser.UserID, EnumStringHelper.ToString(ScoreDefineType.Register), this.webSiteOwner, null, null);

                if (!string.IsNullOrWhiteSpace(pId))
                {
                    string   pUserId   = MySpider.Base64Change.DecodeBase64(pId);
                    UserInfo shareUser = bllUser.GetUserInfo(pUserId);
                    if (shareUser != null)
                    {
                        bllUser.AddUserScoreDetail(regUser.UserID, EnumStringHelper.ToString(ScoreDefineType.RegisterFromShare), this.webSiteOwner, null, null);
                        bllUser.AddUserScoreDetail(shareUser.UserID, EnumStringHelper.ToString(ScoreDefineType.ShareRegister), this.webSiteOwner, null, null);
                    }
                    bllUserExpand.AddUserExpand(BLLJIMP.Enums.UserExpandType.IsSHowInfo, regUser.UserID, IsSHowInfo);
                }

                //绑定微信
                BindWXUser(context, regUser.UserID);
                return(Common.JSONHelper.ObjectToJson(new
                {
                    isSuccess = true,
                    user = new
                    {
                        id = bllUser.GetUserAutoID(regUser.UserID),
                        userid = regUser.UserID,
                        userName = this.bllUser.GetUserDispalyName(regUser),
                        avatar = this.bllUser.GetUserDispalyAvatar(regUser)
                    }
                }));
            }
            else
            {
                resp.errcode = (int)BLLJIMP.Enums.APIErrCode.RegisterFailure;
                resp.errmsg  = "注册失败";
            }
            return(Common.JSONHelper.ObjectToJson(resp));
        }
예제 #10
0
파일: List.ashx.cs 프로젝트: uvbs/mmp
        public void ProcessRequest(HttpContext context)
        {
            int pageIndex  = Convert.ToInt32(context.Request["page"]);
            int pageSize   = Convert.ToInt32(context.Request["rows"]);
            int totalCount = 0;
            List <KeyVauleDataInfo> dataList = bllKeyValueData.GetKeyVauleDataInfoList(pageSize, pageIndex, EnumStringHelper.ToString(KeyVauleDataType.WXTmplmsg), null, bllKeyValueData.WebsiteOwner, out totalCount);

            resp.isSuccess = true;
            resp.returnObj = new
            {
                totalcount = totalCount,
                list       = (from p in dataList
                              select new {
                    id = p.AutoId,
                    data_key = p.DataKey,
                    data_value = p.DataValue
                })
            };
            bllKeyValueData.ContextResponse(context, resp);
        }
예제 #11
0
        public void ProcessRequest(HttpContext context)
        {
            string articleId      = context.Request["activity_id"];
            string content        = context.Request["content"];
            var    replyId        = Convert.ToInt32(context.Request["reply_id"]);//评论了文章里的哪个评论
            int    isHideUserName = Convert.ToInt32(context.Request["is_hide_user_name"]);

            resp.isSuccess = false;
            if (string.IsNullOrWhiteSpace(articleId) || string.IsNullOrWhiteSpace(content))
            {
                resp.errcode = (int)BLLJIMP.Enums.APIErrCode.PrimaryKeyIncomplete;
                resp.errmsg  = "activity_id、content 为必填项,请检查";
                context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                return;
            }
            if (bllJuActivity.GetCount <JuActivityInfo>(string.Format(" WebsiteOwner='{0}' AND  JuActivityID = {1} ", bllJuActivity.WebsiteOwner, articleId)) == 0)
            {
                resp.errcode = (int)BLLJIMP.Enums.APIErrCode.IsNotFound;
                resp.errmsg  = "不存在活动";
                context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                return;
            }
            //敏感词检查
            string errmsg = "";

            if (!bllFilterWord.CheckFilterWord(content, this.bllJuActivity.WebsiteOwner, out errmsg, "0"))
            {
                resp.errmsg  = errmsg;
                resp.errcode = (int)BLLJIMP.Enums.APIErrCode.OperateFail;
                context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                return;
            }
            //添加评论
            int            reviewId = 0;
            JuActivityInfo article  = bllJuActivity.GetJuActivity(int.Parse(articleId), true);

            BLLJIMP.Enums.ReviewTypeKey reviewType = BLLJIMP.Enums.ReviewTypeKey.ArticleComment;
            if (article.ArticleType == "Question")
            {
                reviewType = BLLJIMP.Enums.ReviewTypeKey.Answer;
            }
            if (article.ArticleType == "Appointment")
            {
                reviewType = BLLJIMP.Enums.ReviewTypeKey.AppointmentComment;
            }
            var addResult = bllReview.AddReview(reviewType, articleId, replyId, this.CurrentUserInfo.UserID, "评论", content, this.bllJuActivity.WebsiteOwner, out reviewId, isHideUserName);

            if (addResult)
            {
                if (reviewType == BLLJIMP.Enums.ReviewTypeKey.Answer)
                {
                    bllUser.AddUserScoreDetail(this.CurrentUserInfo.UserID, EnumStringHelper.ToString(ScoreDefineType.AnswerQuestions), this.bllJuActivity.WebsiteOwner, null, null);
                }
                resp.isSuccess   = true;
                resp.returnValue = reviewId.ToString();

                if (article.ArticleType == "Question")
                {
                    bllSystemNotice.SendNotice(BLLJIMP.BLLSystemNotice.NoticeType.QuestionIsAnswered, this.CurrentUserInfo, article, article.UserID, content);
                    List <UserInfo> users = bllUser.GetRelationUserList(BLLJIMP.Enums.CommRelationType.JuActivityFollow, articleId);
                    bllSystemNotice.SendNotice(BLLJIMP.BLLSystemNotice.NoticeType.FollowQuestionIsAnswered, this.CurrentUserInfo, article, users, content);
                }
            }
            else
            {
                resp.errcode   = (int)BLLJIMP.Enums.APIErrCode.OperateFail;
                resp.isSuccess = false;
            }
            context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
        }
예제 #12
0
        public void ProcessRequest(HttpContext context)
        {
            string id          = context.Request["id"];
            string type        = context.Request["type"];
            string content     = context.Request["content"];
            string articleName = context.Request["article_name"];
            string moduleName  = "积分";

            if (!string.IsNullOrWhiteSpace(context.Request["module_name"]))
            {
                moduleName = context.Request["module_name"];
            }
            UserInfo toUser = bllUser.GetUserInfoByAutoID(Convert.ToInt32(id), bll.WebsiteOwner);

            if (toUser == null)
            {
                apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound;
                apiResp.msg  = "通知对象未找到";
                bll.ContextResponse(context, apiResp);
                return;
            }

            if (type == "2") // 收费短信通知
            {
                string sendNoticePrice = bllKeyValueData.GetDataVaule("SendNoticePrice", "1", bllKeyValueData.WebsiteOwner);
                if (string.IsNullOrWhiteSpace(sendNoticePrice))
                {
                    apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound;
                    apiResp.msg  = "未配置短信消费" + moduleName;
                    bll.ContextResponse(context, apiResp);
                    return;
                }
                if (string.IsNullOrWhiteSpace(toUser.Phone))
                {
                    apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound;
                    apiResp.msg  = "通知对象的手机未找到";
                    bll.ContextResponse(context, apiResp);
                    return;
                }
                int sendNoticePriceNum = Convert.ToInt32(sendNoticePrice);
                if (CurrentUserInfo.TotalScore < sendNoticePriceNum)
                {
                    apiResp.code = (int)BLLJIMP.Enums.APIErrCode.OperateFail;
                    apiResp.msg  = moduleName + "不足";
                    bll.ContextResponse(context, apiResp);
                    return;
                }

                bool sendSmsResult = false;

                string smsMsg = "您的";
                if (!string.IsNullOrEmpty(articleName))
                {
                    smsMsg += "《" + articleName + "》有最新提醒:" + content + "   提醒人:" + bllUser.GetUserDispalyName(CurrentUserInfo);
                }


                string verCode      = new Random().Next(111111, 999999).ToString();
                string msg          = "";
                string smsSignature = string.Format("{0}", bllSms.GetWebsiteInfoModelFromDataBase().SmsSignature);//短信签名

                bllSms.SendSmsMisson(toUser.Phone, smsMsg, DateTime.Now.ToString(), smsSignature, out sendSmsResult, out msg);
                if (sendSmsResult)
                {
                    bllUser.AddUserScoreDetail(CurrentUserInfo.UserID, EnumStringHelper.ToString(ScoreDefineType.SendMessage), bll.WebsiteOwner, (0 - sendNoticePriceNum), string.Format("短信通知消耗{0}{1}", sendNoticePriceNum, moduleName));

                    apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.IsSuccess;
                    apiResp.msg    = "短信发送成功";
                    apiResp.status = true;
                }
                else
                {
                    apiResp.code = (int)BLLJIMP.Enums.APIErrCode.OperateFail;
                    apiResp.msg  = "短信发送失败," + msg;
                }
            }
            else
            {
                BLLJIMP.Model.SystemNotice notice = new BLLJIMP.Model.SystemNotice();
                notice.InsertTime   = DateTime.Now;
                notice.UserId       = CurrentUserInfo.UserID;
                notice.Receivers    = toUser.UserID;
                notice.WebsiteOwner = bll.WebsiteOwner;
                notice.NoticeType   = (int)BLLSystemNotice.NoticeType.Message;
                notice.SendType     = 2;
                notice.Ncontent     = bll.GetContentHtml(BLLSystemNotice.NoticeType.Message, CurrentUserInfo, null, content);
                notice.SerialNum    = bll.GetGUID(TransacType.SendSystemNotice);
                bool addResult = bll.Add(notice);
                if (addResult)
                {
                    apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.IsSuccess;
                    apiResp.msg    = "通知发送成功";
                    apiResp.status = true;
                }
                else
                {
                    apiResp.code = (int)BLLJIMP.Enums.APIErrCode.OperateFail;
                    apiResp.msg  = "通知发送失败";
                }
            }
            bll.ContextResponse(context, apiResp);
        }
예제 #13
0
파일: Get.ashx.cs 프로젝트: uvbs/mmp
        public void ProcessRequest(HttpContext context)
        {
            string           AutoId            = context.Request["id"];
            KeyVauleDataInfo KeyVauleDataModel = bllKeyValueData.GetByKey <KeyVauleDataInfo>("AutoId", AutoId);

            if (KeyVauleDataModel == null)
            {
                resp.errcode = (int)APIErrCode.OperateFail;
                resp.errmsg  = "模板没有找到";
                bllKeyValueData.ContextResponse(context, resp);
                return;
            }
            List <KeyVauleDataInfo> oldFieldList = bllKeyValueData.GetKeyVauleDataInfoList(EnumStringHelper.ToString(KeyVauleDataType.WXTmplmsgData), KeyVauleDataModel.DataKey
                                                                                           , KeyVauleDataModel.WebsiteOwner);

            resp.isSuccess = true;
            resp.returnObj = new
            {
                id         = KeyVauleDataModel.AutoId,
                data_key   = KeyVauleDataModel.DataKey,
                data_value = KeyVauleDataModel.DataValue,
                child_list = (from p in oldFieldList
                              select new
                {
                    data_key = p.DataKey,
                    data_value = p.DataValue
                })
            };
            bllKeyValueData.ContextResponse(context, resp);
        }
예제 #14
0
파일: AWARDAPI.ashx.cs 프로젝트: uvbs/mmp
        /// <summary>
        /// 抽奖
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string Scratch(HttpContext context)
        {
            try
            {
                if (!bll.IsLogin)
                {
                    return("请先登录");
                }
                string id = context.Request["id"];
                if (string.IsNullOrEmpty(id))
                {
                    return("id必传");
                }

                /*
                 * 检查是否是签到抽奖,是则:
                 * 1.当前是否是在周日,不在周日则不能抽奖
                 * 2.如果在周日,检查是否一周内有签到记录,否则不能抽奖
                 *
                 */

                var signInModel = new BLLJIMP.BLLSignIn().Get <SignInAddress>(string.Format(" WebsiteOwner='{0}' AND Type='Sign' ", currentUserInfo.WebsiteOwner));
                if (signInModel != null && signInModel.LotteryId == id)
                {
                    var dt = DateTime.Now;

                    if (dt.DayOfWeek != DayOfWeek.Sunday)
                    {
                        return("周日才可以抽奖");
                    }

                    //获取本周签到记录,倒退七天是否有七条
                    var signInCount = bll.GetCount <SignInLog>(string.Format("  cast(SignInDate as date) between '{0}' and '{1}' and  WebsiteOwner = '{2}' and UserID = '{3}' ",
                                                                             dt.AddDays(-6).ToString("yyyy-MM-dd"),
                                                                             dt.ToString("yyyy-MM-dd"),
                                                                             currentUserInfo.WebsiteOwner,
                                                                             currentUserInfo.UserID
                                                                             ));

                    if (signInCount < 7)
                    {
                        return("一周连续签到才可以抽奖");
                    }
                }

                #region 检查是否可以继续
                ScratchJsonModel apiResult = new ScratchJsonModel();
                apiResult.awardName = "谢谢参与";
                WXLotteryV1 model = bll.Get <WXLotteryV1>(string.Format("LotteryID={0}", id));
                if (model == null)
                {
                    goto outoff;
                }
                apiResult.awardId = model.LotteryID;
                apiResult.isStart = model.Status == 1 ? true : false;
                if (model.StartTime != null)
                {
                    apiResult.startTime = model.StartTime.Value.ToString("yyyy/MM/dd HH:mm:ss");
                    if (model.StartTime <= DateTime.Now)//已经到了开奖时间了
                    {
                        if (model.Status == 1)
                        {
                            apiResult.isStart = true;
                        }
                        else
                        {
                            apiResult.errorCode = (int)BLLJIMP.Enums.APIErrCode.NotStart;
                            apiResult.awardName = "刮奖未开启";
                            apiResult.isStart   = false;
                        }
                    }
                    else//开奖时间还没到
                    {
                        apiResult.errorCode = (int)BLLJIMP.Enums.APIErrCode.NotStart;
                        apiResult.awardName = "未到刮奖时间";
                        apiResult.isStart   = false;
                        goto outoff;
                    }
                }

                //检查结束时间
                if (model.EndTime != null)
                {
                    apiResult.startTime = model.EndTime.Value.ToString("yyyy/MM/dd HH:mm:ss");
                    if (model.EndTime.Value <= DateTime.Now)
                    {
                        apiResult.errorCode = (int)BLLJIMP.Enums.APIErrCode.IsEnd;
                        apiResult.awardName = "已结束";
                        apiResult.isStart   = false;
                        goto outoff;
                    }
                }

                if (context.Request["hideAward"] != "1")
                {
                    apiResult.winRecord = bll.GetWXLotteryRecordList(model.LotteryID, currentUserInfo.UserID);
                }
                if (model.WinLimitType.Equals(0))
                {
                    var lotteryRecord = bll.GetWXLotteryRecordV1(currentUserInfo.UserID, model.LotteryID);
                    if (lotteryRecord != null)
                    {
                        if (context.Request["hideAward"] != "1")
                        {
                            WXLotteryLogV1 logWinLimit = new WXLotteryLogV1();
                            logWinLimit.LotteryId  = model.LotteryID;
                            logWinLimit.UserId     = currentUserInfo.UserID;
                            logWinLimit.InsertDate = DateTime.Now;
                            logWinLimit.IP         = Common.MySpider.GetClientIP();
                            if (bll.AddWXLotteryLogV1(logWinLimit))//下一步
                            {
                            }

                            apiResult.awardName = string.Format("{0}", lotteryRecord.WXAwardName);
                            apiResult.isAward   = true;

                            //告诉前端你已经中过奖了
                            apiResult.errorCode = (int)BLLJIMP.Enums.APIErrCode.LotteryHaveRecord;; //LotteryHaveRecord
                        }
                        goto outoff;
                    }
                }

                if (!apiResult.isStart)
                {
                    apiResult.errorCode = (int)BLLJIMP.Enums.APIErrCode.NotStart;
                    apiResult.awardName = "刮奖未开启";
                    apiResult.isStart   = false;
                    goto outoff;
                }
                #endregion

                #region 内定中奖
                List <WXLotteryWinningDataV1> winData = bll.GetList <WXLotteryWinningDataV1>(string.Format("LotteryId={0}", model.LotteryID));
                if (winData.SingleOrDefault(p => p.UserId.Equals(currentUserInfo.UserID)) != null)
                {
                    //给默认中奖者中奖
                    WXLotteryRecordV1 record = new WXLotteryRecordV1();
                    record.InsertDate = DateTime.Now;
                    record.LotteryId  = model.LotteryID;
                    record.Token      = "0";
                    record.WXAwardsId = winData.Single(p => p.UserId.Equals(currentUserInfo.UserID)).WXAwardsId;
                    record.UserId     = currentUserInfo.UserID;
                    record.IsGetPrize = 0;
                    if (bll.AddWXLotteryRecordV1(record))
                    {
                        apiResult.awardName = string.Format("{0}", winData.Single(p => p.UserId.Equals(currentUserInfo.UserID)).WXAwardName);
                        apiResult.isAward   = true;
                    }

                    goto outoff;
                }
                //设置默认中奖
                #endregion

                #region 外部积分读取
                var isSyncYike = new BLLJIMP.BLLCommRelation().ExistRelation(BLLJIMP.Enums.CommRelationType.SyncYike, currentUserInfo.WebsiteOwner, "");

                Open.EZRproSDK.Client zrClient = new Open.EZRproSDK.Client();

                if (isSyncYike)
                {
                    var getBonusResp = zrClient.GetBonus(currentUserInfo.Ex1, currentUserInfo.Ex2, currentUserInfo.Phone);
                    if (getBonusResp != null)
                    {
                        currentUserInfo.TotalScore = getBonusResp.Bonus;
                    }
                    else
                    {
                        currentUserInfo.TotalScore = 0;
                    }
                }
                #endregion


                #region 使用宏巍积分

                Open.HongWareSDK.Client hongWareClient = new Open.HongWareSDK.Client(websiteInfo.WebsiteOwner);
                if (websiteInfo.IsUnionHongware == 1)
                {
                    var hongWareMemberInfo = hongWareClient.GetMemberInfo(currentUserInfo.WXOpenId);
                    if (hongWareMemberInfo.member != null)
                    {
                        currentUserInfo.TotalScore = hongWareMemberInfo.member.point;
                    }
                    else
                    {
                        currentUserInfo.TotalScore = 0;
                    }
                }
                #endregion

                string tempMsg = "";
                #region 抽奖限制 总共多少次或每天几次  用购买的刮奖次数除外

                #region 总共多少次
                if (model.LuckLimitType.Equals(0))//总共多少次
                {
                    int count = bll.GetWXLotteryLogCountV1(model.LotteryID, currentUserInfo.UserID);
                    if (count >= model.MaxCount)
                    {
                        //判读是否够积分
                        if (model.UsePoints > 0)
                        {
                            if (currentUserInfo.TotalScore >= model.UsePoints)
                            {
                                //扣积分
                                if (isSyncYike)
                                {
                                    var resp = zrClient.BonusUpdate(currentUserInfo.Ex2, -model.UsePoints, "抽奖减少积分");
                                }
                                else
                                {
                                    bllUser.AddUserScoreDetail(currentUserInfo.UserID, EnumStringHelper.ToString(ScoreDefineType.Lottery), bllUser.WebsiteOwner, out tempMsg, -model.UsePoints, "抽奖减少积分", "", false);
                                }
                            }
                            else
                            {
                                if (currentUserInfo.LotteryCount == 0)
                                {
                                    apiResult.errorCode = (int)BLLJIMP.Enums.APIErrCode.IntegralProblem;
                                    apiResult.awardName = "积分不足";
                                    apiResult.isStart   = false;
                                    goto outoff;
                                }
                                else
                                {
                                    //剩余刮奖次数减1
                                    if (bll.Update(currentUserInfo, string.Format(" LotteryCount-=1"), string.Format("AutoId={0}", currentUserInfo.AutoID)) <= 0)
                                    {
                                        apiResult.errorCode = (int)BLLJIMP.Enums.APIErrCode.IntegralProblem;
                                        apiResult.awardName = "谢谢参与";
                                        apiResult.isStart   = false;
                                        goto outoff;
                                    }
                                }
                            }
                        }
                        else
                        {
                            apiResult.errorCode = (int)BLLJIMP.Enums.APIErrCode.CountIsOver;
                            apiResult.awardName = "谢谢参与";
                            goto outoff;
                        }
                    }
                }
                #endregion

                #region 每天多少次
                else
                {
                    //判读一天有没有超出
                    int count = bll.GetWXLotteryLogCountV1(model.LotteryID, currentUserInfo.UserID, DateTime.Now);
                    if (count >= model.MaxCount)
                    {
                        //判读是否够积分
                        if (model.UsePoints > 0)
                        {
                            if (currentUserInfo.TotalScore >= model.UsePoints)
                            {
                                if (isSyncYike)
                                {
                                    var resp = zrClient.BonusUpdate(currentUserInfo.Ex2, -model.UsePoints, "抽奖减少积分");
                                }
                                else
                                {
                                    //扣积分
                                    bllUser.AddUserScoreDetail(currentUserInfo.UserID, EnumStringHelper.ToString(ScoreDefineType.Lottery), bllUser.WebsiteOwner, out tempMsg, -model.UsePoints, "抽奖减少积分", "", false);
                                }
                            }
                            else
                            {
                                if (currentUserInfo.LotteryCount == 0)
                                {
                                    apiResult.errorCode = (int)BLLJIMP.Enums.APIErrCode.IntegralProblem;
                                    apiResult.awardName = "积分不足";
                                    apiResult.isStart   = false;
                                    goto outoff;
                                }
                                else
                                {
                                    //剩余刮奖次数减1
                                    if (bll.Update(currentUserInfo, string.Format(" LotteryCount-=1"), string.Format("AutoId={0}", currentUserInfo.AutoID)) <= 0)
                                    {
                                        apiResult.errorCode = (int)BLLJIMP.Enums.APIErrCode.IntegralProblem;
                                        apiResult.awardName = "谢谢参与";
                                        apiResult.isStart   = false;
                                        goto outoff;
                                    }
                                }
                            }
                        }
                        else
                        {
                            apiResult.errorCode = (int)BLLJIMP.Enums.APIErrCode.CountIsOver;
                            apiResult.awardName = "谢谢参与";
                            goto outoff;
                        }
                    }
                }
                #endregion

                #endregion

                WXLotteryLogV1 log = new WXLotteryLogV1();
                log.LotteryId  = model.LotteryID;
                log.UserId     = currentUserInfo.UserID;
                log.InsertDate = DateTime.Now;
                log.IP         = Common.MySpider.GetClientIP();
                if (bll.AddWXLotteryLogV1(log))//下一步
                {
                    #region 奖池生成
                    List <AwardModel> awardModelList = new List <AwardModel>();                                                             //奖池
                    List <WXAwardsV1> awardsList     = bll.GetAwardsListV1(model.LotteryID).Where(p => p.WinCount < p.PrizeCount).ToList(); //奖品列表 //已经中完的不参与
                    foreach (var item in awardsList)
                    {
                        for (int i = 1; i <= item.Probability; i++)
                        {
                            AwardModel m = new AwardModel();
                            m.AwardID    = item.AutoID;
                            m.PrizeName  = item.PrizeName;
                            m.AwardsType = item.AwardsType;
                            m.Img        = item.Img;
                            m.Value      = item.Value;
                            awardModelList.Add(m);
                        }
                    }
                    if (awardsList.Sum(p => p.Probability) < 100)//总中奖概率小于100 补足
                    {
                        for (int i = 1; i <= (100 - (awardsList.Sum(p => p.Probability))); i++)
                        {
                            AwardModel m = new AwardModel();
                            m.AwardID   = 0;
                            m.PrizeName = "谢谢参与";
                            awardModelList.Add(m);
                        }
                    }
                    #endregion
                    //打乱数组顺序
                    awardModelList = GetRandomList <AwardModel>(awardModelList);
                    Random rand  = new Random();
                    int    index = rand.Next(0, awardModelList.Count);

                    #region 抽奖
                    if (awardModelList[index].AwardID > 0)//随机数中奖
                    {
                        string sqlUpdate = string.Format(" Update ZCJ_WXAwardsV1  Set WinCount+=1  where AutoID={0} And WinCount<PrizeCount ", awardModelList[index].AwardID);
                        if (ZentCloud.ZCBLLEngine.BLLBase.ExecuteSql(sqlUpdate) > 0)
                        {
                            int token = rand.Next(1111, 9999);
                            //插入中奖记录
                            WXLotteryRecordV1 record = new WXLotteryRecordV1();
                            record.InsertDate = DateTime.Now;
                            record.LotteryId  = model.LotteryID;
                            record.Token      = token.ToString();
                            record.WXAwardsId = awardModelList[index].AwardID;
                            record.UserId     = currentUserInfo.UserID;
                            record.IsGetPrize = 0;
                            if (bll.AddWXLotteryRecordV1(record))
                            {
                                apiResult.awardName  = string.Format("{0}", awardModelList[index].PrizeName);
                                apiResult.isAward    = true;
                                apiResult.awardsType = awardModelList[index].AwardsType;
                                apiResult.img        = awardModelList[index].Img;
                                apiResult.value      = awardModelList[index].Value;

                                if (apiResult.awardsType == 2)
                                {
                                    BLLJIMP.BLLCardCoupon bllCardCoupon = new BLLJIMP.BLLCardCoupon();

                                    var coupon = bllCardCoupon.GetCardCoupon(int.Parse(apiResult.value));
                                    apiResult.cardcoupon_name  = coupon.Name;
                                    apiResult.cardcoupon_type  = coupon.CardCouponType;
                                    apiResult.cardcoupon_start = coupon.ValidFrom == null ? "" : coupon.ValidFrom.Value.ToShortDateString();
                                    apiResult.cardcoupon_end   = coupon.ValidTo == null ? "" : coupon.ValidTo.Value.ToShortDateString();
                                    if (coupon.ExpireTimeType == "1")
                                    {
                                        apiResult.cardcoupon_start = DateTime.Now.ToShortDateString();
                                        apiResult.cardcoupon_end   = DateTime.Now.AddDays(Convert.ToInt32(coupon.ExpireDay)).ToShortDateString();
                                    }
                                }
                                if (apiResult.awardsType == 1 || apiResult.awardsType == 2)
                                {
                                    //中奖记录标记为已经领奖
                                    WXLotteryRecordV1 rec = bll.Get <WXLotteryRecordV1>(string.Format(" UserId='{0}' And LotteryId={1} And WXAwardsId={2} And Token='{3}'", record.UserId, record.LotteryId, record.WXAwardsId, record.Token));
                                    if (rec != null)
                                    {
                                        rec.IsGetPrize = 1;
                                        bll.Update(rec);
                                    }
                                }

                                goto outoff;
                            }
                            else
                            {
                                goto outoff;
                            }
                        }
                        else
                        {
                            goto outoff;
                        }

                        //}
                        //else
                        //{   //#region 虽然随机数中奖,但是奖项数量已经达到上限,重新随机抽奖
                        //    //if (reCount >= 5)
                        //    //{
                        //    goto outoff;
                        //    //}
                        //    //reCount++;
                        //    //goto start;
                        //}
                    }
                    else
                    {
                        //随机数未中奖
                    }
                    #endregion
                }
outoff:
                if (!string.IsNullOrEmpty(context.Request["callback"]))
                {
                    return(string.Format("{0}({1})", context.Request["callback"], Common.JSONHelper.ObjectToJson(apiResult)));
                }
                return(Common.JSONHelper.ObjectToJson(apiResult));
            }
            catch (Exception ex)
            {
                return(ex.ToString());
            }
        }
예제 #15
0
        public void ProcessRequest(HttpContext context)
        {
            string userName    = context.Request["userid"];
            string pwd         = context.Request["pwd"];
            string applyStatus = context.Request["applystatus"];

            BLLJIMP.Model.API.forbes.Login apiResult = new BLLJIMP.Model.API.forbes.Login();

            UserInfo userInfo = bllUser.GetUserInfo(userName);

            if (userInfo == null)
            {
                userInfo = bllUser.Get <UserInfo>(string.Format(" Phone = '{0}' AND WebsiteOwner = '{1}' ", userName, bllUser.WebsiteOwner));
            }

            if (userInfo == null)
            {
                apiResp.msg  = "用户不存在";
                apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound;
                bllUser.ContextResponse(context, apiResp);
                return;
            }

            if (!userInfo.Password.Equals(pwd))
            {
                apiResp.msg  = "密码错误!";
                apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound;
                bllUser.ContextResponse(context, apiResp);
                return;
            }

            if (!userInfo.IsDisable.Equals(0))
            {
                apiResp.msg  = "账号已被禁用!";
                apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound;
                bllUser.ContextResponse(context, apiResp);
                return;
            }
            if (!string.IsNullOrEmpty(applyStatus))
            {
                if (userInfo.MemberApplyStatus == 1)
                {
                    apiResp.msg  = "账号还在审核中!";
                    apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound;
                    bllUser.ContextResponse(context, apiResp);
                    return;
                }
                if (userInfo.MemberApplyStatus == 2)
                {
                    apiResp.msg  = "账号审核未通过!";
                    apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound;
                    bllUser.ContextResponse(context, apiResp);
                    return;
                }
            }

            if (userInfo != null)
            {
                if (DateTime.Now.ToString("yyyy-MM-dd") != userInfo.LastLoginDate.ToString("yyyy-MM-dd"))
                {
                    bllUser.AddUserScoreDetail(userInfo.UserID, EnumStringHelper.ToString(ScoreDefineType.DayLogin), bllUser.WebsiteOwner, null, null);
                }
                bllUser.UpdateLoginInfo(userInfo);

                context.Session[SessionKey.LoginStatu] = 1;
                context.Session[SessionKey.UserID]     = userInfo.UserID;

                //绑定微信

                var openId = context.Session["currWXOpenId"] == null ? "" : context.Session["currWXOpenId"].ToString();

                //用户第一次登陆微信,绑定微信账号
                if (string.IsNullOrWhiteSpace(userInfo.WXOpenId) && !string.IsNullOrWhiteSpace(openId))
                {
                    if (bllUser.UpdateUserWxOpenId(userInfo.UserID, openId, bllUser.WebsiteOwner))
                    {
                    }
                }


                apiResult.issuccess = true;
                apiResult.userid    = userInfo.UserID;
                apiResult.headimg   = this.bllUser.GetUserDispalyAvatar(userInfo);
                apiResult.userName  = this.bllUser.GetUserDispalyName(userInfo);
                apiResult.avatar    = this.bllUser.GetUserDispalyAvatar(userInfo);
                apiResult.phone     = userInfo.Phone;
                apiResult.id        = userInfo.AutoID;
                apiResult.score     = userInfo.TotalScore;
                apiResult.im_token  = userInfo.IMToken;
            }
            context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(apiResult));
        }
예제 #16
0
        /// <summary>
        /// 获取模板数据
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string GetWXTempmsg(HttpContext context)
        {
            int autoId = Convert.ToInt32(context.Request["AutoId"]);
            KeyVauleDataInfo keyValue = bllKeyValueData.GetKeyData(autoId);

            if (keyValue == null)
            {
                resp.errmsg = "模板没有找到";
                return(Common.JSONHelper.ObjectToJson(resp));
            }
            if (keyValue.WebsiteOwner != bllKeyValueData.WebsiteOwner)
            {
                resp.errmsg = "不是本站模板";
                return(Common.JSONHelper.ObjectToJson(resp));
            }

            List <KeyVauleDataInfo> fieldList = bllKeyValueData.GetKeyVauleDataInfoList(EnumStringHelper.ToString(KeyVauleDataType.WXTmplmsgData), keyValue.DataKey
                                                                                        , bllKeyValueData.WebsiteOwner);

            var fields = from p in fieldList
                         select new {
                p.DataKey,
                p.DataValue
            };

            resp.returnObj = new
            {
                keyValue.DataValue,
                keyValue.DataKey,
                keyValue.OrderBy,
                KeyFields = fields
            };
            resp.isSuccess = true;
            return(Common.JSONHelper.ObjectToJson(resp));
        }
예제 #17
0
파일: Comment.ashx.cs 프로젝트: uvbs/mmp
        public void ProcessRequest(HttpContext context)
        {
            var articleId = context.Request["articleid"];
            var content   = context.Request["content"];
            var replyId   = Convert.ToInt32(context.Request["replyid"]);//评论了文章里的哪个评论

            int isHideUserName = Convert.ToInt32(context.Request["ishideusername"]);

            currentUserInfo = bllUser.GetCurrentUserInfo();
            if (this.currentUserInfo == null)
            {
                apiResp.code = (int)BLLJIMP.Enums.APIErrCode.UserIsNotLogin;
                apiResp.msg  = "请先登录";
                bllUser.ContextResponse(context, apiResp);
                return;
            }

            if (string.IsNullOrWhiteSpace(articleId) || string.IsNullOrWhiteSpace(content))
            {
                apiResp.code = (int)BLLJIMP.Enums.APIErrCode.PrimaryKeyIncomplete;
                bllUser.ContextResponse(context, apiResp);
                return;
            }

            if (bllUser.GetCount <JuActivityInfo>(string.Format(" JuActivityID = {0} ", articleId)) == 0)
            {
                apiResp.code = (int)BLLJIMP.Enums.APIErrCode.ContentNotFound;
                bllUser.ContextResponse(context, apiResp);
                return;
            }
            //敏感词检查
            BLLFilterWord bllFilterWord = new BLLFilterWord();
            string        errmsg        = "";

            if (!bllFilterWord.CheckFilterWord(content, this.bllUser.WebsiteOwner, out errmsg, "0"))
            {
                apiResp.msg  = errmsg;
                apiResp.code = (int)BLLJIMP.Enums.APIErrCode.OperateFail;
                bllUser.ContextResponse(context, apiResp);
                return;
            }
            //添加评论
            int            reviewId = 0;
            JuActivityInfo article  = bll.GetJuActivity(int.Parse(articleId), true);

            BLLJIMP.Enums.ReviewTypeKey reviewType = BLLJIMP.Enums.ReviewTypeKey.ArticleComment;
            if (article.ArticleType == "Question")
            {
                reviewType = BLLJIMP.Enums.ReviewTypeKey.Answer;
            }
            var addResult = bllReview.AddReview(reviewType, articleId, replyId, this.currentUserInfo.UserID, "评论", content, this.bll.WebsiteOwner, out reviewId, isHideUserName);

            if (addResult)
            {
                if (reviewType == BLLJIMP.Enums.ReviewTypeKey.Answer)
                {
                    bllUser.AddUserScoreDetail(this.currentUserInfo.UserID, EnumStringHelper.ToString(ScoreDefineType.AnswerQuestions), this.bll.WebsiteOwner, null, null);
                }

                if (article.ArticleType == "Question")
                {
                    bllSystemNotice.SendNotice(BLLJIMP.BLLSystemNotice.NoticeType.QuestionIsAnswered, this.currentUserInfo, article, article.UserID, content);

                    List <UserInfo> users = bllUser.GetRelationUserList(BLLJIMP.Enums.CommRelationType.JuActivityFollow, articleId);
                    bllSystemNotice.SendNotice(BLLJIMP.BLLSystemNotice.NoticeType.FollowQuestionIsAnswered, this.currentUserInfo, article, users, content);
                }
                apiResp.status = true;
                apiResp.msg    = "评论完成";
                apiResp.result = reviewId.ToString();
                apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.IsSuccess;
            }
            else
            {
                apiResp.code = (int)BLLJIMP.Enums.APIErrCode.OperateFail;
                apiResp.msg  = "评论出错";
            }
            bllReview.ContextResponse(context, apiResp);
        }
예제 #18
0
        /// <summary>
        /// 提交模板数据
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string PostWXTempmsg(HttpContext context)
        {
            int autoId = Convert.ToInt32(context.Request["AutoId"]);
            KeyVauleDataInfo keyValue = new KeyVauleDataInfo();

            if (autoId > 0)
            {
                keyValue = bllKeyValueData.GetKeyData(autoId);
                if (keyValue == null)
                {
                    resp.errmsg = "原模板没有找到";
                    return(Common.JSONHelper.ObjectToJson(resp));
                }
                if (keyValue.WebsiteOwner != bllKeyValueData.WebsiteOwner)
                {
                    resp.errmsg = "原模板不是本站模板";
                    return(Common.JSONHelper.ObjectToJson(resp));
                }
            }
            else
            {
                keyValue.Creater      = currentUserInfo.UserID;
                keyValue.WebsiteOwner = bllKeyValueData.WebsiteOwner;
                keyValue.CreateTime   = DateTime.Now;
                keyValue.PreKey       = "0";
                keyValue.DataType     = EnumStringHelper.ToString(KeyVauleDataType.WXTmplmsg);
            }

            string oldKey = keyValue.DataKey;

            keyValue = bllKeyValueData.ConvertRequestToModel <KeyVauleDataInfo>(keyValue);
            //微信模板Id变化则清除以前的字段数据
            if (!string.IsNullOrWhiteSpace(oldKey) && oldKey != keyValue.DataKey)
            {
                bllKeyValueData.DeleteDataVaule(EnumStringHelper.ToString(KeyVauleDataType.WXTmplmsgData), null, oldKey, bllKeyValueData.WebsiteOwner);
            }

            string keyFieldsJson = context.Request["KeyFields"];
            List <KeyVauleDataInfo> newFieldList = Common.JSONHelper.JsonToModel <List <KeyVauleDataInfo> >(keyFieldsJson);//jSON 反序列化

            for (int i = 0; i < newFieldList.Count; i++)
            {
                newFieldList[i].DataType = EnumStringHelper.ToString(KeyVauleDataType.WXTmplmsgData);
            }
            List <KeyVauleDataInfo> oldFieldList = bllKeyValueData.GetKeyVauleDataInfoList(EnumStringHelper.ToString(KeyVauleDataType.WXTmplmsgData), keyValue.DataKey
                                                                                           , bllKeyValueData.WebsiteOwner);


            List <KeyVauleDataInfo> deleteFieldList = new List <KeyVauleDataInfo>();
            List <KeyVauleDataInfo> editFieldList   = new List <KeyVauleDataInfo>();
            List <KeyVauleDataInfo> addFieldList    = new List <KeyVauleDataInfo>();

            foreach (KeyVauleDataInfo item in oldFieldList)
            {
                KeyVauleDataInfo temp = newFieldList.FirstOrDefault(p => p.DataType == item.DataType && p.DataKey == item.DataKey);
                if (temp == null)
                {
                    deleteFieldList.Add(item);
                }
                else
                {
                    item.DataValue = temp.DataValue;
                    item.OrderBy   = temp.OrderBy;
                    editFieldList.Add(item);
                }
            }

            foreach (KeyVauleDataInfo item in newFieldList)
            {
                if (!oldFieldList.Exists(p => p.DataType == item.DataType && p.DataKey == item.DataKey))
                {
                    item.Creater      = currentUserInfo.UserID;
                    item.WebsiteOwner = bllKeyValueData.WebsiteOwner;
                    item.CreateTime   = DateTime.Now;
                    item.PreKey       = keyValue.DataKey;
                    addFieldList.Add(item);
                }
            }

            if (deleteFieldList.Count > 0)
            {
                string delIds = Common.MyStringHelper.ListToStr(deleteFieldList.Select(p => p.AutoId).ToList(), "", ",");
                bllKeyValueData.DeleteDataVaule(delIds);
            }

            BLLTransaction tran = new BLLTransaction();//事务

            try
            {
                if (keyValue.AutoId == 0)
                {
                    if (!bllKeyValueData.Add(keyValue, tran))
                    {
                        resp.errmsg = "添加模板失败";
                        tran.Rollback();
                        return(Common.JSONHelper.ObjectToJson(resp));
                    }
                }
                else
                {
                    if (!bllKeyValueData.Update(keyValue, tran))
                    {
                        resp.errmsg = "修改模板失败";
                        tran.Rollback();
                        return(Common.JSONHelper.ObjectToJson(resp));
                    }
                }

                foreach (KeyVauleDataInfo item in editFieldList)//添加问题表
                {
                    if (!bllKeyValueData.Update(item, tran))
                    {
                        resp.errmsg = "模板字段修改失败";
                        tran.Rollback();
                        return(Common.JSONHelper.ObjectToJson(resp));
                    }
                }
                foreach (KeyVauleDataInfo item in addFieldList)//添加问题表
                {
                    if (!bllKeyValueData.Add(item, tran))
                    {
                        resp.errmsg = "模板字段添加失败";
                        tran.Rollback();
                        return(Common.JSONHelper.ObjectToJson(resp));
                    }
                }
                tran.Commit();
                resp.isSuccess = true;
            }
            catch (Exception ex)
            {
                resp.errcode = (int)APIErrCode.OperateFail;
                resp.errmsg  = "提交失败," + ex.Message;
                tran.Rollback();
            }
            return(Common.JSONHelper.ObjectToJson(resp));
        }
예제 #19
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(Request.InputStream);
                try
                {
                    xmlDoc.Save(string.Format("C:\\WXPay\\Notify{0}.xml", DateTime.Now.ToString("yyyyMMddHHmmssfff")));
                }
                catch (Exception)
                {
                }
                //全部参数
                Dictionary <string, string> parametersAll = new Dictionary <string, string>();
                foreach (XmlElement item in xmlDoc.DocumentElement.ChildNodes)
                {
                    string key   = item.Name;
                    string value = item.InnerText;
                    if ((!string.IsNullOrEmpty(key)) && (!string.IsNullOrEmpty(value)))
                    {
                        parametersAll.Add(key, value);
                    }
                }

                parametersAll = (from entry in parametersAll
                                 orderby entry.Key ascending
                                 select entry).ToDictionary(pair => pair.Key, pair => pair.Value);//全部参数排序

                BllOrder bllOrder = new BllOrder();
                BLLJIMP.Model.OrderPay orderPay = bllOrder.GetOrderPay(parametersAll["out_trade_no"], "", bllOrder.WebsiteOwner);

                BllPay    bllPay    = new BllPay();
                PayConfig payConfig = bllPay.GetPayConfig();
                if (bllPay.VerifySignatureWx(parametersAll, payConfig.WXPartnerKey))//验证签名
                {
                    if (orderPay == null)
                    {
                        Response.Write("<xml><return_code><![CDATA[FAIL]]></return_code></xml>");
                        return;
                    }

                    if (orderPay.Status == 1)
                    {
                        Response.Write("<xml><return_code><![CDATA[SUCCESS]]></return_code></xml>");
                        return;
                    }
                    orderPay.Status = 1;
                    if (bllOrder.Update(orderPay))
                    {
                        BLLUser bllUser = new BLLUser();
                        if (orderPay.Type == "1")
                        {
                            int score = 0;
                            int.TryParse(orderPay.Ex1, out score);
                            BLLKeyValueData bllKeyValueData  = new BLLKeyValueData();
                            string          ScoreDispalyName = bllKeyValueData.GetDataVaule("ScoreDispalyName", "1", bllKeyValueData.WebsiteOwner);

                            string msg = "消费" + orderPay.Total_Fee + "元,充值" + score + ScoreDispalyName;
                            if (bllUser.AddUserScoreDetail(orderPay.UserId, EnumStringHelper.ToString(ScoreDefineType.Recharge), bllUser.WebsiteOwner, score, msg))
                            {
                                Response.Write("<xml><return_code><![CDATA[SUCCESS]]></return_code></xml>");
                            }
                            else
                            {
                                Response.Write("<xml><return_code><![CDATA[FAIL]]></return_code></xml>");
                            }
                            //BLLSystemNotice bllSystemNotice = new BLLSystemNotice();
                            //bllSystemNotice.SendNotice(BLLSystemNotice.NoticeType.SystemMessage, null, null, orderPay.UserId, msg);
                        }
                        else if (orderPay.Type == "2")
                        {
                            string invoiceMsg;
                            if (orderPay.Ex1 == "1")
                            {
                                invoiceMsg = "带发票,";
                            }
                            else
                            {
                                invoiceMsg = "无发票,";
                            }

                            string msg = "充值VIP," + invoiceMsg + "消费" + orderPay.Total_Fee.ToString() + "元";


                            BLLKeyValueData bllKeyValueData = new BLLKeyValueData();
                            string          VIPDatelong     = bllKeyValueData.GetDataVaule("VIPDatelong", "1", bllKeyValueData.WebsiteOwner);
                            if (string.IsNullOrWhiteSpace(VIPDatelong))
                            {
                                VIPDatelong = "12";
                            }
                            int datelong = Convert.ToInt32(VIPDatelong);

                            BLLUserExpand bllUserExpand = new BLLUserExpand();
                            UserExpand    userVip       = bllUserExpand.GetUserExpand(BLLJIMP.Enums.UserExpandType.UserIsVip, orderPay.UserId);
                            string        userVipEndDate;
                            if (userVip == null || DateTime.Parse(userVip.DataValue) < DateTime.Now)
                            {
                                userVipEndDate = DateTime.Now.AddMonths(datelong).ToString("yyyy-MM-dd");
                            }
                            else
                            {
                                userVipEndDate = DateTime.Parse(userVip.DataValue).AddMonths(datelong).ToString("yyyy-MM-dd");
                            }
                            bllUserExpand.UpdateUserExpand(BLLJIMP.Enums.UserExpandType.UserIsVip, orderPay.UserId, userVipEndDate);

                            //更新用户字段
                            UserScoreDetailsInfo scoreModel = new UserScoreDetailsInfo();
                            scoreModel.AddNote   = msg;
                            scoreModel.AddTime   = DateTime.Now;
                            scoreModel.Score     = 0;
                            scoreModel.UserID    = orderPay.UserId;
                            scoreModel.ScoreType = "RechargeVIP";
                            UserInfo currUser = bllUser.GetUserInfo(orderPay.UserId);
                            scoreModel.TotalScore   = currUser.TotalScore;
                            scoreModel.WebSiteOwner = currUser.WebsiteOwner;
                            if (bllUser.Add(scoreModel))
                            {
                                BLLSystemNotice bllSystemNotice = new BLLSystemNotice();
                                bllSystemNotice.SendNotice(BLLSystemNotice.NoticeType.SystemMessage, null, null, orderPay.UserId, msg);

                                Response.Write("<xml><return_code><![CDATA[SUCCESS]]></return_code></xml>");
                            }
                            else
                            {
                                Response.Write("<xml><return_code><![CDATA[FAIL]]></return_code></xml>");
                            }
                        }

                        return;
                    }
                    else
                    {
                        Response.Write("<xml><return_code><![CDATA[FAIL]]></return_code></xml>");
                        return;
                    }
                }
                Response.Write("<xml><return_code><![CDATA[FAIL]]></return_code></xml>");
            }
            catch (Exception)
            {
                Response.Write("<xml><return_code><![CDATA[FAIL]]></return_code></xml>");
            }
        }
예제 #20
0
        public void ProcessRequest(HttpContext context)
        {
            RequestModel requestModel = new RequestModel();

            try
            {
                requestModel = JsonConvert.DeserializeObject <RequestModel>(context.Request["data"]);
            }
            catch (Exception ex)
            {
                resp.errcode = (int)APIErrCode.OperateFail;
                resp.errmsg  = ex.Message;
                bllKeyValueData.ContextResponse(context, resp);
                return;
            }
            KeyVauleDataInfo KeyVauleDataModel = new KeyVauleDataInfo();

            if (requestModel.id > 0)
            {
                KeyVauleDataModel = bllKeyValueData.GetByKey <KeyVauleDataInfo>("AutoId", requestModel.id.ToString());
                if (KeyVauleDataModel == null)
                {
                    resp.errcode = (int)APIErrCode.OperateFail;
                    resp.errmsg  = "原模板没有找到";
                    bllKeyValueData.ContextResponse(context, resp);
                    return;
                }
                if (KeyVauleDataModel.WebsiteOwner != bllKeyValueData.WebsiteOwner)
                {
                    resp.errcode = (int)APIErrCode.OperateFail;
                    resp.errmsg  = "原模板不是本站模板";
                    bllKeyValueData.ContextResponse(context, resp);
                    return;
                }
            }
            else
            {
                KeyVauleDataModel.Creater      = currentUserInfo.UserID;
                KeyVauleDataModel.WebsiteOwner = bllKeyValueData.WebsiteOwner;
                KeyVauleDataModel.CreateTime   = DateTime.Now;
                KeyVauleDataModel.PreKey       = "0";
                KeyVauleDataModel.DataType     = EnumStringHelper.ToString(KeyVauleDataType.WXTmplmsg);
            }
            string OldKey = KeyVauleDataModel.DataKey;

            KeyVauleDataModel.DataKey   = requestModel.data_key;
            KeyVauleDataModel.DataValue = requestModel.data_value;

            //微信模板Id变化则清除以前的字段数据
            if (!string.IsNullOrWhiteSpace(OldKey) && OldKey != KeyVauleDataModel.DataKey)
            {
                bllKeyValueData.DeleteDataVaule(EnumStringHelper.ToString(KeyVauleDataType.WXTmplmsgData), null, OldKey, bllKeyValueData.WebsiteOwner);
            }

            List <KeyVauleDataInfo> newFieldList = new List <KeyVauleDataInfo>();

            for (int i = 0; i < requestModel.child_list.Count; i++)
            {
                KeyVauleDataInfo newField = new KeyVauleDataInfo();
                newField.Creater      = currentUserInfo.UserID;
                newField.WebsiteOwner = KeyVauleDataModel.WebsiteOwner;
                newField.CreateTime   = DateTime.Now;
                newField.PreKey       = KeyVauleDataModel.DataKey;
                newField.DataType     = EnumStringHelper.ToString(KeyVauleDataType.WXTmplmsgData);
                newField.DataKey      = requestModel.child_list[i].data_key;
                newField.DataValue    = requestModel.child_list[i].data_value;
                newField.OrderBy      = i + 1;
                newFieldList.Add(newField);
            }
            List <KeyVauleDataInfo> oldFieldList = bllKeyValueData.GetKeyVauleDataInfoList(EnumStringHelper.ToString(KeyVauleDataType.WXTmplmsgData), KeyVauleDataModel.DataKey
                                                                                           , KeyVauleDataModel.WebsiteOwner);

            List <KeyVauleDataInfo> deleteFieldList = new List <KeyVauleDataInfo>();
            List <KeyVauleDataInfo> editFieldList   = new List <KeyVauleDataInfo>();
            List <KeyVauleDataInfo> addFieldList    = new List <KeyVauleDataInfo>();

            foreach (KeyVauleDataInfo item in oldFieldList)
            {
                KeyVauleDataInfo temp = newFieldList.FirstOrDefault(p => p.DataType == item.DataType && p.DataKey == item.DataKey);
                if (temp == null)
                {
                    deleteFieldList.Add(item);
                }
                else
                {
                    item.DataValue = temp.DataValue;
                    item.OrderBy   = temp.OrderBy;
                    editFieldList.Add(item);
                }
            }

            foreach (KeyVauleDataInfo item in newFieldList)
            {
                if (!oldFieldList.Exists(p => p.DataType == item.DataType && p.DataKey == item.DataKey))
                {
                    addFieldList.Add(item);
                }
            }


            BLLTransaction tran = new BLLTransaction();//事务

            try
            {
                if (KeyVauleDataModel.AutoId == 0)
                {
                    if (!bllKeyValueData.Add(KeyVauleDataModel, tran))
                    {
                        tran.Rollback();
                        resp.errmsg = "添加模板失败";
                        bllKeyValueData.ContextResponse(context, resp);
                        return;
                    }
                }
                else
                {
                    if (!bllKeyValueData.Update(KeyVauleDataModel, tran))
                    {
                        tran.Rollback();
                        resp.errcode = (int)APIErrCode.OperateFail;
                        resp.errmsg  = "修改模板失败";
                        bllKeyValueData.ContextResponse(context, resp);
                        return;
                    }
                }

                if (deleteFieldList.Count > 0)
                {
                    string delIds = MyStringHelper.ListToStr(deleteFieldList.Select(p => p.AutoId).ToList(), "", ",");
                    if (bllKeyValueData.DeleteMultByKey <KeyVauleDataInfo>("AutoId", delIds) < 0)
                    {
                        tran.Rollback();
                        resp.errcode = (int)APIErrCode.OperateFail;
                        resp.errmsg  = "删除旧字段失败";
                        bllKeyValueData.ContextResponse(context, resp);
                        return;
                    }
                }

                foreach (KeyVauleDataInfo item in editFieldList)//添加问题表
                {
                    if (!bllKeyValueData.Update(item, tran))
                    {
                        tran.Rollback();
                        resp.errcode = (int)APIErrCode.OperateFail;
                        resp.errmsg  = "模板字段修改失败";
                        bllKeyValueData.ContextResponse(context, resp);
                        return;
                    }
                }
                foreach (KeyVauleDataInfo item in addFieldList)//添加问题表
                {
                    if (!bllKeyValueData.Add(item, tran))
                    {
                        tran.Rollback();
                        resp.errcode = (int)APIErrCode.OperateFail;
                        resp.errmsg  = "模板字段添加失败";
                        bllKeyValueData.ContextResponse(context, resp);
                        return;
                    }
                }
                tran.Commit();
                resp.isSuccess = true;
                resp.errcode   = (int)APIErrCode.IsSuccess;
            }
            catch (Exception ex)
            {
                tran.Rollback();
                resp.errcode = (int)APIErrCode.OperateFail;
                resp.errmsg  = "提交失败," + ex.Message;
            }
            bllKeyValueData.ContextResponse(context, resp);
        }