Ejemplo n.º 1
0
        /// <summary>
        /// 修改推荐人
        /// </summary>
        /// <returns></returns>
        public bool ChangeReferee(int userId, string refereeCode, int op_user_id)
        {
            var fac = UserModuleFactory.GetUserModuleInstance();

            if (fac == null)
            {
                Alert("系统错误");
                return(false);
            }
            IUser user = fac.GetUserByID(userId);

            if (user == null)
            {
                Alert("会员信息有误");
                return(false);
            }
            string value_before = user.Refer_ID.HasValue ? user.Refer_ID.Value.ToString() : null;
            IUser  refereeUser  = fac.GetUserByCode(refereeCode);

            if (refereeUser == null)
            {
                Alert("推荐人信息有误");
                return(false);
            }
            if (user.Refer_ID.HasValue && user.Refer_ID.Value == refereeUser.UserId)
            {
                return(true);
            }
            user.Refer_ID = refereeUser.UserId;
            var mgt = fac.GetProfileManager(user);

            if (!mgt.Update())
            {
                Alert("推荐人修改失败");
                return(false);
            }
            LogDetails refereeInfo = new LogDetails
            {
                DATA_FIELD   = "Refer_ID",
                VALUE_AFTER  = refereeUser.UserId.ToString(),
                VALUE_BEFORE = value_before
            };

            AdminDatabaseLog.PersistToDatabase(OperateType.UPDATE, op_user_id, "TNET_USER", user.UserId, "会员管理后台修改推荐人", null, refereeInfo);
            return(true);
        }
Ejemplo n.º 2
0
        public bool EnableUser(int user_id, string reason, int op_user_id)
        {
            if (string.IsNullOrEmpty(reason))
            {
                Alert("请输入解除封禁的原因");
                return(false);
            }
            Tnet_LockCollection daLockCollection = new Tnet_LockCollection();

            daLockCollection.ListLockedByUser_id(user_id);
            if (daLockCollection.Count <= 0)
            {
                return(true);
            }
            BeginTransaction();
            foreach (Tnet_Lock mlock in daLockCollection)
            {
                DateTime before = mlock.Auto_Unlock_Time;
                mlock.Auto_Unlock_Time = DateTime.Now;
                if (!mlock.Update())
                {
                    Rollback();
                    return(false);
                }
                var lockDetails = new LogDetails
                {
                    DATA_FIELD   = "AUTO_UNLOCK_TIME",
                    VALUE_BEFORE = before.ToString(),
                    VALUE_AFTER  = mlock.Auto_Unlock_Time.ToString(),
                };
                if (!AdminDatabaseLog.PersistToDatabase(OperateType.UPDATE, op_user_id, "TNET_LOCK", mlock.Lock_Id, "后台解除封号,原因:" + reason, this.Transaction, lockDetails))
                {
                    Rollback();
                    return(false);
                }
            }
            Commit();
            return(true);
        }
Ejemplo n.º 3
0
        public bool DisableUser(int user_id, int days, string reason, int op_user_id)
        {
            if (days <= 0)
            {
                Alert("封禁时间天数不能小于等于零");
                return(false);
            }
            DateTime            lockDate         = DateTime.Now.AddDays(days);
            Tnet_LockCollection daLockCollection = new Tnet_LockCollection();

            daLockCollection.ListLockedByUser_id(user_id);
            bool     isExist      = daLockCollection.Count > 0;
            int      lockid       = 0;
            DateTime?tempLockDate = null;

            foreach (Tnet_Lock mlock in daLockCollection)
            {
                if (mlock.Auto_Unlock_Time > lockDate)
                {
                    Alert("该用户已由其他原因被封禁,并且封禁时间大于您选择的时间");
                    return(false);
                }
                else
                {
                    if (!tempLockDate.HasValue || tempLockDate.Value > mlock.Auto_Unlock_Time)
                    {
                        tempLockDate = mlock.Auto_Unlock_Time;
                        lockid       = mlock.Lock_Id;
                    }
                }
            }
            BeginTransaction();
            Tnet_Lock daLock = new Tnet_Lock();

            daLock.ReferenceTransactionFrom(Transaction);
            daLock.User_Id          = user_id;
            daLock.Auto_Unlock_Time = lockDate;
            daLock.Lock_Right       = 1;
            daLock.Remarks          = reason;
            if (isExist && lockid > 0)
            {
                daLock.Lock_Id = lockid;
                if (!daLock.Update())
                {
                    Rollback();
                    return(false);
                }
            }
            else if (!daLock.Insert())
            {
                Rollback();
                return(false);
            }
            LogDetails lockDetails = new LogDetails
            {
                DATA_FIELD   = "USER_ID",
                VALUE_BEFORE = isExist ? tempLockDate.ToString() : null,
                VALUE_AFTER  = "LOCKED",
            };

            if (!AdminDatabaseLog.PersistToDatabase(OperateType.ADD, op_user_id, "TNET_LOCK", daLock.Lock_Id, "通过用户后台管理", this.Transaction, lockDetails))
            {
                Rollback();
                return(false);
            }
            Commit();
            return(true);
        }