/// <summary> /// 充值添加 /// </summary> public HttpResponseMessage RechargeRecordAdd(RequestModel request) { var result = WebHelper.GetResult(request); if (result.Code == EnumHelper.GetValue(EnumResultCode.操作成功)) { var model = JsonHelper.Deserialize <RechargeRecordEntity>(request.JsonString); if (VerifyHelper.IsEmpty(model)) { throw new DefaultException(EnumResultCode.请求错误); } model.AccountId = WebHelper.GetMemberId(request); model.RechargeState = EnumHelper.GetValue(EnumRechargeState.待支付); model.Descript = "账户充值"; model.CreateId = GuidHelper.Get(WebHelper.GetContext().Member.MemberId); model.CreateDt = DateTime.Now; model.LastId = model.CreateId; model.LastDt = model.CreateDt; rechargeRecordService.Insert(model); result.Obj = model; } return(WebApiHelper.ToHttpResponseMessage(result)); }
/// <summary> /// 会员注册 /// </summary> public HttpResponseMessage MemberRegist(RequestModel request) { var result = WebHelper.GetResult <string>(request); if (result.Code == EnumHelper.GetValue(EnumResultCode.操作成功)) { string receiver = "", mobile = JsonHelper.GetValue(request.Obj, "Mobile"), email = JsonHelper.GetValue(request.Obj, "Email"), code = JsonHelper.GetValue(request.Obj, "Code"), pwd = JsonHelper.GetValue(request.Obj, "Pwd"), nameTag = JsonHelper.GetValue(request.Obj, "NameTag"), sendType = JsonHelper.GetValue(request.Obj, "SendType"); Guid taskId = GuidHelper.Get(JsonHelper.GetValue(request.Obj, "TaskId")); #region 入信息判断 if (VerifyHelper.IsEmpty(sendType) || (sendType != KeyModel.Config.Template.KeyRegistMobile && sendType != KeyModel.Config.Template.KeyRegistEmail)) { throw new MessageException(EnumMessageCode.信息错误); } if ((VerifyHelper.IsEmpty(mobile) && VerifyHelper.IsEmpty(email)) || VerifyHelper.IsEmpty(taskId)) { throw new MessageException(EnumMessageCode.信息错误); } if (sendType == KeyModel.Config.Template.KeyRegistMobile && VerifyHelper.IsEmpty(mobile)) { throw new MessageException(EnumMessageCode.请输入手机号码); } if (sendType == KeyModel.Config.Template.KeyRegistEmail && VerifyHelper.IsEmpty(email)) { throw new MessageException(EnumMessageCode.请输入邮箱地址); } if (VerifyHelper.IsEmpty(pwd)) { throw new MessageException(EnumMessageCode.请输入密码); } if (VerifyHelper.IsEmpty(code)) { throw new MessageException(EnumMessageCode.请输入验证码); } #endregion receiver = sendType == KeyModel.Config.Template.KeyRegistMobile ? mobile : email; //验证码效验 bool isSuccess = notificationService.ConfirmVerifyCode(taskId, receiver, code, request.CurrentContext.VisitId); if (!isSuccess) { throw new MessageException(EnumMessageCode.验证码错误); } //注册 var entity = memberService.Regist(receiver, email, mobile, pwd, nameTag, BrowserHelper.GetClientIP()); if (VerifyHelper.IsEmpty(entity)) { throw new MessageException(EnumMessageCode.注册失败); } //首次注册,送100元, 添加充值记录信息 rechargeRecordService.Insert(new RechargeRecordEntity { AccountId = entity.Id, MoneyValue = 100, Descript = "注册赠送", CreateId = entity.Id, CreateDt = DateTime.Now, LastId = entity.Id, LastDt = DateTime.Now }); //返回 if (!VerifyHelper.IsEmpty(entity) && !VerifyHelper.IsEmpty(entity.Id)) { notificationService.ExpireVerifyCode(taskId); WebHelper.SetMember(entity); result.Code = EnumHelper.GetValue(EnumResultCode.跳转地址); result.Redirect = UrlsHelper.GetRefUrl(defaultUrl: WebHelper.GetMemberUrl()); } } return(WebApiHelper.ToHttpResponseMessage(result)); }