chuan 3 months ago
parent
commit
93b8c5ca61
  1. 2
      app/admin/controller/setting/PreStock.php
  2. 3
      app/admin/service/AgentService.php
  3. 79
      app/admin/service/UserService.php
  4. 6
      app/admin/service/auth/AuthRuleService.php
  5. 5
      app/admin/service/setting/IPOService.php
  6. 5
      app/model/AdminModel.php

2
app/admin/controller/setting/PreStock.php

@ -37,7 +37,7 @@ class PreStock extends AdminBaseController
$result = (new IPOService())->stockIPO($market_type,$this->request->param());
return json($result);
}
public function note(){
public function fote(){
$service = new IPOService();
$market_type=intval($this->request->param('market_type'));
$result = $service->repeatNoteGo($market_type,$this->request->param());

3
app/admin/service/AgentService.php

@ -24,8 +24,7 @@ class AgentService extends AdminBaseService
try {
// $agentUserId = env('AGENT.AGENT_GROUP_ID');
// $agentAdminUserIds = AuthGroupAccessModel::where('group_id', $agentUserId)->column('uid');
$roleId = 10;
$agentAdminUser = AdminModel::where('role_id', 'in', $roleId)->field('id,user_name,nick_name,email,mobile,status,invite_code')->select();
$agentAdminUser = AdminModel::where('role_id', 'in', AdminModel::ROLE_ID_AGENT)->field('id,user_name,nick_name,email,mobile,status,invite_code')->select();
$rows = [];
if (!$agentAdminUser->isEmpty()) {
foreach ($agentAdminUser as $item) {

79
app/admin/service/UserService.php

@ -11,6 +11,7 @@ use app\model\AwsS3Model;
use app\model\CountryModel;
use app\model\StockMarketModel;
use app\model\UserBankModel;
use app\model\UserChatGroupModel;
use app\model\UserChatLinkModel;
use app\model\UserContractModel;
use app\model\UserContractSecModel;
@ -38,6 +39,7 @@ use app\model\UserStockFundModel;
use think\exception\ValidateException;
use app\utility\UnqId;
use think\facade\Cache;
use think\facade\Log;
class UserService extends AdminBaseService
{
@ -756,22 +758,81 @@ class UserService extends AdminBaseService
if ($emailExists) {
return $this->toData('100300', 'The email has already been registered.', []);
}
// 获取代理id
$isAgent = AdminModel::checkUserIsAgent($adminId);
if ($isAgent) {
$agentId = $adminId;
} else { // 指定一个默认代理
$getAgent = AdminModel::where(['role_id'=>AdminModel::ROLE_ID_AGENT])->find();
if (empty($getAgent)) {
return $this->toData('500', '系统缺少代理账号');
}
$agentId = $getAgent->id;
}
// 查询代理下的一个客服
$getCustomer = AdminModel::where(['parent_id'=>$agentId])->find();
if (empty($getCustomer)) {
return $this->toData('500', '代理下缺少客服账号', ['agent_id'=>$agentId]);
}
$customerId = $getCustomer->id;
// 查询客服的chat信息
$customerChatInfo = UserChatLinkModel::where(['user_id'=>$customerId, 'user_type'=>UserChatLinkModel::USER_CHAT_LINK_USER_TYPE_ADMIN])->find(); //查询客服的聊天账号uuid
if (empty($customerChatInfo)) {
return $this->toData('500', '客服账号缺少chat信息');
}
// 查询代理创建的chat群聊信息
$agentGroup = UserChatGroupModel::where(['user_id'=>$agentId,'remark'=>UserChatGroupModel::USER_CHAT_GROUP_REMARK_ADMIN_INIT])->find();
if (empty($agentGroup)) {
return $this->toData('500', '当前代理还未创建chat群聊');
}
// 入库
// 生成userNo
$userNo = (new BaseHomeService())->getUniqUserNo();
// 请求聊天服务,注册聊天账号
$chatData = [
'Username' => $userNo,
'Password' => '123456',
'Nickname' => 'user_'.explode('@', $param['email'])[0],
'Email' => $param['email'],
];
$chatUrl = env('CHAT_SERVER.BASE_URL') . '/api/user/register';
$chatRes = (new \app\utility\RequestChatServer())->ReqChatServer($chatUrl, $chatData);
if (!isset($chatRes['data']['uuid'])) {
return $this->toData('100400', '注册聊天账号失败,请稍后再试');
}
// 創建用戶
$salt = env('ENCRYPT.SALT');
$password = (new UnqId())->encryptPassword($param['password'], $salt);
$userInviteCode = (new BaseHomeService())->getUniqInviteCode();
$parentUserId = 0;
$ip = (new BaseHomeService())->getClientRealIp();
$userId = UserModel::emailRegister($param['email'], $userNo, $userInviteCode, $parentUserId, $password, $ip, $salt, $param['is_test_user'] ?? 1, 0);
// 判断是否是代理
$isAgent = AdminModel::checkUserIsAgent($adminId);
if ($isAgent) {
UserModel::where('user_id', $userId)->update([
'agent_id' => $adminId
]);
}
$userId = UserModel::emailRegister($param['email'], $userNo, $userInviteCode, $parentUserId, $password, $ip, $salt, $param['is_test_user'] ?? 1, $agentId, $customerId);
// 关联用户与聊天账号
UserChatLinkModel::create([
'user_id' => $userId,
'user_type' => 1,
'chat_uuid' => $chatRes['data']['uuid'],
'chat_name' => $chatRes['data']['username']
]);
// 将当前账号与客服账号的chat_id加为好友
$chatFriendsData = [
'UserUuid' => $chatRes['data']['uuid'],
'CustomerUuid' => $customerChatInfo->chat_uuid,
];
$chatFriendsUrl = env('CHAT_SERVER.BASE_URL') . '/api/eachOtherFriends';
$chatFriendsRes = (new \app\utility\RequestChatServer())->ReqChatServer($chatFriendsUrl, $chatFriendsData);
Log::info("admin创建用户 - 用户与客服chat_id加好友结果:".json_encode($chatFriendsRes));
// 将当前用户加入到代理创建的群聊中
$joinChatGroupUrl = env('CHAT_SERVER.BASE_URL') . '/api/group/join/'.$chatRes['data']['uuid'].'/'.$agentGroup->group_uuid;
$joinChatGroupRes = (new \app\utility\RequestChatServer())->ReqChatServer($joinChatGroupUrl, []);
Log::info("admin创建用户 - 用户的chat_id加入群聊结果:".json_encode($joinChatGroupRes));
(new \app\home\service\UserService())->doRegInitUserInfo($userId, $parentUserId);
return $this->toData('0', 'SUCCESS');
} catch (ValidateException $validateException) {

6
app/admin/service/auth/AuthRuleService.php

@ -79,7 +79,7 @@ class AuthRuleService extends AdminBaseService
//获取用户权限id
$user=AdminModel::find($user_id);
//查询拥有权限
if($user->role_id=='7'){
if($user->role_id == AdminModel::ROLE_ID_ADMIN){
//超级管理员拥有全部权限
$list=$authRule::order('sort', 'asc')->select()->toArray();
}else{
@ -104,7 +104,7 @@ class AuthRuleService extends AdminBaseService
$user=AdminModel::find($user_id);
//查询拥有权限
if($user->role_id=='7'){
if($user->role_id == AdminModel::ROLE_ID_ADMIN){
//超级管理员拥有全部权限
$list=AuthRuleModel::order('sort', 'asc')->select()->toArray();
}else{
@ -151,7 +151,7 @@ class AuthRuleService extends AdminBaseService
$user=AdminModel::find($user_id);
$role=AuthRoleModel::find($user->role_id);
//查询拥有权限
if($user->role_id=='7'){
if($user->role_id == AdminModel::ROLE_ID_ADMIN){
//超级管理员拥有全部权限
$authRule=AuthRuleModel::order('sort', 'asc')->select()->toArray();
}else{

5
app/admin/service/setting/IPOService.php

@ -635,7 +635,10 @@ class IPOService extends AdminBaseService
}
// 未签名 上市
if ($preInStock['open_status'] != 1 || strtotime($preInStock['get_time']) < date('Y-m-d H:i:s')) {
// if ($preInStock['open_status'] != 1 || strtotime($preInStock['get_time']) < date('Y-m-d H:i:s')) {
// return $this->toData('1', '无法操作');
// }
if ($preInStock['open_status'] != 1) {
return $this->toData('1', '无法操作');
}

5
app/model/AdminModel.php

@ -10,6 +10,8 @@ class AdminModel extends BaseModel
const STATUS_ON = 1; // 用户启用状态
const STATUS_FORBID = 2; // 用户禁用状态
const ROLE_ID_ADMIN = 1; //超级管理员角色
const ROLE_ID_AGENT = 2; // 代理角色
// 通过代理id 获取代理下面可以访问的所有用户id
public static function getUserIdsByAgentId($agentId)
{
@ -29,9 +31,8 @@ class AdminModel extends BaseModel
public static function checkUserIsAgent($adminId)
{
// 代理角色
$roleId = 10;
$admin = self::where('id', $adminId)->find();
if($admin && $admin['role_id'] == $roleId){
if($admin && $admin['role_id'] == self::ROLE_ID_AGENT){
return true;
}

Loading…
Cancel
Save