예제 #1
0
        public ApiResult ApplyCrash([FromBody] CrashapplyModel crashapplyModel)
        {
            Argument.ThrowIfNullOrEmpty(crashapplyModel.PaymentType.ToString(), "提现方式");

            //if (crashapplyModel.Money < 500)
            //{
            //    throw new WebApiInnerException("0001", "提现金额不得低于500元");
            //}
            //Argument.ThrowIfNullOrEmpty(crashapplyModel.PayPassword, "支付密码");

            Argument.ThrowIfNullOrEmpty(crashapplyModel.RealName, "真实姓名");

            //支付宝提现 账号不能为空
            if (crashapplyModel.PaymentType == PaymentType.Alipay)
            {
                Argument.ThrowIfNullOrEmpty(crashapplyModel.Account, "提现账号");
            }

            //微信提现 需要绑定微信号
            if (crashapplyModel.PaymentType == PaymentType.WeiXin)
            {
                var oauth = _currencyService.GetSingleByConditon <UserOAuth>(
                    o => o.OAuthType == OAuthType.WeiXin && o.MemberId == AuthorizedUser.Id);
                if (oauth == null)
                {
                    throw new WebApiInnerException("0006", "未绑定微信号");
                }
            }

            Argument.ThrowIfNullOrEmpty(crashapplyModel.SmsVerifyCode, "短信验证码");
            if (!_smsService.VerifyCode(AuthorizedUser.PhoneNumber, crashapplyModel.SmsVerifyCode, WalletModule.Instance, SmsRequestType.Withdrawals.ToString()))
            {
                throw new WebApiInnerException("0002", "短信验证码验证失败");
            }

            var result = new ApiResult();

            if (!_walletService.ApplyCrash(AuthorizedUser.Id, crashapplyModel.Account, crashapplyModel.Money, crashapplyModel.PaymentType, crashapplyModel.RealName))
            {
                throw new WebApiInnerException("0005", "未知异常");
            }
            return(result);
        }