Exemple #1
0
        public GeneralResponse EditMoneyAccounts(IEnumerable <EditMoneyAccountRequest> requests, Guid ModifiedEmployeeID)
        {
            GeneralResponse response = new GeneralResponse();

            try
            {
                foreach (EditMoneyAccountRequest request in requests)
                {
                    MoneyAccount moneyAccount = new MoneyAccount();
                    moneyAccount = _moneyAccountRepository.FindBy(request.ID);
                    moneyAccount.ModifiedDate     = PersianDateTime.Now;
                    moneyAccount.ModifiedEmployee = _employeeRepository.FindBy(ModifiedEmployeeID);
                    moneyAccount.AccountName      = request.AccountName;
                    moneyAccount.BAccountInfo     = request.BAccountInfo;
                    moneyAccount.BAccountNumber   = request.BAccountNumber;
                    moneyAccount.IsBankAccount    = request.IsBankAccount;
                    moneyAccount.Pay                   = request.Pay;
                    moneyAccount.Receipt               = request.Receipt;
                    moneyAccount.Discontinued          = request.Discontinued;
                    moneyAccount.HasUniqueSerialNumber = request.HasUniqueSerialNumber;
                    moneyAccount.Has9Digits            = request.Has9Digits;

                    if (moneyAccount.RowVersion != request.RowVersion)
                    {
                        response.ErrorMessages.Add("EditConcurrencyKey");
                        return(response);
                    }
                    else
                    {
                        moneyAccount.RowVersion += 1;
                    }

                    #region Validation

                    if (moneyAccount.GetBrokenRules().Count() > 0)
                    {
                        foreach (BusinessRule businessRule in moneyAccount.GetBrokenRules())
                        {
                            response.ErrorMessages.Add(businessRule.Rule);
                        }

                        return(response);
                    }

                    #endregion
                    _moneyAccountRepository.Save(moneyAccount);
                }
                _uow.Commit();
            }
            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
                if (ex.InnerException != null)
                {
                    response.ErrorMessages.Add(ex.InnerException.Message);
                }
            }

            return(response);
        }
Exemple #2
0
        public GeneralResponse DeleteMoneyAccount(DeleteRequest request)
        {
            GeneralResponse response = new GeneralResponse();

            MoneyAccount moneyAccount = new MoneyAccount();

            moneyAccount = _moneyAccountRepository.FindBy(request.ID);

            if (moneyAccount != null)
            {
                try
                {
                    _moneyAccountRepository.Remove(moneyAccount);
                    _uow.Commit();

                    ////response.success = true;
                }
                catch (Exception ex)
                {
                    response.ErrorMessages.Add(ex.Message);
                }
            }

            return(response);
        }
Exemple #3
0
        public GeneralResponse EditMoneyAccount(EditMoneyAccountRequestOld request)
        {
            GeneralResponse response     = new GeneralResponse();
            MoneyAccount    moneyAccount = new MoneyAccount();

            moneyAccount = _moneyAccountRepository.FindBy(request.ID);

            if (moneyAccount != null)
            {
                try
                {
                    moneyAccount.ModifiedDate     = PersianDateTime.Now;
                    moneyAccount.ModifiedEmployee = _employeeRepository.FindBy(request.ModifiedEmployeeID);
                    moneyAccount.AccountName      = request.AccountName;
                    moneyAccount.BAccountInfo     = request.BAccountInfo;
                    moneyAccount.BAccountNumber   = request.BAccountNumber;
                    moneyAccount.IsBankAccount    = request.IsBankAccount;
                    moneyAccount.Pay          = request.Pay;
                    moneyAccount.Receipt      = request.Receipt;
                    moneyAccount.Discontinued = request.Discontinued;

                    if (moneyAccount.RowVersion != request.RowVersion)
                    {
                        response.ErrorMessages.Add("کارشناس محترم، یک کاربر همزمان با شما در حال ویرایش این رکورد است. بنابراین اطلاعات شما ذخیره نمی شود.");
                        return(response);
                    }
                    else
                    {
                        moneyAccount.RowVersion += 1;
                    }

                    if (moneyAccount.GetBrokenRules().Count() > 0)
                    {
                        foreach (BusinessRule businessRule in moneyAccount.GetBrokenRules())
                        {
                            response.ErrorMessages.Add(businessRule.Rule);
                        }

                        return(response);
                    }

                    _moneyAccountRepository.Save(moneyAccount);
                    _uow.Commit();

                    ////response.success = true;
                }
                catch (Exception ex)
                {
                    response.ErrorMessages.Add(ex.Message);
                }
            }
            else
            {
                response.ErrorMessages.Add("هیچ موردی جهت ویرایش وجود ندارد.");
            }
            return(response);
        }
 public ActionResult MoneyAccount(MoneyModel moneyModel)
 {
     if (ModelState.IsValid)
     {
         MoneyAccount moneyAccount = new MoneyAccount(unitOfWork);
         moneyAccount.AddMoney(moneyModel.UserId, moneyModel);
         return(RedirectToAction("Index", "Account"));
     }
     return(View());
 }
Exemple #5
0
        /// <summary>
        /// 充值或扣费
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnAddMoney_Click(object sender, EventArgs e)
        {
            if (!Extend.LoginState.Admin.IsSuperAdmin)
            {
                throw new Exception("非系统管理员(即超管)无权此操作权限!");
            }
            Song.Entities.Accounts st = Business.Do <IAccounts>().AccountsSingle(id);
            if (st == null)
            {
                throw new Exception("当前信息不存在!");
            }
            //操作类型
            int type = 2;

            int.TryParse(rblOpera.SelectedItem.Value, out type);
            //操作金额
            int money = 0;

            int.TryParse(tbMoney.Text, out money);
            //操作对象
            Song.Entities.MoneyAccount ma = new MoneyAccount();
            ma.Ma_Money  = money;
            ma.Ma_Total  = st.Ac_Money; //当前资金总数
            ma.Ma_Remark = tbRemark.Text.Trim();
            ma.Ac_ID     = st.Ac_ID;
            ma.Ma_Source = "系统管理员操作";
            //充值方式,管理员充值
            ma.Ma_From      = 1;
            ma.Ma_IsSuccess = true;     //充值结果为“成功”
            //操作者
            Song.Entities.EmpAccount emp = Extend.LoginState.Admin.CurrentUser;
            try
            {
                string mobi = !string.IsNullOrWhiteSpace(emp.Acc_MobileTel) && emp.Acc_AccName != emp.Acc_MobileTel ? emp.Acc_MobileTel : "";
                //如果是充值
                if (type == 2)
                {
                    ma.Ma_Info = string.Format("系统管理员{0}({1}{2})向您充值{3}元", emp.Acc_Name, emp.Acc_AccName, mobi, money);
                    Business.Do <IAccounts>().MoneyIncome(ma);
                }
                //如果是转出
                if (type == 1)
                {
                    ma.Ma_Info = string.Format("系统管理员{0}({1}{2})扣除您{3}元", emp.Acc_Name, emp.Acc_AccName, mobi, money);
                    Business.Do <IAccounts>().MoneyPay(ma);
                }
                Extend.LoginState.Accounts.Refresh(st.Ac_ID);
                Master.AlertCloseAndRefresh("操作成功!");
            }
            catch (Exception ex)
            {
                this.Alert(ex.Message);
            }
        }
Exemple #6
0
        public void ProcessRequest(HttpContext context)
        {
            this.Response = context.Response;
            //来源
            string from = "Recharge.ashx";

            if (context.Request.UrlReferrer != null)
            {
                from = context.Request.UrlReferrer.ToString();
            }
            if (!Extend.LoginState.Accounts.IsLogin)
            {
                context.Response.Redirect(addPara(from, "err=1", "money=" + money, "paiid=" + paiid));
                return;
            }
            ////验证码不正确
            //if (isVerify && !isCodeImg())
            //{
            //    this.Response.Redirect(addPara(from, "err=3"));
            //    return;
            //}
            //支付接口的设置项
            Song.Entities.PayInterface pi = Business.Do <IPayInterface>().PaySingle(paiid);
            if (pi == null)
            {
                //设置项不存在
                context.Response.Redirect(addPara(from, "err=2", "money=" + money, "paiid=" + paiid));
                return;
            }
            else
            {
                //产生流水号
                MoneyAccount ma = new MoneyAccount();
                ma.Ma_Money     = money;
                ma.Ac_ID        = Extend.LoginState.Accounts.CurrentUser.Ac_ID;
                ma.Ma_Source    = pi.Pai_Pattern;
                ma.Pai_ID       = pi.Pai_ID;
                ma.Ma_From      = 3;
                ma.Ma_IsSuccess = false;
                ma = Business.Do <IAccounts>().MoneyIncome(ma);
                //调用指定的支付接口
                if (pi.Pai_Pattern == "支付宝手机支付")
                {
                    Alipaywap(pi, ma);
                }
                if (pi.Pai_Pattern == "支付宝网页直付")
                {
                    Alipayweb(pi, ma);
                }
            }
        }
        /// <summary>
        /// 分配利润
        /// </summary>
        /// <param name="cou">当前课程</param>
        /// <param name="acc">当前学员账户</param>
        /// <param name="money">消费的资金数</param>
        /// <param name="coupon">消费的卡数</param>
        public void Distribution(Course cou, Accounts acc, double money, double coupon)
        {
            Accounts[] parents = Business.Do <IAccounts>().Parents(acc);
            if (parents.Length < 1)
            {
                return;
            }
            //计算分润
            ProfitSharing[] ps = this.Clac(cou, money, coupon);
            if (ps == null)
            {
                return;
            }
            int len = ps.Length > parents.Length ? parents.Length : ps.Length;

            for (int i = 0; i < len; i++)
            {
                //写入资金分润
                if (ps[i].Ps_MoneyValue > 0)
                {
                    MoneyAccount ma = new MoneyAccount();
                    ma.Ma_Money     = ps[i].Ps_MoneyValue;
                    ma.Ac_ID        = parents[i].Ac_ID;
                    ma.Ma_Source    = "分润";
                    ma.Ma_Info      = string.Format("{0}({1})购买课程《{2}》,获取收益{3}", acc.Ac_Name, acc.Ac_AccName, cou.Cou_Name, ps[i].Ps_MoneyValue);
                    ma.Ma_From      = 5; //
                    ma.Ma_IsSuccess = true;
                    ma.Org_ID       = parents[i].Org_ID;
                    if (ma.Ma_Money > 0)
                    {
                        ma = Business.Do <IAccounts>().MoneyIncome(ma);
                    }
                }
                //写入卡券分润
                if (ps[i].Ps_CouponValue > 0)
                {
                    Song.Entities.CouponAccount ca = new CouponAccount();
                    ca.Ac_ID     = parents[i].Ac_ID;
                    ca.Ca_Source = "分润";
                    ca.Ca_Value  = ps[i].Ps_CouponValue;
                    ca.Ca_Total  = parents[i].Ac_Coupon; //当前卡券总数
                    ca.Ca_Info   = string.Format("{0}({1})购买课程《{2}》,获取收益{3}", acc.Ac_Name, acc.Ac_AccName, cou.Cou_Name, ps[i].Ps_CouponValue);
                    ca.Ca_From   = 5;
                    if (ca.Ca_Value > 0)
                    {
                        Business.Do <IAccounts>().CouponAdd(ca);
                    }
                }
            }
        }
Exemple #8
0
        public MoveResponse MoveDown(MoveRequest request)
        {
            MoveResponse response = new MoveResponse();

            MoneyAccount currentMoneyAccount = new MoneyAccount();

            currentMoneyAccount = _moneyAccountRepository.FindBy(request.ID);

            MoneyAccount nextMoneyAccount = new MoneyAccount();

            try
            {
                nextMoneyAccount = _moneyAccountRepository.FindAll()
                                   .Where(s => s.SortOrder > currentMoneyAccount.SortOrder)
                                   .OrderBy(s => s.SortOrder)
                                   .FirstOrDefault();
            }
            catch (Exception ex)
            {
            }

            if (currentMoneyAccount != null && nextMoneyAccount != null)
            {
                try
                {
                    // replacing SortOrders
                    int current  = currentMoneyAccount.SortOrder;
                    int previews = nextMoneyAccount.SortOrder;

                    currentMoneyAccount.SortOrder = previews;
                    nextMoneyAccount.SortOrder    = current;

                    _moneyAccountRepository.Save(currentMoneyAccount);
                    _moneyAccountRepository.Save(nextMoneyAccount);
                    _uow.Commit();
                }
                catch (Exception ex)
                {
                    response.ErrorMessages.Add(ex.Message);
                    return(response);
                }
            }

            return(response);
        }
Exemple #9
0
        private long NewSerialNumber(MoneyAccount moneyAccount)
        {
            Infrastructure.Querying.Query query = new Query();
            Criterion criteria = new Criterion("MoneyAccount.ID", moneyAccount.ID, CriteriaOperator.Equal);

            query.Add(criteria);

            IEnumerable <Fiscal> fiscals = _fiscalRepository.FindBy(query);
            var response = fiscals.OrderByDescending(x => x.SerialNumber).Select(s => s.SerialNumber).First();

            if (response != null)
            {
                return(response == 0 ? 100001 : response + 1);
            }
            else
            {
                return(100001);
            }
        }
Exemple #10
0
        public MapView()
        {
            var road = new Random(Guid.NewGuid().GetHashCode()).Next(0, 13);
            var map  = new Map(Enumerable.Range(0, 14).SelectMany(x => Enumerable.Range(0, 26)
                                                                  .Select(y => x == road ? new Grass(new TileLocation(x, y), new Road()) : new Grass(new TileLocation(x, y)))));

            new CurrentMap().SetMap(map);
            var moneyAccount = new MoneyAccount();

            objs.Add(map);
            var selectedTile = new SelectedTile();

            objs.Add(selectedTile);
            var buildingSelection = new BuildingSelectionOverlay(new Vector2(10, 10));

            objs.Add(buildingSelection);
            objs.Add(new BuildingConstruction(moneyAccount, selectedTile, buildingSelection));
            objs.Add(new MoneyAccountOverlay(moneyAccount, new Vector2(100, 10)));
        }
Exemple #11
0
        public GeneralResponse AddMoneyAccount(AddMoneyAccountRequestOld request)
        {
            GeneralResponse response = new GeneralResponse();

            try
            {
                MoneyAccount moneyAccount = new MoneyAccount();
                moneyAccount.ID             = Guid.NewGuid();
                moneyAccount.CreateDate     = PersianDateTime.Now;
                moneyAccount.CreateEmployee = _employeeRepository.FindBy(request.CreateEmployeeID);
                moneyAccount.AccountName    = request.AccountName;
                moneyAccount.BAccountInfo   = request.BAccountInfo;
                moneyAccount.BAccountNumber = request.BAccountNumber;
                moneyAccount.IsBankAccount  = request.IsBankAccount;
                moneyAccount.Pay            = request.Pay;
                moneyAccount.Receipt        = request.Receipt;
                moneyAccount.Discontinued   = request.Discontinued;
                moneyAccount.RowVersion     = 1;

                _moneyAccountRepository.Add(moneyAccount);
                _uow.Commit();

                ////response.success = true;

                // Validation
                if (moneyAccount.GetBrokenRules().Count() > 0)
                {
                    foreach (BusinessRule businessRule in moneyAccount.GetBrokenRules())
                    {
                        response.ErrorMessages.Add(businessRule.Rule);
                    }

                    return(response);
                }
            }
            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
            }

            return(response);
        }
Exemple #12
0
        public GeneralResponse AddMoneyAccounts(IEnumerable <AddMoneyAccountRequest> requests, Guid CreatEmployeeID)
        {
            GeneralResponse response = new GeneralResponse();

            try
            {
                foreach (AddMoneyAccountRequest request in requests)
                {
                    MoneyAccount moneyAccount = new MoneyAccount();
                    moneyAccount.ID                    = Guid.NewGuid();
                    moneyAccount.CreateDate            = PersianDateTime.Now;
                    moneyAccount.CreateEmployee        = _employeeRepository.FindBy(CreatEmployeeID);
                    moneyAccount.AccountName           = request.AccountName;
                    moneyAccount.BAccountInfo          = request.BAccountInfo;
                    moneyAccount.BAccountNumber        = request.BAccountNumber;
                    moneyAccount.IsBankAccount         = request.IsBankAccount;
                    moneyAccount.Pay                   = request.Pay;
                    moneyAccount.Receipt               = request.Receipt;
                    moneyAccount.Discontinued          = request.Discontinued;
                    moneyAccount.SortOrder             = GetMaxSortOrder();
                    moneyAccount.RowVersion            = 1;
                    moneyAccount.HasUniqueSerialNumber = request.HasUniqueSerialNumber;
                    moneyAccount.Has9Digits            = request.Has9Digits;

                    _moneyAccountRepository.Add(moneyAccount);
                }
                _uow.Commit();
            }
            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
                if (ex.InnerException != null)
                {
                    response.ErrorMessages.Add(ex.InnerException.Message);
                }
            }

            return(response);
        }
Exemple #13
0
        public GetMoneyAccountResponse GetMoneyAccount(GetRequest request)
        {
            GetMoneyAccountResponse response = new GetMoneyAccountResponse();

            try
            {
                MoneyAccount     moneyAccount     = new MoneyAccount();
                MoneyAccountView moneyAccountView = moneyAccount.ConvertToMoneyAccountView();

                moneyAccount = _moneyAccountRepository.FindBy(request.ID);
                if (moneyAccount != null)
                {
                    moneyAccountView = moneyAccount.ConvertToMoneyAccountView();
                }

                response.MoneyAccountView = moneyAccountView;
            }
            catch (Exception ex)
            {
            }

            return(response);
        }
Exemple #14
0
        public ActionResult AcceptWork(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }

            var task     = unitOfWork.Tasks.GetTaskByIdWithJoin(id, false, false, true);
            var request  = unitOfWork.Tasks.GetSelectedRequest(id);
            var executer = unitOfWork.Users.GetItemById(request.UserId);

            unitOfWork.Dispose();
            unitOfWork = new UnitOfWork();

            if (task == null || task.UserId != int.Parse(User.Identity.Name))
            {
                return(HttpNotFound());
            }

            MoneyAccount moneyAccount = new MoneyAccount(unitOfWork);
            var          result       = moneyAccount.TaskPayment(task.Users, executer, request.Price);

            if (result != null)
            {
                return(RedirectToAction("NoMoneyNoHoney", "Account"));
            }

            task.Status = "Закрыта";
            unitOfWork.Tasks.UpdateItem(task);
            unitOfWork.Save();

            MailTools mail = new MailTools();

            mail.SendMailToUser(executer.Email, "Задача закрыта", $"<p>Заказчик принял вашу работу! На ваш счет начислено <b>{request.Price} рублей.</b></p>");

            return(RedirectToAction("TaskDetails", "Tasks", new { id = task.TaskId }));
        }
Exemple #15
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };

                var discountCard = new DiscountCard {
                    CardType = null
                };
                var moneyAccount = new MoneyAccount {
                    Balance = 0, ApplicationUser = user, DiscountCard = discountCard
                };
                user.MoneyAccount = moneyAccount;

                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    return(RedirectToAction("Index", "Home"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Exemple #16
0
 public void AssignOwner(MoneyAccount ownerAccount)
 {
     _moneyAccount = ownerAccount;
 }
Exemple #17
0
 public static MoneyAccountView ConvertToMoneyAccountView(this MoneyAccount moneyAccount)
 {
     return(Mapper.Map <MoneyAccount, MoneyAccountView>(moneyAccount));
 }
Exemple #18
0
 public BuildingConstruction(MoneyAccount moneyAccount, SelectedTile selectedTile, BuildingSelectionOverlay buildingSelection)
 {
     this.moneyAccount      = moneyAccount;
     this.selectedTile      = selectedTile;
     this.buildingSelection = buildingSelection;
 }
Exemple #19
0
 public MoneyAccountOverlay(MoneyAccount moneyAccount, Vector2 screenPosition)
 {
     _moneyAccount   = moneyAccount;
     _screenPosition = screenPosition;
 }