Пример #1
0
        public JsonResult Edit(BankCardModel backCardModel)
        {
            var dto = new BankCardDto();

            dto.Name       = backCardModel.Name;
            dto.BankBranch = backCardModel.BankBranch.Trim();
            dto.Owner      = backCardModel.Owner;
            dto.CardNo     = backCardModel.CardNo.Trim();
            dto.Province   = backCardModel.Province;
            dto.City       = backCardModel.City;
            dto.BankId     = backCardModel.BankId;
            dto.IsDefault  = backCardModel.IsDefault;
            var msg = new RspMessageModel();

            CommunicateManager.Invoke <IAccountService>(service =>
            {
                service.ModifyBank(dto);
                msg.Success = 1;
                msg.Message = "修改银行卡成功";
            }, (p =>
            {
                msg.Success = 0;
                msg.Message = p.Message;
            }));

            return(Json(msg, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        public void Test_Create_BankCardModel(BankCardModel bankCard)
        {
            var validationContext = new ValidationContext(bankCard);
            var actual            = Validator.TryValidateObject(bankCard, validationContext, null, true);

            Assert.True(actual);
        }
Пример #3
0
        public ActionResult AddBankCard([FromBody] BankCardModel bankCardModel)
        {
            var accountId = Request.GetUserId();

            _accountManager.AddBankCardToAccount(bankCardModel.CardNumber, bankCardModel.Validity, accountId);
            return(Ok());
        }
Пример #4
0
        public async Task <User> AddBankCard(int userId, BankCardModel cardModel)
        {
            var user = await _db.Users.FindAsync(userId);

            var tokens = await _bankApi.Authenticate(cardModel);

            user.BankActionToken    = tokens.AccessToken;
            user.BankIdToken        = tokens.IdToken;
            user.CardLastFourDigits = string.Join("", cardModel.CardNumber.Skip(12));

            await _db.SaveChangesAsync();

            return(user);
        }
Пример #5
0
        public void AddNewBankCard(string number, DateTime expDate, string holderName, int userId)
        {
            Guard.WhenArgument(number, "number").IsNull().Throw();
            Guard.WhenArgument(holderName, "holderName").IsNull().Throw();

            BankCardModel bankCardDTO = new BankCardModel()
            {
                Number         = number,
                ExpirationDate = expDate,
                Name           = holderName,
                UserId         = userId
            };

            this.bankCards.Add(this.mapper.Map <BankCardModel, BankCard>(bankCardDTO));
            unitOfWork.SaveChanges();
        }
Пример #6
0
        public JsonResult QueryBankCards()
        {
            List <BankCardDto> list = new List <BankCardDto>();

            CommunicateManager.Invoke <IAccountService>(service =>
            {
                list = service.GetBank();
            });
            List <BankCardModel> banks = new List <BankCardModel>();



            foreach (var cardDto in list)
            {
                var model = new BankCardModel();
                model.BankBranch = cardDto.BankBranch;
                model.BankId     = cardDto.BankId;
                model.CardNo     = cardDto.CardNo;
                model.City       = cardDto.City;
                model.Name       = cardDto.Name;
                model.Owner      = cardDto.Owner;
                model.Province   = cardDto.Province;
                model.IsDefault  = cardDto.IsDefault;
                int length = model.CardNo.Length;
                if (length > 4)
                {
                    var start = model.CardNo.Length - 4;
                    model.CardNoShow = model.CardNo.Substring(0, 4) + "****" + model.CardNo.Substring(start);
                }
                else
                {
                    model.CardNoShow = model.CardNo;
                }

                model.NameCardNoShow = model.Name + "  " + model.CardNoShow;
                banks.Add(model);
            }

            IEnumerable <BankCardModel> query = from m in banks
                                                orderby m.IsDefault descending
                                                select m;

            return(Json(query, JsonRequestBehavior.AllowGet));
        }
Пример #7
0
        public ActionResult CheckBankInfo(BankCardModel model, string userID)
        {
            #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", "预留电话号码不能为空")));
            }
            #endregion

            #region 认证银行卡
            RequestResult result = bll.CheckBankInfo(model, userID);
            if (result.retCode == ReqResultCode.success)
            {
                return(Json(Comm.ToJsonResult("Success", result.retMsg, result.objectData)));
            }
            else
            {
                return(Json(Comm.ToJsonResult("Error", result.retMsg)));
            }
            #endregion
        }
Пример #8
0
        public APIResponse GetList(int userId)
        {
            var bankCards = CurrentDb.BankCard.Where(m => m.UserId == userId && m.IsDelete == false).ToList();

            List <BankCardModel> models = new List <BankCardModel>();

            foreach (var m in bankCards)
            {
                BankCardModel bankCardModel = new BankCardModel();
                bankCardModel.Id            = m.Id;
                bankCardModel.BankId        = m.Id;
                bankCardModel.BankCode      = m.BankCode;
                bankCardModel.BankName      = m.BankName;
                bankCardModel.BankAccountNo = m.BankAccountNo;
                models.Add(bankCardModel);
            }

            APIResult result = new APIResult()
            {
                Result = ResultType.Success, Code = ResultCode.Success, Message = "成功", Data = models
            };

            return(new APIResponse(result));
        }
Пример #9
0
        public void Test_Validate_BankCardModel(BankCardModel bankCard)
        {
            var validationContext = new ValidationContext(bankCard);

            Assert.Empty(bankCard.Validate(validationContext));
        }
Пример #10
0
        public bool RegisterUser
            (string userName, string password, string phoneNumber,
            string firstName      = null,
            string lastName       = null,
            string address        = null,
            string bankCardNumber = null,
            DateTime?expDate      = null,
            string cardName       = null)
        {
            Guard.WhenArgument(userName, "userName").IsNullOrEmpty().Throw();
            Guard.WhenArgument(password, "password").IsNullOrEmpty().Throw();
            Guard.WhenArgument(phoneNumber, "phoneNumber").IsNullOrEmpty().Throw();
            try
            {
                var hashedPassword = hashing.GetSHA1HashData(password);

                var userModel = new UserModel()
                {
                    Username    = userName,
                    Password    = hashedPassword,
                    PhoneNumber = phoneNumber,
                    FirstName   = firstName,
                    LastName    = lastName,
                };

                var userToAdd = this.mapper.Map <UserModel, User>(userModel);
                var user      = this.GetSpecificUser(userModel.Username);

                if (address != string.Empty && address != string.Empty)
                {
                    var a = new AddressModel()
                    {
                        AddressText = address
                    };
                    var addressToAdd = this.mapper.Map <AddressModel, Address>(a);
                    userToAdd.Adresses.Add(addressToAdd);
                }

                if (bankCardNumber != string.Empty && expDate != null && cardName != string.Empty && bankCardNumber != null && expDate != null && cardName != null)
                {
                    var c = new BankCardModel()
                    {
                        Number         = bankCardNumber,
                        ExpirationDate = expDate,
                        Name           = cardName,
                        User           = userToAdd
                    };

                    var cardToAdd = this.mapper.Map <BankCardModel, BankCard>(c);
                    userToAdd.BankCards.Add(cardToAdd);
                }

                this.users.Add(userToAdd);
                unitOfWork.SaveChanges();
                return(true);
            }
            catch (System.Exception)
            {
                return(false);
            }
        }
Пример #11
0
        /// <summary>
        /// 银行卡信息认证
        /// </summary>
        /// <param name="model"></param>
        /// <param name="vUserID"></param>
        /// <returns></returns>
        public RequestResult CheckBankInfo(BankCardModel model, string vUserID)
        {
            #region
            RequestResult result = new RequestResult()
            {
                retCode = ReqResultCode.failed,
                retMsg  = "绑定银行卡失败"
            };

            string randStr = singRand;
            try
            {
                #region 认证银行卡信息是否正确
                RequestResult ret = BankCardAuth.Bank4Authenticate(model);
                if (ret.retCode != ReqResultCode.success)
                {
                    result = ret;
                    return(result);
                }
                #endregion
                using (ApplicationDbContext db = new ApplicationDbContext())
                {
                    //查看此银行卡是否已经绑定
                    VipForwardAccount account = db.VipForwardAccounts.FirstOrDefault(p => p.UserID == vUserID && p.CerCode == model.idNo && p.ForwardName == model.name && p.PhoneNumber == model.phoneNo && p.ForwardAccount == model.cardNo);
                    if (account != null)
                    {
                        result.retMsg = "该银行卡已经绑定,请重新填入";
                        return(result);
                    }
                    Vip vip = db.Vips.FirstOrDefault(p => p.UserID == vUserID);
                    if (vip != null && !string.IsNullOrWhiteSpace(vip.Code))
                    {
                        randStr = vip.Code;
                    }
                }

                result.retCode    = ReqResultCode.success;
                result.retMsg     = "认证成功";
                result.objectData = new MReqBankAccount
                {
                    bankCode = ret.objectData.bankCode,
                    bankName = ret.objectData.bankName,
                    cardNo   = model.cardNo,
                    idNo     = model.idNo,
                    name     = model.name,
                    phoneNo  = model.phoneNo,
                    sign     = Comm.GetMd5Hash($"{ret.objectData.bankCode}{ret.objectData.bankName}{model.cardNo}{model.idNo}{model.name}{model.phoneNo}{randStr}")
                };
            }
            catch (Exception ex)
            {
                result.retCode = ReqResultCode.excetion;
                result.retMsg  = $"银行卡信息认证时发生异常:{ex.Message}";
                //调试日志
                Comm.WriteLog("exception", result.retMsg, Common.Enums.DebugLogLevel.Error, "Bll.VipForwardAccountBLL.CheckBankInfo");
            }

            return(result);

            #endregion
        }
Пример #12
0
        public async Task <CurrentUserViewModel> AddBankCard([FromBody] BankCardModel cardModel)
        {
            var user = await _accountService.AddBankCard(_currentUser.Id, cardModel);

            return(_mapper.Map <CurrentUserViewModel>(user));
        }