p2 project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

617 lines
29 KiB

5 months ago
<?php
namespace app\admin\service;
use app\model\AdminModel;
4 months ago
use app\model\AgentChannelListModel;
use app\model\AuthRoleModel;
5 months ago
use app\model\AwsIvsModel;
4 months ago
use app\model\ForexTradeModel;
use app\model\PurchaseVipModel;
use app\model\RechargeApplyModel;
use app\model\StockJpTradeModel;
use app\model\StockTradeModel;
use app\model\UserChatLinkModel;
5 months ago
use app\model\UserModel;
4 months ago
use app\model\UserWithdrawalModel;
2 months ago
use think\facade\Log;
5 months ago
class AgentService extends AdminBaseService
{
// 代理列表
public function index()
{
try {
// $agentUserId = env('AGENT.AGENT_GROUP_ID');
// $agentAdminUserIds = AuthGroupAccessModel::where('group_id', $agentUserId)->column('uid');
3 months ago
$agentAdminUser = AdminModel::where('role_id', 'in', AdminModel::ROLE_ID_AGENT)->field('id,user_name,nick_name,email,mobile,status,invite_code')->select();
5 months ago
$rows = [];
if (!$agentAdminUser->isEmpty()) {
foreach ($agentAdminUser as $item) {
$rows[] = [
'id' => $item['id'],
'username' => $item['user_name'],
'nickname' => $item['nick_name'],
'email' => $item['email'] ?? '-',
'mobile' => $item['mobile'] ?? '-',
'status' => $item['status'],
'invite_code' => $item['invite_code'],
];
}
}
return $this->toData('0', 'SUCCESS', ['list' => $rows, 'total' => count($rows)]);
} catch (\Exception $exception) {
return $this->toData('1', '系统异常 请稍后重试', [$exception->getMessage(), $exception->getTrace()]);
}
}
// 代理用户
public function user($param)
{
try {
if (empty($param['agent_id'])) {
return $this->toData('0', 'SUCCESS', ['list' => []]);
}
$userList = UserModel::where('agent_id', 'in', [0, $param['agent_id']])->where('parent_id', 0)
->order('user_id', 'desc')
->select();
$rows = [];
if (!$userList->isEmpty()) {
foreach ($userList as $item) {
$rows[] = [
'id' => $item['user_id'],
'email' => $item['email'],
'user_no' => $item['user_no'],
'status' => $item['agent_id'] == $param['agent_id'],
'agent_id' => $param['agent_id'],
];
}
}
return $this->toData('0', 'SUCCESS', ['list' => $rows, 'total' => count($rows)]);
} catch (\Exception $exception) {
return $this->toData('1', '系统异常 请稍后重试', [$exception->getMessage(), $exception->getTrace()]);
}
}
public function manager($param)
{
try {
if (empty($param['id']) || !is_numeric($param['id'])) {
4 months ago
return $this->toData('400', '参错错误', ['list' => []]);
5 months ago
}
if (empty($param['agent_id']) || !is_numeric($param['agent_id'])) {
4 months ago
return $this->toData('400', '参错错误', ['list' => []]);
5 months ago
}
$user = UserModel::where('user_id', $param['id'])->find();
if (empty($user)) {
4 months ago
return $this->toData('500', '用户不存在', ['list' => []]);
5 months ago
}
if ($user['parent_id'] != 0) {
4 months ago
return $this->toData('500', '只能绑定顶层用户', ['list' => []]);
5 months ago
}
// 判断代理是否有效
$admin = AdminModel::where('id', $param['agent_id'])->find();
$roleId = 10;
if (empty($admin) || $admin['role_id'] != $roleId) {
4 months ago
return $this->toData('500', '代理不存在', ['list' => []]);
5 months ago
}
// $agentUserId = env('AGENT.AGENT_GROUP_ID');
// $agentAdminUserIds = AuthGroupAccessModel::where('group_id', $agentUserId)->column('uid');
// if(!in_array($param['agent_id'], $agentAdminUserIds)){
// return $this->toData('1', '代理不存在', ['list' => []]);
// }
// 未绑定 直接绑定
if ($user->agent_id == 0) {
UserModel::update(['agent_id' => $param['agent_id']], ['user_id' => $param['id']]);
4 months ago
return $this->toData('0', 'success');
5 months ago
}
// 取消绑定
if ($user->agent_id == $param['agent_id']) {
UserModel::update(['agent_id' => 0], ['user_id' => $param['id']]);
4 months ago
return $this->toData('0', 'success');
5 months ago
}
return $this->toData('1', '该用户已被其他代理绑定, 请先取消绑定', []);
} catch (\Exception $exception) {
return $this->toData('1', '系统异常 请稍后重试', [$exception->getMessage(), $exception->getTrace()]);
}
}
public function addUser($param)
{
try {
if (empty($param['agent_id']) || !is_numeric($param['agent_id'])) {
4 months ago
return $this->toData('400', '参错错误');
5 months ago
}
if (empty($param['user_id']) || !is_numeric($param['user_id'])) {
4 months ago
return $this->toData('400', '参错错误');
5 months ago
}
$user = UserModel::where('user_id', $param['user_id'])->find();
if (empty($user)) {
4 months ago
return $this->toData('400', '用户不存在');
5 months ago
}
if ($user['parent_id'] != 0) {
4 months ago
return $this->toData('400', '只能绑定顶层用户');
5 months ago
}
// 判断代理是否有效
$admin = AdminModel::where('id', $param['agent_id'])->find();
$roleId = 10;
if (empty($admin) || $admin['role_id'] != $roleId) {
4 months ago
return $this->toData('500', '代理不存在');
5 months ago
}
UserModel::update(['agent_id' => $param['agent_id']], ['user_id' => $param['user_id']]);
4 months ago
return $this->toData('0', 'success');
5 months ago
} catch (\Exception $exception) {
4 months ago
return $this->toData('500', '系统异常 请稍后重试', [$exception->getMessage(), $exception->getTrace()]);
5 months ago
}
}
public function customerList($param)
{
try {
if (empty($param['page']) || !is_numeric($param['page'])) {
4 months ago
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', '系统中还没有客服角色');
5 months ago
}
4 months ago
// 如有指定代理ID, 则查询代理ID下的客服列表,否则查询所有代理下的客服列表
2 months ago
$where = [];
if (isset($param['agent_id'])) { // 根据代理ID过滤客服列表
$teamHeaderIds = [];
$directorIds = AdminModel::where('parent_id', $param['agent_id'])->column('id'); // 代理下的总监账号
if (!empty($directorIds)) {
$teamHeaderIds = AdminModel::where('parent_id', 'in', $directorIds)->column('id'); // 代理下的组长账号
}
$where[] = ['parent_id', 'in', $teamHeaderIds];
} else { // 查询所有客服列表
$where[] = ['role_id', '=', $customerRole->id];
}
$list = AdminModel::where($where)->order('id', 'desc')->paginate([
4 months ago
'list_rows' => $param['limit'],
'page' => $param['page'],
5 months ago
]);
2 months ago
// 获取客服的chat信息
$resData = [];
if (!empty($list->items())) {
$idArr = array_column($list->items(), 'id');
$chatInfos = UserChatLinkModel::where('user_id', 'in', $idArr)->where('user_type', UserChatLinkModel::USER_CHAT_LINK_USER_TYPE_ADMIN)->column('user_id,chat_uuid,chat_name', 'user_id');
foreach ($list->items() as $itm) {
$tmp = $itm;
$tmp['chat_uuid'] = isset($chatInfos[$itm['id']]) ? $chatInfos[$itm['id']]['chat_uuid'] : '';
$tmp['chat_name'] = isset($chatInfos[$itm['id']]) ? $chatInfos[$itm['id']]['chat_name'] : '';
$resData[] = $tmp;
}
}
2 months ago
4 months ago
return $this->toData('0', 'success', [
2 months ago
'list' => $resData, // 当前页的数据
5 months ago
'page' => $list->currentPage(), // 当前页码
'total' => $list->total(), // 总记录数
'last_page' => $list->lastPage(), // 最后一页页码
]);
} catch (\Exception $exception) {
4 months ago
return $this->toData('500', '系统异常 请稍后重试', [$exception->getMessage(), $exception->getTrace()]);
5 months ago
}
}
public function customerReceptionEdit($param)
{
try {
if (empty($param['id']) || empty($param['ext'])) {
return $this->toData('400', '缺少参数');
}
$role = AdminModel::where(['id'=>$param['id']])->find();
if (empty($role)) {
return $this->toData('400', '修改的数据不存在');
}
$role->ext = $param['ext'];
$role->save();
return $this->toData('0', 'success');
} catch (\Exception $e){
return $this->toData('500', '系统异常 请稍后重试', [$e->getMessage(), $e->getTrace()]);
}
}
4 months ago
public function customerUserList($param)
5 months ago
{
try {
if (empty($param['customer_id']) || !is_numeric($param['customer_id'])) {
4 months ago
return $this->toData('400', '参错错误');
5 months ago
}
3 months ago
if (empty($param['page']) || empty($param['limit'])) {
4 months ago
return $this->toData('400', '参错错误');
5 months ago
}
// 查询当前客服下的用户
3 months ago
$list = UserModel::where('customer_id', $param['customer_id'])->order('user_id', 'desc')->paginate([
4 months ago
'list_rows' => $param['limit'],
5 months ago
'page' => $param['page'], // 使用前端传递的页码
]);
4 months ago
return $this->toData('0', 'success', [
5 months ago
'list' => $list->items(), // 当前页的数据
'page' => $list->currentPage(), // 当前页码
'total' => $list->total(), // 总记录数
'last_page' => $list->lastPage(), // 最后一页页码
]);
} catch (\Exception $exception) {
4 months ago
return $this->toData('500', '系统异常 请稍后重试', [$exception->getMessage(), $exception->getTrace()]);
}
}
public function changeUserCustomer($param)
{
try {
if (empty($param['user_id']) || empty($param['new_customer_id'])) {
4 months ago
return $this->toData('400', '参数错误');
}
3 months ago
$user = UserModel::where(['user_id'=>$param['user_id']])->find();
if (empty($user)) {
return $this->toData('500', '用户数据为空');
4 months ago
}
2 months ago
// 获取旧客服chat信息
$oldCustomerChatInfo = UserChatLinkModel::where(['user_id'=>$user->customer_id, 'user_type'=>UserChatLinkModel::USER_CHAT_LINK_USER_TYPE_ADMIN])->find();
if (empty($oldCustomerChatInfo)) {
return $this->toData('500', '旧客服的聊天数据错误');
}
2 months ago
// 变更的客服必须是同一个代理 $user->agent_id
4 months ago
$newCustomer = AdminModel::where(['id'=>$param['new_customer_id']])->find();
if (empty($newCustomer)) {
2 months ago
return $this->toData('500', '变更的客服数据错误');
4 months ago
}
2 months ago
if ($newCustomer->ext == 2) {
return $this->toData('500', '要变更的客服已经停止接待');
}
// 获取新客服所属的代理, 需要先获取所属的组长、总监、代理
$teamHeader = AdminModel::where(['id'=>$newCustomer->parent_id])->find(); // 获取所属组长
if (empty($teamHeader)) {
return $this->toData('500', '新客服所属的组长为空');
}
$director = AdminModel::where(['id'=>$teamHeader->parent_id])->find(); // 获取所属总监
if (empty($director)) {
return $this->toData('500', '新客服所属的总监为空');
}
$agent = AdminModel::where(['id'=>$director->parent_id])->find(); // 获取所属代理
if (empty($agent)) {
return $this->toData('500', '新客服所属的代理为空');
}
// 判断新客服所属的代理是否与旧客服的代理是同一个
if ($agent->id != $user->agent_id) {
return $this->toData('500', '变更的客服与当前客服不属于同一个代理');
4 months ago
}
// 变更客服绑定关系
3 months ago
$user->customer_id = $param['new_customer_id'];
$user->save();
4 months ago
// 将用户与新客服的聊天账号加好友
$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,
2 months ago
'Type' => 1, // 1-转移好友聊天记录
'CustomerOldUuid' => $oldCustomerChatInfo->chat_uuid, // 旧客服的uuid
4 months ago
];
$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()]);
5 months ago
}
}
public function awsIvsList($param)
{
try {
if (empty($param['page']) || !is_numeric($param['page'])) {
4 months ago
return $this->toData('400', '参错错误');
}
if (empty($param['limit']) || !is_numeric($param['limit'])) {
return $this->toData('400', '参错错误');
5 months ago
}
if (isset($param['title'])) {
$list = AwsIvsModel::where('title', $param['title'])->order('id', 'desc')->paginate([
4 months ago
'list_rows' => $param['limit'],
5 months ago
'page' => $param['page'],
]);
} else {
$list = AwsIvsModel::order('id', 'desc')->paginate([
4 months ago
'list_rows' => $param['limit'],
5 months ago
'page' => $param['page'],
]);
}
2 months ago
// 请求chat服务获取每个直播间的审核状态
$items = [];
if (!empty($list->items())) {
$httpClient = new \app\utility\RequestChatServer();
foreach ($list->items() as $v) {
$chatFriendsUrl = env('CHAT_SERVER.BASE_URL') . '/api/message/auditProcess/'.$v['agent_chat_group_id'];
$httpRes = $httpClient->ReqChatServer($chatFriendsUrl, [], 'GET');
$tmp = $v;
$tmp['review_status'] = $httpRes['data'];
$items[] = $tmp;
}
}
4 months ago
return $this->toData('0', 'success', [
2 months ago
'list' => $items, // 当前页的数据
5 months ago
'page' => $list->currentPage(), // 当前页码
'total' => $list->total(), // 总记录数
'last_page' => $list->lastPage(), // 最后一页页码
]);
} catch (\Exception $exception) {
4 months ago
return $this->toData('500', '系统异常 请稍后重试', [$exception->getMessage(), $exception->getTrace()]);
5 months ago
}
}
public function awsIvsAdd($param)
{
try {
if (empty($param['title'])) {
4 months ago
return $this->toData('400', 'Missing param title');
5 months ago
}
if (empty($param['anchor_name'])) {
4 months ago
return $this->toData('400', 'Missing param anchor_name');
5 months ago
}
if (empty($param['desc'])) {
4 months ago
return $this->toData('400', 'Missing param desc');
5 months ago
}
if (empty($param['push_url'])) {
4 months ago
return $this->toData('400', 'Missing param push_url');
5 months ago
}
if (empty($param['secret_key'])) {
4 months ago
return $this->toData('400', 'Missing param secret_key');
5 months ago
}
if (empty($param['play_url'])) {
4 months ago
return $this->toData('400', 'Missing param play_url');
5 months ago
}
if (empty($param['agent_id'])) {
4 months ago
return $this->toData('400', 'Missing param agent_id');
5 months ago
}
//判断一个代理下只能有一个推流配置
$ckInfo = AwsIvsModel::where('agent_id', $param['agent_id'])->find();
if ($ckInfo) {
4 months ago
return $this->toData('500', '一个代理下只能配置一个推流信息');
5 months ago
}
//保存推流配置
$res = AwsIvsModel::create([
'title' => $param['title'],
'anchor_name' => $param['anchor_name'],
'avatar' => $param['avatar'],
'desc' => $param['desc'],
'push_url' => $param['push_url'],
'secret_key' => $param['secret_key'],
'play_url' => $param['play_url'],
2 months ago
'agent_id' => $param['agent_id'],
'ad_content' => $param['ad_content'] ?? "",
'state' => $param['state'] ?? 1,
5 months ago
]);
4 months ago
return $this->toData('0', 'success', ['id' => $res->id]);
5 months ago
} catch (\Exception $exception) {
4 months ago
return $this->toData('500', '系统异常 请稍后重试', [$exception->getMessage(), $exception->getTrace()]);
5 months ago
}
}
public function awsIvsEdit($param)
{
try {
if (empty($param['id'])) {
4 months ago
return $this->toData('400', 'Missing param id');
5 months ago
}
2 months ago
if (!isset($param['state'])) {
return $this->toData('400', 'Parameter error');
}
5 months ago
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'])) {
4 months ago
return $this->toData('400', 'Parameter error');
5 months ago
}
// 检查是否存在数据
$ckInfo = AwsIvsModel::where('id', $param['id'])->find();
if (empty($ckInfo)) {
4 months ago
return $this->toData('500', '编辑的数据不存在');
5 months ago
}
$ckInfo->title = $param['title'];
$ckInfo->anchor_name = $param['anchor_name'];
$ckInfo->avatar = $param['avatar'];
$ckInfo->desc = $param['desc'];
$ckInfo->push_url = $param['push_url'];
$ckInfo->secret_key = $param['secret_key'];
$ckInfo->play_url = $param['play_url'];
2 months ago
$ckInfo->ad_content = $param['ad_content'] ?? '';
$ckInfo->state = $param['state'];
5 months ago
$ckInfo->save();
4 months ago
return $this->toData('0', 'success');
5 months ago
} catch (\Exception $exception) {
4 months ago
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()]);
5 months ago
}
}
4 months ago
5 months ago
}