public ActionResult Profile()
        {
            AccountService accountService = new AccountService();
            UserTransfer   user           = new UserTransfer();
            string         userName       = User.Identity.Name;

            ViewBag.userName = userName;
            user             = accountService.GetUserData(userName).Single();

            List <DepartmentAccess> departments = new List <DepartmentAccess>();

            departments        = accountService.GetDepartmentData();
            ViewBag.department = new SelectList(departments, "departmentId", "name", user.Dempartment.DepartmentId);

            List <CampusAccess> campuses = new List <CampusAccess>();

            campuses       = accountService.GetCampusData();
            ViewBag.campus = new SelectList(campuses, "campusId", "name", user.Campus.CampusId);

            SelectListItem administrator = new SelectListItem()
            {
                Text = "Administrator", Value = "Administrator"
            };
            SelectListItem manager = new SelectListItem()
            {
                Text = "Manager", Value = "Manager"
            };
            SelectListItem regular = new SelectListItem()
            {
                Text = "RegularUser", Value = "RegularUser"
            };

            ViewBag.userType = new SelectList(new SelectListItem[] { administrator, manager, regular }, "Value", "Text", user.Account.UserType);

            List <PersonAccess> persons = new List <PersonAccess>();

            persons = accountService.GetPersonData();
            //first name will be changed to full name ?????????
            if (user.Person.SupervisorId == 0)
            {
                ViewBag.supervisor = new SelectList(persons, "personId", "firstName");
            }
            else
            {
                ViewBag.supervisor = new SelectList(persons, "personId", "firstName", user.Person.SupervisorId);
            }

            SelectListItem female = new SelectListItem()
            {
                Text = "Female", Value = "F"
            };
            SelectListItem male = new SelectListItem()
            {
                Text = "Male", Value = "M"
            };

            ViewBag.gender = new SelectList(new SelectListItem[] { female, male }, "Value", "Text", user.Person.Gender);

            return(View(user));
        }
示例#2
0
        public long Insert(UserTransfer transfer)
        {
            string sql = "INSERT INTO [dbo].[UserTransfers]([Timestamp],[OrderNo],[FromUserAccountId],[FromUserWalletId],[CoinId],[CoinCode],[ToUserAccountId],[ToUserWalletId],[Amount],[Status],[Remark])";

            sql += " VALUES ";
            sql += "(@Timestamp,@OrderNo,@FromUserAccountId,@FromUserWalletId,@CoinId,@CoinCode,@ToUserAccountId,@ToUserWalletId,@Amount,@Status,@Remark); SELECT SCOPE_IDENTITY()";
            using (var con = WriteConnection())
            {
                return(con.ExecuteScalar <long>(sql, transfer));
            }
        }
        //List of all subordinates.
        // GET: /Managers/

        public ActionResult Index()
        {
            AccountService accountService = new AccountService();
            List <EmployeeReportTransfer> employeeReportList = new List <EmployeeReportTransfer>();
            List <UserTransfer>           userList           = new List <UserTransfer>();
            UserTransfer user = new UserTransfer();

            string userName = User.Identity.Name;

            userName = "******";
            userList = accountService.GetUserData(userName);
            user     = userList.Single();

            employeeReportList = accountService.GetEmployeeInfo(user.Person.PersonId);
            Session.Add("employeeList", employeeReportList);

            return(View(employeeReportList));
        }
示例#4
0
        /// <summary>
        /// 查询转账信息
        /// </summary>
        /// <param name="site">商户</param>
        /// <param name="game">游戏配置</param>
        /// <param name="orderId">商户的转账订单号</param>
        /// <returns></returns>
        public QueryTransferResult QueryTransfer(Site site, GameSetting game, string orderId)
        {
            // 加锁,不允许对同一个订单号进行并发查询
            lock (LockHelper.GetLoker($"{game.ID}-{orderId}"))
            {
                UserTransfer order = TransferAgent.Instance().GetUserTransfer(site.ID, game.ID, orderId);
                if (order == null)
                {
                    return(new QueryTransferResult(ResultStatus.NoOrder));
                }
                if (order.Status == TransferStatus.Paying)
                {
                    return(new QueryTransferResult(ResultStatus.OrderPaying));
                }

                if (order.Status == TransferStatus.Exception)
                {
                    UserGame user = UserAgent.Instance().GetUserGameInfo(order.UserID, game.ID);
                    // 调用API接口
                    ResultStatus status = game.Setting.QueryTransfer(new QueryTransferInfo()
                    {
                        UserName = user.Account,
                        OrderID  = orderId,
                        Currency = site.Currency
                    });
                    if (status == ResultStatus.Exception)
                    {
                        return(new QueryTransferResult(ResultStatus.Exception));
                    }

                    order.Status = status == ResultStatus.Success ? TransferStatus.Success : TransferStatus.Faild;
                    this.WriteDB.Update(order, t => t.Status);
                }

                if (order.Status == TransferStatus.Success)
                {
                    return(new QueryTransferResult(order.Money, order.CreateAt, UserAgent.Instance().GetUserName(order.UserID), order.Action, site.Currency));
                }

                return(new QueryTransferResult(ResultStatus.OrderFaild));
            }
        }
示例#5
0
        /// <summary>
        /// 转账
        /// </summary>
        /// <param name="siteId">所属商户</param>
        /// <param name="game">当前游戏配置</param>
        /// <param name="user">用户信息</param>
        /// <param name="action">转入转出类型</param>
        /// <param name="orderID">转账订单号(本地)</param>
        /// <param name="currency">货币类型</param>
        /// <param name="money">金额</param>
        /// <returns></returns>
        public TransferResult Transfer(Site site, GameSetting game, UserGame user, TransferAction action, string orderID, decimal money)
        {
            if (user == null)
            {
                return(new TransferResult(ResultStatus.NoUser));
            }
            // 订单格式的判断
            if (WebAgent.IsUserName(orderID, 2, 16))
            {
                return(new TransferResult(ResultStatus.OrderIDFormat));
            }

            // 金额判断(默认是2位小数,如果游戏接口的特别要求,则在游戏接口中返回金额错误)
            if (money <= 0M || Math.Round(money, 2) != money)
            {
                return(new TransferResult(ResultStatus.BadMoney));
            }

            // 本地锁(如果部署集群则需要修改成为分布式锁)
            lock (LockHelper.GetLoker($"{user.ToString()}"))
            {
                //同一个商户订单重复,不允许操作
                if (this.ReadDB.Exists <UserTransfer>(t => t.SiteID == site.ID && t.SourceID == orderID))
                {
                    return(new TransferResult(ResultStatus.ExistsOrder));
                }

                //添加转账记录,把状态设置为转账中
                UserTransfer userTransfer = new UserTransfer()
                {
                    SiteID   = site.ID,
                    GameID   = game.ID,
                    UserID   = user.UserID,
                    Money    = money,
                    Action   = action,
                    CreateAt = DateTime.Now,
                    FinishAt = DateTime.MinValue,
                    SystemID = string.Empty,
                    SourceID = orderID,
                    Status   = TransferStatus.Paying
                };
                this.WriteDB.InsertIdentity(userTransfer);

                // 调用API接口
                TransferResult result = game.Setting.Transfer(new TransferInfo()
                {
                    Prefix   = site.Prefix,
                    UserName = user.Account,
                    Action   = action,
                    OrderID  = orderID,
                    Currency = site.Currency,
                    Money    = money
                });

                userTransfer.SystemID = result.SystemID;
                userTransfer.FinishAt = DateTime.Now;
                userTransfer.Status   = result.Status switch
                {
                    ResultStatus.Exception => TransferStatus.Exception,
                    ResultStatus.Success => TransferStatus.Success,
                    _ => TransferStatus.Faild
                };
                this.WriteDB.Update(userTransfer, t => t.SystemID, t => t.FinishAt, t => t.Status);

                if (!result)
                {
                    return(new TransferResult(result.Status));
                }

                if (result.Balance != null)
                {
                    UserAgent.Instance().UpdateBalance(user, result.Balance.Value);
                }
                else
                {
                    BalanceResult balanceResult = this.GetBalance(site, game, user);
                    if (balanceResult)
                    {
                        result.Balance = balanceResult.Balance;
                    }
                }
                return(result);
            }
        }
示例#6
0
        public TransferOM Transfer(UserAccount account, TransferIM im)
        {
            SecurityVerify.Verify(new PinVerifier(), SystemPlatform.FiiiPay, account.Id.ToString(), account.Pin, im.Pin);
            if (account.L1VerifyStatus != VerifyStatus.Certified)
            {
                throw new ApplicationException();
            }
            if (account.IsAllowTransfer.HasValue && !account.IsAllowTransfer.Value)
            {
                throw new CommonException(ReasonCode.TRANSFER_FORBIDDEN, MessageResources.TransferForbidden);
            }
            var toAccount = new UserAccountDAC().GetByCountryIdAndCellphone(im.ToCountryId, im.ToCellphone);

            if (toAccount == null)
            {
                throw new CommonException(ReasonCode.ACCOUNT_NOT_EXISTS, MessageResources.AccountNotExist);
            }
            if (toAccount.IsAllowTransfer.HasValue && !toAccount.IsAllowTransfer.Value)
            {
                throw new CommonException(ReasonCode.TRANSFER_FORBIDDEN, MessageResources.ToAccountTransferForbidden);
            }
            if (im.Amount >= Convert.ToDecimal(Math.Pow(10, 11)))
            {
                throw new CommonException(ReasonCode.TRANSFER_AMOUNT_OVERFLOW, MessageResources.TransferAmountOverflow);
            }
            var currency = new CryptocurrencyDAC().GetById(im.CoinId);

            if (!currency.Status.HasFlag(CryptoStatus.Transfer) || currency.Enable == 0)
            {
                throw new CommonException(ReasonCode.CURRENCY_FORBIDDEN, MessageResources.CurrencyForbidden);
            }
            if (im.Amount < (decimal)Math.Pow(10, -currency.DecimalPlace))
            {
                throw new CommonException(ReasonCode.TRANSFER_AMOUNT_OVERFLOW, MessageResources.TransferAmountTooSmall);
            }
            var decimalDigits = im.Amount.ToString().Length - im.Amount.ToString().IndexOf('.') - 1;

            if (decimalDigits > currency.DecimalPlace)
            {
                throw new CommonException(ReasonCode.TRANSFER_AMOUNT_OVERFLOW, MessageResources.TransferAmountOverflow);
            }

            if (account.Id == toAccount.Id)
            {
                throw new CommonException(ReasonCode.TRANSFER_TO_SELF, MessageResources.TransferToSelf);
            }

            var uwComponent = new UserWalletComponent();

            var toWallet = uwComponent.GetUserWallet(toAccount.Id, im.CoinId);

            if (toWallet == null)
            {
                toWallet = uwComponent.GenerateWallet(toAccount.Id, currency.Id);
            }

            var      country      = new CountryComponent().GetById(im.ToCountryId);
            DateTime dtCreateTime = DateTime.UtcNow;

            var fromWallet = uwComponent.GetUserWallet(account.Id, im.CoinId);

            if (fromWallet.Balance < im.Amount)
            {
                throw new CommonException(ReasonCode.TRANSFER_BALANCE_LOW, MessageResources.TransferBalanceLow);
            }

            UserTransfer transfer = new UserTransfer
            {
                Timestamp         = dtCreateTime,
                OrderNo           = CreateOrderno(),
                FromUserAccountId = account.Id,
                FromUserWalletId  = fromWallet.Id,
                CoinId            = currency.Id,
                CoinCode          = currency.Code,
                ToUserAccountId   = toAccount.Id,
                ToUserWalletId    = toWallet.Id,
                Amount            = im.Amount,
                Status            = (byte)TransactionStatus.Confirmed
            };

            var uwDAC  = new UserWalletDAC();
            var uwsDAC = new UserWalletStatementDAC();
            var utDAC  = new UserTransactionDAC();

            //var pushComponent = new FiiiPayPushComponent();
            using (var scope = new System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.Required, new TimeSpan(0, 0, 1, 30)))
            {
                transfer.Id = new UserTransferDAC().Insert(transfer);

                utDAC.Insert(new UserTransaction
                {
                    Id         = Guid.NewGuid(),
                    AccountId  = transfer.FromUserAccountId,
                    CryptoId   = transfer.CoinId,
                    CryptoCode = transfer.CoinCode,
                    Type       = UserTransactionType.TransferOut,
                    DetailId   = transfer.Id.ToString(),
                    Status     = transfer.Status,
                    Timestamp  = dtCreateTime,
                    Amount     = transfer.Amount,
                    OrderNo    = transfer.OrderNo
                });

                utDAC.Insert(new UserTransaction
                {
                    Id         = Guid.NewGuid(),
                    AccountId  = transfer.ToUserAccountId,
                    CryptoId   = transfer.CoinId,
                    CryptoCode = transfer.CoinCode,
                    Type       = UserTransactionType.TransferIn,
                    DetailId   = transfer.Id.ToString(),
                    Status     = transfer.Status,
                    Timestamp  = dtCreateTime,
                    Amount     = transfer.Amount,
                    OrderNo    = transfer.OrderNo
                });

                uwDAC.Decrease(fromWallet.Id, transfer.Amount);
                uwDAC.Increase(toWallet.Id, transfer.Amount);

                uwsDAC.Insert(new UserWalletStatement
                {
                    WalletId      = fromWallet.Id,
                    Action        = UserWalletStatementAction.TansferOut,
                    Amount        = -transfer.Amount,
                    Balance       = fromWallet.Balance - transfer.Amount,
                    FrozenAmount  = 0,
                    FrozenBalance = fromWallet.FrozenBalance,
                    Timestamp     = dtCreateTime
                });

                uwsDAC.Insert(new UserWalletStatement
                {
                    WalletId      = toWallet.Id,
                    Action        = UserWalletStatementAction.TansferIn,
                    Amount        = transfer.Amount,
                    Balance       = toWallet.Balance + transfer.Amount,
                    FrozenAmount  = 0,
                    FrozenBalance = toWallet.FrozenBalance,
                    Timestamp     = dtCreateTime
                });

                scope.Complete();
            }

            RabbitMQSender.SendMessage("UserTransferOutFiiiPay", transfer.Id);
            RabbitMQSender.SendMessage("UserTransferIntoFiiiPay", transfer.Id);
            //pushComponent.PushTransferOut(transfer.Id);
            //pushComponent.PushTransferInto(transfer.Id);

            return(new TransferOM
            {
                Timestamp = dtCreateTime.ToUnixTime().ToString(),
                TracingId = transfer.Id,
                TracingNo = transfer.OrderNo,
                AccountName = country.PhoneCode + " " + toAccount.Cellphone
            });
        }
        public ActionResult UpdatePersonalInfo()
        {
            AccountService accountService = new AccountService();
            UserTransfer   user           = new UserTransfer();
            string         userName       = User.Identity.Name;

            ViewBag.userName = userName;
            user             = accountService.GetUserData(userName).Single();

            user.Account.Password = Request.Form["Password"];
            //user.Account.UserType = Request.Form["userType"];
            user.Account.UserName = Request.Form["UserName"];

            var userType = Request.Form["userType"];

            string[] userNameArray = new string[] { user.Account.UserName };

            //user.Account.UserType = "administrator";
            user.Person.FirstName = Request.Form["FirstName"];
            user.Person.LastName  = Request.Form["LastName"];
            if (Request.Form["gender"] == "F")
            {
                user.Person.Gender = 'F';
            }
            else if (Request.Form["gender"] == "M")
            {
                user.Person.Gender = 'M';
            }
            user.Person.Address     = Request.Form["Address"];
            user.Person.Email       = Request.Form["Email"];
            user.Person.PhoneNumber = Request.Form["PhoneNumber"];
            if (Request.Form["supervisor"] == null || Request.Form["supervisor"] == "")
            {
                user.Person.SupervisorId = 0;
            }
            else
            {
                user.Person.SupervisorId = Convert.ToInt32(Request.Form["supervisor"]);
            }
            user.Dempartment.DepartmentId = Convert.ToInt32(Request.Form["Department"]);
            user.Campus.CampusId          = Convert.ToInt32(Request.Form["Campus"]);

            if (accountService.UpdateUser(user))
            {
                var token = WebSecurity.GeneratePasswordResetToken(user.Account.UserName);
                WebSecurity.ResetPassword(token, user.Account.Password);

                return(RedirectToAction("Success"));
            }
            TempData["message"] = "Failed to update your personal information, Please try it later.";
            List <DepartmentAccess> departments = new List <DepartmentAccess>();

            departments        = accountService.GetDepartmentData();
            ViewBag.department = new SelectList(departments, "departmentId", "name");

            List <CampusAccess> campuses = new List <CampusAccess>();

            campuses       = accountService.GetCampusData();
            ViewBag.campus = new SelectList(campuses, "campusId", "name");

            SelectListItem administrator = new SelectListItem()
            {
                Text = "Administrator", Value = "Administrator"
            };
            SelectListItem manager = new SelectListItem()
            {
                Text = "Manager", Value = "Manager"
            };
            SelectListItem regular = new SelectListItem()
            {
                Text = "RegularUser", Value = "RegularUser"
            };

            ViewBag.userType = new SelectList(new SelectListItem[] { administrator, manager, regular }, "Value", "Text", "RegularUser");

            List <PersonAccess> persons = new List <PersonAccess>();

            persons = accountService.GetPersonData();
            //first name will be changed to full name ?????????
            ViewBag.supervisor = new SelectList(persons, "personId", "firstName");

            SelectListItem female = new SelectListItem()
            {
                Text = "Female", Value = "F"
            };
            SelectListItem male = new SelectListItem()
            {
                Text = "Male", Value = "M"
            };

            ViewBag.gender = new SelectList(new SelectListItem[] { female, male }, "Value", "Text");

            return(View(user));
        }
示例#8
0
        public ActionResult Edit()
        {
            var            userName       = Request.Form["UserName"];
            AccountService accountService = new AccountService();

            user = accountService.GetUserData(userName).Single();
            user.Account.Password = Request.Form["Password"];
            string UserType = Request.Form["userType"];

            user.Account.UserName = Request.Form["UserName"];

            var userType = Request.Form["userType"];

            string[] userNameArray = new string[] { user.Account.UserName };
            if (UserType != "")
            {
                string[] users = Roles.GetUsersInRole(UserType);
                if (!users.Contains(userName))
                {
                    Roles.RemoveUserFromRole(userName, user.Account.UserType);
                    Roles.AddUsersToRole(userNameArray, userType);
                    user.Account.UserType = UserType;
                }
            }    //Roles.DeleteRole("administrator");

            //user.Account.UserType = "administrator";
            user.Person.FirstName = Request.Form["FirstName"];
            user.Person.LastName  = Request.Form["LastName"];
            if (Request.Form["gender"] == "F")
            {
                user.Person.Gender = 'F';
            }
            else if (Request.Form["gender"] == "M")
            {
                user.Person.Gender = 'M';
            }
            user.Person.Address     = Request.Form["Address"];
            user.Person.Email       = Request.Form["Email"];
            user.Person.PhoneNumber = Request.Form["PhoneNumber"];
            if (Request.Form["supervisor"] == null || Request.Form["supervisor"] == "")
            {
                user.Person.SupervisorId = 0;
            }
            else
            {
                user.Person.SupervisorId = Convert.ToInt32(Request.Form["supervisor"]);
            }
            user.Dempartment.DepartmentId = Convert.ToInt32(Request.Form["Department"]);
            user.Campus.CampusId          = Convert.ToInt32(Request.Form["Campus"]);

            if (accountService.UpdateUser(user))
            {
                var token = WebSecurity.GeneratePasswordResetToken(user.Account.UserName);
                WebSecurity.ResetPassword(token, user.Account.Password);

                return(RedirectToAction("ListAccount"));
            }

            List <DepartmentAccess> departments = new List <DepartmentAccess>();

            departments        = accountService.GetDepartmentData();
            ViewBag.department = new SelectList(departments, "departmentId", "name");

            List <CampusAccess> campuses = new List <CampusAccess>();

            campuses       = accountService.GetCampusData();
            ViewBag.campus = new SelectList(campuses, "campusId", "name");

            SelectListItem administrator = new SelectListItem()
            {
                Text = "Administrator", Value = "Administrator"
            };
            SelectListItem manager = new SelectListItem()
            {
                Text = "Manager", Value = "Manager"
            };
            SelectListItem regular = new SelectListItem()
            {
                Text = "RegularUser", Value = "RegularUser"
            };

            ViewBag.userType = new SelectList(new SelectListItem[] { administrator, manager, regular }, "Value", "Text", "RegularUser");

            List <PersonAccess> persons = new List <PersonAccess>();

            persons = accountService.GetPersonData();
            //first name will be changed to full name ?????????
            ViewBag.supervisor = new SelectList(persons, "personId", "firstName");

            SelectListItem female = new SelectListItem()
            {
                Text = "Female", Value = "F"
            };
            SelectListItem male = new SelectListItem()
            {
                Text = "Male", Value = "M"
            };

            ViewBag.gender = new SelectList(new SelectListItem[] { female, male }, "Value", "Text");

            return(View(user));
        }