|
|
@ -4,6 +4,8 @@ namespace app\admin\controller; |
|
|
|
|
|
|
|
use app\admin\service\AdminBaseService; |
|
|
|
use app\admin\service\setting\IPOService; |
|
|
|
use app\model\AdminModel; |
|
|
|
use app\model\AuthRoleModel; |
|
|
|
use app\model\BrokerageSettingModel; |
|
|
|
use app\model\ContractListMode; |
|
|
|
use app\model\ContractTradeModel; |
|
|
@ -12,12 +14,6 @@ use app\model\DigitalTradeModel; |
|
|
|
use app\model\DrawalSettingModel; |
|
|
|
use app\model\FeeSettingModel; |
|
|
|
use app\model\ForexListModel; |
|
|
|
use app\model\PreIdnStockModel; |
|
|
|
use app\model\PreInStockModel; |
|
|
|
use app\model\PreMysStockModel; |
|
|
|
use app\model\PreSgdStockModel; |
|
|
|
use app\model\PreThaStockModel; |
|
|
|
use app\model\PreUsStockModel; |
|
|
|
use app\model\RechargeApplyModel; |
|
|
|
use app\model\StockBrlListModel; |
|
|
|
use app\model\StockEurListModel; |
|
|
@ -39,25 +35,8 @@ use app\model\StockSgdListModel; |
|
|
|
use app\model\StockThaListModel; |
|
|
|
use app\model\StockThaTradeModel; |
|
|
|
use app\model\StockTradeModel; |
|
|
|
use app\model\UserIdnPreStockOrderModel; |
|
|
|
use app\model\UserInPreStockOrderModel; |
|
|
|
use app\model\UserModel; |
|
|
|
use app\model\UserMysPreStockOrderModel; |
|
|
|
use app\model\UserSgdPreStockOrderModel; |
|
|
|
use app\model\UserStockIdnLogModel; |
|
|
|
use app\model\UserStockIdnModel; |
|
|
|
use app\model\UserStockInLogModel; |
|
|
|
use app\model\UserStockInModel; |
|
|
|
use app\model\UserStockLogModel; |
|
|
|
use app\model\UserStockModel; |
|
|
|
use app\model\UserStockMysLogModel; |
|
|
|
use app\model\UserStockMysModel; |
|
|
|
use app\model\UserStockSgdLogModel; |
|
|
|
use app\model\UserStockSgdModel; |
|
|
|
use app\model\UserStockThaLogModel; |
|
|
|
use app\model\UserStockThaModel; |
|
|
|
use app\model\UserThaPreStockOrderModel; |
|
|
|
use app\model\UserUsPreStockOrderModel; |
|
|
|
use app\model\UserVerifyLogModel; |
|
|
|
use app\model\UserWithdrawalModel; |
|
|
|
use app\utility\ClientGo; |
|
|
|
use think\facade\Db; |
|
|
@ -84,68 +63,126 @@ class Index extends AdminBaseController |
|
|
|
$userWithdrawTableName = $prefix . (new UserWithdrawalModel())->getName(); |
|
|
|
|
|
|
|
|
|
|
|
// 总注册人数(用户的总数) |
|
|
|
$totalRegisterNum = Db::table($userTableName)->count(); |
|
|
|
// 获取当登录账号信息 |
|
|
|
$adminId = $this->request->user_id; |
|
|
|
$account = AdminModel::where('id', $adminId)->find(); |
|
|
|
if (empty($account)) { |
|
|
|
return json(['code' => '500', 'message' => '当前账号数据为空', 'data' => []]); |
|
|
|
} |
|
|
|
// 查询当前账号的角色信息 |
|
|
|
$role = AuthRoleModel::where(['id'=>$account->role_id])->find(); |
|
|
|
if (empty($role)) { |
|
|
|
return json(['code' => '500', 'message' => '当前账号分配的角色数据为空', 'data' => []]); |
|
|
|
} |
|
|
|
|
|
|
|
$today = date('Y-m-d'); // 今天凌晨 |
|
|
|
$tomorrow = date('Y-m-d', strtotime('tomorrow')); // 明天凌晨 |
|
|
|
$whereInUser = []; |
|
|
|
// 根据角色获取数据统计范围 |
|
|
|
switch ($role->name) { |
|
|
|
case AuthRoleModel::NAME_ADMIN: // 超级管理员可以查看所有数据 |
|
|
|
// 今日注册用户 |
|
|
|
$todayRegisterNum = UserModel::whereTime('create_time', 'between', [$today, $tomorrow])->count(); |
|
|
|
// 总注册人数(用户的总数) |
|
|
|
$totalRegisterNum = UserModel::count(); |
|
|
|
// // 今日充值用户 完成状态 |
|
|
|
// $todayRechargeNum = RechargeApplyModel::where('status', 1)->whereTime('create_time', 'between', [$today, $tomorrow])->group('user_id')->count(); |
|
|
|
// 总充值用户(充值用户的个数 以用户id分组) |
|
|
|
// $totalRechargeNum = RechargeApplyModel::where('status', 1)->group('user_id')->count(); |
|
|
|
break; |
|
|
|
case AuthRoleModel::NAME_AGENT: // 代理 - 查看代理下可以查看的用户 |
|
|
|
// 今日注册用户 |
|
|
|
$todayRegisterNum = UserModel::whereTime('create_time', 'between', [$today, $tomorrow])->where('agent_id', $adminId)->count(); |
|
|
|
// 总注册人数(用户的总数) |
|
|
|
$userIds = UserModel::where('agent_id', $adminId)->column('user_id'); |
|
|
|
$totalRegisterNum = count($userIds); |
|
|
|
$whereInUser[] = ['user_id', 'in', $userIds]; |
|
|
|
break; |
|
|
|
case AuthRoleModel::NAME_DIRECTOR: // 总监 - 查询总监下可以查看的用户 |
|
|
|
$customerIds = []; |
|
|
|
$teamHeaderIds = AdminModel::where('parent_id', $adminId)->column('id'); // 总监下面的组长ID |
|
|
|
if (!empty($teamHeaderIds)) { |
|
|
|
$customerIds = AdminModel::whereIn('parent_id', $teamHeaderIds)->column('id'); // 组长下面的ID |
|
|
|
} |
|
|
|
// 今日注册用户 |
|
|
|
$todayRegisterNum = UserModel::whereTime('create_time', 'between', [$today, $tomorrow])->whereIn('customer_id', $customerIds)->count(); |
|
|
|
// 总注册人数(用户的总数) |
|
|
|
$userIds = UserModel::whereIn('customer_id', $customerIds)->column('user_id'); |
|
|
|
$totalRegisterNum = count($userIds); |
|
|
|
$whereInUser[] = ['user_id', 'in', $userIds]; |
|
|
|
break; |
|
|
|
case AuthRoleModel::NAME_TEAM_HEADER: // 组长 - 查看组长下可以查看的用户 |
|
|
|
$customerIds = AdminModel::where('parent_id', $adminId)->column('id'); // 组长下面的客服ID |
|
|
|
// 今日注册用户 |
|
|
|
$todayRegisterNum = UserModel::whereTime('create_time', 'between', [$today, $tomorrow])->whereIn('customer_id', $customerIds)->count(); |
|
|
|
// 总注册人数(用户的总数) |
|
|
|
$userIds = UserModel::whereIn('customer_id', $customerIds)->column('user_id'); |
|
|
|
$totalRegisterNum = count($userIds); |
|
|
|
$whereInUser[] = ['user_id', 'in', $userIds]; |
|
|
|
break; |
|
|
|
case AuthRoleModel::NAME_CUSTOMER: // 客服 - 查看客服下的用户 |
|
|
|
// 今日注册用户 |
|
|
|
$todayRegisterNum = UserModel::whereTime('create_time', 'between', [$today, $tomorrow])->where('customer_id', $adminId)->count(); |
|
|
|
// 总注册人数(用户的总数) |
|
|
|
$userIds = UserModel::where('customer_id', $adminId)->column('user_id'); |
|
|
|
$totalRegisterNum = count($userIds); |
|
|
|
$whereInUser[] = ['user_id', 'in', $userIds]; |
|
|
|
break; |
|
|
|
default: |
|
|
|
return json(['code' => '500', 'message' => '当前角色未知,不能提供数据统计', 'data' => []]); |
|
|
|
} |
|
|
|
|
|
|
|
// 今日充值用户 完成状态 |
|
|
|
$todayRechargeNum = RechargeApplyModel::where('status', 1)->whereTime('create_time', 'between', [$today, $tomorrow])->where($whereInUser)->group('user_id')->count(); |
|
|
|
// 总充值用户(充值用户的个数 以用户id分组) |
|
|
|
$totalRechargeNum = Db::table($rechargeApplyTableName)->where('status', 1)->group('user_id')->count(); |
|
|
|
$totalRechargeNum = RechargeApplyModel::where('status', 1)->where($whereInUser)->group('user_id')->count(); |
|
|
|
|
|
|
|
// 总交易用户(合约 股票 现货 交易的用户去重 订单状态为持仓 和 完成 订单) |
|
|
|
$contractTradeUserId = Db::table($ContractTradeTableName)->where('status', 'in', [1, 3])->distinct(true)->column('user_id'); |
|
|
|
$stockTradeUserId = Db::table($stockTradeTableName)->where('status', 'in', [1, 3])->distinct(true)->column('user_id'); |
|
|
|
$stockMysTradeUserId = Db::table($stockMysTradeTableName)->where('status', 'in', [1, 3])->distinct(true)->column('user_id'); |
|
|
|
$stockThaTradeUserId = Db::table($stockThaTradeTableName)->where('status', 'in', [1, 3])->distinct(true)->column('user_id'); |
|
|
|
$stockIdnTradeUserId = Db::table($stockIdnTradeTableName)->where('status', 'in', [1, 3])->distinct(true)->column('user_id'); |
|
|
|
$stockInTradeUserId = Db::table($stockInTradeTableName)->where('status', 'in', [1, 3])->distinct(true)->column('user_id'); |
|
|
|
$digitalTradeUserId = Db::table($digitalTradeTableName)->where('status', 'in', [1, 3])->distinct(true)->column('user_id'); |
|
|
|
$contractTradeUserId = Db::table($ContractTradeTableName)->where('status', 'in', [1, 3])->where($whereInUser)->distinct(true)->column('user_id'); |
|
|
|
$stockTradeUserId = Db::table($stockTradeTableName)->where('status', 'in', [1, 3])->where($whereInUser)->distinct(true)->column('user_id'); |
|
|
|
$stockMysTradeUserId = Db::table($stockMysTradeTableName)->where('status', 'in', [1, 3])->where($whereInUser)->distinct(true)->column('user_id'); |
|
|
|
$stockThaTradeUserId = Db::table($stockThaTradeTableName)->where('status', 'in', [1, 3])->where($whereInUser)->distinct(true)->column('user_id'); |
|
|
|
$stockIdnTradeUserId = Db::table($stockIdnTradeTableName)->where('status', 'in', [1, 3])->where($whereInUser)->distinct(true)->column('user_id'); |
|
|
|
$stockInTradeUserId = Db::table($stockInTradeTableName)->where('status', 'in', [1, 3])->where($whereInUser)->distinct(true)->column('user_id'); |
|
|
|
$digitalTradeUserId = Db::table($digitalTradeTableName)->where('status', 'in', [1, 3])->where($whereInUser)->distinct(true)->column('user_id'); |
|
|
|
|
|
|
|
$totalArrayMerge = array_unique(array_merge($contractTradeUserId, $stockTradeUserId, $digitalTradeUserId, $stockMysTradeUserId, $stockIdnTradeUserId, $stockThaTradeUserId, $stockInTradeUserId)); |
|
|
|
$totalTradeNum = count($totalArrayMerge); |
|
|
|
|
|
|
|
// 总提现用户(以用户id 分组查询数量) |
|
|
|
$totalWithdrawalNum = Db::table($userWithdrawTableName)->group('user_id')->count(); |
|
|
|
$totalWithdrawalNum = Db::table($userWithdrawTableName)->where($whereInUser)->group('user_id')->count(); |
|
|
|
|
|
|
|
// 总充值金额 充值完成 |
|
|
|
$totalRechargeAmount = Db::table($rechargeApplyTableName)->where('status', 1)->sum('recharge_num'); |
|
|
|
$totalRechargeAmount = Db::table($rechargeApplyTableName)->where($whereInUser)->where('status', 1)->sum('recharge_num'); |
|
|
|
|
|
|
|
// 总提款金额 提款完成 |
|
|
|
$totalWithdrawAmount = Db::table($userWithdrawTableName)->where('status', 2)->sum('apply_num'); |
|
|
|
$totalWithdrawAmount = Db::table($userWithdrawTableName)->where($whereInUser)->where('status', 2)->sum('apply_num'); |
|
|
|
|
|
|
|
|
|
|
|
// 今日注册用户 |
|
|
|
$today = date('Y-m-d'); // 今天凌晨 |
|
|
|
$tomorrow = date('Y-m-d', strtotime('tomorrow')); // 明天凌晨 |
|
|
|
$todayRegisterNum = Db::table($userTableName)->whereTime('create_time', 'between', [$today, $tomorrow])->count(); |
|
|
|
|
|
|
|
// 今日充值用户 完成状态 |
|
|
|
$todayRechargeNum = Db::table($userTableName)->where('status', 1) |
|
|
|
->whereTime('create_time', 'between', [$today, $tomorrow]) |
|
|
|
->group('user_id')->count(); |
|
|
|
|
|
|
|
// 今日交易用户 |
|
|
|
// 合约 |
|
|
|
$todayContractTradeUserId = Db::table($ContractTradeTableName)->where('status', 'in', [1, 3]) |
|
|
|
->whereTime('create_time', 'between', [$today, $tomorrow]) |
|
|
|
->whereTime('create_time', 'between', [$today, $tomorrow])->where($whereInUser) |
|
|
|
->distinct(true)->column('user_id'); |
|
|
|
//股票 |
|
|
|
$todayStockTradeUserId = Db::table($stockTradeTableName)->where('status', 'in', [1, 3]) |
|
|
|
->whereTime('create_time', 'between', [$today, $tomorrow]) |
|
|
|
->whereTime('create_time', 'between', [$today, $tomorrow])->where($whereInUser) |
|
|
|
->distinct(true)->column('user_id'); |
|
|
|
$todayStockMysTradeUserId = Db::table($stockMysTradeTableName)->where('status', 'in', [1, 3]) |
|
|
|
->whereTime('create_time', 'between', [$today, $tomorrow]) |
|
|
|
->whereTime('create_time', 'between', [$today, $tomorrow])->where($whereInUser) |
|
|
|
->distinct(true)->column('user_id'); |
|
|
|
$todayStockThaTradeUserId = Db::table($stockThaTradeTableName)->where('status', 'in', [1, 3]) |
|
|
|
->whereTime('create_time', 'between', [$today, $tomorrow]) |
|
|
|
->whereTime('create_time', 'between', [$today, $tomorrow])->where($whereInUser) |
|
|
|
->distinct(true)->column('user_id'); |
|
|
|
$todayStockIndTradeUserId = Db::table($stockIdnTradeTableName)->where('status', 'in', [1, 3]) |
|
|
|
->whereTime('create_time', 'between', [$today, $tomorrow]) |
|
|
|
->whereTime('create_time', 'between', [$today, $tomorrow])->where($whereInUser) |
|
|
|
->distinct(true)->column('user_id'); |
|
|
|
$todayStockInTradeUserId = Db::table($stockInTradeTableName)->where('status', 'in', [1, 3]) |
|
|
|
->whereTime('create_time', 'between', [$today, $tomorrow]) |
|
|
|
->whereTime('create_time', 'between', [$today, $tomorrow])->where($whereInUser) |
|
|
|
->distinct(true)->column('user_id'); |
|
|
|
// 现货 |
|
|
|
$todayDigitalTradeUserId = Db::table($digitalTradeTableName)->where('status', 'in', [1, 3]) |
|
|
|
->whereTime('create_time', 'between', [$today, $tomorrow]) |
|
|
|
->whereTime('create_time', 'between', [$today, $tomorrow])->where($whereInUser) |
|
|
|
->distinct(true)->column('user_id'); |
|
|
|
|
|
|
|
// 计算总数 |
|
|
@ -154,39 +191,53 @@ class Index extends AdminBaseController |
|
|
|
|
|
|
|
// 今日提款用户 |
|
|
|
$todayWithdrawNum = Db::table($userWithdrawTableName) |
|
|
|
->whereTime('create_time', 'between', [$today, $tomorrow]) |
|
|
|
->whereTime('create_time', 'between', [$today, $tomorrow])->where($whereInUser) |
|
|
|
->group('user_id')->count(); |
|
|
|
|
|
|
|
// 今日充值金额 完成状态 |
|
|
|
$todayRechargeAmount = Db::table($rechargeApplyTableName) |
|
|
|
->whereTime('create_time', 'between', [$today, $tomorrow]) |
|
|
|
->whereTime('create_time', 'between', [$today, $tomorrow])->where($whereInUser) |
|
|
|
->where('status', 1)->sum('recharge_num'); |
|
|
|
|
|
|
|
// 今日提款金额 完成状态 |
|
|
|
$todayWithdrawAmount = Db::table($userWithdrawTableName) |
|
|
|
->whereTime('create_time', 'between', [$today, $tomorrow]) |
|
|
|
->whereTime('create_time', 'between', [$today, $tomorrow])->where($whereInUser) |
|
|
|
->where('status', 2)->sum('apply_num'); |
|
|
|
|
|
|
|
// 等待处理充值订单数量 |
|
|
|
$pendingRecharge = RechargeApplyModel::where('status', 0)->where($whereInUser)->count(); |
|
|
|
// 等待处理提款订单数量 |
|
|
|
$pendingWithdraw = UserWithdrawalModel::where('status', 4)->where($whereInUser)->count(); |
|
|
|
// 等待实名审核数量 |
|
|
|
$pendingUserVerify = UserVerifyLogModel::where('status', 1)->where($whereInUser)->count(); |
|
|
|
|
|
|
|
$data = [ |
|
|
|
'todayRegisterNum' => $todayRegisterNum, // 今日注册用户 |
|
|
|
'totalRegisterNum' => $totalRegisterNum, // 总注册人数 |
|
|
|
'totalRechargeNum' => $totalRechargeNum,// 总充值用户 |
|
|
|
'totalTradeNum' => $totalTradeNum,// 总交易用户 |
|
|
|
'totalWithdrawalNum' => $totalWithdrawalNum,// 总提现用户 |
|
|
|
'totalRechargeAmount' => $totalRechargeAmount,// 总充值金额 |
|
|
|
'totalWithdrawAmount' => $totalWithdrawAmount, // 总提款金额 |
|
|
|
|
|
|
|
'todayRegisterNum' => $todayRegisterNum, // 今日注册用户 |
|
|
|
'todayRechargeNum' => $todayRechargeNum, // 今日充值用户 |
|
|
|
'totalRechargeNum' => $totalRechargeNum,// 总充值用户 |
|
|
|
|
|
|
|
'todayTradeNum' => $todayTradeNum, // 今日交易用户 |
|
|
|
'totalTradeNum' => $totalTradeNum,// 总交易用户 |
|
|
|
|
|
|
|
'todayWithdrawNum' => $todayWithdrawNum, // 今日提款用户 |
|
|
|
'totalWithdrawalNum' => $totalWithdrawalNum,// 总提现用户 |
|
|
|
|
|
|
|
'todayRechargeAmount' => $todayRechargeAmount, // 今日充值金额 |
|
|
|
'totalRechargeAmount' => $totalRechargeAmount,// 总充值金额 |
|
|
|
|
|
|
|
'todayWithdrawAmount' => $todayWithdrawAmount, // 今日提款金额 |
|
|
|
'totalWithdrawAmount' => $totalWithdrawAmount, // 总提款金额 |
|
|
|
|
|
|
|
'no_deal_recharge' => $pendingRecharge, // 等待处理充值订单数量 |
|
|
|
'no_deal_withdraw' => $pendingWithdraw, // 等待处理提款订单数量 |
|
|
|
'no_deal_real' => $pendingUserVerify, // 等待实名审核数量 |
|
|
|
]; |
|
|
|
|
|
|
|
return json(['code' => '0', 'message' => 'SUCCESS', 'data' => $data]); |
|
|
|
} catch (\Exception $exception) { |
|
|
|
return json(['code' => '1', 'message' => '系统繁忙']); |
|
|
|
return json(['code' => '1', 'message' => '系统繁忙', [$exception->getMessage(), $exception->getTrace()]]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|