예제 #1
0
        public ActionResult BindBankAccount(MReqBankAccount model, string userID, string phoneNumber, string validCode)
        {
            #region 校验数据
            if (string.IsNullOrWhiteSpace(userID))
            {
                return(Json(Comm.ToJsonResult("Error", "userID参数不能为空")));
            }
            if (model == null)
            {
                return(Json(Comm.ToJsonResult("Error", "提交的数据不能为空")));
            }
            if (string.IsNullOrWhiteSpace(model.idNo))
            {
                return(Json(Comm.ToJsonResult("Error", "证件号不能为空")));
            }
            if (string.IsNullOrWhiteSpace(model.cardNo))
            {
                return(Json(Comm.ToJsonResult("Error", "银行卡号不能为空")));
            }
            if (string.IsNullOrWhiteSpace(model.name))
            {
                return(Json(Comm.ToJsonResult("Error", "开户名不能为空")));
            }
            if (string.IsNullOrWhiteSpace(model.phoneNo))
            {
                return(Json(Comm.ToJsonResult("Error", "银行预留手机号不能为空")));
            }
            if (string.IsNullOrWhiteSpace(model.bankCode))
            {
                return(Json(Comm.ToJsonResult("Error", "银行编号不能为空")));
            }
            if (string.IsNullOrWhiteSpace(model.bankName))
            {
                return(Json(Comm.ToJsonResult("Error", "银行名称不能为空")));
            }
            if (string.IsNullOrWhiteSpace(validCode))
            {
                return(Json(Comm.ToJsonResult("Error", "手机验证码不能为空")));
            }
            if (string.IsNullOrWhiteSpace(phoneNumber))
            {
                return(Json(Comm.ToJsonResult("Error", "用户手机号不能为空")));
            }
            #endregion

            #region 绑定银行卡
            RequestResult result = bll.CreateBankAccount(model, userID, phoneNumber, validCode);
            if (result.retCode == ReqResultCode.success)
            {
                return(Json(Comm.ToJsonResult("Success", result.retMsg)));
            }
            else
            {
                return(Json(Comm.ToJsonResult("Error", result.retMsg)));
            }
            #endregion
        }
예제 #2
0
        /// <summary>
        /// 绑定提现银行卡
        /// </summary>
        /// <param name="model"></param>
        /// <param name="vUserID"></param>
        /// <returns></returns>
        public RequestResult CreateBankAccount(MReqBankAccount model, string vUserID, string phoneNumber, string validCode)
        {
            #region
            RequestResult result = new RequestResult()
            {
                retCode = ReqResultCode.failed,
                retMsg  = "绑定银行卡失败"
            };

            int rows = 0;
            try
            {
                string randStr = singRand;

                using (ApplicationDbContext db = new ApplicationDbContext())
                {
                    #region 验证校验码是否正确
                    VerificationCode vCode = db.VerificationCodes.FirstOrDefault(p => p.Code == validCode && p.To == phoneNumber.Replace(" ", ""));
                    if (vCode == null)
                    {
                        result.retMsg = "手机验证码不正确";
                        return(result);
                    }
                    else if (DateTime.Now > vCode.EndDateTime)
                    {
                        result.retMsg = "验证码已过期";
                        return(result);
                    }
                    #endregion
                    Vip vip = db.Vips.FirstOrDefault(p => p.UserID == vUserID);
                    if (vip != null)
                    {
                        #region 验证签名是否正确
                        if (!string.IsNullOrWhiteSpace(vip.Code))
                        {
                            randStr = vip.Code;
                        }
                        string sign = Comm.GetMd5Hash($"{model.bankCode}{model.bankName}{model.cardNo}{model.idNo}{model.name}{model.phoneNo}{randStr}");
                        if (!sign.Equals(model.sign))
                        {
                            result.retMsg = "签名不正确,您的信息可能已被更改";
                            return(result);
                        }
                        #endregion
                        int count = db.VipForwardAccounts.Where(p => p.UserID == vUserID).Count();
                        if (count >= 5)
                        {
                            result.retMsg = "提现银行卡最多只能绑定5张,如需添加新卡,请删除已绑定的银行卡";
                            return(result);
                        }
                        VipForwardAccount account = new VipForwardAccount()
                        {
                            Bank           = model.bankName,
                            BankCode       = model.bankCode,
                            CerCode        = model.idNo,
                            CreateDateTime = DateTime.Now,
                            ForwardAccount = model.cardNo,
                            ForwardName    = model.name,
                            ForwardType    = Common.Enums.VipForwardType.BankCard,
                            PhoneNumber    = model.phoneNo,
                            UserID         = vUserID,
                            VipID          = vip.ID
                        };
                        db.VipForwardAccounts.Add(account);
                        rows = db.SaveChanges();
                    }
                    else
                    {
                        result.retMsg = "vip用户不存在";
                        return(result);
                    }
                }
                if (rows > 0)
                {
                    result.retCode = ReqResultCode.success;
                    result.retMsg  = "绑定成功";
                }
                else
                {
                    result.retMsg = "绑定失败";
                }
            }
            catch (Exception ex)
            {
                result.retCode = ReqResultCode.excetion;
                result.retMsg  = $"绑定提现银行卡时发生异常:{ex.Message}";
                //调试日志
                Comm.WriteLog("exception", result.retMsg, Common.Enums.DebugLogLevel.Error, "Bll.VipForwardAccountBLL.CreateBankAccount");
            }

            return(result);

            #endregion
        }