|
|
@@ -3,9 +3,9 @@
|
|
|
namespace App\Module\User;
|
|
|
|
|
|
use App\Module\App\SessionApp;
|
|
|
-use App\Module\User\Enums\ActionStatus;
|
|
|
-use App\Module\User\Enums\ActionType;
|
|
|
-use App\Module\User\Enums\Status2;
|
|
|
+use App\Module\User\Enums\ACTION_STATUS;
|
|
|
+use App\Module\User\Enums\ACTION_TYPE;
|
|
|
+use App\Module\User\Enums\STATUS2;
|
|
|
use App\Module\User\Models\UserAction;
|
|
|
use App\Module\User\Unit\UserPublic;
|
|
|
use Dcore\Db\Arr;
|
|
|
@@ -33,7 +33,7 @@ class Action
|
|
|
*/
|
|
|
static public function ban($admin_id, $user_id, $desc, $re_id, $re_type,$exp = 360000)
|
|
|
{
|
|
|
- return self::call_type($admin_id, $user_id, $desc, $re_id, $re_type,ActionType::Ban,$exp);
|
|
|
+ return self::call_type($admin_id, $user_id, $desc, $re_id, $re_type,ACTION_TYPE::BAN,$exp);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -44,7 +44,7 @@ class Action
|
|
|
* @param $re_type
|
|
|
* @return UserAction
|
|
|
*/
|
|
|
- static public function call_type($admin_id, $user_id, $desc, $re_id, $re_type,ActionType $type,$exp = 360000)
|
|
|
+ static public function call_type($admin_id, $user_id, $desc, $re_id, $re_type,ACTION_TYPE $type,$exp = 360000)
|
|
|
{
|
|
|
Helper::check_tr();
|
|
|
// 增加封禁记录
|
|
|
@@ -57,20 +57,20 @@ class Action
|
|
|
$model->type =$type;
|
|
|
if($exp){
|
|
|
$model->exp_time = time()+$exp;
|
|
|
- $model->status = ActionStatus::Ing;
|
|
|
+ $model->status = ACTION_STATUS::ING;
|
|
|
}else{
|
|
|
$model->exp_time = 0;
|
|
|
- $model->status = ActionStatus::Ok;
|
|
|
+ $model->status = ACTION_STATUS::OK;
|
|
|
}
|
|
|
if(! $model->save()){
|
|
|
throw new \LogicException("user - Action save type error. ");
|
|
|
}
|
|
|
|
|
|
$list = [
|
|
|
- ActionType::Restrict->value() => Status2::Restrict->value(),
|
|
|
- ActionType::Normal->value() => Status2::Normal->value(),
|
|
|
- ActionType::Delete->value() => Status2::Deleteing->value(),
|
|
|
- ActionType::Ban->value() => Status2::Ban->value(),
|
|
|
+ ACTION_TYPE::RESTRICT->value() => STATUS2::Restrict->value(),
|
|
|
+ ACTION_TYPE::NORMAL->value() => STATUS2::Normal->value(),
|
|
|
+ ACTION_TYPE::DELETE->value() => STATUS2::Deleteing->value(),
|
|
|
+ ACTION_TYPE::BAN->value() => STATUS2::Ban->value(),
|
|
|
];
|
|
|
$status = $list[$type->value()]??null;
|
|
|
if(is_null($status)){
|
|
|
@@ -84,34 +84,34 @@ class Action
|
|
|
throw new \LogicException("user - Action save error. ");
|
|
|
|
|
|
}
|
|
|
- if($type === ActionType::Normal){
|
|
|
+ if($type === ACTION_TYPE::NORMAL){
|
|
|
// 正常化处理,需要解除进行中的惩罚
|
|
|
// 没有过期时间的
|
|
|
UserAction::query()
|
|
|
->where('user_id',$user_id)
|
|
|
- ->where('status',ActionStatus::Ok)
|
|
|
+ ->where('status',ACTION_STATUS::OK)
|
|
|
|
|
|
- ->whereNotIn('type',[ActionType::Normal])
|
|
|
+ ->whereNotIn('type',[ACTION_TYPE::NORMAL])
|
|
|
->update([
|
|
|
- 'status'=>ActionStatus::End->value
|
|
|
+ 'status'=>ACTION_STATUS::END->value
|
|
|
]);
|
|
|
// 生效中
|
|
|
UserAction::query()
|
|
|
->where('user_id',$user_id)
|
|
|
- ->where('status',ActionStatus::Ing)
|
|
|
- ->whereNotIn('type',[ActionType::Normal])
|
|
|
+ ->where('status',ACTION_STATUS::ING)
|
|
|
+ ->whereNotIn('type',[ACTION_TYPE::NORMAL])
|
|
|
->update([
|
|
|
- 'status'=>ActionStatus::End->value
|
|
|
+ 'status'=>ACTION_STATUS::END->value
|
|
|
]);
|
|
|
}
|
|
|
Logger::info('type',[$type->value()]);
|
|
|
|
|
|
- if($type === ActionType::Ban){
|
|
|
+ if($type === ACTION_TYPE::BAN){
|
|
|
// 禁止
|
|
|
Logger::info('ban');
|
|
|
SessionApp::removeUKeys($user_id);
|
|
|
}
|
|
|
- if($type === ActionType::Restrict){
|
|
|
+ if($type === ACTION_TYPE::RESTRICT){
|
|
|
// 限制登陆
|
|
|
Logger::info('Restrict');
|
|
|
SessionApp::removeUKeys($user_id);
|
|
|
@@ -133,7 +133,7 @@ class Action
|
|
|
* @var UserAction[] $list
|
|
|
*/
|
|
|
$list = UserAction::query()
|
|
|
- ->where('status', ActionStatus::Ing)
|
|
|
+ ->where('status', ACTION_STATUS::ING)
|
|
|
->where('exp_time','>',0)
|
|
|
->where('exp_time','<',$time)
|
|
|
->limit(10)
|
|
|
@@ -143,7 +143,7 @@ class Action
|
|
|
|
|
|
try {
|
|
|
DB::beginTransaction();
|
|
|
- $item->status = ActionStatus::OutTime;
|
|
|
+ $item->status = ACTION_STATUS::OUT_TIME;
|
|
|
$item->save();
|
|
|
self::callItem($item);
|
|
|
DB::commit();
|
|
|
@@ -166,7 +166,7 @@ class Action
|
|
|
$type = $action->type->value();
|
|
|
// 判断是否存在其他生效的禁令
|
|
|
$lsit = UserAction::query()
|
|
|
- ->where('status', '=', ActionStatus::Ing)
|
|
|
+ ->where('status', '=', ACTION_STATUS::ING)
|
|
|
->where('user_id','=',$action->user_id)
|
|
|
->where('type','=', $action->type)
|
|
|
->where(function ( \Illuminate\Database\Eloquent\Builder $builder) {
|
|
|
@@ -181,20 +181,20 @@ class Action
|
|
|
return;
|
|
|
}
|
|
|
$info = User::infoinfo($action->user_id,true);
|
|
|
- if($action->type === ActionType::Ban){
|
|
|
- if($info->status2 === Status2::Ban){
|
|
|
+ if($action->type === ACTION_TYPE::BAN){
|
|
|
+ if($info->status2 === STATUS2::Ban){
|
|
|
// 接触 封禁
|
|
|
- self::call_type(\App\Module\Sys\Admin::AUTO_BOT,$action->user_id,"到期自动解除-封禁",$action->id,'ActionAuto',ActionType::Normal,0);
|
|
|
+ self::call_type(\App\Module\Sys\Admin::AUTO_BOT,$action->user_id,"到期自动解除-封禁",$action->id,'ActionAuto',ACTION_TYPE::NORMAL,0);
|
|
|
Logger::info("callItem $action->id $type ban ->Normal ");
|
|
|
}else{
|
|
|
Logger::info("callItem $action->id $type now no ban ");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if($action->type === ActionType::Restrict){
|
|
|
- if($info->status2 === Status2::Restrict){
|
|
|
+ if($action->type === ACTION_TYPE::RESTRICT){
|
|
|
+ if($info->status2 === STATUS2::Restrict){
|
|
|
// 接触禁止登录
|
|
|
- self::call_type(\App\Module\Sys\Admin::AUTO_BOT,$action->user_id,"到期自动解除-限制登录",$action->id,'ActionAuto',ActionType::Normal);
|
|
|
+ self::call_type(\App\Module\Sys\Admin::AUTO_BOT,$action->user_id,"到期自动解除-限制登录",$action->id,'ActionAuto',ACTION_TYPE::NORMAL);
|
|
|
Logger::info("callItem $action->id $type Restrict ->Normal ");
|
|
|
}else{
|
|
|
Logger::info("callItem $action->id $type now no Restrict ");
|