Example #1
0
        public void Save()
        {
            using (var scope = Context.Database.BeginTransaction())
            {
                var user = (from u in Context.UserInfos where u.UserInfoId == UserInfoId select u).First();
                Context.UserInfoPermissions.RemoveRange(from p in Context.UserInfoPermissions where p.UserInfoId == UserInfoId select p);
                Context.SaveChanges();
                if (Permission != null)
                {
                    var permissions = from p in Context.Permissions where Permission.Contains(p.NavId) select p;

                    StringBuilder sb = new StringBuilder();
                    foreach (Permission permission in permissions)
                    {
                        sb.Append($"[{BaseData.GetNavName(permission.NavId)}]");
                        Context.UserInfoPermissions.Add(new UserInfoPermission()
                        {
                            UserInfoId   = UserInfoId,
                            PermissionId = permission.PermissionId
                        });
                    }
                    UserOperateLogService.Log($"编辑用户[{user.Name}]的权限:{sb}", Context);
                    Context.SaveChanges();
                }

                scope.Commit();
            }
        }
        public ServiceResult Save()
        {
            using (var scope = Context.Database.BeginTransaction())
            {
                var exist = (from r in Context.Roles where r.RoleId == RoleId select r).First();
                Context.RolePermissions.RemoveRange(from rp in Context.RolePermissions where rp.RoleId == RoleId select rp);
                Context.SaveChanges();
                var           permissions = from p in Context.Permissions where PermissionDatas.Contains(p.NavId) select p;
                StringBuilder sb          = new StringBuilder();
                foreach (Permission permission in permissions)
                {
                    sb.Append($"[{BaseData.GetNavName(permission.NavId)}]");
                    Context.RolePermissions.Add(new RolePermission()
                    {
                        RoleId       = RoleId,
                        PermissionId = permission.PermissionId
                    });
                }
                UserOperateLogService.Log($"编辑角色[{exist.Name}]的权限:{sb}", Context);
                Context.SaveChanges();
                scope.Commit();
            }

            return(new ServiceResult(ServiceResultCode.Success));
        }
        public ServiceResult Save()
        {
            RateOfGroupClient entity = new RateOfGroupClient();

            if (this.Rate > 100 || this.Rate < 0)
            {
                return(new ServiceResult(ServiceResultCode.Error, "请输入0~100的概率"));
            }
            var groupEntity = Context.Groups.Where(c => c.UnqiueId == this.UniqueId).Select(c => new { c.UnqiueId, c.GroupId }).FirstOrDefault();

            if (groupEntity == null)
            {
                return(new ServiceResult(ServiceResultCode.Error, "不存在此群号,请重新输入"));
            }

            var clientEntity = Context.Clients.Where(c => c.LiaoxinNumber == this.LiaoxinNumber).Select(c => new { c.LiaoxinNumber, c.ClientId }).FirstOrDefault();

            if (clientEntity == null)
            {
                return(new ServiceResult(ServiceResultCode.Error, "不存在客户聊信号,请重新输入"));
            }
            entity.GroupId  = groupEntity.GroupId;
            entity.ClientId = clientEntity.ClientId;
            entity.IsStop   = this.IsStop;
            entity.Priority = this.Priority;
            entity.Rate     = this.Rate;
            Context.RateOfGroupClients.Add(entity);
            UserOperateLogService.Log($"新增[{entity.RateOfGroupClientId}]客户群组概率", Context);
            Context.SaveChanges();
            return(new ServiceResult(ServiceResultCode.Success));
        }
Example #4
0
        public ServiceResult Save()
        {
            var entity = Context.Clients.Where(c => c.ClientId == this.ClientId).FirstOrDefault();

            if (!string.IsNullOrEmpty(this.CoinPassword))
            {
                entity.CoinPassword = SecurityHelper.Encrypt(CoinPassword);
            }
            if (!string.IsNullOrEmpty(this.Password))
            {
                entity.Password = SecurityHelper.Encrypt(Password);
            }
            if (!string.IsNullOrEmpty(this.Telephone))
            {
                entity.Telephone = this.Telephone;
            }
            if (!string.IsNullOrEmpty(this.HuanXinId))
            {
                entity.HuanXinId = this.HuanXinId;
            }
            if (this.Cover.HasValue)
            {
                entity.Cover = this.Cover.Value;
            }
            entity.CanWithdraw = this.CanWithdraw;
            entity.UpdateTime  = DateTime.Now;
            Context.Clients.Update(entity);
            UserOperateLogService.Log($"编辑[{entity.LiaoxinNumber}]聊信客户", Context);
            Context.SaveChanges();
            return(new ServiceResult(ServiceResultCode.Success));
        }
Example #5
0
 public void Save()
 {
     using (var scope = Context.Database.BeginTransaction())
     {
         var user = (from u in Context.UserInfos where u.UserInfoId == UserInfoId select u).First();
         Context.UserInfoRoles.RemoveRange(from u in Context.UserInfoRoles where u.UserInfoId == UserInfoId select u);
         Context.SaveChanges();
         if (Roles != null)
         {
             StringBuilder sb = new StringBuilder();
             foreach (var number in Roles)
             {
                 var id   = int.Parse(number);
                 var role = (from r in Context.Roles where r.RoleId == id select r).First();
                 sb.Append($"[{role.Name}]");
                 Context.UserInfoRoles.Add(new UserInfoRole()
                 {
                     RoleId     = int.Parse(number),
                     UserInfoId = UserInfoId
                 });
             }
             UserOperateLogService.Log($"编辑用户[{user.Name}]的角色:{sb}", Context);
             Context.SaveChanges();
         }
         scope.Commit();
     }
 }
 public ServiceResult Save()
 {
     Context.Announcements.Add(new Announcement(Title, Content, ShowOpenTime));
     UserOperateLogService.Log($"新增[{Title}]公告", Context);
     Context.SaveChanges();
     return(new ServiceResult(ServiceResultCode.Success));
 }
        public void Delete()
        {
            var exist = (from a in Context.Announcements where a.AnnouncementId == AnnouncementId select a).First();

            exist.IsEnable = false;
            UserOperateLogService.Log($"删除[{Title}]公告", Context);
            Context.SaveChanges();
        }
Example #8
0
        public void Delete()
        {
            var exist = (from u in Context.UserInfos where u.UserInfoId == UserInfoId select u).First();

            exist.IsEnable = false;
            UserOperateLogService.Log($"删除用户[{exist.Name}]", Context);
            Context.SaveChanges();
        }
        public ServiceResult Save()
        {
            List <string> lis = new List <string>();

            lis.Add(SourceLiaoxinNumber);
            lis.Add(ToLiaoxinNumber);
            var source       = Context.Clients.Where(c => lis.Contains(c.LiaoxinNumber)).Select(c => new { c.ClientId, c.LiaoxinNumber }).ToList();
            var sourceClient = source.FirstOrDefault(c => c.LiaoxinNumber == SourceLiaoxinNumber);

            if (sourceClient == null)
            {
                return(new ServiceResult(ServiceResultCode.QueryNull, "没有找到源聊信号"));
            }
            var toClient = source.FirstOrDefault(c => c.LiaoxinNumber == ToLiaoxinNumber);

            if (toClient == null)
            {
                return(new ServiceResult(ServiceResultCode.QueryNull, "没有找到目标聊信号"));
            }

            var applySourceCnt = Context.ClientAdds.Where(c => c.ClientId == sourceClient.ClientId).Count();
            var applyToCnt     = Context.ClientAddDetails.Where(c => c.ClientId == toClient.ClientId &&
                                                                c.Status != ClientAddDetailTypeEnum.StandBy).Count();

            if (applySourceCnt > 0 && applyToCnt > 0)
            {
                return(new ServiceResult(ServiceResultCode.Error, "你已申请添加此客户,无需要重复申请"));
            }

            var sourceCnt = Context.ClientRelations.Where(c => c.ClientId == sourceClient.ClientId && c.RelationType == ClientRelation.RelationTypeEnum.Friend).Count();
            var toCnt     = Context.ClientRelationDetails.Where(c => c.ClientId == toClient.ClientId).Count();

            if (sourceCnt > 0 && toCnt > 0)
            {
                return(new ServiceResult(ServiceResultCode.Error, "你已添加此客户,无需要重复添加"));
            }
            ClientAdd clientAddEntity = new ClientAdd();;

            clientAddEntity.ClientId = sourceClient.ClientId;

            if (applySourceCnt == 0)
            {
                Context.ClientAdds.Add(clientAddEntity);
            }
            ClientAddDetail detailEntity = new ClientAddDetail()
            {
                ClientAddId = clientAddEntity.ClientAddId,
                AddRemark   = Remark,
                ClientId    = toClient.ClientId
            };

            Context.ClientAddDetails.Add(detailEntity);
            UserOperateLogService.Log($"添加客户申请,源客户[{sourceClient.LiaoxinNumber}]申请添加客户[{toClient.LiaoxinNumber}]", Context);
            Context.SaveChanges();
            return(new ServiceResult(ServiceResultCode.Success));
        }
        public void Save()
        {
            var exist = (from a in Context.Announcements where a.AnnouncementId == AnnouncementId select a).First();

            exist.Content      = Content;
            exist.Title        = Title;
            exist.ShowOpenTime = ShowOpenTime;
            UserOperateLogService.Log($"编辑[{Title}]公告", Context);
            Context.SaveChanges();
        }
 public virtual ServiceResult Save()
 {
     if (AffixId == null)
     {
         return(new ServiceResult(ServiceResultCode.Error, "请上传滚动图"));
     }
     Context.PictureNewses.Add(new PictureNews(AffixId.Value, Url, SortIndex));
     UserOperateLogService.Log($"新增滚动图,图片编号是[{AffixId}]", Context);
     Context.SaveChanges();
     return(new ServiceResult());
 }
Example #12
0
        public ServiceResult Save()
        {
            if (UserInfoId.ToString() == HttpContextAccessor.HttpContext.User.Identity.Name)
            {
                return(new ServiceResult(ServiceResultCode.Error, "不能修改当前账号的密码"));
            }

            var user = (from u in Context.UserInfos where u.UserInfoId == UserInfoId select u).First();

            user.Password = SecurityHelper.Encrypt(Password);
            user.Update();
            UserOperateLogService.Log($"修改用户[{user.Name}]的密码", Context);
            Context.SaveChanges();
            return(new ServiceResult(ServiceResultCode.Success));
        }
Example #13
0
        public ServiceResult Save()
        {
            var role = from r in Context.Roles where r.Name == Name select r;

            if (role.Any())
            {
                return(new ServiceResult(ServiceResultCode.Error, "已存在相同的角色,无法添加"));
            }
            Context.Roles.Add(new Role()
            {
                Name = Name
            });
            UserOperateLogService.Log($"新增角色[{Name}]", Context);
            Context.SaveChanges();
            return(new ServiceResult());
        }
Example #14
0
        public ServiceResult Save()
        {
            var client = new Client()
            {
                NickName     = NickName,
                Password     = SecurityHelper.Encrypt(Password),
                CoinPassword = SecurityHelper.Encrypt(CoinPassword),
                Telephone    = Telephone,
                HuanXinId    = HuanXinId,
                Cover        = Cover.Value,
            };

            Context.Clients.Add(client);
            UserOperateLogService.Log($"新增[{client.LiaoxinNumber}]聊信客户", Context);
            Context.SaveChanges();
            return(new ServiceResult(ServiceResultCode.Success));
        }
Example #15
0
        public ServiceResult Save()
        {
            if (this.Rate > 100 || this.Rate < 0)
            {
                return(new ServiceResult(ServiceResultCode.Error, "请输入0~100的概率"));
            }
            var entity = Context.RateOfGroupClients.Where(c => c.RateOfGroupClientId == this.RateOfGroupClientId).FirstOrDefault();

            entity.IsStop     = this.IsStop;
            entity.Priority   = this.Priority;
            entity.Rate       = this.Rate;
            entity.UpdateTime = DateTime.Now;
            Context.RateOfGroupClients.Update(entity);
            UserOperateLogService.Log($"编辑[{entity.RateOfGroupClientId}]群组概率", Context);
            Context.SaveChanges();
            return(new ServiceResult(ServiceResultCode.Success));
        }
        public override ServiceResult Save()
        {
            if (AffixId == null)
            {
                return(new ServiceResult(ServiceResultCode.Error, "请上传滚动图"));
            }
            var exist =
                (from p in Context.PictureNewses where p.PictureNewsId == PictureNewsId select p).First();

            exist.SortIndex = SortIndex;
            exist.AffixId   = AffixId.Value;
            exist.Url       = Url;
            exist.Update();
            UserOperateLogService.Log($"编辑滚动图,主键为[{PictureNewsId}]", Context);
            Context.SaveChanges();
            return(new ServiceResult());
        }
Example #17
0
        public ServiceResult Save()
        {
            var exist = (from u in Context.UserInfos where u.Name == Name select u).FirstOrDefault();

            if (exist != null)
            {
                return(new ServiceResult(ServiceResultCode.Error, "该用户名已存在,请重新输入"));
            }

            UserOperateLogService.Log($"新增用户[{Name}]", Context);
            Context.UserInfos.Add(new UserInfo()
            {
                Name = Name, Password = SecurityHelper.Encrypt(Password)
            });
            Context.SaveChanges();
            return(new ServiceResult(ServiceResultCode.Success));
        }
Example #18
0
        public virtual ServiceResult Save()
        {
            if (AffixId == null)
            {
                return(new ServiceResult(ServiceResultCode.Error, "请上传活动图片"));
            }

            Context.ActivityAnnouncements.Add(new ActivityAnnouncement(Title, BeginTime, EndTime, Content,
                                                                       AffixId.Value)
            {
                SortIndex = SortIndex
            });

            UserOperateLogService.Log($"新增活动公告[{Title}]", Context);

            Context.SaveChanges();
            return(new ServiceResult());
        }
Example #19
0
        public ServiceResult EnableOperation()
        {
            var entity = Context.GroupClients.Where(c => c.GroupClientId == this.GroupMemberId).FirstOrDefault();

            if (entity == null)
            {
                return(new ServiceResult(ServiceResultCode.QueryNull, "找不到群成员"));
            }

            entity.IsBlock = !this.IsBlock;
            Context.GroupClients.Update(entity);
            string title = this.IsBlock ? "解禁言" : "禁言";

            UserOperateLogService.Log($"[群编号:{entity.Group.GroupId} {title}了+{entity.Client.LiaoxinNumber}]聊信客户", Context);
            int res = Context.SaveChanges();

            return(new ServiceResult(ServiceResultCode.Success));
        }
Example #20
0
        public ServiceResult EnableOperation()
        {
            var entity = Context.Clients.Where(c => c.ClientId == this.ClientId).FirstOrDefault();

            if (entity == null)
            {
                return(new ServiceResult(ServiceResultCode.QueryNull, "找不到客户"));
            }

            entity.IsFreeze = !this.IsFreeze;
            string title = entity.IsFreeze ? "禁用" : "启用";

            Context.Clients.Update(entity);
            UserOperateLogService.Log($"[{title}了+{entity.LiaoxinNumber}]聊信客户", Context);
            int res = Context.SaveChanges();

            return(new ServiceResult(ServiceResultCode.Success));
        }
Example #21
0
        public ServiceResult Save()
        {
            if (BannerAffixId == null)
            {
                return(new ServiceResult(ServiceResultCode.Error, "请上传银行图片"));
            }

            MerchantsBank bank = new MerchantsBank();

            if (MerchantsBankId >= 0)
            {
                bank = (from m in Context.MerchantsBanks where m.MerchantsBankId == MerchantsBankId select m).First();
            }
            bank.BannerAffixId = BannerAffixId.Value;

            try
            {
                SaveDoSomething(bank);
            }
            catch (ZzbException e)
            {
                return(new ServiceResult(ServiceResultCode.Error, e.Message));
            }

            bank.Type      = BankType;
            bank.Name      = Name;
            bank.Min       = Min;
            bank.Max       = Max;
            bank.IndexSort = IndexSort;
            bank.IsUseful  = IsUseful;
            if (MerchantsBankId >= 0)
            {
                UserOperateLogService.Log($"编辑收款银行[{Name}]", Context);
            }
            else
            {
                Context.MerchantsBanks.Add(bank);
                UserOperateLogService.Log($"添加收款银行[{Name}]", Context);
            }

            Context.SaveChanges();
            return(new ServiceResult(ServiceResultCode.Success));
        }
Example #22
0
        public ServiceResult SaveGroup()
        {
            var entity = Context.Groups.Where(c => c.GroupId == this.GroupId).FirstOrDefault();

            if (!string.IsNullOrEmpty(this.Name))
            {
                entity.Name = this.Name;
            }

            if (!string.IsNullOrEmpty(this.HuanxinGroupId))
            {
                entity.HuanxinGroupId = this.HuanxinGroupId;
            }
            entity.AllBlock          = this.AllBlock;
            entity.SureConfirmInvite = this.SureConfirmInvite;
            entity.UpdateTime        = DateTime.Now;
            Context.Groups.Update(entity);
            UserOperateLogService.Log($"编辑[{entity.HuanxinGroupId}]群组", Context);
            Context.SaveChanges();
            return(new ServiceResult(ServiceResultCode.Success));
        }
Example #23
0
        public override ServiceResult Save()
        {
            if (AffixId == null)
            {
                return(new ServiceResult(ServiceResultCode.Error, "请上传活动图片"));
            }

            var exist = (from a in Context.ActivityAnnouncements
                         where a.ActivityAnnouncementId == ActivityAnnouncementId
                         select a).First();

            exist.AffixId   = AffixId.Value;
            exist.Title     = Title;
            exist.BeginTime = BeginTime;
            exist.EndTime   = EndTime;
            exist.Content   = Content;
            exist.SortIndex = SortIndex;

            UserOperateLogService.Log($"编辑公告[{Title}]", Context);
            Context.SaveChanges();
            return(new ServiceResult());
        }
Example #24
0
        public ServiceResult Save()
        {
            var client = (from p in Context.Clients where p.LiaoxinNumber == this.LiaoxinNumber select p).FirstOrDefault();

            if (client == null)
            {
                return(new ServiceResult(ServiceResultCode.Error, "客户不存在"));
            }
            var exist = (from r in Context.Recharges where r.ClientId == client.ClientId && r.ClientBankId == null orderby r.CreateTime descending select r).FirstOrDefault();

            if (exist != null && exist.CreateTime.AddSeconds(10) > DateTime.Now)
            {
                return(new ServiceResult(ServiceResultCode.Error, "该客户充值太频繁,请稍后再试"));
            }
            var recharge = Context.Recharges.Add(new Recharge(client.ClientId, Money, Remark, null, RechargeStateEnum.AdminOk));

            client.AddMoney(Money, CoinLogTypeEnum.InsteadRecharge, recharge.Entity.RechargeId, out var log, Remark);

            //player.UpdateReportDate();
            Context.CoinLogs.Add(log);
            UserOperateLogService.Log($"手动给[{client.RealName}/{client.LiaoxinNumber}]充值了[{recharge.Entity.Money}]元,订单号为[{recharge.Entity.OrderNo}]", Context);
            Context.SaveChanges();
            return(new ServiceResult());
        }
Example #25
0
        public ServiceResult Save()
        {
            var player = (from p in Context.Players where p.Name == Name select p).First();

            Rebate /= 100;

            StringBuilder sb = new StringBuilder();

            if (!string.IsNullOrEmpty(Password))
            {
                sb.Append(",修改登录密码");
                player.Password = SecurityHelper.Encrypt(Password);
            }
            if (!string.IsNullOrEmpty(CoidPassword))
            {
                sb.Append(",修改资金密码");
                player.CoinPassword = SecurityHelper.Encrypt(CoidPassword);
            }



            UserOperateLogService.Log($"修改玩家[{player.Name}]资料{sb}{MvcHelper.LogDifferent(new LogDifferentViewModel((player.Rebate * 100).ToDecimalString(), (Rebate * 100).ToDecimalString(), "返点"), new LogDifferentViewModel(player.DailyWageRate == null ? null : (player.DailyWageRate.Value * 100).ToDecimalString(), DailyWageRate?.ToDecimalString(), "标准日工资"), new LogDifferentViewModel(player.DividendRate == null ? null : (player.DividendRate.Value * 100).ToDecimalString(), DividendRate?.ToDecimalString(), "分红比例"), new LogDifferentViewModel(player.IsFreeze.ToString(), IsFreeze.ToString(), "是否冻结"), new LogDifferentViewModel(player.CanWithdraw.ToString(), CanWithdraw.ToString(), "是否可以提现"))}", Context);

            if (player.ParentPlayer != null)
            {
                if (player.ParentPlayer.Rebate < Rebate)
                {
                    return(new ServiceResult(ServiceResultCode.Error, $"返点不能超过上级[{player.ParentPlayer.Rebate.ToPercenString()}]"));
                }

                if (DailyWageRate != null)
                {
                    if (player.ParentPlayer.DailyWageRate == null)
                    {
                        return(new ServiceResult(ServiceResultCode.Error, $"上级没有设置标准日工资"));
                    }
                    if (player.ParentPlayer.DailyWageRate * 100 < DailyWageRate)
                    {
                        return(new ServiceResult(ServiceResultCode.Error, $"标准日工资不能超过上级[{player.ParentPlayer.DailyWageRate?.ToPercenString()}]"));
                    }
                }

                if (DividendRate != null)
                {
                    if (player.ParentPlayer.DividendRate == null)
                    {
                        return(new ServiceResult(ServiceResultCode.Error, $"上级没有设置比例分红"));
                    }

                    if (player.ParentPlayer.DividendRate * 100 < DividendRate)
                    {
                        return(new ServiceResult(ServiceResultCode.Error, $"比例分红不能超过上级[{player.ParentPlayer.DividendRate?.ToPercenString()}]"));
                    }
                }
            }
            else
            {
                if (BaseConfig.CreateInstance(SystemConfigEnum.MaxRebate).DecimalValue < Rebate)
                {
                    return(new ServiceResult(ServiceResultCode.Error, $"返点不能超过最高返点[{(BaseConfig.CreateInstance(SystemConfigEnum.MaxRebate).DecimalValue * 100).ToDecimalString() + "%"}]"));
                }
            }

            if (player.Players.Any())
            {
                var min = (from p in player.Players orderby p.Rebate descending select p.Rebate).First();
                if (min > Rebate)
                {
                    return(new ServiceResult(ServiceResultCode.Error, $"返点不能低于下级[{min.ToPercenString()}]"));
                }
            }

            if (player.Players.Any(t => t.DailyWageRate != null))
            {
                if (DailyWageRate == null)
                {
                    return(new ServiceResult(ServiceResultCode.Error, $"标准日工资不能为空,因为已有下级设置了标准日工资"));
                }
                var min = (from p in player.Players where p.DailyWageRate != null orderby p.DailyWageRate descending select p.DailyWageRate).First();
                if (min > DailyWageRate)
                {
                    return(new ServiceResult(ServiceResultCode.Error, $"标准日工资不能低于下级[{min?.ToPercenString()}]"));
                }
            }

            if (player.Players.Any(t => t.DividendRate != null))
            {
                if (DividendRate == null)
                {
                    return(new ServiceResult(ServiceResultCode.Error, $"比例分红不能为空,因为已有下级设置了标准日工资"));
                }
                var min = (from p in player.Players where p.DividendRate != null orderby p.DividendRate descending select p.DividendRate).First();
                if (min > DividendRate)
                {
                    return(new ServiceResult(ServiceResultCode.Error, $"比例分红不能低于下级[{min?.ToPercenString()}]"));
                }
            }

            player.Rebate = Rebate;
            if (DailyWageRate != null)
            {
                player.DailyWageRate = DailyWageRate.Value / 100;
            }
            else
            {
                player.DailyWageRate = null;
            }

            if (DividendRate != null)
            {
                player.DividendRate = DividendRate.Value / 100;
            }
            else
            {
                player.DividendRate = null;
            }

            player.IsFreeze    = IsFreeze;
            player.CanWithdraw = CanWithdraw;

            player.Update();
            Context.SaveChanges();
            return(new ServiceResult(ServiceResultCode.Success));
        }