Пример #1
0
        public IMessageProvider Create()
        {
            var serialNo = SerialNoHelper.Create();

            TransactionHelper.BeginTransaction();
            string str = "S" + DateTime.Now.ToString("yyyyMMdd");

            InnerObject.OrderId   = str + "-" + OrderService.GetOrderSerialnumber();
            InnerObject.AccountId = AccountId;
            InnerObject.Phone     = Phone;
            var user = SecurityHelper.GetCurrentUser();

            InnerObject.Creater    = user.CurrentUser.DisplayName;
            InnerObject.CreaterId  = user.CurrentUser.UserId;
            InnerObject.createDate = DateTime.Now;
            base.OnSave(InnerObject);
            OrderService.CreateOrder(InnerObject);
            foreach (var item in this.Detials)
            {
                item.OrderId = InnerObject.OrderId;
                OrderService.AddOrderDetial(item);
            }
            AddMessage("success", InnerObject.OrderId);
            Logger.LogWithSerialNo(LogTypes.AddOrder, serialNo, 0);
            return(TransactionHelper.CommitAndReturn(this));
        }
Пример #2
0
        public void Complete(int id)
        {
            //完成订单。

            TransactionHelper.BeginTransaction();
            var serialNo = SerialNoHelper.Create();
            var item     = this.OrderService.QueryOrder(new OrderRequest()
            {
                Serialnumber = id
            }).FirstOrDefault();

            if (item != null)
            {
                if (item.State == OrderState.Partially || item.State == OrderState.Carry)
                {
                    item.State = OrderState.Completed;
                    OrderService.UpdateOrder(item);
                    Logger.LogWithSerialNo(LogTypes.EditOrder, serialNo, item.Serialnumber, item.OrderId);
                    AddMessage("Update.success", item.OrderId);
                }
                else
                {
                    AddError("当前状态不能进入完成状态", item.OrderId);
                }
            }
            TransactionHelper.Commit();
        }
Пример #3
0
        public object Print(int id)
        {
            try
            {
                var item = this.PrintTicketService.GetById(id);
                if (item != null)
                {
                    item.PrintCount++;
                    PrintTicketService.Update(item);

                    Logger.LogWithSerialNo(LogTypes.PrintTicketPrint, SerialNoHelper.Create(), id, item.AccountName, ModelHelper.GetBoundText(item, x => x.LogType));
                    AddMessage("print.success", item.AccountName, ModelHelper.GetBoundText(item, x => x.LogType));
                    return(new DataAjaxResult()
                    {
                        Data1 = item.Content
                    });
                }
                return(new SimpleAjaxResult(Localize("nonTicket", "ж╦╤╗п║ф╠н╢ур╣╫")));
            }
            catch (System.Exception ex)
            {
                Logger.Error(LogTypes.PrintTicketPrint, ex);
                return(new SimpleAjaxResult(ex.Message));
            }
        }
Пример #4
0
        public void Execute(User currentUser)
        {
            var serialNo = SerialNoHelper.Create();

            using (var proxy = new ServiceProxy <IAccountDealService>())
            {
                var rollback = this.RollbackShopDealLogService.GetById(RollbackId);
                if (rollback == null || rollback.State != RollbackShopDealLogState.Processing)
                {
                    throw new Exception("³åÕýÇëÇóδÕÒµ½");
                }
                var shopDealLog = this.ShopDealLogService.GetById(rollback.ShopDealLogId);
                var dealLog     = this.DealLogService.GetById(shopDealLog.Addin);
                var account     = this.AccountService.GetById(dealLog.AccountId);
                var request     = new PayRequest_(dealLog.AccountName, "", dealLog.SourcePosName, Math.Abs(dealLog.Amount), serialNo, dealLog.SerialNo, account.AccountToken, dealLog.SourceShopName)
                {
                    IsForce = true
                };
                var rsp = proxy.Proxy.Roolback(request);
                if (rsp.Code != ResponseCode.Success)
                {
                    throw new Exception(ModelHelper.GetBoundText(rsp, x => x.Code));
                }
                rollback.State = RollbackShopDealLogState.Done;
                RollbackShopDealLogService.Update(rollback);
            }
        }
Пример #5
0
        public ResultMsg Delete(int id)
        {
            ResultMsg msg = new ResultMsg();

            try
            {
                var oldUser = MembershipService.GetUserById(id);

                AdminUser adminUser = oldUser as AdminUser;
                if (adminUser != null && !adminUser.BuildIn)
                {
                    MembershipService.DeleteUser(oldUser);
                    Logger.LogWithSerialNo(LogTypes.AdminUserDelete, SerialNoHelper.Create(), id, adminUser.Name);
                    // AddMessage("delete.success", adminUser.Name);
                    msg.Code     = 1;
                    msg.CodeText = "删除用户 " + adminUser.DisplayName + " 成功";
                }
                else
                {
                    msg.CodeText = "不好意思,没有找到用户";
                }
                return(msg);
            }
            catch (Exception ex)
            {
                msg.CodeText = "不好意思,系统异常";
                Logger.Error("停用用户", ex);
                return(msg);
            }
        }
Пример #6
0
        public ResultMsg Approve(int id)
        {
            ResultMsg msg = new ResultMsg();

            try
            {
                Account item = AccountService.GetById(id);
                if (item != null && item.State == AccountStates.Created)
                {
                    item.State = AccountStates.Ready;
                    AccountService.Update(item);

                    Logger.LogWithSerialNo(LogTypes.AccountApprove, SerialNoHelper.Create(), id, item.Name);
                    msg.Code     = 1;
                    msg.CodeText = "审核会员 " + item.Name + " 成功";
                }
                else
                {
                    msg.CodeText = "不好意思,没有找到会员";
                }
                return(msg);
            }
            catch (Exception ex)
            {
                msg.CodeText = "不好意思,系统异常";
                Logger.Error("审核会员", ex);
                return(msg);
            }
        }
Пример #7
0
        public ResultMsg Delete(int id)
        {
            ResultMsg msg = new ResultMsg();

            try
            {
                Account item = AccountService.GetById(id);
                if (item != null && item.State == AccountStates.Initialized)
                {
                    AccountService.Delete(item);

                    Logger.LogWithSerialNo(LogTypes.AccountDelete, SerialNoHelper.Create(), id, item.Name);
                    msg.Code     = 1;
                    msg.CodeText = "删除会员 " + item.Name + " 成功";
                }
                else
                {
                    msg.CodeText = "删除失败,只有初始化状态的卡片可以删除";
                }
                return(msg);
            }
            catch (Exception ex)
            {
                msg.CodeText = "不好意思,系统异常";
                Logger.Error("删除会员", ex);
                return(msg);
            }
        }
Пример #8
0
        public ResultMsg Suspend(int id)
        {
            ResultMsg msg = new ResultMsg();

            try
            {
                var posEndPoint = PosEndPointService.GetById(id);
                if (posEndPoint != null && posEndPoint.State == PosEndPointStates.Normal)
                {
                    posEndPoint.State = PosEndPointStates.Invalid;
                    PosEndPointService.Update(posEndPoint);

                    var shop = ShopService.GetById(posEndPoint.ShopId);
                    Logger.LogWithSerialNo(LogTypes.PosSuspend, SerialNoHelper.Create(), id, posEndPoint.Name, shop.Name);
                    // AddMessage("suspend.success", posEndPoint.Name, shop.Name);
                    msg.Code     = 1;
                    msg.CodeText = "停用终端 " + posEndPoint.DisplayName + " 成功";
                    CacheService.Refresh(CacheKeys.PosKey);
                }
                else
                {
                    msg.CodeText = "不好意思,没有找到终端";
                }
                return(msg);
            }
            catch (Exception ex)
            {
                msg.CodeText = "不好意思,系统异常";
                Logger.Error("停用终端", ex);
                return(msg);
            }
        }
Пример #9
0
        public ResultMsg Delete(int id)
        {
            ResultMsg msg = new ResultMsg();

            try
            {
                var posEndPoint = PosEndPointService.GetById(id);
                if (posEndPoint != null)
                {
                    var shop = ShopService.GetById(posEndPoint.ShopId);
                    Logger.LogWithSerialNo(LogTypes.PosDelete, SerialNoHelper.Create(), id, posEndPoint.Name, shop.Name);
                    //AddMessage("delete.success", posEndPoint.Name, shop.Name);
                    msg.Code     = 1;
                    msg.CodeText = "删除终端 " + posEndPoint.DisplayName + " 成功";
                    PosEndPointService.Delete(posEndPoint);
                    CacheService.Refresh(CacheKeys.PosKey);
                }
                else
                {
                    msg.CodeText = "不好意思,没有找到终端";
                }
                return(msg);
            }
            catch (Exception ex)
            {
                msg.CodeText = "不好意思,系统异常";
                Logger.Error("删除终端", ex);
                return(msg);
            }
        }
Пример #10
0
        public IMessageProvider Create()
        {
            var serialNo = SerialNoHelper.Create();
            var roles    = MembershipService.QueryRoles(new RoleRequest {
                Name = RoleNames.ShopOwner
            }).ToList();

            TransactionHelper.BeginTransaction();
            OnSave(InnerObject, Owner);
            Owner.SetPassword(Password);
            InnerObject.State          = States.Normal;
            InnerObject.RechargeAmount = RechargeAmount;
            Owner.State = States.Normal;
            ShopService.Create(InnerObject);
            Owner.ShopId = InnerObject.ShopId;
            MembershipService.CreateUser(Owner);
            MembershipService.AssignRoles(Owner, roles.Select(x => x.RoleId).ToArray());
            ShopDealLog log = new ShopDealLog(serialNo, DealTypes.Open, 0, null, null, null, InnerObject, 0);

            ShopDealLogService.Create(log);
            AddMessage("success", ShopName);
            Logger.LogWithSerialNo(LogTypes.ShopCreate, serialNo, InnerObject.ShopId, ShopName);
            CacheService.Refresh(CacheKeys.PosKey);
            return(TransactionHelper.CommitAndReturn(this));
        }
Пример #11
0
        public IMessageProvider Save()
        {
            var serialNo    = SerialNoHelper.Create();
            var distributor = DistributorService.GetById(DistributorId);

            if (distributor != null)
            {
                var owner = MembershipService.GetUserById(distributor.UserId) as DistributorUser;

                if (owner == null)
                {
                    AddError(LogTypes.DistributorEdit, "noOwner");
                    return(this);
                }

                owner.DisplayName = DisplayName;

                if (!string.IsNullOrEmpty(Password))
                {
                    owner.SetPassword(Password);
                }
                OnSave(distributor, owner);

                DistributorService.Update(distributor);
                UpdateAccountLevelPolicy(distributor);
                MembershipService.UpdateUser(owner);
                AddMessage("success", owner.Name);
                Logger.LogWithSerialNo(LogTypes.DistributorEdit, serialNo, distributor.DistributorId, owner.Name);
                CacheService.Refresh(CacheKeys.PosKey);
            }
            return(this);
        }
Пример #12
0
        public ResultMsg Delete(int id)
        {
            ResultMsg msg = new ResultMsg();

            try
            {
                TransactionHelper.BeginTransaction();
                var distributor = DistributorService.GetById(id);
                if (distributor != null)
                {
                    //把下属经销商的上级设为要删除的经销商的上级。
                    List <Distributor> list = DistributorService.GetByParentId(id);
                    foreach (var item in list)
                    {
                        if (item != null)
                        {
                            //var user1 = MembershipService.GetUserById(item.UserId);
                            item.ParentId = distributor.ParentId;
                            //TransactionHelper.BeginTransaction();
                            // MembershipService.DeleteUser(user1);
                            DistributorService.Update(item);

                            Logger.LogWithSerialNo(LogTypes.DistributorEdit, SerialNoHelper.Create(), id, item.Name);
                            AddMessage("update.success", item.Name);
                            //TransactionHelper.Commit();

                            CacheService.Refresh(CacheKeys.DistributorKey);
                        }
                    }
                    var accounts = AccountService.Query(new AccountRequest()).Where(x => x.DistributorId == id);
                    foreach (var account in accounts)
                    {
                        account.DistributorId = distributor.ParentId;
                        AccountService.Update(account);
                    }
                    var user = MembershipService.GetUserById(distributor.UserId);
                    MembershipService.DeleteUser(user);
                    DistributorService.Delete(distributor);

                    Logger.LogWithSerialNo(LogTypes.DistributorDelete, SerialNoHelper.Create(), id, user.Name);
                    //AddMessage("delete.success", user.Name);
                    msg.Code     = 1;
                    msg.CodeText = "删除 " + user.DisplayName + " 成功";
                    TransactionHelper.Commit();

                    CacheService.Refresh(CacheKeys.PosKey);
                }
                else
                {
                    msg.CodeText = "不好意思,没有找到经销商";
                }
                return(msg);
            }
            catch (Exception ex)
            {
                msg.CodeText = "不好意思,系统异常";
                Logger.Error("删除经销商", ex);
                return(msg);
            }
        }
Пример #13
0
        public void Save()
        {
            var serialNo  = SerialNoHelper.Create();
            var oldUser   = MembershipService.GetUserById(InnerObject.UserId);
            var adminUser = oldUser as AdminUser;

            if (adminUser == null)
            {
                return;
            }
            TransactionHelper.BeginTransaction();

            adminUser.Email       = Email;
            adminUser.DisplayName = DisplayName;
            if (!string.IsNullOrEmpty(Password))
            {
                adminUser.SetPassword(Password);
            }
            adminUser.BirthDate = BirthDate;
            adminUser.Mobile    = Mobile;
            //adminUser.IsSale = IsSale;
            var roleIds = Roles.GetCheckedIds();

            MembershipService.UpdateUser(adminUser);
            OnSaved(adminUser);
            MembershipService.DeleteRolesForUser(adminUser.UserId);
            MembershipService.AssignRoles(adminUser, roleIds);
            AddMessage("success", oldUser.Name);
            Logger.LogWithSerialNo(LogTypes.AdminUserEdit, serialNo, adminUser.UserId, oldUser.Name);
            TransactionHelper.Commit();
        }
Пример #14
0
        public object OpenReceipt(int id)
        {
            try
            {
                SystemDealLog dealLog = SystemDealLogService.GetById(id);
                if (dealLog != null && !dealLog.HasReceipt && dealLog.DealType == SystemDealLogTypes.Recharge && dealLog.Amount > 0 && dealLog.State == SystemDealLogStates.Normal)
                {
                    dealLog.HasReceipt = true;

                    TransactionHelper.BeginTransaction();

                    SystemDealLogService.Update(dealLog);
                    LogHelper.LogWithSerialNo(LogTypes.SystemDealLogOpenReceipt, SerialNoHelper.Create(), dealLog.SystemDealLogId, dealLog.SerialNo);
                    AddMessage(Localize("OpenReceipt.success"), dealLog.SystemDealLogId);

                    SendMessage(dealLog);
                    return(TransactionHelper.CommitAndReturn(new SimpleAjaxResult()));
                }
                return(new SimpleAjaxResult(Localize("OpenReceipt.failed", "原交易不存在")));
            }
            catch (Exception ex)
            {
                Logger.Error(LogTypes.SystemDealLogOpenReceipt, ex);
                return(new SimpleAjaxResult(ex.Message));
            }
        }
Пример #15
0
        public ResultMsg Resumes(int id)
        {
            ResultMsg msg = new ResultMsg();

            try
            {
                var item = AdmissionTicketService.GetById(id);
                if (item != null && item.state == AdmissionTicketState.Invalid)
                {
                    var serialNo = SerialNoHelper.Create();
                    item.state = AdmissionTicketState.Normal;
                    AdmissionTicketService.Update(item);
                    Logger.LogWithSerialNo(LogTypes.AdmissionTicketResume, serialNo, item.id, item.name);
                }
                msg.Code     = 1;
                msg.CodeText = "启用门票成功";
                return(msg);
            }
            catch (Exception ex)
            {
                Logger.Error(LogTypes.AdmissionTicketResume, ex);
                msg.CodeText = "不好意思,系统异常";
                return(msg);
            }
        }
Пример #16
0
        public IMessageProvider Create()
        {
            var serialNo = SerialNoHelper.Create();

            InnerObject.State = PointGiftStates.Normal;
            HttpContext context = HttpContext.Current;

            if (Photo != null && Photo.File != null)
            {
                var name = Guid.NewGuid().ToString("N") + ".jpg";
                InnerObject.Photo = name;
                var fileName = context.Server.MapPath("~/content/pointgiftphotos/" + name);
                Moonlit.IO.DirectoryEnsure.EnsureFromFile(fileName);
                Photo.File.SaveAs(fileName);
            }

            TransactionHelper.BeginTransaction();
            base.OnSave(InnerObject);
            PointGiftService.Create(InnerObject);

            AddMessage("success", DisplayName);
            Logger.LogWithSerialNo(LogTypes.PointGiftCreate, serialNo, InnerObject.PointGiftId, DisplayName);

            return(TransactionHelper.CommitAndReturn(this));
        }
Пример #17
0
        public ResultMsg Deletes(int id)
        {
            ResultMsg msg = new ResultMsg()
            {
                Code = -1, CodeText = "删除失败"
            };

            try
            {
                var item = AdmissionTicketService.GetById(id);
                if (item != null)
                {
                    var serialNo = SerialNoHelper.Create();
                    AdmissionTicketService.Delete(item);
                    Logger.LogWithSerialNo(LogTypes.AdmissionTicketDelete, serialNo, item.id, item.name);
                    msg.Code     = 1;
                    msg.CodeText = "删除门票" + item.name + "成功";
                }
                return(msg);
            }
            catch (Exception ex)
            {
                Logger.Error(LogTypes.AdmissionTicketDelete, ex);
                msg.CodeText = "不好意思,系统异常";
                return(msg);
            }
        }
Пример #18
0
        public IMessageProvider Edit()
        {
            var newObject = OrderService.QueryOrder(new Services.OrderRequest()
            {
                OrderId = InnerObject.OrderId
            }).FirstOrDefault();

            if (newObject != null)
            {
                var serialNo = SerialNoHelper.Create();
                TransactionHelper.BeginTransaction();
                //InnerObject.AccountId = AccountID;
                //InnerObject.State = MyState;
                //newObject.Address = Address;
                newObject.Phone = AccountPhone;
                //newObject.SubmitTime = DateTime.Now;
                base.OnSave(newObject);
                OrderService.UpdateOrder(newObject);
                OrderService.DeleteOrderDetials(InnerObject.OrderId);
                foreach (var item in this.Detials)
                {
                    item.OrderId = OrderId;
                    OrderService.AddOrderDetial(item);
                }
                AddMessage("Edit.success", InnerObject.OrderId);
                Logger.LogWithSerialNo(LogTypes.EditOrder, serialNo, InnerObject.Serialnumber, InnerObject.OrderId);
                return(TransactionHelper.CommitAndReturn(this));
            }
            else
            {
                AddError(LogTypes.EditOrder, "无此订单!", null);
                return(this);
            }
        }
Пример #19
0
        public ResultMsg SetDistributorId(int id, int distributor)
        {
            ResultMsg msg = new ResultMsg();

            try
            {
                Account item   = AccountService.GetById(id);
                int[]   status = { AccountStates.Created, AccountStates.Initialized, AccountStates.Ready };
                var     dis    = DistributorService.GetById(distributor);
                if (item != null && status.Contains(item.State) && dis != null)
                {
                    item.DistributorId = distributor;
                    AccountService.Update(item);

                    Logger.LogWithSerialNo(LogTypes.AdminUserEdit, SerialNoHelper.Create(), id, item.Name);
                    msg.Code     = 1;
                    msg.CodeText = item.Name + " 设置经销商成功成功";
                }
                else
                {
                    msg.CodeText = "所选择的经销商无效或者当前卡状态不能转换经销商";
                }
                return(msg);
            }
            catch (Exception ex)
            {
                msg.CodeText = "不好意思,系统异常";
                Logger.Error("设置经销商", ex);
                return(msg);
            }
        }
Пример #20
0
        //停用
        public ResultMsg Suspend(int id)
        {
            ResultMsg msg = new ResultMsg();

            try
            {
                var oldRole = MembershipService.GetRoleById(id);
                if (oldRole != null && !oldRole.BuildIn)
                {
                    oldRole.State = RoleStates.Invalid;
                    MembershipService.UpdateRole(oldRole);

                    Logger.LogWithSerialNo(LogTypes.RoleSuspend, SerialNoHelper.Create(), id, oldRole.Name);
                    // AddMessage("suspend.success", oldRole.Name);
                    msg.Code     = 1;
                    msg.CodeText = "停用角色 " + oldRole.DisplayName + " 成功";
                }
                else
                {
                    msg.CodeText = "不好意思,没有找到角色";
                }
                return(msg);
            }
            catch (Exception ex)
            {
                msg.CodeText = "不好意思,系统异常";
                Logger.Error("停用角色", ex);
                return(msg);
            }
        }
Пример #21
0
        public ResultMsg Create(int id)
        {
            ResultMsg msg = new ResultMsg();

            try
            {
                Account item = AccountService.GetById(id);

                if (item == null || item.State != AccountStates.Initialized)
                {
                    //this.AddError("accountNameNotExist");
                    msg.CodeText = "不好意思,没有找到会员";
                    return(msg);
                }
                item.State = AccountStates.Created;
                AccountService.Update(item);
                Logger.LogWithSerialNo(LogTypes.AccountCreate, SerialNoHelper.Create(), id, item.Name);
                msg.Code     = 1;
                msg.CodeText = "会员建卡 " + item.Name + " 成功";

                return(msg);
            }
            catch (Exception ex)
            {
                msg.CodeText = "不好意思,系统异常";
                Logger.Error("批量建卡", ex);
                return(msg);
            }
        }
Пример #22
0
        public ResultMsg Delete(int id)
        {
            ResultMsg msg = new ResultMsg();

            try
            {
                var role = MembershipService.GetRoleById(id);

                if (role != null && !role.BuildIn)
                {
                    MembershipService.DeleteRole(role);
                    Logger.LogWithSerialNo(LogTypes.RoleDelete, SerialNoHelper.Create(), id, role.Name);
                    // AddMessage("delete.success", role.Name);
                    msg.Code     = 1;
                    msg.CodeText = "删除角色 " + role.DisplayName + " 成功";
                }
                else
                {
                    msg.CodeText = "不好意思,没有找到角色";
                }
                return(msg);
            }
            catch (Exception ex)
            {
                msg.CodeText = "不好意思,系统异常";
                Logger.Error("删除角色", ex);
                return(msg);
            }
        }
Пример #23
0
        public ResultMsg Resume(int id)
        {
            ResultMsg msg = new ResultMsg();

            try
            {
                var oldUser = MembershipService.GetUserById(id);

                AdminUser adminUser = oldUser as AdminUser;
                if (adminUser != null && !adminUser.BuildIn && adminUser.State == UserStates.Invalid)
                {
                    adminUser.State = UserStates.Normal;
                    MembershipService.UpdateUser(adminUser);
                    Logger.LogWithSerialNo(LogTypes.AdminUserResume, SerialNoHelper.Create(), id, adminUser.Name);
                    //AddMessage("resume.success", adminUser.Name);
                    msg.Code     = 1;
                    msg.CodeText = "启用用户 " + adminUser.DisplayName + " 成功";
                }
                else
                {
                    msg.CodeText = "不好意思,没有找到用户";
                }
                return(msg);
            }
            catch (Exception ex)
            {
                msg.CodeText = "不好意思,系统异常";
                Logger.Error("停用用户", ex);
                return(msg);
            }
        }
Пример #24
0
        public ResultMsg Delete(int id)
        {
            ResultMsg msg = new ResultMsg();

            try
            {
                var item = SecondKillCommoditysService.GetById(id);
                if (item != null)
                {
                    SecondKillCommoditysService.Delete(item);
                    Logger.LogWithSerialNo(LogTypes.SecondKillCommoditysDelete, SerialNoHelper.Create(), item.id, item.commodityNo);
                    msg.Code     = 1;
                    msg.CodeText = "删除用户 " + item.commodityNo + " 成功";
                }
                else
                {
                    msg.CodeText = "不好意思,没有找到商品";
                }
                return(msg);
            }
            catch (Exception ex)
            {
                msg.CodeText = "不好意思,系统异常";
                Logger.Error("删除秒杀商品", ex);
                return(msg);
            }
        }
Пример #25
0
        public IMessageProvider Done()
        {
            this.Ready();
            if (this.ShouldPayAmount < this.Amount)
            {
                AddError(LogTypes.CashDealLogDone, "amountInvalidate", ShouldPayAmount, Amount);
                return(this);
            }
            var serialNo = SerialNoHelper.Create();
            var user     = SecurityHelper.GetCurrentUser().CurrentUser;
            var amount   = Amount;

            using (var tran = TransactionHelper.BeginTransaction())
            {
                // InnerObject.AccountLevel = AccountLevel;
                InnerObject.DealType   = CashDealLogTypes.EmployeeDeposit;
                InnerObject.UserId     = user.UserId;
                InnerObject.OwnerId    = OwnerId;
                InnerObject.Amount     = -amount;
                InnerObject.SubmitTime = DateTime.Now;
                InnerObject.SubmitDate = this.SubmitDate;
                CashDealLogService.Create(InnerObject);
                AddMessage("success", ShouldPayAmount, amount);
                Logger.LogWithSerialNo(LogTypes.CashDealLogDone, serialNo, InnerObject.CashDealLogId /*, InnerObject.DisplayName*/);
                Amount = amount;
                tran.Commit();
                return(this);
            }
        }
Пример #26
0
        public IMessageProvider Save()
        {
            var serialNo = SerialNoHelper.Create();

            TransactionHelper.BeginTransaction();
            var role = MembershipService.GetRoleById(InnerObject.RoleId);

            if (role == null)
            {
                return(this);
            }

            role.DisplayName = DisplayName;
            if (Users != null && !role.BuildIn)
            {
                var roleIds = Users.GetCheckedIds();
                //role.Users = MembershipService.QueryUsers<User>(new UserRequest() { Ids = roleIds }).ToList();

                MembershipService.DeleteUsersForRole(role.RoleId);
                MembershipService.AssignUsers(role, roleIds);
            }
            var ids         = this.Permissions.GetCheckedIds();
            var permissions = PermissionService.QueryPermissions(this.UserType).Where(x => ids.Contains(x.PermissionId)).Select(x => x.Name).ToArray();

            role.Permissions = string.Join(",", permissions);
            MembershipService.UpdateRole(role);
            this.Logger.LogWithSerialNo(LogTypes.RoleEdit, serialNo, role.RoleId, InnerObject.Name);
            AddMessage("success", InnerObject.Name);
            return(TransactionHelper.CommitAndReturn(this));
        }
Пример #27
0
        public void Carry(int orderId, int senderId)
        {
            //派送。

            TransactionHelper.BeginTransaction();
            var serialNo = SerialNoHelper.Create();
            var item     = this.OrderService.QueryOrder(new OrderRequest()
            {
                Serialnumber = orderId
            }).FirstOrDefault();

            if (item != null)
            {
                if (item.State == OrderState.Normal)
                {
                    var user = MembershipService.GetUserById(senderId);
                    item.State      = OrderState.Carry;
                    item.SenderId   = senderId;
                    item.Sender     = user.DisplayName;
                    item.SubmitTime = DateTime.Now;
                    OrderService.UpdateOrder(item);
                    Logger.LogWithSerialNo(LogTypes.EditOrder, serialNo, item.Serialnumber, item.OrderId);
                    AddMessage("Update.success", item.OrderId);
                }
                else
                {
                    AddError("当前状态不能进入派送阶段", item.OrderId);
                }
            }
            TransactionHelper.Commit();
        }
Пример #28
0
 public SimpleAjaxResult Save(int accountId)
 {
     try
     {
         var    serialNo = SerialNoHelper.Create();
         var    passwordService = UnityContainer.Resolve <IPasswordService>(HostSite.PasswordType);
         string password1, password2;
         passwordService.Decrypto(this.Password, this.PasswordConfirm, out password1, out password2);
         if (password1 != password2)
         {
             return(new SimpleAjaxResult(Localize("passwordNotEquals")));
         }
         Account account = AccountService.GetById(accountId);
         if (account == null || (account.State != AccountStates.Normal && account.State != AccountStates.Invalid))
         {
             return(new SimpleAjaxResult(Localize("accountNoExisting")));
         }
         account.SetPassword(password1);
         TransactionHelper.BeginTransaction();
         AccountService.Update(account);
         Logger.LogWithSerialNo(LogTypes.AccountChangePassword, serialNo, account.AccountId, AccountName);
         AddMessage("success");
         TransactionHelper.CommitAndReturn(this);
         return(new SimpleAjaxResult());
     }
     catch (System.Exception ex)
     {
         Logger.Error(LogTypes.AccountChangePassword, ex);
         return(new SimpleAjaxResult(ex.Message));
     }
 }
Пример #29
0
        public IMessageProvider Save()
        {
            var serialNo = SerialNoHelper.Create();
            var shop     = ShopService.GetById(ShopId);

            if (shop != null)
            {
                var owner = MembershipService.QueryUsersOfShops <ShopUser>(null, ShopRoles.Owner, shop.ShopId).FirstOrDefault();
                shop.DisplayName           = DisplayName;
                shop.ShopDealLogChargeRate = InnerObject.ShopDealLogChargeRate;
                shop.RechargeAmount        = RechargeAmount;
                if (!string.IsNullOrEmpty(Password))
                {
                    if (owner == null)
                    {
                        AddError(LogTypes.ShopEdit, "noOwner");
                        return(this);
                    }
                    owner.SetPassword(Password);
                }
                OnSave(shop, owner);
                ShopService.Update(shop);
                MembershipService.UpdateUser(owner);
                AddMessage("success", shop.Name);
                Logger.LogWithSerialNo(LogTypes.ShopEdit, serialNo, shop.ShopId, shop.Name);
                CacheService.Refresh(CacheKeys.PosKey);
            }
            return(this);
        }
Пример #30
0
        public AccountServiceResponse DoRecharge()
        {
            var user = SecurityHelper.GetCurrentUser();

            if (user is ShopUserModel)
            {
                var shopUser = user.CurrentUser as ShopUser;
                var shop     = ShopService.GetById(shopUser.ShopId);
                if (shop == null)
                {
                    return new AccountServiceResponse(-1)
                           {
                               CodeText = "无效商户"
                           }
                }
                ;
                Account account     = null;
                var     accountUser = (AccountUser)_membershipService.GetByMobile(AccountName.Trim());
                if (accountUser != null)
                {
                    account = AccountService.QueryByOwnerId(accountUser).FirstOrDefault();
                    //return new AccountServiceResponse(ResponseCode.NonFoundAccount) { CodeText = "找不到会员,请检查输入是否正确,会员卡状态是否正常!" };
                }
                else
                {
                    account = AccountService.GetByName(AccountName.Trim());
                }
                // var account = AccountService.GetByName(AccountName.Trim());
                if (account == null || account.State != AccountStates.Normal)
                {
                    return new AccountServiceResponse(ResponseCode.NonFoundAccount)
                           {
                               CodeText = "找不到会员,请检查输入是否正确,会员卡状态是否正常!"
                           }
                }
                ;
                var sn = SerialNoHelper.Create();
                AccountServiceResponse rsp = new AccountServiceResponse(0);
                rsp = AccountDealService.Recharge(new PayRequest(account.Name, "", "", Amount, sn, "", shop.Name, shop.Name), true);
                if (rsp.Code == ResponseCode.Success)
                {
                    //做日志
                    // Logger.LogWithSerialNo(LogTypes.Deal, sn, account.AccountId, rsp.AccountType, account.Name);
                }
                return(rsp);
            }
            else if (user is AdminUserModel)
            {
                return(Save());
            }
            else
            {
                return(new AccountServiceResponse(-1)
                {
                    CodeText = "无效商户"
                });
            }
        }