/// <summary> /// 保存五步会赞 /// </summary> /// <param name="context"></param> /// <returns></returns> private string AddParnerPraiseNum(HttpContext context) { BLLJIMP.Model.ForwardingRecord forRecord = bllJuactivity.Get <BLLJIMP.Model.ForwardingRecord>(string.Format(" FUserID='{0}' AND RUserID='{1}' AND websiteOwner='{2}' AND TypeName='五伴会赞'", this.currentUserInfo.UserID, context.Request["id"], bllUser.WebsiteOwner)); WBHPartnerInfo model = bllUser.Get <WBHPartnerInfo>(string.Format("AutoId={0}", context.Request["id"])); if (forRecord == null) { forRecord = new BLLJIMP.Model.ForwardingRecord() { FUserID = this.currentUserInfo.UserID, RUserID = model.AutoId.ToString(), RdateTime = DateTime.Now, WebsiteOwner = bll.WebsiteOwner, TypeName = "五伴会赞" }; bllUser.Add(forRecord); model.ParTnerStep++; if (bllUser.Update(model)) { resp.Status = 1; resp.ExInt = model.ParTnerStep; resp.ExStr = "1"; } else { resp.Status = -1; resp.Msg = "系统错误,请联系管理员"; } } else { int count = bllUser.Delete(forRecord); model.ParTnerStep = model.ParTnerStep - 1; if (bllUser.Update(model) && count > 0) { resp.Status = 1; resp.ExInt = model.ParTnerStep; resp.ExStr = "0"; } else { resp.Status = -1; } } return(Common.JSONHelper.ObjectToJson(resp)); }
public async Task <ResponseAddUser> Post([FromBody] User user) { ResponseAddUser response; if (ModelState.IsValid) { response = await Task.FromResult(BLLUser.Add(user)).Result; } else { // need to transport the exception response = new ResponseAddUser(false, "error", false); } return(response); }
protected void btnSave_Click(object sender, EventArgs e) { try { BLLUser bllUser = new BLLUser(this.txtUserID.Text.Trim()); ZentCloud.BLLJIMP.Model.UserInfo model = new ZentCloud.BLLJIMP.Model.UserInfo(); model.UserID = bllUser.UserID; model.Password = this.txtPassword.Text; model.TrueName = this.txtTrueName.Text; model.Company = this.txtCompany.Text; model.Phone = this.txtPhone.Text; model.Email = this.txtEmail.Text; model.Regtime = DateTime.Now;; model.Account = 0; model.Points = 0; model.EmailPoints = 0; model.UserType = 2;//注册用户默认为普通用户 //判断用户是否已存在 if (bllUser.Exists(model, "UserID")) { ZentCloud.Common.WebMessageBox.Show(this.Page, "用户已存在!"); return; } if (bllUser.Add(model)) { //将用户添加到微博用户组 ZentCloud.BLLPermission.BLLMenuPermission pmsBll = new BLLPermission.BLLMenuPermission(model.UserID); pmsBll.SetUserPmsGroup(model.UserID, 508); ZentCloud.Common.WebMessageBox.ShowAndRedirect(this.Page, "注册成功!", Common.ConfigHelper.GetConfigString("loginUrl")); } else { ZentCloud.Common.WebMessageBox.Show(this.Page, "注册失败!"); } } catch (Exception ex) { ZentCloud.Common.WebMessageBox.Show(this.Page, "添加失败!"); } }
/// <summary> /// 保存分享记录 /// </summary> /// <param name="context"></param> /// <returns></returns> private bool SavaForwardingRecord(string userId) { if (currentUserInfo != null) { BLLJIMP.Model.ForwardingRecord record = new BLLJIMP.Model.ForwardingRecord() { RUserID = this.currentUserInfo.UserID, RUserName = this.currentUserInfo.TrueName, RdateTime = DateTime.Now, FUserID = currentUserInfo.UserID, FuserName = currentUserInfo.TrueName, WebsiteOwner = bllUser.WebsiteOwner, TypeName = "分享" }; return(bllUser.Add(record)); } return(false); }
public void ProcessRequest(HttpContext context) { //string openid = context.Request["openid"]; string phone = context.Request["phone"]; string code = context.Request["code"]; string msg = ""; if (!bllUser.SmsLogin(phone, code, out msg)) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = msg; bllUser.ContextResponse(context, apiResp); return; } string unionid = context.Request["unionid"]; string websiteOwner = bllUser.WebsiteOwner; UserInfo user = bllUser.GetUserInfoByPhone(phone, websiteOwner); if (user == null) { user = new UserInfo(); user.UserID = user.UserID = string.Format("Phone{0}", Guid.NewGuid().ToString()); user.Phone = phone; user.Password = ZentCloud.Common.Rand.Str_char(12); user.UserType = 2; user.WebsiteOwner = websiteOwner; user.Regtime = DateTime.Now; user.RegIP = ZentCloud.Common.MySpider.GetClientIP(); } string oUnionid = user.WXUnionID; string oNickname = user.WXNickname; bool hasOther = (user.AutoID != 0 && oUnionid != unionid); string password = context.Request["password"]; string city = context.Request["city"]; string country = context.Request["country"]; string headimgurl = context.Request["headimgurl"]; string nickname = context.Request["nickname"]; string privilege = context.Request["privilege"]; string province = context.Request["province"]; string sex = context.Request["sex"]; user.Password = password.Trim(); if (string.IsNullOrWhiteSpace(user.Password)) { user.Password = ZentCloud.Common.Rand.Str_char(6); } user.WXCity = city; user.WXCountry = country; user.WXHeadimgurl = headimgurl; user.WXNickname = nickname; user.WXPrivilege = ZentCloud.Common.JSONHelper.ObjectToJson(privilege); user.WXProvince = province; user.WXSex = Convert.ToInt32(sex); user.WXUnionID = unionid; user.LastLoginIP = ZentCloud.Common.MySpider.GetClientIP(); user.LastLoginDate = DateTime.Now; user.LoginTotalCount = user.LoginTotalCount + 1; bool status = false; if (user.AutoID == 0) { //更新微信授权信息 status = bllUser.Add(user); } else { status = bllUser.Update(user); } if (status) { if (hasOther) { BLLLog bllLog = new BLLLog(); string rmk = string.Format("账号({0})绑定信息变更,微信UnionID:[{1}-{2}],昵称:[{3}-{4}]", user.AutoID, oUnionid, unionid, oNickname, nickname); bllLog.Add(ZentCloud.BLLJIMP.Enums.EnumLogType.OAuthBind, ZentCloud.BLLJIMP.Enums.EnumLogTypeAction.SignIn, user.UserID, rmk); } context.Session[SessionKey.UserID] = user.UserID; context.Session[SessionKey.LoginStatu] = 1; context.Response.Cookies.Add(bllUser.CreateLoginCookie(user.UserID, user.WXOpenId, user.WXNickname)); apiResp.status = true; apiResp.code = (int)APIErrCode.IsSuccess; apiResp.msg = "授权绑定手机完成"; } else { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "授权绑定手机失败"; } bllUser.ContextResponse(context, apiResp); }
/// <summary> /// 保存投票信息 /// </summary> /// <param name="context"></param> /// <returns></returns> private string SaveDataInfo(HttpContext context) { string autoId = context.Request["AutoId"]; string ids = context.Request["Ids"]; if (string.IsNullOrEmpty(ids)) { resp.Status = -1; resp.Msg = "请选择投票内容"; goto OutF; } ids = ids.Replace("0,", ""); BLLJIMP.Model.TheVoteInfo voteInfo = bllUser.Get <BLLJIMP.Model.TheVoteInfo>(string.Format(" AutoId=" + autoId)); if (voteInfo.MaxSelectItemCount > 0) { if (ids.Split(',').Length > voteInfo.MaxSelectItemCount) { resp.Status = -1; resp.Msg = "最多可以同时选中" + voteInfo.MaxSelectItemCount + "个选项"; goto OutF; } } if (DateTime.Now > voteInfo.TheVoteOverDate) { resp.Status = -1; resp.Msg = "投票结束"; goto OutF; } ZentCloud.ZCBLLEngine.BLLTransaction tran = new ZCBLLEngine.BLLTransaction(); int count = 0; if (currentUserInfo != null) { count = bllJuActivity.GetCount <BLLJIMP.Model.UserVoteInfo>(string.Format(" UserId='{0}' AND VoteId='{1}'", currentUserInfo.UserID, autoId)); } else { //currentUserInfo = new BLLJIMP.Model.UserInfo() //{ // UserID = "user" //}; } if (count > 0) { resp.Status = -1; resp.Msg = "您已经投过票,不可再次投票。"; goto OutF; } bool isSuccess = bllUser.Add(new BLLJIMP.Model.UserVoteInfo() { UserId = currentUserInfo.UserID, VoteId = autoId, DiInfoId = ids }, tran); string[] idsArry = ids.Split(','); voteInfo.PNumber = voteInfo.PNumber + 1; //int num = idsArry.Length; //if (idsArry.Length > 1) //{ // num = idsArry.Length - 1; //} //else //{ // num = idsArry.Length; //} //voteInfo.VoteNumbers = (voteInfo.VoteNumbers + num); bll.Update(voteInfo, string.Format(" PNumber+=1,VoteNumbers+={0}", idsArry.Length), string.Format(" AutoId={0}", voteInfo.AutoId)); //bllUser.Update(voteInfo, tran); for (int i = 0; i < idsArry.Length; i++) { BLLJIMP.Model.DictionaryInfo diInfo = bllUser.Get <BLLJIMP.Model.DictionaryInfo>(" AutoID=" + idsArry[i]); if (diInfo != null) { diInfo.VoteNums = diInfo.VoteNums + 1; bll.Update(diInfo, string.Format("VoteNums+=1"), string.Format(" AutoID={0}", diInfo.AutoID)); //bllUser.Update(diInfo, tran); } } if (isSuccess) { resp.Status = 0; resp.Msg = "投票成功"; tran.Commit(); } else { resp.Status = -1; resp.Msg = "投票失败"; tran.Rollback(); } OutF: return(Common.JSONHelper.ObjectToJson(resp)); }
public void ProcessRequest(HttpContext context) { string code = context.Request["code"]; string Phone = context.Request["Phone"]; UserInfo CurrentUserInfo = bllUser.GetCurrentUserInfo(); #region 检查是否已登录 if (CurrentUserInfo != null) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "本功能仅供新用户使用"; bllUser.ContextResponse(context, apiResp); return; } #endregion #region 检查是否微信服务号 if (context.Session["currWXOpenId"] == null) { apiResp.code = (int)APIErrCode.UserIsNotLogin; apiResp.msg = "本功能仅供微信服务号使用"; bllUser.ContextResponse(context, apiResp); return; } #endregion string wxOpenId = context.Session["currWXOpenId"].ToString(); CurrentUserInfo = bllUser.GetUserInfoByOpenId(wxOpenId); if (CurrentUserInfo != null) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "OpenId已被绑定"; bllUser.ContextResponse(context, apiResp); return; } #region 判断手机格式 if (!MyRegex.PhoneNumLogicJudge(Phone)) { apiResp.code = (int)APIErrCode.PhoneFormatError; apiResp.msg = "手机格式错误"; bllUser.ContextResponse(context, apiResp); return; } #endregion #region 判断手机是否已被使用 UserInfo model = bllUser.GetUserInfoByPhone(Phone); if (model != null) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "手机号码已被其他账号使用,请联系管理员"; bllSms.ContextResponse(context, apiResp); return; } #endregion #region 判断验证码是否正确 SmsVerificationCode sms = bllSms.GetLastSmsVerificationCode(Phone); if (sms == null || sms.VerificationCode != code) { apiResp.code = (int)APIErrCode.CheckCodeErr; apiResp.msg = "验证码错误"; bllSms.ContextResponse(context, apiResp); return; } #endregion List <TableFieldMapping> listFieldList = bllTableFieldMap.GetTableFieldMapByWebsite(bllTableFieldMap.WebsiteOwner, "ZCJ_UserInfo", null, null, "0", null); List <string> defFields = new List <string>() { "AutoID", "UserID", "Password", "UserType", "TrueName", "Phone" }; #region 账号检查 未登录时检查已有账号 CurrentUserInfo = bllUser.GetUserInfoByAllPhone(Phone); if (CurrentUserInfo != null) { List <string> tempFields = new List <string>() { "Phone1", "Phone2", "Phone3" }; List <GetCompleteField.ResultField> resultList = new List <GetCompleteField.ResultField>(); #region 取姓名 TableFieldMapping AcountTrueNameField = listFieldList.FirstOrDefault(p => p.Field.Equals("TrueName")); if (AcountTrueNameField == null) { resultList.Add(new GetCompleteField.ResultField { field = "TrueName", field_name = "姓名", type = "txt", no_null = 1, value = CurrentUserInfo.TrueName, read_only = 0 }); } else { resultList.Add(new GetCompleteField.ResultField { field = "TrueName", field_name = AcountTrueNameField.MappingName, type = "txt", no_null = AcountTrueNameField.FieldIsNull, value = CurrentUserInfo.TrueName, read_only = AcountTrueNameField.IsReadOnly }); } #endregion #region 取手机 if (!string.IsNullOrWhiteSpace(CurrentUserInfo.Phone1)) { TableFieldMapping AcountPhone1Field = listFieldList.FirstOrDefault(p => p.Field.Equals("Phone1")); if (AcountPhone1Field == null) { resultList.Add(new GetCompleteField.ResultField { field = "TrueName", field_name = "手机", type = "txt", no_null = 1, value = CurrentUserInfo.Phone1, read_only = 0 }); } else { resultList.Add(new GetCompleteField.ResultField { field = "TrueName", field_name = AcountPhone1Field.MappingName, type = "txt", no_null = AcountPhone1Field.FieldIsNull, value = CurrentUserInfo.Phone1, read_only = AcountPhone1Field.IsReadOnly }); } } if (!string.IsNullOrWhiteSpace(CurrentUserInfo.Phone2)) { TableFieldMapping AcountPhone2Field = listFieldList.FirstOrDefault(p => p.Field.Equals("Phone2")); if (AcountPhone2Field == null) { resultList.Add(new GetCompleteField.ResultField { field = "Phone2", field_name = "手机", type = "txt", no_null = 1, value = CurrentUserInfo.Phone2, read_only = 0 }); } else { resultList.Add(new GetCompleteField.ResultField { field = "Phone2", field_name = AcountPhone2Field.MappingName, type = "txt", no_null = AcountPhone2Field.FieldIsNull, value = CurrentUserInfo.Phone2, read_only = AcountPhone2Field.IsReadOnly }); } } if (!string.IsNullOrWhiteSpace(CurrentUserInfo.Phone3)) { TableFieldMapping AcountPhone3Field = listFieldList.FirstOrDefault(p => p.Field.Equals("Phone3")); if (AcountPhone3Field == null) { resultList.Add(new GetCompleteField.ResultField { field = "Phone3", field_name = "手机", type = "txt", no_null = 1, value = CurrentUserInfo.Phone3, read_only = 0 }); } else { resultList.Add(new GetCompleteField.ResultField { field = "Phone3", field_name = AcountPhone3Field.MappingName, type = "txt", no_null = AcountPhone3Field.FieldIsNull, value = CurrentUserInfo.Phone3, read_only = AcountPhone3Field.IsReadOnly }); } } #endregion #region 取其他信息 JObject tCurUser = JObject.FromObject(CurrentUserInfo); foreach (var item in listFieldList.Where(p => !defFields.Contains(p.Field) && !tempFields.Contains(p.Field))) { if (tCurUser[item.Field] == null) { continue; } if (string.IsNullOrWhiteSpace(tCurUser[item.Field].ToString())) { continue; } string FieldType = string.IsNullOrWhiteSpace(item.FieldType) ? "txt" : item.FieldType; resultList.Add(new GetCompleteField.ResultField { field = item.Field, field_name = item.MappingName, type = FieldType, no_null = item.FieldIsNull, value = tCurUser[item.Field].ToString(), read_only = item.IsReadOnly }); } #endregion apiResp.code = (int)APIErrCode.HaveHistoryAcount; apiResp.msg = "注册手机已存在账号"; apiResp.result = new { have_acount = true, id = CurrentUserInfo.AutoID, info_list = resultList }; bllSms.ContextResponse(context, apiResp); return; } else { CurrentUserInfo = new UserInfo(); string guidString = Guid.NewGuid().ToString(); CurrentUserInfo.UserID = string.Format("WXUser{0}", guidString); //Guid CurrentUserInfo.Password = guidString.Substring(0, 8); //Guid CurrentUserInfo.WXHeadimgurl = string.Format("http://{0}", context.Request.Url.Authority) + "/img/persion.png"; CurrentUserInfo.WebsiteOwner = bllUser.WebsiteOwner; CurrentUserInfo.UserType = 2; CurrentUserInfo.WXOpenId = wxOpenId; CurrentUserInfo.Regtime = DateTime.Now; CurrentUserInfo.LastLoginDate = DateTime.Now; } #endregion //string oldPhone = CurrentUserInfo.Phone; CurrentUserInfo = bllTableFieldMap.ConvertRequestToModel <UserInfo>(CurrentUserInfo); //if(CurrentUserInfo.IsPhoneVerify == 1) CurrentUserInfo.Phone = oldPhone; #region 默认信息检查 姓名 TableFieldMapping TrueNameField = listFieldList.FirstOrDefault(p => p.Field.Equals("TrueName")); if ((TrueNameField == null || TrueNameField.FieldIsNull == 1) && string.IsNullOrWhiteSpace(CurrentUserInfo.TrueName)) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "请完善姓名"; bllTableFieldMap.ContextResponse(context, apiResp); return; } #endregion JObject jtCurUser = JObject.FromObject(CurrentUserInfo); foreach (var item in listFieldList.Where(p => p.FieldIsNull == 1 && !defFields.Contains(p.Field)).OrderBy(p => p.Sort)) { if (jtCurUser[item.Field] == null) { continue; } if (string.IsNullOrWhiteSpace(jtCurUser[item.Field].ToString())) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "请完善" + item.MappingName; bllTableFieldMap.ContextResponse(context, apiResp); return; } if (!string.IsNullOrWhiteSpace(item.FormatValiFunc)) { #region 检查数据格式 //检查数据格式 if (item.FormatValiFunc == "number") { if (!MyRegex.IsNumber(jtCurUser[item.Field].ToString())) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = string.Format("{0}格式不正确", item.MappingName); bllTableFieldMap.ContextResponse(context, apiResp); return; } } if (item.FormatValiFunc == "phone")//email检查 { if (!MyRegex.PhoneNumLogicJudge(jtCurUser[item.Field].ToString())) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = string.Format("{0}格式不正确", item.MappingName); bllTableFieldMap.ContextResponse(context, apiResp); return; } } if (item.FormatValiFunc == "email")//email检查 { if (!MyRegex.EmailLogicJudge(jtCurUser[item.Field].ToString())) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = string.Format("{0}格式不正确", item.MappingName); bllTableFieldMap.ContextResponse(context, apiResp); return; } } if (item.FormatValiFunc == "url") //url检查 { System.Text.RegularExpressions.Regex regUrl = new System.Text.RegularExpressions.Regex(@"http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?"); //网址 System.Text.RegularExpressions.Match match = regUrl.Match(jtCurUser[item.Field].ToString()); if (!match.Success) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = string.Format("{0}格式不正确", item.MappingName); bllTableFieldMap.ContextResponse(context, apiResp); return; } } #endregion } } CurrentUserInfo.IsPhoneVerify = 1; CompanyWebsite_Config nWebsiteConfig = bllWebSite.GetCompanyWebsiteConfig(); if (nWebsiteConfig.MemberStandard == 2) { if (CurrentUserInfo.AccessLevel < 1) { CurrentUserInfo.AccessLevel = 1; CurrentUserInfo.MemberStartTime = DateTime.Now; } //CurrentUserInfo.MemberApplyStatus = 9; } else if (nWebsiteConfig.MemberStandard == 3) { CurrentUserInfo.MemberApplyStatus = 1; CurrentUserInfo.MemberApplyTime = DateTime.Now; } if (bllUser.Add(CurrentUserInfo)) { apiResp.status = true; apiResp.code = (int)APIErrCode.IsSuccess; apiResp.msg = "提交完成"; context.Session[ZentCloud.Common.SessionKey.UserID] = CurrentUserInfo.UserID; context.Session[ZentCloud.Common.SessionKey.LoginStatu] = 1; //设置登录状态 } else { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "提交失败"; } bllUser.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { int score = Convert.ToInt32(context.Request["score"]); string moduleName = "积分"; if (!string.IsNullOrWhiteSpace(context.Request["module_name"])) { moduleName = context.Request["module_name"]; } string websiteOwner = bllKeyValueData.WebsiteOwner; if (score <= 0) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = moduleName + "不能为0"; bllKeyValueData.ContextResponse(context, apiResp); return; } string rechargeValue = bllKeyValueData.GetDataVaule("Recharge", "100", websiteOwner); string minScore = bllKeyValueData.GetDataVaule("MinScore", "1", websiteOwner); string minWithdrawCashScore = bllKeyValueData.GetDataVaule("MinWithdrawCashScore", "1", websiteOwner); if (score < Convert.ToDecimal(minWithdrawCashScore)) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "提现数额不能少于" + minWithdrawCashScore + moduleName; bllKeyValueData.ContextResponse(context, apiResp); return; } double curTotalScore = CurrentUserInfo.TotalScore; double sTotalScore = curTotalScore - score; double nScore = Convert.ToDouble(minScore) + score; if (sTotalScore < Convert.ToDouble(minScore)) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = moduleName + "不足"; bllKeyValueData.ContextResponse(context, apiResp); return; } decimal rechargeFee = Convert.ToDecimal(rechargeValue); decimal money = rechargeFee / 100 * score; WithdrawCash model = new WithdrawCash(); model.Amount = money; model.UserId = CurrentUserInfo.UserID; model.TrueName = CurrentUserInfo.TrueName; model.WebSiteOwner = websiteOwner; model.WithdrawCashType = "ScoreOnLine"; model.TransfersType = 1; model.Status = 0; model.Score = score; model.RealAmount = money; model.ServerFee = 0; model.Phone = CurrentUserInfo.Phone; model.LastUpdateDate = DateTime.Now; model.InsertDate = DateTime.Now; model.IsPublic = 2; //积分明细 UserScoreDetailsInfo scoreModel = new UserScoreDetailsInfo(); scoreModel.AddNote = string.Format("申请提现消耗{0}{1}", score, moduleName); scoreModel.AddTime = DateTime.Now; scoreModel.Score = 0 - score; scoreModel.UserID = CurrentUserInfo.UserID; scoreModel.ScoreType = "WithdrawCash"; scoreModel.TotalScore = sTotalScore; scoreModel.WebSiteOwner = websiteOwner; //通知 BLLJIMP.Model.SystemNotice notice = new BLLJIMP.Model.SystemNotice(); notice.Ncontent = scoreModel.AddNote; notice.UserId = CurrentUserInfo.UserID; notice.Receivers = CurrentUserInfo.UserID; notice.SendType = 2; notice.SerialNum = bllKeyValueData.GetGUID(TransacType.SendSystemNotice); notice.Title = "申请提现消耗淘股币"; notice.NoticeType = 1; notice.WebsiteOwner = websiteOwner; notice.InsertTime = DateTime.Now; BLLTransaction tran = new BLLTransaction(); if (bllUser.Update(CurrentUserInfo, string.Format("TotalScore=TotalScore-{0}", score), string.Format("AutoID={0} AND WebsiteOwner='{1}' AND TotalScore>{2}", CurrentUserInfo.AutoID, websiteOwner, nScore), tran) > 0 && bllUser.Add(scoreModel, tran) && bllUser.Add(notice, tran) && bllUser.Add(model, tran)) { tran.Commit(); apiResp.code = (int)APIErrCode.IsSuccess; apiResp.msg = "申请成功"; apiResp.status = true; } else { tran.Rollback(); apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "申请失败"; } bllKeyValueData.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { UserInfo tUser = new UserInfo(); tUser = bllUser.ConvertRequestToModel <UserInfo>(tUser); tUser.UserType = 2; tUser.RegIP = ZentCloud.Common.MySpider.GetClientIP(); tUser.Regtime = DateTime.Now; tUser.LoginTotalCount = 0; tUser.IsSubAccount = "1"; tUser.WebsiteOwner = bllUser.WebsiteOwner; tUser.LastLoginDate = DateTime.Now; if (string.IsNullOrWhiteSpace(tUser.UserID) || string.IsNullOrWhiteSpace(tUser.Password)) { apiResp.code = (int)APIErrCode.PrimaryKeyIncomplete; apiResp.msg = "账户和密码不能为空"; bllUser.ContextResponse(context, apiResp); return; } if (!string.IsNullOrWhiteSpace(tUser.Phone) && !ZentCloud.Common.MyRegex.PhoneNumLogicJudge(tUser.Phone)) { apiResp.code = (int)APIErrCode.PrimaryKeyIncomplete; apiResp.msg = "请输入正确的手机号码"; bllUser.ContextResponse(context, apiResp); return; } if (!string.IsNullOrWhiteSpace(tUser.Phone3) && !ZentCloud.Common.MyRegex.PhoneNumLogicJudge(tUser.Phone3)) { apiResp.code = (int)APIErrCode.PrimaryKeyIncomplete; apiResp.msg = "请输入正确的手机号码"; bllUser.ContextResponse(context, apiResp); return; } UserInfo oUser = bllUser.GetUserInfo(tUser.UserID, bllUser.WebsiteOwner); if (oUser != null) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "账户名已存在"; bllUser.ContextResponse(context, apiResp); return; } if (!string.IsNullOrWhiteSpace(tUser.Phone)) { oUser = bllUser.GetUserInfoByPhone(tUser.Phone, bllUser.WebsiteOwner); if (oUser != null) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "联系手机,已有账号"; bllUser.ContextResponse(context, apiResp); return; } } if (!string.IsNullOrWhiteSpace(tUser.Email) && !ZentCloud.Common.MyRegex.EmailLogicJudge(tUser.Email)) { apiResp.code = (int)APIErrCode.PrimaryKeyIncomplete; apiResp.msg = "请输入正确的邮箱地址"; bllUser.ContextResponse(context, apiResp); return; } if (!tUser.PermissionGroupID.HasValue) { apiResp.code = (int)APIErrCode.PrimaryKeyIncomplete; apiResp.msg = "请选择角色"; bllUser.ContextResponse(context, apiResp); return; } ZentCloud.BLLPermission.Model.PermissionGroupInfo perGroup = bllUser.Get <ZentCloud.BLLPermission.Model.PermissionGroupInfo>(string.Format(" GroupID={0}", tUser.PermissionGroupID)); if (perGroup.GroupType == 4) { tUser.DistributionOwner = bllUser.WebsiteOwner; } BLLTransaction tran = new BLLTransaction(); if (!bllUser.Add(tUser, tran)) { tran.Rollback(); apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "添加用户出错"; bllUser.ContextResponse(context, apiResp); return; } var group = new BLLPermission.Model.UserPmsGroupRelationInfo() { UserID = tUser.UserID, GroupID = tUser.PermissionGroupID.Value }; if (!bllUser.Add(group, tran))//添加权限组 { tran.Rollback(); apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "添加权限组出错"; bllUser.ContextResponse(context, apiResp); return; } tran.Commit(); apiResp.code = (int)APIErrCode.IsSuccess; apiResp.status = true; apiResp.msg = "添加完成"; bllUser.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { if (CurrentUserInfo.IsLock == 1) { apiResp.code = (int)APIErrCode.NoPms; apiResp.msg = "账号已被锁定"; bllUser.ContextResponse(context, apiResp); return; } if (CurrentUserInfo.MemberApplyStatus != 9) { apiResp.code = (int)APIErrCode.NoPms; apiResp.msg = "您的账号正在审核中"; bllUser.ContextResponse(context, apiResp); return; } BLLJIMP.Model.API.User.PayRegisterUser requestUser = bll.ConvertRequestToModel <BLLJIMP.Model.API.User.PayRegisterUser>(new BLLJIMP.Model.API.User.PayRegisterUser()); string websiteOwner = bll.WebsiteOwner; WebsiteInfo website = bllUser.GetWebsiteInfoModelFromDataBase(websiteOwner); if (string.IsNullOrWhiteSpace(requestUser.level.ToString())) { apiResp.code = (int)APIErrCode.PrimaryKeyIncomplete; apiResp.msg = "请选择会员级别"; bll.ContextResponse(context, apiResp); return; } if (string.IsNullOrWhiteSpace(requestUser.phone)) { apiResp.code = (int)APIErrCode.PrimaryKeyIncomplete; apiResp.msg = "请输入手机号码"; bll.ContextResponse(context, apiResp); return; } if (string.IsNullOrWhiteSpace(requestUser.spreadid)) { apiResp.code = (int)APIErrCode.PrimaryKeyIncomplete; apiResp.msg = "请输入推荐人编号"; bll.ContextResponse(context, apiResp); return; } if (!ZentCloud.Common.MyRegex.PhoneNumLogicJudge(requestUser.phone)) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "手机号码格式不正确"; bll.ContextResponse(context, apiResp); return; } if (!ZentCloud.Common.MyRegex.IsIDCard(requestUser.idcard)) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "身份证号码必须如实填写"; bll.ContextResponse(context, apiResp); return; } UserLevelConfig levelConfig = bll.QueryUserLevel(websiteOwner, "DistributionOnLine", requestUser.level.ToString()); if (levelConfig == null) { apiResp.code = (int)APIErrCode.IsNotFound; apiResp.msg = "会员级别未找到"; bll.ContextResponse(context, apiResp); return; } if (levelConfig.IsDisable == 1) { apiResp.code = (int)APIErrCode.IsNotFound; apiResp.msg = "会员级别禁止注册"; bll.ContextResponse(context, apiResp); return; } decimal levelAmount = Convert.ToDecimal(levelConfig.FromHistoryScore); if (CurrentUserInfo.TotalAmount < levelAmount) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = string.Format("您的{0}不足", website.TotalAmountShowName); bll.ContextResponse(context, apiResp); return; } UserInfo spreadUser = bllUser.GetSpreadUser(requestUser.spreadid, websiteOwner); if (spreadUser == null) { apiResp.code = (int)APIErrCode.IsNotFound; apiResp.msg = "推荐人未找到"; bll.ContextResponse(context, apiResp); return; } requestUser.spreadid = spreadUser.UserID; //推荐人 UserInfo regUser = bllUser.GetUserInfoByPhone(requestUser.phone, websiteOwner); if (regUser != null && regUser.MemberLevel >= 10) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "该手机已注册会员"; bll.ContextResponse(context, apiResp); return; } if (regUser != null && regUser.MemberLevel >= requestUser.level) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "该会员有更高级别"; bll.ContextResponse(context, apiResp); return; } if (regUser == null) { regUser = new UserInfo(); regUser.UserID = string.Format("ZYUser{0}{1}", DateTime.Now.ToString("yyyyMMdd"), Guid.NewGuid().ToString("N").ToUpper()); regUser.UserType = 2; regUser.WebsiteOwner = websiteOwner; regUser.Regtime = DateTime.Now; regUser.LastLoginDate = DateTime.Parse("1970-01-01"); } regUser.TrueName = requestUser.truename; regUser.DistributionOwner = requestUser.spreadid; regUser.Phone = requestUser.phone; regUser.MemberLevel = requestUser.level; regUser.MemberApplyTime = DateTime.Now; regUser.MemberStartTime = DateTime.Now; regUser.MemberApplyStatus = 9; regUser.IdentityCard = requestUser.idcard; regUser.Province = requestUser.province; regUser.City = requestUser.city; regUser.District = requestUser.district; regUser.Town = requestUser.town; regUser.ProvinceCode = requestUser.provinceCode; regUser.CityCode = requestUser.cityCode; regUser.DistrictCode = requestUser.districtCode; regUser.TownCode = requestUser.townCode; regUser.RegIP = context.Request.UserHostAddress;//ip regUser.Password = ZentCloud.Common.Rand.Number(6); regUser.RegUserID = CurrentUserInfo.UserID; regUser.EmptyBill = 0; regUser.RegisterWay = "余额"; regUser.IsDisable = 0; int disLevel = 1; if (website.DistributionLimitLevel > 1) { disLevel = website.DistributionLimitLevel; } StringBuilder sbSql = new StringBuilder(); UserInfo upUserLevel1 = null; //分销上一级 UserInfo upUserLevel2 = null; //分销上二级 UserInfo upUserLevel3 = null; //分销上三级 UserLevelConfig levelConfig1 = null; //分销上一级规则 UserLevelConfig levelConfig2 = null; //分销上二级规则 UserLevelConfig levelConfig3 = null; //分销上三级规则 ProjectCommission modelLevel1 = new ProjectCommission(); ScoreLockInfo scoreLockLevel1Info = new ScoreLockInfo(); ProjectCommission modelLevel1ex1 = new ProjectCommission(); ScoreLockInfo scoreLockLevel1ex1Info = new ScoreLockInfo(); ProjectCommission modelLevel2 = new ProjectCommission(); ScoreLockInfo scoreLockLevel2Info = new ScoreLockInfo(); ProjectCommission modelLevel3 = new ProjectCommission(); ScoreLockInfo scoreLockLevel3Info = new ScoreLockInfo(); string projectId = bll.GetGUID(TransacType.PayRegisterOrder); //计算分佣 bll.ComputeTransfers(disLevel, regUser, projectId, levelAmount, websiteOwner, "他人代替注册", ref sbSql, ref upUserLevel1, ref upUserLevel2, ref upUserLevel3, ref levelConfig1, ref levelConfig2, ref levelConfig3, ref modelLevel1, ref scoreLockLevel1Info, ref modelLevel1ex1, ref scoreLockLevel1ex1Info, ref modelLevel2, ref scoreLockLevel2Info, ref modelLevel3, ref scoreLockLevel3Info, levelConfig.LevelString); BLLTransaction tran = new BLLTransaction(); #region 注册会员 if (regUser.AutoID == 0) { regUser.AutoID = Convert.ToInt32(bllUser.AddReturnID(regUser, tran)); if (regUser.AutoID <= 0) { tran.Rollback(); apiResp.msg = "注册用户出错"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } } else { if (!bllUser.Update(regUser, tran)) { tran.Rollback(); apiResp.msg = "注册用户出错"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } } #endregion #region 消耗报单人金额 if (bllUser.AddScoreDetail(CurrentUserInfo.UserID, websiteOwner, (double)(0 - levelAmount), string.Format("替{0}[{1}]注册{2}", regUser.TrueName, regUser.Phone, levelConfig.LevelString), "TotalAmount", (double)(CurrentUserInfo.TotalAmount - levelAmount), "", "替他人注册", "", "", (double)levelAmount, 0, regUser.UserID, tran, ex3: levelConfig.LevelNumber.ToString(), ex4: levelConfig.LevelString) <= 0) { tran.Rollback(); apiResp.msg = "记录明细出错"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } if (bllUser.Update(CurrentUserInfo, string.Format("TotalAmount=ISNULL(TotalAmount,0)-{0},AccountAmountEstimate=ISNULL(AccountAmountEstimate,0)-{0}", levelAmount), string.Format("UserID='{0}' And WebsiteOwner='{1}' And TotalAmount-{2}>=0 ", CurrentUserInfo.UserID, websiteOwner, levelAmount), tran) <= 0) { tran.Rollback(); apiResp.msg = string.Format("消耗报单人可用{0}出错", website.TotalAmountShowName); apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } #endregion #region 注册账号余额明细 //自己的消费记录 if (bllUser.AddScoreDetail(regUser.UserID, websiteOwner, (double)(levelAmount), string.Format("{0}[{1}]转入", CurrentUserInfo.TrueName, CurrentUserInfo.Phone, (double)levelAmount), "TotalAmount", (double)(levelAmount), "", "他人注册转入", "", "", (double)levelAmount, 0, CurrentUserInfo.UserID, tran, ex3: levelConfig.LevelNumber.ToString(), ex4: levelConfig.LevelString) <= 0) { tran.Rollback(); apiResp.msg = "他人注册转入记录出错"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } int mainDetailId = bllUser.AddScoreDetail(regUser.UserID, websiteOwner, (double)(0 - levelAmount), string.Format("{0}[{1}]替您注册{2}", CurrentUserInfo.TrueName, CurrentUserInfo.Phone, levelConfig.LevelString), "TotalAmount", 0, "", "他人代替注册", "", "", (double)levelAmount, 0, CurrentUserInfo.UserID, tran, ex3: levelConfig.LevelNumber.ToString(), ex4: levelConfig.LevelString); if (mainDetailId <= 0) { tran.Rollback(); apiResp.msg = "他人注册记录出错"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } #endregion bool hasProjectCommission = false; #region 记录分佣信息 if (modelLevel1.Amount > 0) { hasProjectCommission = true; int modelLevel1Id = Convert.ToInt32(bll.AddReturnID(modelLevel1, tran)); if (modelLevel1Id <= 0) { tran.Rollback(); apiResp.msg = "一级返利失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } scoreLockLevel1Info.ForeignkeyId2 = modelLevel1Id.ToString(); scoreLockLevel1Info.AutoId = Convert.ToInt32(bll.AddReturnID(scoreLockLevel1Info, tran)); if (scoreLockLevel1Info.AutoId <= 0) { tran.Rollback(); apiResp.msg = "一级返利冻结失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } string scoreDetailEvent = modelLevel1.ProjectName.Contains("购房补助") ? "返购房补助" : "返利"; if (bllUser.AddScoreDetail(scoreLockLevel1Info.UserId, websiteOwner, (double)scoreLockLevel1Info.Score, scoreLockLevel1Info.Memo, "TotalAmount", (double)(upUserLevel1.TotalAmount + scoreLockLevel1Info.Score), scoreLockLevel1Info.AutoId.ToString(), scoreDetailEvent, "", projectId, (double)modelLevel1.SourceAmount, (double)modelLevel1.DeductAmount, modelLevel1.CommissionUserId, tran, ex3: levelConfig.LevelNumber.ToString(), ex4: levelConfig.LevelString, ex5: modelLevel1.CommissionLevel) <= 0) { tran.Rollback(); apiResp.msg = "一级返利明细记录失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } } if (modelLevel1ex1.Amount > 0) { hasProjectCommission = true; int modelLevel1ex1Id = Convert.ToInt32(bll.AddReturnID(modelLevel1ex1, tran)); if (modelLevel1ex1Id <= 0) { tran.Rollback(); apiResp.msg = "一级返购房补助失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } scoreLockLevel1ex1Info.ForeignkeyId2 = modelLevel1ex1Id.ToString(); scoreLockLevel1ex1Info.AutoId = Convert.ToInt32(bll.AddReturnID(scoreLockLevel1ex1Info, tran)); if (scoreLockLevel1ex1Info.AutoId <= 0) { tran.Rollback(); apiResp.msg = "一级返购房补助冻结失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } string scoreDetailEvent = modelLevel1ex1.ProjectName.Contains("购房补助") ? "返购房补助" : "返利"; if (bllUser.AddScoreDetail(scoreLockLevel1ex1Info.UserId, websiteOwner, (double)scoreLockLevel1ex1Info.Score, scoreLockLevel1ex1Info.Memo, "TotalAmount", (double)(upUserLevel1.TotalAmount + scoreLockLevel1ex1Info.Score), scoreLockLevel1ex1Info.AutoId.ToString(), scoreDetailEvent, "", projectId, (double)modelLevel1ex1.SourceAmount, (double)modelLevel1ex1.DeductAmount, modelLevel1ex1.CommissionUserId, tran, ex3: levelConfig.LevelNumber.ToString(), ex4: levelConfig.LevelString, ex5: modelLevel1ex1.CommissionLevel) <= 0) { tran.Rollback(); apiResp.msg = "一级返购房补助明细记录失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } } if (modelLevel2.Amount > 0) { hasProjectCommission = true; int modelLevel2Id = Convert.ToInt32(bll.AddReturnID(modelLevel2, tran)); if (modelLevel2Id <= 0) { tran.Rollback(); apiResp.msg = "二级返利失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } scoreLockLevel2Info.ForeignkeyId2 = modelLevel2Id.ToString(); scoreLockLevel2Info.AutoId = Convert.ToInt32(bll.AddReturnID(scoreLockLevel2Info, tran)); if (scoreLockLevel2Info.AutoId <= 0) { tran.Rollback(); apiResp.msg = "二级返利冻结失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } string scoreDetailEvent = modelLevel2.ProjectName.Contains("购房补助") ? "返购房补助" : "返利"; if (bllUser.AddScoreDetail(scoreLockLevel2Info.UserId, websiteOwner, (double)scoreLockLevel2Info.Score, scoreLockLevel2Info.Memo, "TotalAmount", (double)(upUserLevel2.TotalAmount + scoreLockLevel2Info.Score), scoreLockLevel2Info.AutoId.ToString(), scoreDetailEvent, "", projectId, (double)modelLevel2.SourceAmount, (double)modelLevel2.DeductAmount, modelLevel2.CommissionUserId, tran, ex3: levelConfig.LevelNumber.ToString(), ex4: levelConfig.LevelString, ex5: modelLevel2.CommissionLevel) <= 0) { tran.Rollback(); apiResp.msg = "二级返利明细记录失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } } if (modelLevel3.Amount > 0) { hasProjectCommission = true; int modelLevel3Id = Convert.ToInt32(bll.AddReturnID(modelLevel3, tran)); if (!bll.Add(modelLevel3, tran)) { tran.Rollback(); apiResp.msg = "三级返利失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } scoreLockLevel3Info.ForeignkeyId2 = modelLevel3Id.ToString(); scoreLockLevel3Info.AutoId = Convert.ToInt32(bll.AddReturnID(scoreLockLevel3Info, tran)); if (scoreLockLevel3Info.AutoId <= 0) { tran.Rollback(); apiResp.msg = "三级返利冻结失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } string scoreDetailEvent = modelLevel3.ProjectName.Contains("购房补助") ? "返购房补助" : "返利"; if (bllUser.AddScoreDetail(scoreLockLevel3Info.UserId, websiteOwner, (double)scoreLockLevel3Info.Score, scoreLockLevel3Info.Memo, "TotalAmount", (double)(upUserLevel3.TotalAmount + scoreLockLevel3Info.Score), scoreLockLevel3Info.AutoId.ToString(), scoreDetailEvent, "", projectId, (double)modelLevel3.SourceAmount, (double)modelLevel3.DeductAmount, modelLevel3.CommissionUserId, tran, ex3: levelConfig.LevelNumber.ToString(), ex4: levelConfig.LevelString, ex5: modelLevel3.CommissionLevel) <= 0) { tran.Rollback(); apiResp.msg = "三级返利明细记录失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } } if (hasProjectCommission) { if (BLLBase.ExecuteSql(sbSql.ToString(), tran) <= 0) { tran.Rollback(); apiResp.msg = string.Format("更新分佣账面{0}出错", website.TotalAmountShowName); apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } } #endregion #region 记录业绩明细 TeamPerformanceDetails perDetail = new TeamPerformanceDetails(); perDetail.AddType = "注册"; perDetail.AddNote = "注册" + levelConfig.LevelString; perDetail.AddTime = DateTime.Now; perDetail.DistributionOwner = regUser.DistributionOwner; perDetail.UserId = regUser.UserID; perDetail.UserName = regUser.TrueName; perDetail.UserPhone = regUser.Phone; perDetail.Performance = levelAmount; string yearMonthString = perDetail.AddTime.ToString("yyyyMM"); int yearMonth = Convert.ToInt32(yearMonthString); perDetail.YearMonth = yearMonth; perDetail.WebsiteOwner = websiteOwner; if (!bllUser.Add(perDetail, tran)) { tran.Rollback(); apiResp.msg = "记录业绩明细失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } #endregion tran.Commit(); if (hasProjectCommission) { //异步修改积分明细表 Thread th1 = new Thread(delegate() { //计算相关业绩 bll.BuildCurMonthPerformanceByUserID(websiteOwner, regUser.UserID); }); th1.Start(); } string msg = ""; #region 短信发送密码 BLLSMS bllSms = new BLLSMS(""); bool smsBool = false; string smsString = string.Format("恭喜您成功注册为天下华商月供宝:{1},您的初始密码为:{0}。您可关注公众号:songhetz,登录账户修改密码,并设置支付密码。", regUser.Password, levelConfig.LevelString); bllSms.SendSmsMisson(regUser.Phone, smsString, "", website.SmsSignature, out smsBool, out msg); #endregion if (string.IsNullOrWhiteSpace(msg)) { msg = "注册成功"; } apiResp.msg = msg; apiResp.code = (int)APIErrCode.IsSuccess; apiResp.status = true; apiResp.result = new { password = regUser.Password }; bll.ContextResponse(context, apiResp); }
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; } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "application/json"; context.Response.Expires = 0; string name = context.Request["name"]; string email = context.Request["email"]; string phone = context.Request["phone"]; string company = context.Request["company"]; string pwd = context.Request["pwd"]; string hasCode = context.Request["hasCode"]; //0时没有验证码 string verCode = context.Request["vercode"]; string currWXOpenId = ""; if (context.Session["currWXOpenId"] != null) { currWXOpenId = context.Session["currWXOpenId"].ToString(); } if (string.IsNullOrEmpty(name)) { resp.errcode = (int)APIErrCode.UserNameIsEmpty; resp.errmsg = "请输入姓名"; bllUser.ContextResponse(context, resp); return; } if (string.IsNullOrEmpty(email)) { resp.errcode = (int)APIErrCode.PrimaryKeyIncomplete; resp.errmsg = "请输入邮箱"; bllUser.ContextResponse(context, resp); return; } if (string.IsNullOrEmpty(pwd)) { resp.errcode = (int)APIErrCode.PrimaryKeyIncomplete; resp.errmsg = "请输入密码"; bllUser.ContextResponse(context, resp); return; } if (!ZentCloud.Common.MyRegex.EmailLogicJudge(email)) { resp.errcode = 5; resp.errmsg = "邮箱格式不正确"; bllUser.ContextResponse(context, resp); return; } if (phone != null) { if (string.IsNullOrWhiteSpace(phone)) { resp.errcode = (int)APIErrCode.PrimaryKeyIncomplete; resp.errmsg = "请输入手机"; bllUser.ContextResponse(context, resp); return; } if (!ZentCloud.Common.MyRegex.PhoneNumLogicJudge(phone)) { resp.errcode = (int)APIErrCode.PhoneFormatError; resp.errmsg = "手机格式不正确"; bllUser.ContextResponse(context, resp); return; } if (bllUser.GetUserInfoByPhone(phone) != null) { resp.errcode = (int)APIErrCode.OperateFail; resp.errmsg = "此手机号已被注册,请输入别的手机号"; bllUser.ContextResponse(context, resp); return; } } if (hasCode != "0") { if (string.IsNullOrWhiteSpace(verCode)) { resp.errcode = (int)APIErrCode.PrimaryKeyIncomplete; resp.errmsg = "请输入验证码"; bllUser.ContextResponse(context, resp); return; } var serverCheckCode = context.Session["CheckCode"]; if (!verCode.Equals(serverCheckCode.ToString(), StringComparison.OrdinalIgnoreCase)) { resp.errcode = (int)APIErrCode.CheckCodeErr; resp.errmsg = "验证码错误"; bllUser.ContextResponse(context, resp); return; } } bool isSyncPass = true; string basePath = string.Format("http://{0}{1}", context.Request.Url.Host, context.Request.Url.Port != 80 ? ":" + context.Request.Url.Port.ToString() : ""); #region 步国烨账号注册检查 if (bllUser.WebsiteOwner == "guoye") { isSyncPass = false; Dictionary <string, string> param = new Dictionary <string, string>(); param.Add("email", email); param.Add("phone", phone); param.Add("pwd", pwd); param.Add("openid", currWXOpenId); param.Add("name", name); param.Add("company", company); using (HttpWebResponse wr = ZentCloud.Common.HttpInterFace.CreatePostHttpResponse( "http://www.chinayie.com/api/register", param, null, null, Encoding.UTF8, null)) { using (StreamReader sr = new StreamReader(wr.GetResponseStream())) { JToken jto = JToken.Parse(sr.ReadToEnd()); if (jto["result"] != null && jto["result"].ToString().ToLower() == "true") { isSyncPass = true; } else if (jto["result"] != null && jto["msg"] != null && jto["result"].ToString().ToLower() == "false") { resp.errcode = (int)APIErrCode.RegisterFailure; resp.errmsg = jto["msg"].ToString(); bllUser.ContextResponse(context, resp); return; } } } if (isSyncPass) { resp.errcode = (int)APIErrCode.IsSuccess; resp.errmsg = "注册成功"; resp.isSuccess = true; } else { resp.errcode = (int)APIErrCode.RegisterFailure; resp.errmsg = "注册失败"; } bllUser.ContextResponse(context, resp); return; } #endregion UserInfo regUser = new UserInfo(); regUser = bllUser.GetUserInfoByOpenId(currWXOpenId); if (regUser != null) { resp.errcode = (int)APIErrCode.RegisterFailure; resp.errmsg = "已经注册过"; bllUser.ContextResponse(context, resp); return; } regUser = new UserInfo(); regUser.TrueName = name; regUser.WXOpenId = currWXOpenId; regUser.WXHeadimgurl = basePath + "/img/persion.png"; regUser.Email = email; regUser.Phone = phone; regUser.Company = company; regUser.Password = pwd; regUser.UserID = string.Format("ZYUser{0}{1}", StringHelper.GetDateTimeNum(), Rand.Str(5)); regUser.WebsiteOwner = bllUser.WebsiteOwner; regUser.UserType = 2; regUser.Regtime = DateTime.Now; regUser.LastLoginDate = DateTime.Now; if (isSyncPass && bllUser.Add(regUser)) { context.Session[SessionKey.UserID] = regUser.UserID; context.Session[SessionKey.LoginStatu] = 1; resp.errcode = (int)APIErrCode.IsSuccess; resp.errmsg = "注册成功"; resp.isSuccess = true; resp.returnObj = new { session_id = context.Session.SessionID, openid = regUser.WXOpenId }; } else { resp.errcode = (int)APIErrCode.RegisterFailure; resp.errmsg = "注册失败"; } bllUser.ContextResponse(context, resp); }
public void ProcessRequest(HttpContext context) { List <TableFieldMapping> formField = bllTableFieldMap.GetTableFieldMapByWebsite(bllTableFieldMap.WebsiteOwner, "ZCJ_UserInfo", null, null, context.Request["mapping_type"]); formField = formField.Where(p => p.IsReadOnly == 0 && p.IsDelete == 0 && p.Field != "AutoID").ToList(); if (formField.Count == 0) { apiResp.msg = "没有可编辑字段"; apiResp.code = (int)APIErrCode.OperateFail; bllTableFieldMap.ContextResponse(context, apiResp); return; } List <string> limitFields = new List <string>() { "UserID", "Phone", "WXOpenId" }; #region 默认信息检查 姓名 string autoID = context.Request["AutoID"]; if (string.IsNullOrWhiteSpace(autoID) || autoID == "0") { apiResp.msg = "用户未找到"; apiResp.code = (int)APIErrCode.OperateFail; bllTableFieldMap.ContextResponse(context, apiResp); return; } UserInfo curUser = bllTableFieldMap.GetByKey <UserInfo>("AutoID", autoID); if (curUser == null) { apiResp.msg = "用户未找到"; apiResp.code = (int)APIErrCode.OperateFail; bllTableFieldMap.ContextResponse(context, apiResp); return; } #endregion List <string> pms = new List <string>(); #region 构造修改字段 TableFieldMapping userIDField = formField.FirstOrDefault(p => p.Field.Equals("UserID")); if (userIDField != null) { string val = context.Request[userIDField.Field]; if (!string.IsNullOrWhiteSpace(val)) { List <UserInfo> oUserList = bllTableFieldMap.GetColList <UserInfo>(int.MaxValue, 1, string.Format("UserID='{0}' And AutoID != {1} ", val, autoID), "AutoID,UserID"); if (oUserList.Count > 0) { apiResp.msg = "账号已被使用"; apiResp.code = (int)APIErrCode.OperateFail; bllTableFieldMap.ContextResponse(context, apiResp); return; } pms.Add(string.Format("{0}='{1}'", userIDField.Field, val)); } } TableFieldMapping phoneField = formField.FirstOrDefault(p => p.Field.Equals("Phone")); if (phoneField != null) { string val = context.Request[phoneField.Field]; if (!string.IsNullOrWhiteSpace(val)) { List <UserInfo> oUserList = bllTableFieldMap.GetColList <UserInfo>(int.MaxValue, 1, string.Format("Phone='{0}' And WebsiteOwner='{2}' And AutoID != {1} And IsSubAccount!='1'", val, autoID, bllTableFieldMap.WebsiteOwner), "AutoID,Phone"); if (oUserList.Count > 0) { apiResp.msg = "手机号已被使用"; apiResp.code = (int)APIErrCode.OperateFail; bllTableFieldMap.ContextResponse(context, apiResp); return; } pms.Add(string.Format("{0}='{1}'", phoneField.Field, val)); } } TableFieldMapping wXOpenIdField = formField.FirstOrDefault(p => p.Field.Equals("WXOpenId")); if (wXOpenIdField != null) { string val = context.Request[wXOpenIdField.Field]; if (!string.IsNullOrWhiteSpace(val)) { List <UserInfo> oUserList = bllTableFieldMap.GetColList <UserInfo>(int.MaxValue, 1, string.Format("WXOpenId='{0}' And WebsiteOwner='{2}' And AutoID != {1} ", val, autoID, bllTableFieldMap.WebsiteOwner), "AutoID,Phone"); if (oUserList.Count > 0) { apiResp.msg = "WXOpenId已被使用"; apiResp.code = (int)APIErrCode.OperateFail; bllTableFieldMap.ContextResponse(context, apiResp); return; } pms.Add(string.Format("{0}='{1}'", wXOpenIdField.Field, val)); } } foreach (TableFieldMapping item in formField.Where(p => !limitFields.Contains(p.Field))) { string val = context.Request[item.Field]; if (string.IsNullOrWhiteSpace(val) && item.FieldIsNull == 1) { apiResp.msg = item.MappingName + "不能为空"; apiResp.code = (int)APIErrCode.OperateFail; bllTableFieldMap.ContextResponse(context, apiResp); return; } if (string.IsNullOrWhiteSpace(val)) { pms.Add(string.Format("{0}=Null", item.Field)); } else { if (!string.IsNullOrWhiteSpace(item.FormatValiFunc)) { #region 检查数据格式 //检查数据格式 if (item.FormatValiFunc == "number") { if (!MyRegex.IsNumber(val)) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = string.Format("{0}格式不正确", item.MappingName); bllTableFieldMap.ContextResponse(context, apiResp); return; } } if (item.FormatValiFunc == "phone")//email检查 { if (!MyRegex.PhoneNumLogicJudge(val)) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = string.Format("{0}格式不正确", item.MappingName); bllTableFieldMap.ContextResponse(context, apiResp); return; } } if (item.FormatValiFunc == "email")//email检查 { if (!MyRegex.EmailLogicJudge(val)) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = string.Format("{0}格式不正确", item.MappingName); bllTableFieldMap.ContextResponse(context, apiResp); return; } } if (item.FormatValiFunc == "url") //url检查 { System.Text.RegularExpressions.Regex regUrl = new System.Text.RegularExpressions.Regex(@"http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?"); //网址 System.Text.RegularExpressions.Match match = regUrl.Match(val); if (!match.Success) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = string.Format("{0}格式不正确", item.MappingName); bllTableFieldMap.ContextResponse(context, apiResp); return; } } #endregion } pms.Add(string.Format("{0}='{1}'", item.Field, val)); } } #endregion if (bllTableFieldMap.Update(new UserInfo(), ZentCloud.Common.MyStringHelper.ListToStr(pms, "", ","), string.Format("AutoID={0}", autoID)) > 0) { apiResp.status = true; apiResp.msg = "编辑完成"; apiResp.code = (int)APIErrCode.IsSuccess; bllUser.AddUserScoreDetail(curUser.UserID, CommonPlatform.Helper.EnumStringHelper.ToString(ZentCloud.BLLJIMP.Enums.ScoreDefineType.UpdateMyInfo), bllUser.WebsiteOwner, null, null); // TableFieldMapping tagNameField = formField.FirstOrDefault(p => p.Field.Equals("TagName")); if (tagNameField != null && context.Request["TagName"] != null) { foreach (var tag in context.Request["TagName"].Split(',')) { if (bllUser.GetCount <ZentCloud.BLLJIMP.Model.MemberTag>(string.Format(" WebsiteOwner='{0}' And TagName='{1}' And TagType='Member'", bllUser.WebsiteOwner, tag)) == 0) { ZentCloud.BLLJIMP.Model.MemberTag model = new BLLJIMP.Model.MemberTag(); model.CreateTime = DateTime.Now; model.WebsiteOwner = bllUser.WebsiteOwner; model.TagType = "Member"; model.TagName = tag; model.Creator = currentUserInfo.UserID; if (!bllUser.Add(model)) { apiResp.msg = "新增标签失败"; apiResp.code = (int)APIErrCode.OperateFail; bllTableFieldMap.ContextResponse(context, apiResp); } } } } // } else { apiResp.msg = "编辑失败"; apiResp.code = (int)APIErrCode.OperateFail; } bllTableFieldMap.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { BLLQuestion bllQuestion = new BLLQuestion(); BLLUser bllUser = new BLLUser(); ZentCloud.ZCBLLEngine.BLLTransaction tran = new ZCBLLEngine.BLLTransaction(); int examId = 0; try { string jsonData = context.Request["JsonData"]; QuestionnaireRecordList list = ZentCloud.Common.JSONHelper.JsonToModel <QuestionnaireRecordList>(jsonData); if (list.Data.Count > 0) { examId = list.Data[0].QuestionnaireID; if (bllUser.GetCount <QuestionnaireRecord>(string.Format("UserId='{0}' And QuestionnaireID={1}", CurrentUserInfo.UserID, list.Data[0].QuestionnaireID)) > 0) { apiResp.msg = "您已经提交过了"; context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp)); return; } long recordId = Convert.ToInt64(bllQuestion.GetRecordGUID()); foreach (var item in list.Data) { ZentCloud.BLLJIMP.Model.QuestionnaireRecordDetail model = new BLLJIMP.Model.QuestionnaireRecordDetail(); model.UserID = CurrentUserInfo.UserID; model.QuestionnaireID = item.QuestionnaireID; model.QuestionID = item.QuestionID; model.AnswerID = item.AnswerID; model.AnswerContent = item.AnswerContent; model.RecordID = recordId; if (!bllUser.Add(model)) { tran.Rollback(); apiResp.msg = "提交失败"; context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp)); return; } } QuestionnaireRecord record = new QuestionnaireRecord(); record.UserId = CurrentUserInfo.UserID; record.QuestionnaireID = list.Data[0].QuestionnaireID; record.InsertDate = DateTime.Now; record.IP = context.Request.UserHostAddress; record.RecordID = recordId; if (!bllUser.Add(record)) { tran.Rollback(); apiResp.msg = "提交失败"; context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp)); return; } } else//自动提交 { QuestionnaireRecord record = new QuestionnaireRecord(); record.UserId = CurrentUserInfo.UserID; record.QuestionnaireID = int.Parse(context.Request["examId"]); record.InsertDate = DateTime.Now; record.IP = context.Request.UserHostAddress; record.RecordID = 0; if (bllQuestion.Add(record)) { apiResp.status = true; Questionnaire questionModelA = bllUser.Get <Questionnaire>(string.Format(" QuestionnaireID={0} ", examId)); questionModelA.SubmitCount = bllUser.GetCount <QuestionnaireRecord>(string.Format(" QuestionnaireID={0}", examId)); bllUser.Update(questionModelA); } context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp)); return; } } catch (Exception ex) { tran.Rollback(); apiResp.msg = ex.Message; context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp)); return; } tran.Commit(); apiResp.status = true; int submitCount = bllUser.GetCount <QuestionnaireRecord>(string.Format(" QuestionnaireID={0}", examId)); Questionnaire questionModel = bllUser.Get <Questionnaire>(string.Format(" QuestionnaireID={0} ", examId)); if (questionModel != null) { questionModel.SubmitCount = submitCount; bllUser.Update(questionModel); } context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp)); }
public ActionResult Add(MODEL_USERS_Index model) { ReturnObject ro; if (ModelState.IsValid) { if (Request.IsAjaxRequest()) { if (model.ADD_FORM.USERGROUP_ID == 0) { ro = new ReturnObject { Code = 1, Message = "Kullanıcı için bir yetki grubu seçmelisiniz. Yetkilerini arttırmak/azaltmak için kullanıcıyı ekledikten sonra Yetkileri bölümünden gerekli işlemleri yapabilirsiniz." }; return(Json(new { ro })); } using (var bllUser = new BLLUser()) { var usr = bllUser.UserAddEditAnyControl(model.EDIT_FORM.FORM.USERNAME, model.EDIT_FORM.FORM.EMAIL); if (usr) { ro = new ReturnObject { Code = 1, Message = "Belirtilen Kullanıcı Adı / E-Posta adresi sistemte zaten kayıtlı." }; return(Json(new { ro })); } model.ADD_FORM.FORM.ADDED_DATETIME = DateTime.Now; model.ADD_FORM.FORM.ACTIVE = true; model.ADD_FORM.FORM.PASSWORD = model.ADD_FORM.FORM.PASSWORD.ToMD5(); var q = bllUser.Add(model.ADD_FORM.FORM); using (var bllUserPermission = new BLLUserPermission()) { bllUserPermission.Add(new TBL_USER_PERMISSION { USER_ID = q.ID, USERGROUP_ID = model.ADD_FORM.USERGROUP_ID }); } } ro = new ReturnObject { Code = 0, Url = Url.Action("Index") }; return(Json(new { ro })); } return(null); } ro = new ReturnObject { Code = 1, Message = "Model valid değil." }; return(Json(new { ro })); }
public void ProcessRequest(HttpContext context) { int uid = int.Parse(context.Request["AutoID"]); UserInfo tUser = bllUser.GetUserInfoByAutoID(uid); long oPermissionGroupID = tUser.PermissionGroupID.HasValue ? tUser.PermissionGroupID.Value : 0; string oPhone = tUser.Phone; string oEmail = tUser.Email; tUser = bllUser.ConvertRequestToModel <UserInfo>(tUser); if (string.IsNullOrWhiteSpace(tUser.UserID) || string.IsNullOrWhiteSpace(tUser.Password)) { apiResp.code = (int)APIErrCode.PrimaryKeyIncomplete; apiResp.msg = "账户和密码不能为空"; bllUser.ContextResponse(context, apiResp); return; } //if (!string.IsNullOrWhiteSpace(tUser.Phone) && !ZentCloud.Common.MyRegex.PhoneNumLogicJudge(tUser.Phone)) //{ // apiResp.code = (int)APIErrCode.PrimaryKeyIncomplete; // apiResp.msg = "请输入正确的手机号码"; // bllUser.ContextResponse(context, apiResp); // return; //} if (!string.IsNullOrWhiteSpace(tUser.Email) && !ZentCloud.Common.MyRegex.EmailLogicJudge(tUser.Email)) { apiResp.code = (int)APIErrCode.PrimaryKeyIncomplete; apiResp.msg = "请输入正确的邮箱地址"; bllUser.ContextResponse(context, apiResp); return; } if (!tUser.PermissionGroupID.HasValue) { apiResp.code = (int)APIErrCode.PrimaryKeyIncomplete; apiResp.msg = "请选择角色"; bllUser.ContextResponse(context, apiResp); return; } BLLTransaction tran = new BLLTransaction(); if (!bllUser.Update(tUser, tran)) { tran.Rollback(); apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "编辑用户出错"; bllUser.ContextResponse(context, apiResp); return; } if (oPermissionGroupID != tUser.PermissionGroupID.Value) { var ogroup = new BLLPermission.Model.UserPmsGroupRelationInfo() { UserID = tUser.UserID, GroupID = oPermissionGroupID }; if (bllUser.Delete(ogroup) < 0)//删除权限组 { tran.Rollback(); apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "删除旧权限组出错"; bllUser.ContextResponse(context, apiResp); return; } var group = new BLLPermission.Model.UserPmsGroupRelationInfo() { UserID = tUser.UserID, GroupID = tUser.PermissionGroupID.Value }; if (bllUser.GetCount <BLLPermission.Model.UserPmsGroupRelationInfo>(string.Format("UserID='{0}' And GroupID={1}", group.UserID, group.GroupID)) == 0) { if (!bllUser.Add(group))//添加权限组 { tran.Rollback(); apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "添加权限组出错"; bllUser.ContextResponse(context, apiResp); return; } } } tran.Commit(); apiResp.code = (int)APIErrCode.IsSuccess; apiResp.status = true; apiResp.msg = "修改完成"; bllUser.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { BLLJIMP.Model.API.User.PayUpgrade requestUpgrade = bll.ConvertRequestToModel <BLLJIMP.Model.API.User.PayUpgrade>(new BLLJIMP.Model.API.User.PayUpgrade()); string websiteOwner = bll.WebsiteOwner; requestUpgrade.level = CurrentUserInfo.MemberLevel; WebsiteInfo website = bllUser.GetWebsiteInfoModelFromDataBase(websiteOwner); UserLevelConfig levelConfig = bll.QueryUserLevel(websiteOwner, "DistributionOnLine", requestUpgrade.level.ToString()); if (levelConfig == null) { requestUpgrade.userTotalAmount = 0; } else { requestUpgrade.userTotalAmount = Convert.ToDecimal(levelConfig.FromHistoryScore); } UserLevelConfig toLevelConfig = bll.QueryUserLevel(websiteOwner, "DistributionOnLine", requestUpgrade.toLevel.ToString()); if (toLevelConfig == null) { apiResp.code = (int)APIErrCode.IsNotFound; apiResp.msg = "会员等级未找到"; bll.ContextResponse(context, apiResp); return; } if (toLevelConfig.IsDisable == 1) { apiResp.code = (int)APIErrCode.IsNotFound; apiResp.msg = "会员级别禁止升级"; bll.ContextResponse(context, apiResp); return; } requestUpgrade.needAmount = Convert.ToDecimal(toLevelConfig.FromHistoryScore); requestUpgrade.amount = requestUpgrade.needAmount - requestUpgrade.userTotalAmount; if (requestUpgrade.amount < 0) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "暂时不支持降级"; bll.ContextResponse(context, apiResp); return; } string configV1CouponId = ZentCloud.Common.ConfigHelper.GetConfigString("YGBV1CouponId"); string configV2CouponId = ZentCloud.Common.ConfigHelper.GetConfigString("YGBV2CouponId"); string v1LevelNumber = ZentCloud.Common.ConfigHelper.GetConfigString("V1LevelNumber"); string v2LevelNumber = ZentCloud.Common.ConfigHelper.GetConfigString("V2LevelNumber"); string couponId = string.Empty; CardCoupons cardModel = null; MyCardCoupons myCardCoupon = null; if (requestUpgrade.vType == "V1") { if (string.IsNullOrEmpty(configV1CouponId)) { apiResp.code = (int)APIErrCode.ContentNotFound; apiResp.msg = "V1优惠券未配置"; bllUser.ContextResponse(context, apiResp); return; } couponId = configV1CouponId; cardModel = bllCardCoupon.GetCardCoupon(Convert.ToInt32(couponId)); myCardCoupon = bllCardCoupon.GetMyCardCouponMainId(Convert.ToInt32(couponId), CurrentUserInfo.UserID); if (cardModel == null || myCardCoupon == null) { apiResp.code = (int)APIErrCode.ContentNotFound; apiResp.msg = "优惠券不存在"; bllUser.ContextResponse(context, apiResp); return; } if (requestUpgrade.toLevel.ToString() != v1LevelNumber) { apiResp.code = (int)APIErrCode.ContentNotFound; apiResp.msg = "优惠券不匹配"; bllUser.ContextResponse(context, apiResp); return; } } if (requestUpgrade.vType == "V2") { if (string.IsNullOrEmpty(configV2CouponId)) { apiResp.code = (int)APIErrCode.ContentNotFound; apiResp.msg = "V2优惠券未配置"; bllUser.ContextResponse(context, apiResp); return; } couponId = configV2CouponId; cardModel = bllCardCoupon.GetCardCoupon(Convert.ToInt32(couponId)); myCardCoupon = bllCardCoupon.GetMyCardCouponMainId(Convert.ToInt32(couponId), CurrentUserInfo.UserID); if (cardModel == null || myCardCoupon == null) { apiResp.code = (int)APIErrCode.ContentNotFound; apiResp.msg = "优惠券不存在"; bllUser.ContextResponse(context, apiResp); return; } if (requestUpgrade.toLevel.ToString() != v2LevelNumber) { apiResp.code = (int)APIErrCode.ContentNotFound; apiResp.msg = "优惠券不能用于此升级"; bllUser.ContextResponse(context, apiResp); return; } } BLLTransaction tran = new BLLTransaction(); StringBuilder sbSql = new StringBuilder(); UserInfo upUserLevel1 = null; //分销上一级 UserInfo upUserLevel2 = null; //分销上二级 UserInfo upUserLevel3 = null; //分销上三级 UserLevelConfig levelConfig1 = null; //分销上一级规则 UserLevelConfig levelConfig2 = null; //分销上二级规则 UserLevelConfig levelConfig3 = null; //分销上三级规则 ProjectCommission modelLevel1 = new ProjectCommission(); ScoreLockInfo scoreLockLevel1Info = new ScoreLockInfo(); ProjectCommission modelLevel1ex1 = new ProjectCommission(); ScoreLockInfo scoreLockLevel1ex1Info = new ScoreLockInfo(); ProjectCommission modelLevel2 = new ProjectCommission(); ScoreLockInfo scoreLockLevel2Info = new ScoreLockInfo(); ProjectCommission modelLevel3 = new ProjectCommission(); ScoreLockInfo scoreLockLevel3Info = new ScoreLockInfo(); int disLevel = 1; if (website.DistributionLimitLevel > 1) { disLevel = website.DistributionLimitLevel; } string projectId = bll.GetGUID(TransacType.PayRegisterOrder); CurrentUserInfo.MemberLevel = requestUpgrade.toLevel; CurrentUserInfo.MemberApplyStatus = 9; //计算分佣 bll.ComputeTransfers(disLevel, CurrentUserInfo, projectId, requestUpgrade.amount, websiteOwner, "余额升级", ref sbSql, ref upUserLevel1, ref upUserLevel2, ref upUserLevel3, ref levelConfig1, ref levelConfig2, ref levelConfig3, ref modelLevel1, ref scoreLockLevel1Info, ref modelLevel1ex1, ref scoreLockLevel1ex1Info, ref modelLevel2, ref scoreLockLevel2Info, ref modelLevel3, ref scoreLockLevel3Info, toLevelConfig.LevelString); if (bll.Update(CurrentUserInfo, string.Format(" MemberLevel={0},IsDisable=0,MemberApplyStatus=9 ", CurrentUserInfo.MemberLevel), string.Format(" AutoId='{0}' ", CurrentUserInfo.AutoID), tran) <= 0) { tran.Rollback(); apiResp.msg = "更新用户等级失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } bool hasProjectCommission = false; #region 记录分佣信息 if (modelLevel1.Amount > 0) { hasProjectCommission = true; int modelLevel1Id = Convert.ToInt32(bll.AddReturnID(modelLevel1, tran)); if (modelLevel1Id <= 0) { apiResp.msg = "一级返利失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } scoreLockLevel1Info.ForeignkeyId2 = modelLevel1Id.ToString(); scoreLockLevel1Info.AutoId = Convert.ToInt32(bll.AddReturnID(scoreLockLevel1Info, tran)); if (scoreLockLevel1Info.AutoId <= 0) { apiResp.msg = "一级返利冻结失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } string scoreDetailEvent = modelLevel1.ProjectName.Contains("购房补助") ? "返购房补助" : "返利"; if (bllUser.AddScoreDetail(scoreLockLevel1Info.UserId, websiteOwner, (double)scoreLockLevel1Info.Score, scoreLockLevel1Info.Memo, "TotalAmount", (double)(upUserLevel1.TotalAmount + scoreLockLevel1Info.Score), scoreLockLevel1Info.AutoId.ToString(), scoreDetailEvent, "", projectId, (double)modelLevel1.SourceAmount, (double)modelLevel1.DeductAmount, modelLevel1.CommissionUserId, tran, ex1: levelConfig.LevelNumber.ToString(), ex2: levelConfig.LevelString, ex3: toLevelConfig.LevelNumber.ToString(), ex4: toLevelConfig.LevelString, ex5: modelLevel1.CommissionLevel) <= 0) { tran.Rollback(); apiResp.msg = "一级返利明细记录失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } } if (modelLevel1ex1.Amount > 0) { hasProjectCommission = true; int modelLevel1ex1Id = Convert.ToInt32(bll.AddReturnID(modelLevel1ex1, tran)); if (modelLevel1ex1Id <= 0) { apiResp.msg = "一级返购房补助失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } scoreLockLevel1ex1Info.ForeignkeyId2 = modelLevel1ex1Id.ToString(); scoreLockLevel1ex1Info.AutoId = Convert.ToInt32(bll.AddReturnID(scoreLockLevel1ex1Info, tran)); if (scoreLockLevel1ex1Info.AutoId <= 0) { apiResp.msg = "一级返购房补助冻结失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } string scoreDetailEvent = modelLevel1ex1.ProjectName.Contains("购房补助") ? "返购房补助" : "返利"; if (bllUser.AddScoreDetail(scoreLockLevel1ex1Info.UserId, websiteOwner, (double)scoreLockLevel1ex1Info.Score, scoreLockLevel1ex1Info.Memo, "TotalAmount", (double)(upUserLevel1.TotalAmount + scoreLockLevel1ex1Info.Score), scoreLockLevel1ex1Info.AutoId.ToString(), scoreDetailEvent, "", projectId, (double)modelLevel1ex1.SourceAmount, (double)modelLevel1ex1.DeductAmount, modelLevel1ex1.CommissionUserId, tran, ex1: levelConfig.LevelNumber.ToString(), ex2: levelConfig.LevelString, ex3: toLevelConfig.LevelNumber.ToString(), ex4: toLevelConfig.LevelString, ex5: modelLevel1ex1.CommissionLevel) <= 0) { tran.Rollback(); apiResp.msg = "一级返购房补助明细记录失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } } if (modelLevel2.Amount > 0) { hasProjectCommission = true; int modelLevel2Id = Convert.ToInt32(bll.AddReturnID(modelLevel2, tran)); if (modelLevel2Id <= 0) { apiResp.msg = "二级返利失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } scoreLockLevel2Info.ForeignkeyId2 = modelLevel2Id.ToString(); scoreLockLevel2Info.AutoId = Convert.ToInt32(bll.AddReturnID(scoreLockLevel2Info, tran)); if (scoreLockLevel2Info.AutoId <= 0) { tran.Rollback(); apiResp.msg = "二级返利冻结失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } string scoreDetailEvent = modelLevel2.ProjectName.Contains("购房补助") ? "返购房补助" : "返利"; if (bllUser.AddScoreDetail(scoreLockLevel2Info.UserId, websiteOwner, (double)scoreLockLevel2Info.Score, scoreLockLevel2Info.Memo, "TotalAmount", (double)(upUserLevel2.TotalAmount + scoreLockLevel2Info.Score), scoreLockLevel2Info.AutoId.ToString(), scoreDetailEvent, "", projectId, (double)modelLevel2.SourceAmount, (double)modelLevel2.DeductAmount, modelLevel2.CommissionUserId, tran, ex1: levelConfig.LevelNumber.ToString(), ex2: levelConfig.LevelString, ex3: toLevelConfig.LevelNumber.ToString(), ex4: toLevelConfig.LevelString, ex5: modelLevel2.CommissionLevel) <= 0) { tran.Rollback(); apiResp.msg = "二级返利明细记录失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } } if (modelLevel3.Amount > 0) { hasProjectCommission = true; int modelLevel3Id = Convert.ToInt32(bll.AddReturnID(modelLevel3, tran)); if (!bll.Add(modelLevel3, tran)) { tran.Rollback(); apiResp.msg = "三级返利失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } scoreLockLevel3Info.ForeignkeyId2 = modelLevel3Id.ToString(); scoreLockLevel3Info.AutoId = Convert.ToInt32(bll.AddReturnID(scoreLockLevel3Info, tran)); if (scoreLockLevel3Info.AutoId <= 0) { tran.Rollback(); apiResp.msg = "三级返利冻结失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } string scoreDetailEvent = modelLevel3.ProjectName.Contains("购房补助") ? "返购房补助" : "返利"; if (bllUser.AddScoreDetail(scoreLockLevel3Info.UserId, websiteOwner, (double)scoreLockLevel3Info.Score, scoreLockLevel3Info.Memo, "TotalAmount", (double)(upUserLevel3.TotalAmount + scoreLockLevel3Info.Score), scoreLockLevel3Info.AutoId.ToString(), scoreDetailEvent, "", projectId, (double)modelLevel3.SourceAmount, (double)modelLevel3.DeductAmount, modelLevel3.CommissionUserId, tran, ex1: levelConfig.LevelNumber.ToString(), ex2: levelConfig.LevelString, ex3: toLevelConfig.LevelNumber.ToString(), ex4: toLevelConfig.LevelString, ex5: modelLevel3.CommissionLevel) <= 0) { tran.Rollback(); apiResp.msg = "三级返利明细记录失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } } #endregion #region 更新分佣账面金额 if (hasProjectCommission) { if (BLLBase.ExecuteSql(sbSql.ToString(), tran) <= 0) { tran.Rollback(); apiResp.msg = string.Format("更新分佣账面{0}出错", website.TotalAmountShowName); apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } } #endregion #region 记录余额明细 //自己的消费记录 if (bllUser.AddScoreDetail(CurrentUserInfo.UserID, websiteOwner, (double)(0 - requestUpgrade.amount), string.Format("{1}为{0}", toLevelConfig.LevelString, "升级"), "TotalAmount", (double)(CurrentUserInfo.TotalAmount - requestUpgrade.amount), "", "升级会员", "", "", (double)requestUpgrade.amount, 0, "", tran, ex1: levelConfig.LevelNumber.ToString(), ex2: levelConfig.LevelString, ex3: toLevelConfig.LevelNumber.ToString(), ex4: toLevelConfig.LevelString) <= 0) { tran.Rollback(); apiResp.msg = "升级会员明细出错"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } #endregion #region 修改优惠券 更新支付状态 myCardCoupon.UseDate = DateTime.Now; myCardCoupon.Status = 1; if (!bllCardCoupon.Update(myCardCoupon, tran)) { tran.Rollback(); apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "更新优惠券状态失败"; bll.ContextResponse(context, apiResp); return; } #endregion #region 记录业绩明细 TeamPerformanceDetails perDetail = new TeamPerformanceDetails(); perDetail.AddType = "升级"; perDetail.AddNote = "由" + levelConfig.LevelString + "升级" + toLevelConfig.LevelString; perDetail.AddTime = DateTime.Now; perDetail.DistributionOwner = CurrentUserInfo.DistributionOwner; perDetail.UserId = CurrentUserInfo.UserID; perDetail.UserName = CurrentUserInfo.TrueName; perDetail.UserPhone = CurrentUserInfo.Phone; perDetail.Performance = requestUpgrade.amount; string yearMonthString = perDetail.AddTime.ToString("yyyyMM"); int yearMonth = Convert.ToInt32(yearMonthString); perDetail.WebsiteOwner = websiteOwner; perDetail.YearMonth = yearMonth; if (!bllUser.Add(perDetail, tran)) { tran.Rollback(); apiResp.msg = "记录业绩明细失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } #endregion tran.Commit(); if (hasProjectCommission) { //异步修改积分明细表 Thread th1 = new Thread(delegate() { //计算相关业绩 bll.BuildCurMonthPerformanceByUserID(websiteOwner, CurrentUserInfo.UserID); }); th1.Start(); } apiResp.msg = "升级完成"; apiResp.code = (int)APIErrCode.IsSuccess; apiResp.status = true; bll.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { if (CurrentUserInfo.IsLock == 1) { apiResp.code = (int)APIErrCode.NoPms; apiResp.msg = "账号已被锁定"; bllUser.ContextResponse(context, apiResp); return; } if (CurrentUserInfo.MemberApplyStatus != 9) { apiResp.code = (int)APIErrCode.NoPms; apiResp.msg = "您的账号正在审核中"; bllUser.ContextResponse(context, apiResp); return; } BLLJIMP.Model.API.User.PayUpgrade requestUpgrade = bll.ConvertRequestToModel <BLLJIMP.Model.API.User.PayUpgrade>(new BLLJIMP.Model.API.User.PayUpgrade()); string websiteOwner = bll.WebsiteOwner; requestUpgrade.level = CurrentUserInfo.MemberLevel; WebsiteInfo website = bllUser.GetWebsiteInfoModelFromDataBase(websiteOwner); UserLevelConfig levelConfig = bll.QueryUserLevel(websiteOwner, "DistributionOnLine", requestUpgrade.level.ToString()); if (levelConfig == null) { requestUpgrade.userTotalAmount = 0; } else { requestUpgrade.userTotalAmount = Convert.ToDecimal(levelConfig.FromHistoryScore); } UserLevelConfig toLevelConfig = bll.QueryUserLevel(websiteOwner, "DistributionOnLine", requestUpgrade.toLevel.ToString()); if (toLevelConfig == null) { apiResp.code = (int)APIErrCode.IsNotFound; apiResp.msg = "会员等级未找到"; bll.ContextResponse(context, apiResp); return; } if (toLevelConfig.IsDisable == 1) { apiResp.code = (int)APIErrCode.IsNotFound; apiResp.msg = "会员级别禁止升级"; bll.ContextResponse(context, apiResp); return; } requestUpgrade.needAmount = Convert.ToDecimal(toLevelConfig.FromHistoryScore); requestUpgrade.amount = requestUpgrade.needAmount - requestUpgrade.userTotalAmount; if (requestUpgrade.amount < 0) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "暂时不支持降级"; bll.ContextResponse(context, apiResp); return; } if (CurrentUserInfo.TotalAmount < requestUpgrade.amount) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = string.Format("您的可用{0}不足", website.TotalAmountShowName); bll.ContextResponse(context, apiResp); return; } BLLTransaction tran = new BLLTransaction(); StringBuilder sbSql = new StringBuilder(); UserInfo upUserLevel1 = null; //分销上一级 UserInfo upUserLevel2 = null; //分销上二级 UserInfo upUserLevel3 = null; //分销上三级 UserLevelConfig levelConfig1 = null; //分销上一级规则 UserLevelConfig levelConfig2 = null; //分销上二级规则 UserLevelConfig levelConfig3 = null; //分销上三级规则 ProjectCommission modelLevel1 = new ProjectCommission(); ScoreLockInfo scoreLockLevel1Info = new ScoreLockInfo(); ProjectCommission modelLevel1ex1 = new ProjectCommission(); ScoreLockInfo scoreLockLevel1ex1Info = new ScoreLockInfo(); ProjectCommission modelLevel2 = new ProjectCommission(); ScoreLockInfo scoreLockLevel2Info = new ScoreLockInfo(); ProjectCommission modelLevel3 = new ProjectCommission(); ScoreLockInfo scoreLockLevel3Info = new ScoreLockInfo(); int disLevel = 1; if (website.DistributionLimitLevel > 1) { disLevel = website.DistributionLimitLevel; } string projectId = bll.GetGUID(TransacType.PayRegisterOrder); CurrentUserInfo.MemberLevel = requestUpgrade.toLevel; CurrentUserInfo.MemberApplyStatus = 9; //计算分佣 bll.ComputeTransfers(disLevel, CurrentUserInfo, projectId, requestUpgrade.amount, websiteOwner, "余额升级", ref sbSql, ref upUserLevel1, ref upUserLevel2, ref upUserLevel3, ref levelConfig1, ref levelConfig2, ref levelConfig3, ref modelLevel1, ref scoreLockLevel1Info, ref modelLevel1ex1, ref scoreLockLevel1ex1Info, ref modelLevel2, ref scoreLockLevel2Info, ref modelLevel3, ref scoreLockLevel3Info, toLevelConfig.LevelString); bool hasProjectCommission = false; #region 记录分佣信息 if (modelLevel1.Amount > 0) { hasProjectCommission = true; int modelLevel1Id = Convert.ToInt32(bll.AddReturnID(modelLevel1, tran)); if (modelLevel1Id <= 0) { apiResp.msg = "一级返利失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } scoreLockLevel1Info.ForeignkeyId2 = modelLevel1Id.ToString(); scoreLockLevel1Info.AutoId = Convert.ToInt32(bll.AddReturnID(scoreLockLevel1Info, tran)); if (scoreLockLevel1Info.AutoId <= 0) { apiResp.msg = "一级返利冻结失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } string scoreDetailEvent = modelLevel1.ProjectName.Contains("购房补助") ? "返购房补助" : "返利"; if (bllUser.AddScoreDetail(scoreLockLevel1Info.UserId, websiteOwner, (double)scoreLockLevel1Info.Score, scoreLockLevel1Info.Memo, "TotalAmount", (double)(upUserLevel1.TotalAmount + scoreLockLevel1Info.Score), scoreLockLevel1Info.AutoId.ToString(), scoreDetailEvent, "", projectId, (double)modelLevel1.SourceAmount, (double)modelLevel1.DeductAmount, modelLevel1.CommissionUserId, tran, ex1: levelConfig.LevelNumber.ToString(), ex2: levelConfig.LevelString, ex3: toLevelConfig.LevelNumber.ToString(), ex4: toLevelConfig.LevelString, ex5: modelLevel1.CommissionLevel) <= 0) { tran.Rollback(); apiResp.msg = "一级返利明细记录失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } } if (modelLevel1ex1.Amount > 0) { hasProjectCommission = true; int modelLevel1ex1Id = Convert.ToInt32(bll.AddReturnID(modelLevel1ex1, tran)); if (modelLevel1ex1Id <= 0) { apiResp.msg = "一级返购房补助失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } scoreLockLevel1ex1Info.ForeignkeyId2 = modelLevel1ex1Id.ToString(); scoreLockLevel1ex1Info.AutoId = Convert.ToInt32(bll.AddReturnID(scoreLockLevel1ex1Info, tran)); if (scoreLockLevel1ex1Info.AutoId <= 0) { apiResp.msg = "一级返购房补助冻结失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } string scoreDetailEvent = modelLevel1ex1.ProjectName.Contains("购房补助") ? "返购房补助" : "返利"; if (bllUser.AddScoreDetail(scoreLockLevel1ex1Info.UserId, websiteOwner, (double)scoreLockLevel1ex1Info.Score, scoreLockLevel1ex1Info.Memo, "TotalAmount", (double)(upUserLevel1.TotalAmount + scoreLockLevel1ex1Info.Score), scoreLockLevel1ex1Info.AutoId.ToString(), scoreDetailEvent, "", projectId, (double)modelLevel1ex1.SourceAmount, (double)modelLevel1ex1.DeductAmount, modelLevel1ex1.CommissionUserId, tran, ex1: levelConfig.LevelNumber.ToString(), ex2: levelConfig.LevelString, ex3: toLevelConfig.LevelNumber.ToString(), ex4: toLevelConfig.LevelString, ex5: modelLevel1ex1.CommissionLevel) <= 0) { tran.Rollback(); apiResp.msg = "一级返购房补助明细记录失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } } if (modelLevel2.Amount > 0) { hasProjectCommission = true; int modelLevel2Id = Convert.ToInt32(bll.AddReturnID(modelLevel2, tran)); if (modelLevel2Id <= 0) { apiResp.msg = "二级返利失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } scoreLockLevel2Info.ForeignkeyId2 = modelLevel2Id.ToString(); scoreLockLevel2Info.AutoId = Convert.ToInt32(bll.AddReturnID(scoreLockLevel2Info, tran)); if (scoreLockLevel2Info.AutoId <= 0) { tran.Rollback(); apiResp.msg = "二级返利冻结失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } string scoreDetailEvent = modelLevel2.ProjectName.Contains("购房补助") ? "返购房补助" : "返利"; if (bllUser.AddScoreDetail(scoreLockLevel2Info.UserId, websiteOwner, (double)scoreLockLevel2Info.Score, scoreLockLevel2Info.Memo, "TotalAmount", (double)(upUserLevel2.TotalAmount + scoreLockLevel2Info.Score), scoreLockLevel2Info.AutoId.ToString(), scoreDetailEvent, "", projectId, (double)modelLevel2.SourceAmount, (double)modelLevel2.DeductAmount, modelLevel2.CommissionUserId, tran, ex1: levelConfig.LevelNumber.ToString(), ex2: levelConfig.LevelString, ex3: toLevelConfig.LevelNumber.ToString(), ex4: toLevelConfig.LevelString, ex5: modelLevel2.CommissionLevel) <= 0) { tran.Rollback(); apiResp.msg = "二级返利明细记录失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } } if (modelLevel3.Amount > 0) { hasProjectCommission = true; int modelLevel3Id = Convert.ToInt32(bll.AddReturnID(modelLevel3, tran)); if (!bll.Add(modelLevel3, tran)) { tran.Rollback(); apiResp.msg = "三级返利失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } scoreLockLevel3Info.ForeignkeyId2 = modelLevel3Id.ToString(); scoreLockLevel3Info.AutoId = Convert.ToInt32(bll.AddReturnID(scoreLockLevel3Info, tran)); if (scoreLockLevel3Info.AutoId <= 0) { tran.Rollback(); apiResp.msg = "三级返利冻结失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } string scoreDetailEvent = modelLevel3.ProjectName.Contains("购房补助") ? "返购房补助" : "返利"; if (bllUser.AddScoreDetail(scoreLockLevel3Info.UserId, websiteOwner, (double)scoreLockLevel3Info.Score, scoreLockLevel3Info.Memo, "TotalAmount", (double)(upUserLevel3.TotalAmount + scoreLockLevel3Info.Score), scoreLockLevel3Info.AutoId.ToString(), scoreDetailEvent, "", projectId, (double)modelLevel3.SourceAmount, (double)modelLevel3.DeductAmount, modelLevel3.CommissionUserId, tran, ex1: levelConfig.LevelNumber.ToString(), ex2: levelConfig.LevelString, ex3: toLevelConfig.LevelNumber.ToString(), ex4: toLevelConfig.LevelString, ex5: modelLevel3.CommissionLevel) <= 0) { tran.Rollback(); apiResp.msg = "三级返利明细记录失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } } #endregion #region 更新分佣账面金额 if (hasProjectCommission) { if (BLLBase.ExecuteSql(sbSql.ToString(), tran) <= 0) { tran.Rollback(); apiResp.msg = string.Format("更新分佣账面{0}出错", website.TotalAmountShowName); apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } } #endregion #region 记录余额明细 //自己的消费记录 if (bllUser.AddScoreDetail(CurrentUserInfo.UserID, websiteOwner, (double)(0 - requestUpgrade.amount), string.Format("{1}为{0}", toLevelConfig.LevelString, "升级"), "TotalAmount", (double)(CurrentUserInfo.TotalAmount - requestUpgrade.amount), "", "升级会员", "", "", (double)requestUpgrade.amount, 0, "", tran, ex1: levelConfig.LevelNumber.ToString(), ex2: levelConfig.LevelString, ex3: toLevelConfig.LevelNumber.ToString(), ex4: toLevelConfig.LevelString) <= 0) { tran.Rollback(); apiResp.msg = "升级会员明细出错"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } #endregion #region 修改金额 更新支付状态 if (BLLBase.ExecuteSql(string.Format("UPDATE ZCJ_UserInfo SET MemberLevel={0},IsDisable=0,MemberApplyStatus=9,TotalAmount=ISNULL(TotalAmount,0)-{3},AccountAmountEstimate=ISNULL(AccountAmountEstimate,0)-{3} FROM ZCJ_UserInfo WHERE UserID='{1}' And WebsiteOwner='{2}' And ISNULL(TotalAmount,0)-{3}>=0 ;", requestUpgrade.toLevel, CurrentUserInfo.UserID, websiteOwner, requestUpgrade.amount), tran) <= 0) { tran.Rollback(); apiResp.msg = string.Format("扣除用户可用{0}出错", website.TotalAmountShowName); apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } #endregion #region 记录业绩明细 TeamPerformanceDetails perDetail = new TeamPerformanceDetails(); perDetail.AddType = "升级"; perDetail.AddNote = "由" + levelConfig.LevelString + "升级" + toLevelConfig.LevelString; perDetail.AddTime = DateTime.Now; perDetail.DistributionOwner = CurrentUserInfo.DistributionOwner; perDetail.UserId = CurrentUserInfo.UserID; perDetail.UserName = CurrentUserInfo.TrueName; perDetail.UserPhone = CurrentUserInfo.Phone; perDetail.Performance = requestUpgrade.amount; string yearMonthString = perDetail.AddTime.ToString("yyyyMM"); int yearMonth = Convert.ToInt32(yearMonthString); perDetail.WebsiteOwner = websiteOwner; perDetail.YearMonth = yearMonth; if (!bllUser.Add(perDetail, tran)) { tran.Rollback(); apiResp.msg = "记录业绩明细失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } #endregion tran.Commit(); if (hasProjectCommission) { //异步修改积分明细表 Thread th1 = new Thread(delegate() { //计算相关业绩 bll.BuildCurMonthPerformanceByUserID(websiteOwner, CurrentUserInfo.UserID); }); th1.Start(); } apiResp.msg = "升级完成"; apiResp.code = (int)APIErrCode.IsSuccess; apiResp.status = true; bll.ContextResponse(context, apiResp); }
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>"); } }
////数据回传接收,更新或新增会员数据 //public string CallBackMemberInfo(Entity.MemberCallBackReq memberResp) //{ // string result = string.Empty; // var timestamp = ZentCloud.Common.DateTimeHelper.GetTimeIntStr(DateTime.Now); // var sign = ZentCloud.Common.SHA1.SHA1_Encrypt(string.Format("AppId={0}&Timestamp={1}&Token={2}", AppId, timestamp, Token)); // Entity.MemberInfo member = memberResp.Args; // if (string.IsNullOrWhiteSpace(member.WxUnionId)) // { // return JsonConvert.SerializeObject(new // { // Status = false, // StatusCode = 0, // Msg = "错误:WxUnionId为空", // Timestamp = timestamp, // Sign = sign, // Result = 0 // }); // } // var inputSign = CreateSign(memberResp.AppId, memberResp.Timestamp, Token).ToUpper(); // if (inputSign != memberResp.Sign.ToUpper()) // { // return JsonConvert.SerializeObject(new // { // Status = false, // StatusCode = 0, // Msg = "错误:签名错误", // Timestamp = timestamp, // Sign = sign, // Result = 0 // }); // } // BLLUser bllUser = new BLLUser(); // bool updateResult = false; // if (member != null) // { // //根据WXUnionId 查找系统用户 // var userInfo = bllUser.GetUserInfoByWXUnionID(member.WxUnionId); // //更新用户数据 // if (userInfo != null) // { // #region 更新用户信息 // if (bllUser.Update( // new ZentCloud.BLLJIMP.Model.UserInfo(), // string.Format(" Ex1='{0}',Ex2='{1}',WXNickname='{2}',Phone='{3}',TrueName='{4}',WXSex={5},Birthday='{6}',WXUnionID='{8}',WeiboID='{9}',QQ='{10}',TaobaoId='{11}',Email='{12}',Ex3='{13}',Ex4='{14}',WXProvince='{15}',WXCity='{16}',WXCountry='{17}',Password='******'", // member.OldCode, // member.Code, // member.NickName, // member.MobileNo, // member.Name, // member.Sex, // member.Birthday, // member.WxNo,//不更新 // member.WxUnionId, // member.WeibNo, // member.QqNo, // member.TbNo, // member.Email, // member.RegShop, // member.RegDate, // member.Province, // member.City, // member.County, // member.PassWord // ), // string.Format(" UserID = '{0}' ", userInfo.UserID)) > 0 // ) // { // updateResult = true; // } // #endregion // } // else // { // #region 新增用户信息 // //新增用户信息 // userInfo = new ZentCloud.BLLJIMP.Model.UserInfo(); // //userInfo.UserID = string.Format("WXUser_yike_{0}{1}", ZentCloud.Common.StringHelper.GetDateTimeNum(), ZentCloud.Common.Rand.Str(5));//WXUser+时间字符串+随机5位数字 // userInfo.UserID = string.Format("WXUser_yike_{0}", Guid.NewGuid().ToString()); // userInfo.Password = ZentCloud.Common.Rand.Str_char(12); // userInfo.UserType = 2; // userInfo.WebsiteOwner = bllUser.WebsiteOwner; // userInfo.Regtime = DateTime.Now; // userInfo.RegIP = ZentCloud.Common.MySpider.GetClientIP(); // userInfo.LastLoginIP = ZentCloud.Common.MySpider.GetClientIP(); // userInfo.LastLoginDate = DateTime.Now; // userInfo.LoginTotalCount = 1; // userInfo.Ex1 = member.OldCode;//线下会员卡号 // userInfo.Ex2 = member.Code;//线上会员卡号 // userInfo.WXNickname = member.NickName; // userInfo.Phone = member.MobileNo; // userInfo.TrueName = member.Name; // userInfo.WXSex = Convert.ToInt32(member.Sex); // DateTime bd = DateTime.Now; // if(DateTime.TryParse(member.Birthday, out bd)) // { // userInfo.Birthday = bd; // } // /* // TODO:新增的用户,如果是驿氪那边进入的而没经过我们这边,openId会跟我们这边的不一样不记录,UnionId记录, // 但是现有机制是,我们会根据新的openId创建新用户,可能会导致两个不同的OpenId出现相同的UnionId,后续考虑下怎么改 // 目前先禁止没有经过我们这边就创建会员的数据进来 // 测试可以允许注册进来 // */ // //userInfo.WXOpenId = member.WxNo; // userInfo.WXUnionID = member.WxUnionId; // userInfo.WeiboID = member.WeibNo; // userInfo.QQ = member.QqNo; // userInfo.TaobaoId = member.TbNo; // userInfo.Email = member.Email; // userInfo.Ex3 = member.RegShop;//开卡门店 // userInfo.Ex4 = member.RegDate;//开卡时间 // userInfo.WXProvince = member.Province; // userInfo.WXCity = member.City; // userInfo.WXCountry = member.County; // userInfo.Password = member.PassWord; // if (bllUser.Add(userInfo)) // { // updateResult = true; // } // #endregion // } // } // result = JsonConvert.SerializeObject(new // { // Status = updateResult, // StatusCode = 200, // Msg = updateResult? "成功":"失败", // Timestamp = timestamp, // Sign = sign, // Result = 1 // }); // return result; //} public string CallBackMemberInfo(Entity.MemberCallBackReq memberResp) { Tolog("into bll CallBackMemberInfo"); string result = string.Empty; var timestamp = ZentCloud.Common.DateTimeHelper.GetTimeIntStr(DateTime.Now); var sign = ZentCloud.Common.SHA1.SHA1_Encrypt(string.Format("AppId={0}&Timestamp={1}&Token={2}", AppId, timestamp, Token)); Tolog("CallBackMemberInfo - sign:" + sign); Tolog("CallBackMemberInfo - timestamp:" + timestamp); Entity.MemberInfo member = memberResp.Args; if (string.IsNullOrWhiteSpace(member.WxUnionId)) { Tolog("CallBackMemberInfo - 错误:WxUnionId为空"); return(JsonConvert.SerializeObject(new { Status = false, StatusCode = 0, Msg = "错误:WxUnionId为空", Timestamp = timestamp, Sign = sign, Result = 0 })); } var inputSign = CreateSign(memberResp.AppId, memberResp.Timestamp, Token).ToUpper(); Tolog("CreateSign ok"); Tolog("inputSign:" + inputSign); //Tolog("memberResp:" + JsonConvert.SerializeObject(memberResp)); Tolog("memberResp.Sign:" + memberResp.Sign); if (inputSign != memberResp.Sign.ToUpper()) { Tolog("CallBackMemberInfo - 错误:签名错误"); return(JsonConvert.SerializeObject(new { Status = false, StatusCode = 0, Msg = "错误:签名错误", Timestamp = timestamp, Sign = sign, Result = 0 })); } BLLUser bllUser = new BLLUser(); Tolog(" 开始处理会员信息 "); bool updateResult = false; if (member != null) { Tolog(" CallBackMemberInfo: member != null "); //根据WXUnionId 查找系统用户 var userInfo = bllUser.GetUserInfoByWXUnionID(member.WxUnionId); //更新用户数据 if (userInfo != null) { Tolog("CallBackMemberInfo - 更新用户信息"); var strWhere = string.Format(" Ex1='{0}',Ex2='{1}',WXNickname='{2}',Phone='{3}',TrueName='{4}',WXSex='{5}',Birthday='{6}',WXUnionID='{8}',WeiboID='{9}',QQ='{10}',TaobaoId='{11}',Email='{12}',Ex3='{13}',Ex4='{14}',WXProvince='{15}',WXCity='{16}',WXCountry='{17}',Password='******'", member.OldCode, member.Code, member.NickName, member.MobileNo, member.Name, member.Sex, member.Birthday, member.WxNo,//不更新 member.WxUnionId, member.WeibNo, member.QqNo, member.TbNo, member.Email, member.RegShop, member.RegDate, member.Province, member.City, member.County, member.PassWord ); Tolog("strWhere : " + strWhere); Tolog("UserID : " + userInfo.UserID); #region 更新用户信息 if (bllUser.Update( new ZentCloud.BLLJIMP.Model.UserInfo(), strWhere , string.Format(" UserID = '{0}' ", userInfo.UserID)) > 0 ) { updateResult = true; Tolog("CallBackMemberInfo - 更新用户信息 ok"); } #endregion } else { Tolog("CallBackMemberInfo - 新增用户信息"); #region 新增用户信息 //新增用户信息 userInfo = new ZentCloud.BLLJIMP.Model.UserInfo(); userInfo.UserID = string.Format("WXUser_yike_{0}", Guid.NewGuid().ToString()); userInfo.Password = ZentCloud.Common.Rand.Str_char(12); userInfo.UserType = 2; userInfo.WebsiteOwner = bllUser.WebsiteOwner; userInfo.Regtime = DateTime.Now; userInfo.RegIP = ZentCloud.Common.MySpider.GetClientIP(); userInfo.LastLoginIP = ZentCloud.Common.MySpider.GetClientIP(); userInfo.LastLoginDate = DateTime.Now; userInfo.LoginTotalCount = 1; userInfo.Ex1 = member.OldCode; //线下会员卡号 userInfo.Ex2 = member.Code; //线上会员卡号 userInfo.WXNickname = member.NickName; userInfo.Phone = member.MobileNo; userInfo.TrueName = member.Name; userInfo.WXSex = Convert.ToInt32(member.Sex); DateTime bd = DateTime.Now; if (DateTime.TryParse(member.Birthday, out bd)) { userInfo.Birthday = bd; } /* * TODO:新增的用户,如果是驿氪那边进入的而没经过我们这边,openId会跟我们这边的不一样不记录,UnionId记录, * 但是现有机制是,我们会根据新的openId创建新用户,可能会导致两个不同的OpenId出现相同的UnionId,后续考虑下怎么改 * 目前先禁止没有经过我们这边就创建会员的数据进来 * 测试可以允许注册进来 */ //userInfo.WXOpenId = member.WxNo; userInfo.WXUnionID = member.WxUnionId; userInfo.WeiboID = member.WeibNo; userInfo.QQ = member.QqNo; userInfo.TaobaoId = member.TbNo; userInfo.Email = member.Email; userInfo.Ex3 = member.RegShop; //开卡门店 userInfo.Ex4 = member.RegDate; //开卡时间 userInfo.WXProvince = member.Province; userInfo.WXCity = member.City; userInfo.WXCountry = member.County; userInfo.Password = member.PassWord; if (bllUser.Add(userInfo)) { Tolog("CallBackMemberInfo - 新增用户信息 ok"); updateResult = true; } #endregion } } Tolog("CallBackMemberInfo - 返回结果"); result = JsonConvert.SerializeObject(new { Status = updateResult, StatusCode = 200, Msg = updateResult ? "成功" : "失败", Timestamp = timestamp, Sign = sign, Result = 1 }); Tolog("CallBackMemberInfo - 返回结果"); return(result); }