diff --git a/app/common/service/StockOrdersService.php b/app/common/service/StockOrdersService.php index 19371b0..fdfd1fb 100644 --- a/app/common/service/StockOrdersService.php +++ b/app/common/service/StockOrdersService.php @@ -129,6 +129,8 @@ class StockOrdersService } } + // 检查绑定 + (new UserService())->checkBind($userId); return $data; } diff --git a/app/common/service/UserService.php b/app/common/service/UserService.php index 32a7d43..6ea31bd 100644 --- a/app/common/service/UserService.php +++ b/app/common/service/UserService.php @@ -227,4 +227,26 @@ class UserService return $config; } + + + public function checkBind($userId) + { + $user = \app\common\model\User::find($userId); + if (!$user->report_to) { + throw new BusinessException('请先前往个人中心-绑定直属上级'); + } + + if ($user->sign_img === null || $user->sign_img === '') { + throw new BusinessException('请先前往个人中心-操作签名'); + } + + $ug = \app\common\model\UserGroupMembers::with(['group' => function($query) { + $query->where('scenario_code', 'stock_orders'); + }])->where('user_id', $userId)->first(); + if (!$ug) { + throw new BusinessException('请先前往个人中心-绑定内勤'); + } + + return true; + } } \ No newline at end of file diff --git a/app/common/utils/WsEvents.php b/app/common/utils/WsEvents.php index 96596b8..5bf4792 100644 --- a/app/common/utils/WsEvents.php +++ b/app/common/utils/WsEvents.php @@ -2,6 +2,7 @@ namespace app\common\utils; +use app\common\model\UserRoles; use GatewayWorker\Lib\Gateway; use app\common\utils\WsResponse; use app\common\service\MessageNotificationsService; @@ -303,30 +304,29 @@ class WsEvents public function initCheck(int $userId) { $data = [ - 'is_report_to' => false, - 'is_office_clerk' => false, + // 'is_report_to' => false, + // 'is_office_clerk' => false, 'is_sign' => false ]; $user = \app\common\model\User::find($userId); - - if ($user->report_to > 0) { - $data['is_report_to'] = true; - } + // if ($user->report_to > 0) { + // $data['is_report_to'] = true; + // } if ($user->sign_img !== null && $user->sign_img !== '') { $data['is_sign'] = true; } - $ug = \app\common\model\UserGroupMembers::with(['group' => function($query) { - $query->where('scenario_code', 'stock_orders'); - }])->where('user_id', $userId)->first(); - if ($ug !== null) { - $data['is_office_clerk'] = true; - } + // $ug = \app\common\model\UserGroupMembers::with(['group' => function($query) { + // $query->where('scenario_code', 'stock_orders'); + // }])->where('user_id', $userId)->first(); + // if ($ug !== null) { + // $data['is_office_clerk'] = true; + // } - if ($data['is_report_to'] && $data['is_office_clerk'] && $data['is_sign']) { - Redis::hSet('user:init:check:'.$userId, 'status', 1); + if ($data['is_sign']) { + Redis::hSet('user:check:sign'.$userId, 'status', 1); } return $data; diff --git a/app/crmAdmin/controller/StatisticsController.php b/app/crmAdmin/controller/StatisticsController.php index 77db8a0..2d1e47f 100644 --- a/app/crmAdmin/controller/StatisticsController.php +++ b/app/crmAdmin/controller/StatisticsController.php @@ -139,7 +139,6 @@ class StatisticsController extends BaseController // 1. 计算时间范围 $now = Carbon::now(); $sixMonthsAgo = $now->copy()->subMonths(5)->startOfMonth(); // 包含6个月 - var_dump($sixMonthsAgo->timestamp); // 2. 获取关联渠道ID $channelIds = $this->getChannelIdsByCompany($companyId); diff --git a/app/process/CheckWeb.php b/app/process/CheckWeb.php index 31c67b5..3cdfe77 100644 --- a/app/process/CheckWeb.php +++ b/app/process/CheckWeb.php @@ -3,7 +3,6 @@ namespace app\process; use app\common\model\User; -use app\common\model\UserRoles; use app\common\utils\WsEvents; use support\Redis; use Workerman\Crontab\Crontab; @@ -24,9 +23,9 @@ class CheckWeb } new Crontab('*/3 * * * * *', function(){ - $userIds = UserRoles::where('role_id', 1)->pluck('user_id')->toArray(); + $userIds = User::where('status', 1)->toArray(); foreach ($userIds as $userId) { - $status = Redis::hGet('user:init:check:'.$userId, 'status'); + $status = Redis::hGet('user:check:sign'.$userId, 'status'); if ($status) { continue; }