|
@@ -3,6 +3,7 @@
|
|
|
namespace App\Http\Controllers\Admin;
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
|
|
|
|
use App\AdminConfig;
|
|
use App\AdminConfig;
|
|
|
|
|
+use App\dao\Estatisticas\RechargeWithDraw;
|
|
|
use App\Facade\TableName;
|
|
use App\Facade\TableName;
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Controllers\Controller;
|
|
|
use App\Http\helper\NumConfig;
|
|
use App\Http\helper\NumConfig;
|
|
@@ -45,6 +46,8 @@ class RechargeController extends Controller
|
|
|
$chargeMoney = $request->chargeMoney ?: '';
|
|
$chargeMoney = $request->chargeMoney ?: '';
|
|
|
$payMethod = (int)$request->input('payMethod', 0);
|
|
$payMethod = (int)$request->input('payMethod', 0);
|
|
|
$amountSort = $request->amountSort ?: '';
|
|
$amountSort = $request->amountSort ?: '';
|
|
|
|
|
+ // 操作人筛选:空=全部,0=无操作人,正整数=指定管理员 id
|
|
|
|
|
+ $operator_admin_id = $request->input('operator_admin_id', '');
|
|
|
|
|
|
|
|
$type_list = DB::table('agent.dbo.admin_configs')->where('type', 'pay')
|
|
$type_list = DB::table('agent.dbo.admin_configs')->where('type', 'pay')
|
|
|
->pluck('name');
|
|
->pluck('name');
|
|
@@ -170,35 +173,79 @@ class RechargeController extends Controller
|
|
|
$where[] = ['o.pay_at', '<=', $time->subHours(11)->format('Y-m-d H:i:s')];
|
|
$where[] = ['o.pay_at', '<=', $time->subHours(11)->format('Y-m-d H:i:s')];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 操作人(补单等)筛选:与列表相同的 AccountsRecord 关联
|
|
|
|
|
+ if ($operator_admin_id !== '' && $operator_admin_id !== null) {
|
|
|
|
|
+ if ((string)$operator_admin_id === '0') {
|
|
|
|
|
+ $where[] = [function ($q) {
|
|
|
|
|
+ $q->whereNull('ar.admin_id');
|
|
|
|
|
+ }];
|
|
|
|
|
+ } elseif (ctype_digit((string)$operator_admin_id) && (int)$operator_admin_id > 0) {
|
|
|
|
|
+ $where[] = ['ar.admin_id', '=', (int)$operator_admin_id];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
$order ? $orderby = 'g.price desc' : $orderby = 'sum(o.amount) desc';
|
|
$order ? $orderby = 'g.price desc' : $orderby = 'sum(o.amount) desc';
|
|
|
|
|
|
|
|
- // 充值总金额、手续费汇总(管理员可见)
|
|
|
|
|
- $payTotalMoney = DB::connection('write')->table('agent.dbo.order as o')
|
|
|
|
|
- ->leftJoin('QPAccountsDB.dbo.AccountsInfo as ai', 'o.user_id', '=', 'ai.UserID')
|
|
|
|
|
- ->lock('with(nolock)')
|
|
|
|
|
- ->where($where)->selectRaw('sum(amount) as amount,sum(ISNULL(payment_fee,0)) as total_payment_fee,count(distinct(user_id)) count_u,count(id) count_id')->first();
|
|
|
|
|
|
|
+ $operatorFilterActive = $operator_admin_id !== '' && $operator_admin_id !== null
|
|
|
|
|
+ && ((string)$operator_admin_id === '0'
|
|
|
|
|
+ || (ctype_digit((string)$operator_admin_id) && (int)$operator_admin_id > 0));
|
|
|
|
|
+
|
|
|
|
|
+ $aggregateBase = function () use ($table, $operatorFilterActive) {
|
|
|
|
|
+ $q = DB::connection('write')->table($table)
|
|
|
|
|
+ ->leftJoin('QPAccountsDB.dbo.AccountsInfo as ai', 'o.user_id', '=', 'ai.UserID')
|
|
|
|
|
+ ->lock('with(nolock)');
|
|
|
|
|
+ if ($operatorFilterActive) {
|
|
|
|
|
+ $q->leftJoin('QPAccountsDB.dbo.AccountsRecord as ar', function ($join) {
|
|
|
|
|
+ $join->on('o.id', '=', 'ar.RecordID');
|
|
|
|
|
+ $join->where('ar.type', 2);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ return $q;
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ // 充值总金额、手续费汇总(管理员可见);有操作人筛选时 join ar,汇总用 distinct 避免重复行
|
|
|
|
|
+ $payTotalMoney = $aggregateBase()
|
|
|
|
|
+ ->where($where)
|
|
|
|
|
+ ->selectRaw(
|
|
|
|
|
+ $operatorFilterActive
|
|
|
|
|
+ ? 'sum(o.amount) as amount,sum(ISNULL(o.payment_fee,0)) as total_payment_fee,count(distinct o.user_id) count_u,count(distinct o.id) count_id'
|
|
|
|
|
+ : 'sum(amount) as amount,sum(ISNULL(payment_fee,0)) as total_payment_fee,count(distinct(user_id)) count_u,count(id) count_id'
|
|
|
|
|
+ )
|
|
|
|
|
+ ->first();
|
|
|
|
|
|
|
|
$totalMoney = isset($payTotalMoney->amount) ? number_float($payTotalMoney->amount / NumConfig::NUM_VALUE) : 0;
|
|
$totalMoney = isset($payTotalMoney->amount) ? number_float($payTotalMoney->amount / NumConfig::NUM_VALUE) : 0;
|
|
|
$totalPaymentFee = isset($payTotalMoney->total_payment_fee) ? number_float($payTotalMoney->total_payment_fee / NumConfig::NUM_VALUE) : 0;
|
|
$totalPaymentFee = isset($payTotalMoney->total_payment_fee) ? number_float($payTotalMoney->total_payment_fee / NumConfig::NUM_VALUE) : 0;
|
|
|
|
|
|
|
|
// 已到账
|
|
// 已到账
|
|
|
if ($recharge_type == 1) {
|
|
if ($recharge_type == 1) {
|
|
|
- $payOverMoney = DB::connection('write')->table('agent.dbo.order as o')
|
|
|
|
|
- ->join('QPAccountsDB.dbo.AccountsInfo as ai', 'o.user_id', '=', 'ai.UserID')
|
|
|
|
|
|
|
+ $payOverMoney = $aggregateBase()
|
|
|
->where($where)
|
|
->where($where)
|
|
|
- ->lock('with(nolock)')
|
|
|
|
|
- ->selectRaw('sum(amount) as amount,count(distinct(user_id)) count_u,count(id) count_id')
|
|
|
|
|
|
|
+ ->selectRaw(
|
|
|
|
|
+ $operatorFilterActive
|
|
|
|
|
+ ? 'sum(o.amount) as amount,count(distinct o.user_id) count_u,count(distinct o.id) count_id'
|
|
|
|
|
+ : 'sum(amount) as amount,count(distinct(user_id)) count_u,count(id) count_id'
|
|
|
|
|
+ )
|
|
|
->first();
|
|
->first();
|
|
|
} elseif (empty($recharge_type)) {
|
|
} elseif (empty($recharge_type)) {
|
|
|
- $payOverMoney = DB::connection('write')->table('agent.dbo.order as o')
|
|
|
|
|
- ->join('QPAccountsDB.dbo.AccountsInfo as ai', 'o.user_id', '=', 'ai.UserID')
|
|
|
|
|
|
|
+ $payOverMoney = $aggregateBase()
|
|
|
->where($where)
|
|
->where($where)
|
|
|
- ->lock('with(nolock)')
|
|
|
|
|
->where('pay_status', 1)
|
|
->where('pay_status', 1)
|
|
|
- ->selectRaw('sum(amount) as amount,count(distinct(user_id)) count_u,count(id) count_id')->first();
|
|
|
|
|
|
|
+ ->selectRaw(
|
|
|
|
|
+ $operatorFilterActive
|
|
|
|
|
+ ? 'sum(o.amount) as amount,count(distinct o.user_id) count_u,count(distinct o.id) count_id'
|
|
|
|
|
+ : 'sum(amount) as amount,count(distinct(user_id)) count_u,count(id) count_id'
|
|
|
|
|
+ )->first();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$overMoney = isset($payOverMoney->amount) ? number_float($payOverMoney->amount / NumConfig::NUM_VALUE) : 0;
|
|
$overMoney = isset($payOverMoney->amount) ? number_float($payOverMoney->amount / NumConfig::NUM_VALUE) : 0;
|
|
|
|
|
+ $successUserRate = 0;
|
|
|
|
|
+ $successOrderRate = 0;
|
|
|
|
|
+ if (!empty($payTotalMoney->count_u)) {
|
|
|
|
|
+ $successUserRate = round((($payOverMoney->count_u ?? 0) / $payTotalMoney->count_u) * 100, 2);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!empty($payTotalMoney->count_id)) {
|
|
|
|
|
+ $successOrderRate = round((($payOverMoney->count_id ?? 0) / $payTotalMoney->count_id) * 100, 2);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
if ($excel) {
|
|
if ($excel) {
|
|
|
$cellData = $build_sql
|
|
$cellData = $build_sql
|
|
@@ -297,8 +344,19 @@ class RechargeController extends Controller
|
|
|
if(!in_array($admin->roles[0]->id,[1,12,2010,2011])){
|
|
if(!in_array($admin->roles[0]->id,[1,12,2010,2011])){
|
|
|
$viewAll=0;
|
|
$viewAll=0;
|
|
|
}
|
|
}
|
|
|
|
|
+ $operatorOptions = DB::connection('write')
|
|
|
|
|
+ ->table('QPAccountsDB.dbo.AccountsRecord as ar')
|
|
|
|
|
+ ->join('agent.dbo.admin_users as au', 'ar.admin_id', '=', 'au.id')
|
|
|
|
|
+ ->where('ar.type', 2)
|
|
|
|
|
+ ->whereNotNull('ar.admin_id')
|
|
|
|
|
+ ->select('au.id', 'au.account')
|
|
|
|
|
+ ->distinct()
|
|
|
|
|
+ ->orderBy('au.account')
|
|
|
|
|
+ ->get();
|
|
|
return view('admin.recharge.list', [
|
|
return view('admin.recharge.list', [
|
|
|
'viewAll' => $viewAll,
|
|
'viewAll' => $viewAll,
|
|
|
|
|
+ 'operator_admin_id' => $operator_admin_id,
|
|
|
|
|
+ 'operatorOptions' => $operatorOptions,
|
|
|
'list' => $list,
|
|
'list' => $list,
|
|
|
'UserID' => $userid,
|
|
'UserID' => $userid,
|
|
|
'order_sn' => $order_sn,
|
|
'order_sn' => $order_sn,
|
|
@@ -315,6 +373,8 @@ class RechargeController extends Controller
|
|
|
'overMoney' => $overMoney,
|
|
'overMoney' => $overMoney,
|
|
|
'payOverMoney' => $payOverMoney ?? 0,
|
|
'payOverMoney' => $payOverMoney ?? 0,
|
|
|
'payTotalMoney' => $payTotalMoney,
|
|
'payTotalMoney' => $payTotalMoney,
|
|
|
|
|
+ 'successUserRate' => $successUserRate,
|
|
|
|
|
+ 'successOrderRate' => $successOrderRate,
|
|
|
'date' => $date,
|
|
'date' => $date,
|
|
|
'dates' => $dates,
|
|
'dates' => $dates,
|
|
|
'allChannel' => $allChannel,
|
|
'allChannel' => $allChannel,
|