|
@ -3,10 +3,19 @@ |
|
|
namespace app\admin\service; |
|
|
namespace app\admin\service; |
|
|
|
|
|
|
|
|
use app\model\AdminModel; |
|
|
use app\model\AdminModel; |
|
|
|
|
|
use app\model\AgentChannelListModel; |
|
|
use app\model\AuthGroupAccessModel; |
|
|
use app\model\AuthGroupAccessModel; |
|
|
|
|
|
use app\model\AuthRoleModel; |
|
|
use app\model\AwsIvsModel; |
|
|
use app\model\AwsIvsModel; |
|
|
use app\model\CustomerRelationalModel; |
|
|
use app\model\CustomerRelationalModel; |
|
|
|
|
|
use app\model\ForexTradeModel; |
|
|
|
|
|
use app\model\PurchaseVipModel; |
|
|
|
|
|
use app\model\RechargeApplyModel; |
|
|
|
|
|
use app\model\StockJpTradeModel; |
|
|
|
|
|
use app\model\StockTradeModel; |
|
|
|
|
|
use app\model\UserChatLinkModel; |
|
|
use app\model\UserModel; |
|
|
use app\model\UserModel; |
|
|
|
|
|
use app\model\UserWithdrawalModel; |
|
|
|
|
|
|
|
|
class AgentService extends AdminBaseService |
|
|
class AgentService extends AdminBaseService |
|
|
{ |
|
|
{ |
|
@ -72,27 +81,27 @@ class AgentService extends AdminBaseService |
|
|
{ |
|
|
{ |
|
|
try { |
|
|
try { |
|
|
if (empty($param['id']) || !is_numeric($param['id'])) { |
|
|
if (empty($param['id']) || !is_numeric($param['id'])) { |
|
|
return $this->toData('1', '参错错误', ['list' => []]); |
|
|
return $this->toData('400', '参错错误', ['list' => []]); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (empty($param['agent_id']) || !is_numeric($param['agent_id'])) { |
|
|
if (empty($param['agent_id']) || !is_numeric($param['agent_id'])) { |
|
|
return $this->toData('1', '参错错误', ['list' => []]); |
|
|
return $this->toData('400', '参错错误', ['list' => []]); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
$user = UserModel::where('user_id', $param['id'])->find(); |
|
|
$user = UserModel::where('user_id', $param['id'])->find(); |
|
|
if (empty($user)) { |
|
|
if (empty($user)) { |
|
|
return $this->toData('1', '用户不存在', ['list' => []]); |
|
|
return $this->toData('500', '用户不存在', ['list' => []]); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if ($user['parent_id'] != 0) { |
|
|
if ($user['parent_id'] != 0) { |
|
|
return $this->toData('1', '只能绑定顶层用户', ['list' => []]); |
|
|
return $this->toData('500', '只能绑定顶层用户', ['list' => []]); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 判断代理是否有效 |
|
|
// 判断代理是否有效 |
|
|
$admin = AdminModel::where('id', $param['agent_id'])->find(); |
|
|
$admin = AdminModel::where('id', $param['agent_id'])->find(); |
|
|
$roleId = 10; |
|
|
$roleId = 10; |
|
|
if (empty($admin) || $admin['role_id'] != $roleId) { |
|
|
if (empty($admin) || $admin['role_id'] != $roleId) { |
|
|
return $this->toData('1', '代理不存在', ['list' => []]); |
|
|
return $this->toData('500', '代理不存在', ['list' => []]); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// $agentUserId = env('AGENT.AGENT_GROUP_ID'); |
|
|
// $agentUserId = env('AGENT.AGENT_GROUP_ID'); |
|
@ -104,13 +113,13 @@ class AgentService extends AdminBaseService |
|
|
// 未绑定 直接绑定 |
|
|
// 未绑定 直接绑定 |
|
|
if ($user->agent_id == 0) { |
|
|
if ($user->agent_id == 0) { |
|
|
UserModel::update(['agent_id' => $param['agent_id']], ['user_id' => $param['id']]); |
|
|
UserModel::update(['agent_id' => $param['agent_id']], ['user_id' => $param['id']]); |
|
|
return $this->toData('0', 'SUCCESS', []); |
|
|
return $this->toData('0', 'success'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 取消绑定 |
|
|
// 取消绑定 |
|
|
if ($user->agent_id == $param['agent_id']) { |
|
|
if ($user->agent_id == $param['agent_id']) { |
|
|
UserModel::update(['agent_id' => 0], ['user_id' => $param['id']]); |
|
|
UserModel::update(['agent_id' => 0], ['user_id' => $param['id']]); |
|
|
return $this->toData('0', 'SUCCESS', []); |
|
|
return $this->toData('0', 'success'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return $this->toData('1', '该用户已被其他代理绑定, 请先取消绑定', []); |
|
|
return $this->toData('1', '该用户已被其他代理绑定, 请先取消绑定', []); |
|
@ -124,33 +133,33 @@ class AgentService extends AdminBaseService |
|
|
{ |
|
|
{ |
|
|
try { |
|
|
try { |
|
|
if (empty($param['agent_id']) || !is_numeric($param['agent_id'])) { |
|
|
if (empty($param['agent_id']) || !is_numeric($param['agent_id'])) { |
|
|
return $this->toData('1', '参错错误'); |
|
|
return $this->toData('400', '参错错误'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (empty($param['user_id']) || !is_numeric($param['user_id'])) { |
|
|
if (empty($param['user_id']) || !is_numeric($param['user_id'])) { |
|
|
return $this->toData('1', '参错错误'); |
|
|
return $this->toData('400', '参错错误'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
$user = UserModel::where('user_id', $param['user_id'])->find(); |
|
|
$user = UserModel::where('user_id', $param['user_id'])->find(); |
|
|
if (empty($user)) { |
|
|
if (empty($user)) { |
|
|
return $this->toData('1', '用户不存在'); |
|
|
return $this->toData('400', '用户不存在'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if ($user['parent_id'] != 0) { |
|
|
if ($user['parent_id'] != 0) { |
|
|
return $this->toData('1', '只能绑定顶层用户'); |
|
|
return $this->toData('400', '只能绑定顶层用户'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 判断代理是否有效 |
|
|
// 判断代理是否有效 |
|
|
$admin = AdminModel::where('id', $param['agent_id'])->find(); |
|
|
$admin = AdminModel::where('id', $param['agent_id'])->find(); |
|
|
$roleId = 10; |
|
|
$roleId = 10; |
|
|
if (empty($admin) || $admin['role_id'] != $roleId) { |
|
|
if (empty($admin) || $admin['role_id'] != $roleId) { |
|
|
return $this->toData('1', '代理不存在'); |
|
|
return $this->toData('500', '代理不存在'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
UserModel::update(['agent_id' => $param['agent_id']], ['user_id' => $param['user_id']]); |
|
|
UserModel::update(['agent_id' => $param['agent_id']], ['user_id' => $param['user_id']]); |
|
|
return $this->toData('0', 'SUCCESS', []); |
|
|
return $this->toData('0', 'success'); |
|
|
} catch (\Exception $exception) { |
|
|
} catch (\Exception $exception) { |
|
|
return $this->toData('1', '系统异常 请稍后重试', [$exception->getMessage(), $exception->getTrace()]); |
|
|
return $this->toData('500', '系统异常 请稍后重试', [$exception->getMessage(), $exception->getTrace()]); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -158,12 +167,20 @@ class AgentService extends AdminBaseService |
|
|
{ |
|
|
{ |
|
|
try { |
|
|
try { |
|
|
if (empty($param['page']) || !is_numeric($param['page'])) { |
|
|
if (empty($param['page']) || !is_numeric($param['page'])) { |
|
|
return $this->toData('1', '参错错误'); |
|
|
return $this->toData('400', '参错错误'); |
|
|
|
|
|
} |
|
|
|
|
|
if (empty($param['limit']) || !is_numeric($param['limit'])) { |
|
|
|
|
|
return $this->toData('400', '参错错误'); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 查询客服角色的ID |
|
|
|
|
|
$customerRole = AuthRoleModel::where(['name'=>AuthRoleModel::NAME_CUSTOMER])->find(); |
|
|
|
|
|
if (empty($customerRole)) { |
|
|
|
|
|
return $this->toData('500', '系统中还没有客服角色'); |
|
|
} |
|
|
} |
|
|
|
|
|
$roleId = $customerRole->id; |
|
|
|
|
|
|
|
|
// 角色ID |
|
|
// 如有指定代理ID, 则查询代理ID下的客服列表,否则查询所有代理下的客服列表 |
|
|
$roleId = 11; |
|
|
|
|
|
// 代理ID |
|
|
|
|
|
$agentId = 0; |
|
|
$agentId = 0; |
|
|
if (isset($param['agent_id']) && is_numeric($param['agent_id'])) { |
|
|
if (isset($param['agent_id']) && is_numeric($param['agent_id'])) { |
|
|
$agentId = $param['agent_id']; |
|
|
$agentId = $param['agent_id']; |
|
@ -173,11 +190,11 @@ class AgentService extends AdminBaseService |
|
|
}, function ($query) use($roleId) { |
|
|
}, function ($query) use($roleId) { |
|
|
$query->where('role_id', $roleId)->order('id', 'desc'); //查询所有客服列表 |
|
|
$query->where('role_id', $roleId)->order('id', 'desc'); //查询所有客服列表 |
|
|
})->paginate([ |
|
|
})->paginate([ |
|
|
'list_rows' => 15, // 每页显示 10 条 |
|
|
'list_rows' => $param['limit'], |
|
|
'page' => $param['page'], // 使用前端传递的页码 |
|
|
'page' => $param['page'], |
|
|
]); |
|
|
]); |
|
|
|
|
|
|
|
|
return $this->toData('0', 'SUCCESS', [ |
|
|
return $this->toData('0', 'success', [ |
|
|
'list' => $list->items(), // 当前页的数据 |
|
|
'list' => $list->items(), // 当前页的数据 |
|
|
'page' => $list->currentPage(), // 当前页码 |
|
|
'page' => $list->currentPage(), // 当前页码 |
|
|
'total' => $list->total(), // 总记录数 |
|
|
'total' => $list->total(), // 总记录数 |
|
@ -185,22 +202,22 @@ class AgentService extends AdminBaseService |
|
|
'agent_id' => $agentId, |
|
|
'agent_id' => $agentId, |
|
|
]); |
|
|
]); |
|
|
} catch (\Exception $exception) { |
|
|
} catch (\Exception $exception) { |
|
|
return $this->toData('1', '系统异常 请稍后重试', [$exception->getMessage(), $exception->getTrace()]); |
|
|
return $this->toData('500', '系统异常 请稍后重试', [$exception->getMessage(), $exception->getTrace()]); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function customerUser($param) |
|
|
public function customerUserList($param) |
|
|
{ |
|
|
{ |
|
|
try { |
|
|
try { |
|
|
if (empty($param['customer_id']) || !is_numeric($param['customer_id'])) { |
|
|
if (empty($param['customer_id']) || !is_numeric($param['customer_id'])) { |
|
|
return $this->toData('1', '参错错误'); |
|
|
return $this->toData('400', '参错错误'); |
|
|
} |
|
|
} |
|
|
if (empty($param['page']) || !is_numeric($param['page'])) { |
|
|
if (empty($param['page']) || !is_numeric($param['page'])) { |
|
|
return $this->toData('1', '参错错误'); |
|
|
return $this->toData('400', '参错错误'); |
|
|
} |
|
|
} |
|
|
// 查询当前客服下的用户 |
|
|
// 查询当前客服下的用户 |
|
|
$list = CustomerRelationalModel::where('customer_id', $param['customer_id'])->order('id', 'desc')->paginate([ |
|
|
$list = CustomerRelationalModel::where('customer_id', $param['customer_id'])->order('id', 'desc')->paginate([ |
|
|
'list_rows' => $param['limit'] ?? 15, |
|
|
'list_rows' => $param['limit'], |
|
|
'page' => $param['page'], // 使用前端传递的页码 |
|
|
'page' => $param['page'], // 使用前端传递的页码 |
|
|
]); |
|
|
]); |
|
|
$userIds = array_column($list->items(), 'user_id'); // 获取当前页的用户id |
|
|
$userIds = array_column($list->items(), 'user_id'); // 获取当前页的用户id |
|
@ -210,7 +227,7 @@ class AgentService extends AdminBaseService |
|
|
$userDetails = UserModel::whereIn('user_id', $userIds)->select()->toArray(); |
|
|
$userDetails = UserModel::whereIn('user_id', $userIds)->select()->toArray(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return $this->toData('0', 'SUCCESS', [ |
|
|
return $this->toData('0', 'success', [ |
|
|
'list' => $list->items(), // 当前页的数据 |
|
|
'list' => $list->items(), // 当前页的数据 |
|
|
'user_details' => $userDetails, |
|
|
'user_details' => $userDetails, |
|
|
'page' => $list->currentPage(), // 当前页码 |
|
|
'page' => $list->currentPage(), // 当前页码 |
|
@ -218,7 +235,51 @@ class AgentService extends AdminBaseService |
|
|
'last_page' => $list->lastPage(), // 最后一页页码 |
|
|
'last_page' => $list->lastPage(), // 最后一页页码 |
|
|
]); |
|
|
]); |
|
|
} catch (\Exception $exception) { |
|
|
} catch (\Exception $exception) { |
|
|
return $this->toData('1', '系统异常 请稍后重试', [$exception->getMessage(), $exception->getTrace()]); |
|
|
return $this->toData('500', '系统异常 请稍后重试', [$exception->getMessage(), $exception->getTrace()]); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function changeUserCustomer($param) |
|
|
|
|
|
{ |
|
|
|
|
|
try { |
|
|
|
|
|
if (empty($param['user_id']) || empty($param['old_customer_id']) || empty($param['new_customer_id'])) { |
|
|
|
|
|
return $this->toData('400', '参数错误'); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$cstRlt = CustomerRelationalModel::where(['user_id'=>$param['user_id'], 'customer_id'=>$param['old_customer_id']])->find(); |
|
|
|
|
|
if (empty($cstRlt)) { |
|
|
|
|
|
return $this->toData('500', '操作的数据不存在'); |
|
|
|
|
|
} |
|
|
|
|
|
// 变更的客服必须是同一个代理 |
|
|
|
|
|
$newCustomer = AdminModel::where(['id'=>$param['new_customer_id']])->find(); |
|
|
|
|
|
if (empty($newCustomer)) { |
|
|
|
|
|
return $this->toData('500', '要变更的客服不存在'); |
|
|
|
|
|
} |
|
|
|
|
|
if ($newCustomer->parent_id != $cstRlt->agent_id) { |
|
|
|
|
|
return $this->toData('500', '新客服不属于同一个代理'); |
|
|
|
|
|
} |
|
|
|
|
|
// 变更客服绑定关系 |
|
|
|
|
|
$cstRlt->customer_id = $param['new_customer_id']; |
|
|
|
|
|
$cstRlt->save(); |
|
|
|
|
|
|
|
|
|
|
|
// 将用户与新客服的聊天账号加好友 |
|
|
|
|
|
$userChatInfo = UserChatLinkModel::where(['user_id'=>$param['user_id'], 'user_type'=>UserChatLinkModel::USER_CHAT_LINK_USER_TYPE_PC])->find(); |
|
|
|
|
|
if (empty($userChatInfo)) { |
|
|
|
|
|
return $this->toData('500', '用户的聊天数据错误'); |
|
|
|
|
|
} |
|
|
|
|
|
$customerChatInfo = UserChatLinkModel::where(['user_id'=>$param['new_customer_id'], 'user_type'=>UserChatLinkModel::USER_CHAT_LINK_USER_TYPE_ADMIN])->find(); |
|
|
|
|
|
if (empty($customerChatInfo)) { |
|
|
|
|
|
return $this->toData('500', '客服的聊天数据错误'); |
|
|
|
|
|
} |
|
|
|
|
|
$chatFriendsData = [ |
|
|
|
|
|
'UserUuid' => $userChatInfo->chat_uuid, |
|
|
|
|
|
'CustomerUuid' => $customerChatInfo->chat_uuid, |
|
|
|
|
|
]; |
|
|
|
|
|
$chatFriendsUrl = env('CHAT_SERVER.BASE_URL') . '/api/eachOtherFriends'; |
|
|
|
|
|
$chatFriendsRes = (new \app\utility\RequestChatServer())->ReqChatServer($chatFriendsUrl, $chatFriendsData); |
|
|
|
|
|
return $this->toData('0', 'success', $chatFriendsRes); |
|
|
|
|
|
} catch (\Exception $exception) { |
|
|
|
|
|
return $this->toData('500', '系统异常 请稍后重试', [$exception->getMessage(), $exception->getTrace()]); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -226,29 +287,32 @@ class AgentService extends AdminBaseService |
|
|
{ |
|
|
{ |
|
|
try { |
|
|
try { |
|
|
if (empty($param['page']) || !is_numeric($param['page'])) { |
|
|
if (empty($param['page']) || !is_numeric($param['page'])) { |
|
|
return $this->toData('1', '参错错误'); |
|
|
return $this->toData('400', '参错错误'); |
|
|
|
|
|
} |
|
|
|
|
|
if (empty($param['limit']) || !is_numeric($param['limit'])) { |
|
|
|
|
|
return $this->toData('400', '参错错误'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (isset($param['title'])) { |
|
|
if (isset($param['title'])) { |
|
|
$list = AwsIvsModel::where('title', $param['title'])->order('id', 'desc')->paginate([ |
|
|
$list = AwsIvsModel::where('title', $param['title'])->order('id', 'desc')->paginate([ |
|
|
'list_rows' => 15, |
|
|
'list_rows' => $param['limit'], |
|
|
'page' => $param['page'], |
|
|
'page' => $param['page'], |
|
|
]); |
|
|
]); |
|
|
} else { |
|
|
} else { |
|
|
$list = AwsIvsModel::order('id', 'desc')->paginate([ |
|
|
$list = AwsIvsModel::order('id', 'desc')->paginate([ |
|
|
'list_rows' => 15, |
|
|
'list_rows' => $param['limit'], |
|
|
'page' => $param['page'], |
|
|
'page' => $param['page'], |
|
|
]); |
|
|
]); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return $this->toData('0', 'SUCCESS', [ |
|
|
return $this->toData('0', 'success', [ |
|
|
'list' => $list->items(), // 当前页的数据 |
|
|
'list' => $list->items(), // 当前页的数据 |
|
|
'page' => $list->currentPage(), // 当前页码 |
|
|
'page' => $list->currentPage(), // 当前页码 |
|
|
'total' => $list->total(), // 总记录数 |
|
|
'total' => $list->total(), // 总记录数 |
|
|
'last_page' => $list->lastPage(), // 最后一页页码 |
|
|
'last_page' => $list->lastPage(), // 最后一页页码 |
|
|
]); |
|
|
]); |
|
|
} catch (\Exception $exception) { |
|
|
} catch (\Exception $exception) { |
|
|
return $this->toData('1', '系统异常 请稍后重试', [$exception->getMessage(), $exception->getTrace()]); |
|
|
return $this->toData('500', '系统异常 请稍后重试', [$exception->getMessage(), $exception->getTrace()]); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -256,30 +320,30 @@ class AgentService extends AdminBaseService |
|
|
{ |
|
|
{ |
|
|
try { |
|
|
try { |
|
|
if (empty($param['title'])) { |
|
|
if (empty($param['title'])) { |
|
|
return $this->toData('1', 'Missing param title'); |
|
|
return $this->toData('400', 'Missing param title'); |
|
|
} |
|
|
} |
|
|
if (empty($param['anchor_name'])) { |
|
|
if (empty($param['anchor_name'])) { |
|
|
return $this->toData('1', 'Missing param anchor_name'); |
|
|
return $this->toData('400', 'Missing param anchor_name'); |
|
|
} |
|
|
} |
|
|
if (empty($param['desc'])) { |
|
|
if (empty($param['desc'])) { |
|
|
return $this->toData('1', 'Missing param desc'); |
|
|
return $this->toData('400', 'Missing param desc'); |
|
|
} |
|
|
} |
|
|
if (empty($param['push_url'])) { |
|
|
if (empty($param['push_url'])) { |
|
|
return $this->toData('1', 'Missing param push_url'); |
|
|
return $this->toData('400', 'Missing param push_url'); |
|
|
} |
|
|
} |
|
|
if (empty($param['secret_key'])) { |
|
|
if (empty($param['secret_key'])) { |
|
|
return $this->toData('1', 'Missing param secret_key'); |
|
|
return $this->toData('400', 'Missing param secret_key'); |
|
|
} |
|
|
} |
|
|
if (empty($param['play_url'])) { |
|
|
if (empty($param['play_url'])) { |
|
|
return $this->toData('1', 'Missing param play_url'); |
|
|
return $this->toData('400', 'Missing param play_url'); |
|
|
} |
|
|
} |
|
|
if (empty($param['agent_id'])) { |
|
|
if (empty($param['agent_id'])) { |
|
|
return $this->toData('1', 'Missing param agent_id'); |
|
|
return $this->toData('400', 'Missing param agent_id'); |
|
|
} |
|
|
} |
|
|
//判断一个代理下只能有一个推流配置 |
|
|
//判断一个代理下只能有一个推流配置 |
|
|
$ckInfo = AwsIvsModel::where('agent_id', $param['agent_id'])->find(); |
|
|
$ckInfo = AwsIvsModel::where('agent_id', $param['agent_id'])->find(); |
|
|
if ($ckInfo) { |
|
|
if ($ckInfo) { |
|
|
return $this->toData('1', '一个代理下只能配置一个推流信息'); |
|
|
return $this->toData('500', '一个代理下只能配置一个推流信息'); |
|
|
} |
|
|
} |
|
|
//保存推流配置 |
|
|
//保存推流配置 |
|
|
$res = AwsIvsModel::create([ |
|
|
$res = AwsIvsModel::create([ |
|
@ -292,9 +356,9 @@ class AgentService extends AdminBaseService |
|
|
'play_url' => $param['play_url'], |
|
|
'play_url' => $param['play_url'], |
|
|
'agent_id' => $param['agent_id'] |
|
|
'agent_id' => $param['agent_id'] |
|
|
]); |
|
|
]); |
|
|
return $this->toData('0', 'SUCCESS', ['id' => $res->id]); |
|
|
return $this->toData('0', 'success', ['id' => $res->id]); |
|
|
} catch (\Exception $exception) { |
|
|
} catch (\Exception $exception) { |
|
|
return $this->toData('1', '系统异常 请稍后重试', [$exception->getMessage(), $exception->getTrace()]); |
|
|
return $this->toData('500', '系统异常 请稍后重试', [$exception->getMessage(), $exception->getTrace()]); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -302,15 +366,15 @@ class AgentService extends AdminBaseService |
|
|
{ |
|
|
{ |
|
|
try { |
|
|
try { |
|
|
if (empty($param['id'])) { |
|
|
if (empty($param['id'])) { |
|
|
return $this->toData('1', 'Missing param id'); |
|
|
return $this->toData('400', 'Missing param id'); |
|
|
} |
|
|
} |
|
|
if (empty($param['title']) || empty($param['anchor_name']) || empty($param['desc']) || empty($param['push_url']) || empty($param['secret_key']) || empty($param['play_url']) || empty($param['agent_id'])) { |
|
|
if (empty($param['title']) || empty($param['anchor_name']) || empty($param['desc']) || empty($param['push_url']) || empty($param['secret_key']) || empty($param['play_url']) || empty($param['agent_id'])) { |
|
|
return $this->toData('1', 'Parameter error'); |
|
|
return $this->toData('400', 'Parameter error'); |
|
|
} |
|
|
} |
|
|
// 检查是否存在数据 |
|
|
// 检查是否存在数据 |
|
|
$ckInfo = AwsIvsModel::where('id', $param['id'])->find(); |
|
|
$ckInfo = AwsIvsModel::where('id', $param['id'])->find(); |
|
|
if (empty($ckInfo)) { |
|
|
if (empty($ckInfo)) { |
|
|
return $this->toData('1', '编辑的数据不存在'); |
|
|
return $this->toData('500', '编辑的数据不存在'); |
|
|
} |
|
|
} |
|
|
$ckInfo->title = $param['title']; |
|
|
$ckInfo->title = $param['title']; |
|
|
$ckInfo->anchor_name = $param['anchor_name']; |
|
|
$ckInfo->anchor_name = $param['anchor_name']; |
|
@ -320,9 +384,166 @@ class AgentService extends AdminBaseService |
|
|
$ckInfo->secret_key = $param['secret_key']; |
|
|
$ckInfo->secret_key = $param['secret_key']; |
|
|
$ckInfo->play_url = $param['play_url']; |
|
|
$ckInfo->play_url = $param['play_url']; |
|
|
$ckInfo->save(); |
|
|
$ckInfo->save(); |
|
|
return $this->toData('1', 'Successful'); |
|
|
return $this->toData('0', 'success'); |
|
|
} catch (\Exception $exception) { |
|
|
} catch (\Exception $exception) { |
|
|
return $this->toData('1', '系统异常 请稍后重试', [$exception->getMessage(), $exception->getTrace()]); |
|
|
return $this->toData('500', '系统异常 请稍后重试', [$exception->getMessage(), $exception->getTrace()]); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 代理下每个渠道的用户注册列表 |
|
|
|
|
|
public function userListByChannel($param) |
|
|
|
|
|
{ |
|
|
|
|
|
try { |
|
|
|
|
|
if (empty($param['agent_channel_id']) || empty($param['page']) || empty($param['limit'])) { |
|
|
|
|
|
return $this->toData('400', '参数错误'); |
|
|
} |
|
|
} |
|
|
|
|
|
// 检测是否存在目标代理渠道 |
|
|
|
|
|
$agentChannel = AgentChannelListModel::where(['id'=>$param['agent_channel_id']])->find(); |
|
|
|
|
|
if (empty($agentChannel)) { |
|
|
|
|
|
return $this->toData('500', '代理渠道数据为空'); |
|
|
} |
|
|
} |
|
|
|
|
|
// 查询该代理渠道下的用户数据 |
|
|
|
|
|
$list = UserModel::where(['ch_code'=>$agentChannel->ch_code])->order('user_id', 'desc')->paginate([ |
|
|
|
|
|
'list_rows' => $param['limit'], |
|
|
|
|
|
'page' => $param['page'], |
|
|
|
|
|
]); |
|
|
|
|
|
if (empty($list->items())) { |
|
|
|
|
|
return $this->toData('0', 'success', [ |
|
|
|
|
|
'list' => $list->items(), // 当前页的数据 |
|
|
|
|
|
'page' => $list->currentPage(), // 当前页码 |
|
|
|
|
|
'total' => $list->total(), // 总记录数 |
|
|
|
|
|
'last_page' => $list->lastPage(), // 最后一页页码 |
|
|
|
|
|
]); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 获取所有用户ID |
|
|
|
|
|
$userIdArr = array_column($list->items(), 'user_id'); |
|
|
|
|
|
// 获取用户是否会员VIP |
|
|
|
|
|
$userVipList = PurchaseVipModel::where('user_id', 'in', $userIdArr)->column('expire,created_at', 'user_id'); |
|
|
|
|
|
|
|
|
|
|
|
$resArr = []; |
|
|
|
|
|
foreach ($list->items() as $v) { |
|
|
|
|
|
$resArr[] = [ |
|
|
|
|
|
'user_id' => $v['user_id'], |
|
|
|
|
|
'user_no' => $v['user_no'], |
|
|
|
|
|
'nick_name' => $v['nick_name'], |
|
|
|
|
|
'email' => $v['email'], |
|
|
|
|
|
'phone_number' => $v['phone_number'], |
|
|
|
|
|
'parent_id' => $v['parent_id'], |
|
|
|
|
|
'origin_user_id' => $v['origin_user_id'], |
|
|
|
|
|
'agent_id' => $v['agent_id'], |
|
|
|
|
|
'is_real' => $v['is_real'], |
|
|
|
|
|
'real_status' => $v['real_status'], |
|
|
|
|
|
'head_img_id' => $v['head_img_id'], |
|
|
|
|
|
'last_login_time' => $v['last_login_time'], |
|
|
|
|
|
'customer_remark' => $v['customer_remark'], |
|
|
|
|
|
'label' => $v['label'], |
|
|
|
|
|
'ch_code' => $v['ch_code'], |
|
|
|
|
|
'create_time' => $v['create_time'], |
|
|
|
|
|
'is_vip' => isset($userVipList[$v['user_id']]) ?? '', |
|
|
|
|
|
'vip_expire' => $userVipList[$v['user_id']]['expire'] ?? '', |
|
|
|
|
|
'vip_created' => $userVipList[$v['user_id']]['created_at'] ?? '', |
|
|
|
|
|
]; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $this->toData('0', 'success', [ |
|
|
|
|
|
'list' => $resArr, |
|
|
|
|
|
'page' => $list->currentPage(), // 当前页码 |
|
|
|
|
|
'total' => $list->total(), // 总记录数 |
|
|
|
|
|
'last_page' => $list->lastPage(), // 最后一页页码 |
|
|
|
|
|
]); |
|
|
|
|
|
} catch (\Exception $exception) { |
|
|
|
|
|
return $this->toData('500', '系统异常 请稍后重试', [$exception->getMessage(), $exception->getTrace()]); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 按天统计每个渠道下的数据 |
|
|
|
|
|
public function statsByChannel($param) |
|
|
|
|
|
{ |
|
|
|
|
|
try { |
|
|
|
|
|
if (empty($param['ch_code'])) { |
|
|
|
|
|
return $this->toData('400', '参数错误'); |
|
|
|
|
|
} |
|
|
|
|
|
if (empty($param['day'])) { |
|
|
|
|
|
return $this->toData('400', '参数错误'); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 注册数 |
|
|
|
|
|
$userStats = UserModel::whereDay('create_time', $param['day'])->where(['ch_code'=>$param['ch_code']])->select()->toArray(); |
|
|
|
|
|
$regCount = count($userStats); |
|
|
|
|
|
$userIds = array_column($userStats, 'user_id'); |
|
|
|
|
|
if (empty($userIds)) { |
|
|
|
|
|
return $this->toData('0', 'success', [ |
|
|
|
|
|
'reg_count' => $regCount, |
|
|
|
|
|
'recharge_count' => 0, |
|
|
|
|
|
'recharge_amount' => 0, |
|
|
|
|
|
'withdraw_count' => 0, |
|
|
|
|
|
'withdraw_amount' => 0, |
|
|
|
|
|
'stock_count' => 0, //美股交易笔数 |
|
|
|
|
|
'stock_in_amount' => 0, //美股交易买入总金额 |
|
|
|
|
|
'stock_out_amount' => 0, //美股交易卖出总金额 |
|
|
|
|
|
'stock_diff_amount' => 0, //美股买入与卖出差 |
|
|
|
|
|
'stock_jp_count' => 0, //日股 |
|
|
|
|
|
'stock_jp_in_amount' => 0, |
|
|
|
|
|
'stock_jp_out_amount' => 0, |
|
|
|
|
|
'stock_jp_diff_amount' => 0, |
|
|
|
|
|
'stock_forex_count' => 0, // 大宗外汇 |
|
|
|
|
|
'stock_forex_in_amount' => 0, |
|
|
|
|
|
'stock_forex_out_amount' => 0, |
|
|
|
|
|
'stock_forex_diff_amount' => 0, |
|
|
|
|
|
]); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 充值数 - 充值笔数、充值金额、 |
|
|
|
|
|
$rechargeCount = RechargeApplyModel::whereDay('create_time', $param['day'])->whereIn('user_id', $userIds)->count(); |
|
|
|
|
|
$rechargeAmount = RechargeApplyModel::whereDay('create_time', $param['day'])->whereIn('user_id', $userIds)->sum('recharge_num'); |
|
|
|
|
|
|
|
|
|
|
|
// 提款数 - 提现笔数、提现金额 |
|
|
|
|
|
$withdrawCount = UserWithdrawalModel::whereDay('create_time', $param['day'])->whereIn('user_id', $userIds)->count(); |
|
|
|
|
|
$withdrawAmount = UserWithdrawalModel::whereDay('create_time', $param['day'])->whereIn('user_id', $userIds)->sum('apply_num'); |
|
|
|
|
|
|
|
|
|
|
|
// 美股交易数 - 交易笔数、交易总盈亏 |
|
|
|
|
|
$stockCount = StockTradeModel::whereDay('create_time', $param['day'])->whereIn('user_id', $userIds)->count(); |
|
|
|
|
|
$stockInAmount = StockTradeModel::whereDay('create_time', $param['day'])->whereIn('user_id', $userIds)->where('trade_type', 1)->sum('order_money'); // 买入总金额 |
|
|
|
|
|
$stockOutAmount = StockTradeModel::whereDay('create_time', $param['day'])->whereIn('user_id', $userIds)->where('trade_type', 2)->sum('order_money'); // 卖出总金额 |
|
|
|
|
|
$stockDiffAmount = $stockInAmount - $stockOutAmount; |
|
|
|
|
|
|
|
|
|
|
|
// 日股交易数 - 交易笔数、交易总盈亏 |
|
|
|
|
|
$stockJpCount = StockJpTradeModel::whereDay('create_time', $param['day'])->whereIn('user_id', $userIds)->count(); |
|
|
|
|
|
$stockJpInAmount = StockJpTradeModel::whereDay('create_time', $param['day'])->whereIn('user_id', $userIds)->where('trade_type', 1)->sum('order_money'); // 买入总金额 |
|
|
|
|
|
$stockJpOutAmount = StockJpTradeModel::whereDay('create_time', $param['day'])->whereIn('user_id', $userIds)->where('trade_type', 2)->sum('order_money'); // 卖出总金额 |
|
|
|
|
|
$stockJpDiffAmount = $stockJpInAmount - $stockJpOutAmount; |
|
|
|
|
|
|
|
|
|
|
|
// 大宗(外汇)交易数据 - 交易笔数、交易总金额 |
|
|
|
|
|
$stockForexCount = ForexTradeModel::whereDay('create_time', $param['day'])->whereIn('user_id', $userIds)->count(); |
|
|
|
|
|
$stockForexInAmount = ForexTradeModel::whereDay('create_time', $param['day'])->whereIn('user_id', $userIds)->where('trade_type', 1)->sum('order_money'); // 买入总金额 |
|
|
|
|
|
$stockForexOutAmount = ForexTradeModel::whereDay('create_time', $param['day'])->whereIn('user_id', $userIds)->where('trade_type', 2)->sum('order_money'); // 卖出总金额 |
|
|
|
|
|
$stockForexDiffAmount = $stockForexInAmount - $stockForexOutAmount; |
|
|
|
|
|
|
|
|
|
|
|
// 交易数 - 交易笔数、交易总数盈亏 |
|
|
|
|
|
return $this->toData('0', 'success', [ |
|
|
|
|
|
'reg_count' => $regCount, |
|
|
|
|
|
'recharge_count' => $rechargeCount, |
|
|
|
|
|
'recharge_amount' => $rechargeAmount, |
|
|
|
|
|
'withdraw_count' => $withdrawCount, |
|
|
|
|
|
'withdraw_amount' => $withdrawAmount, |
|
|
|
|
|
'stock_count' => $stockCount, //美股交易总笔数 |
|
|
|
|
|
'stock_in_amount' => $stockInAmount, //美股交易买入总金额 |
|
|
|
|
|
'stock_out_amount' => $stockOutAmount, //美股交易卖出总金额 |
|
|
|
|
|
'stock_diff_amount' => $stockDiffAmount, //美股买入与卖出差 |
|
|
|
|
|
'stock_jp_count' => $stockJpCount, //日股 |
|
|
|
|
|
'stock_jp_in_amount' => $stockJpInAmount, |
|
|
|
|
|
'stock_jp_out_amount' => $stockJpOutAmount, |
|
|
|
|
|
'stock_jp_diff_amount' => $stockJpDiffAmount, |
|
|
|
|
|
'stock_forex_count' => $stockForexCount, // 大宗外汇 |
|
|
|
|
|
'stock_forex_in_amount' => $stockForexInAmount, |
|
|
|
|
|
'stock_forex_out_amount' => $stockForexOutAmount, |
|
|
|
|
|
'stock_forex_diff_amount' => $stockForexDiffAmount, |
|
|
|
|
|
]); |
|
|
|
|
|
} catch (\Exception $exception) { |
|
|
|
|
|
return $this->toData('500', '系统异常 请稍后重试', [$exception->getMessage(), $exception->getTrace()]); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |