|
|
@@ -45,6 +45,8 @@ class RechargeController extends Controller
|
|
|
$chargeMoney = $request->chargeMoney ?: '';
|
|
|
$payMethod = (int)$request->input('payMethod', 0);
|
|
|
$amountSort = $request->amountSort ?: '';
|
|
|
+ // 操作人筛选:空=全部,0=无操作人,正整数=指定管理员 id
|
|
|
+ $operator_admin_id = $request->input('operator_admin_id', '');
|
|
|
|
|
|
$type_list = DB::table('agent.dbo.admin_configs')->where('type', 'pay')
|
|
|
->pluck('name');
|
|
|
@@ -170,32 +172,68 @@ class RechargeController extends Controller
|
|
|
$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';
|
|
|
|
|
|
- // 充值总金额、手续费汇总(管理员可见)
|
|
|
- $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;
|
|
|
$totalPaymentFee = isset($payTotalMoney->total_payment_fee) ? number_float($payTotalMoney->total_payment_fee / NumConfig::NUM_VALUE) : 0;
|
|
|
|
|
|
// 已到账
|
|
|
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)
|
|
|
- ->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();
|
|
|
} 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)
|
|
|
- ->lock('with(nolock)')
|
|
|
->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;
|
|
|
@@ -297,8 +335,19 @@ class RechargeController extends Controller
|
|
|
if(!in_array($admin->roles[0]->id,[1,12,2010,2011])){
|
|
|
$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', [
|
|
|
'viewAll' => $viewAll,
|
|
|
+ 'operator_admin_id' => $operator_admin_id,
|
|
|
+ 'operatorOptions' => $operatorOptions,
|
|
|
'list' => $list,
|
|
|
'UserID' => $userid,
|
|
|
'order_sn' => $order_sn,
|