예제 #1
0
        /// <summary>
        ///     注册
        /// </summary>
        /// <returns></returns>
        private async Task <AccountUsers> Register(AccountUsers user)
        {
            //注册一个用户
            string cellphone = user.CellPhone;
            //RegisterSuccessInfo responseRegisterSuccessInfo = new RegisterSuccessInfo { IsSuccess = false };
            //发送验证码 并且验证该手机号是否存在
            //发送验证码
            SmsCodeInfo smsCodeInfo = await this.jymService.GetSmsCodeInfo(new SendVeriCodeRequest { Cellphone = cellphone });

            //验证
            if (await this.jymService.VerifyCellPhone(new VerifyRequest {
                Cellphone = cellphone, Code = smsCodeInfo.Code.Split('|')[0], Type = 10
            }))
            {
                //成功后注册
                RegisterInfo info = new RegisterInfo {
                    Token = smsCodeInfo.Token, InviteBy = user.InviteBy, ContractId = "300020150820103000", Password = user.Pwd
                };
                if (await this.jymService.Register(info))
                {
                    //认证
                    string realName     = user.RealName;
                    string credentialNo = user.CredentialNo;
                    IdentityAuthenticationResponse registerSuccess = await this.jymService.IdentityAuthentication(new IdentityAuthenticationRequest { Credential = "10", CredentialNo = credentialNo, RealName = realName }, cellphone, user.Pwd);

                    if (registerSuccess.IsSuccess)
                    {
                        user.UserIdentifier = registerSuccess.UserIdentifier;
                        user.IsVerifed      = 1;
                        //将数据存入数据库中
                        bool addSuccess = SqlHelper.ExecuteNoneQuery($"insert into AccountUsers(BankCardNo,CellPhone,CgCellPhone,CredentialNo,InviteBy,InviteFor,IsActivity,IsAuthInvest,IsAuthWithdraw,IsVerifed,Pwd,RealName,RechargeAmount,RechargeNums,RigisterTime,UserIdentifier,UserMac,IsBankAuth)values('{user.BankCardNo}','{user.CellPhone}','{user.CgCellPhone}','{user.CredentialNo}','{user.InviteBy}','{user.InviteFor}',{user.IsActivity},{user.IsAuthInvest},{user.IsAuthWithdraw},{user.IsVerifed},'{user.Pwd}','{user.RealName}',{user.RechargeAmount},{user.RechargeNums},'{user.RigisterTime}','{user.UserIdentifier}','{user.UserMac}',0)") > 0;
                        if (addSuccess)
                        {
                            return(user);
                        }
                    }
                    return(null);
                }
            }
            return(null);
        }