Ver código fonte

代付失败,如果是余额不足的话自动免审权限配置成0

Tree 5 dias atrás
pai
commit
b6d33aa517

+ 1 - 1
app/Http/Controllers/Admin/GameEnterLogController.php

@@ -45,7 +45,7 @@ class GameEnterLogController extends Controller
             $totalMs = (int) $row->total_duration_ms;
             $avgMs = $enterCount > 0 ? $totalMs / $enterCount : 0;
 
-            $gameName = __('auto.δ֪ÓÎÏ·');
+            $gameName = __('auto.未知游�');
             if (isset($games[$gameId])) {
                 $game = $games[$gameId];
                 $gameName = $game->brand . ' - ' . $game->title;

+ 19 - 0
app/Http/Controllers/Admin/MailController.php

@@ -247,6 +247,25 @@ class MailController extends Controller
         }
     }
 
+
+    public function mailDelete($type, $id)
+    {
+        if (empty($id)) {
+            return $this->json(500, '邮件不存在');
+        }
+
+        $table = $type == 1 ? 'QPAccountsDB.dbo.SystemMail' : 'QPAccountsDB.dbo.PrivateMail';
+        $result = DB::table($table)
+            ->where('MailID', $id)
+            ->delete();
+
+        if ($result !== false) {
+            return $this->json(200, '删除成功');
+        }
+
+        return $this->json(500, '删除失败,请重试');
+    }
+
     // 邮件充值记录
     public function mailRecord(Request $request)
     {

+ 1 - 0
app/Http/Controllers/Admin/WithdrawalController.php

@@ -179,6 +179,7 @@ class WithdrawalController extends BaseController
         $list['request'] = $request;
         $admin = session('admin');
         $list['viewAll'] = $admin && isset($admin->roles[0]->id) && in_array($admin->roles[0]->id, [1, 12, 2010, 2011]) ? 1 : 0;
+        $list['isSuperAdmin'] = $admin && isset($admin->roles[0]->id) && $admin->roles[0]->id == 1 ? 1 : 0;
         return view('admin.Withdrawal.verify_finish', $list);
     }
 

+ 4 - 0
app/Http/Controllers/Game/GameEnterLogController.php

@@ -35,6 +35,10 @@ class GameEnterLogController extends Controller
                 return apiReturnFail('time must be a non-negative number');
             }
 
+            if ($durationMs > 1000*200) {
+                return apiReturnFail('time must be a non-negative number');
+            }
+
             $result = GameEnterLog::addLog([
                 'user_id' => $userId,
                 'game_id' => $gameId,

+ 2 - 0
app/Http/logic/api/AiNewPayCashierLogic.php

@@ -10,6 +10,7 @@ use App\Models\RecordUserDataStatistics;
 use App\Services\PayConfig;
 use App\Services\PayUtils;
 use App\Services\StoredProcedure;
+use App\Services\WithdrawalPayoutMonitor;
 use App\Util;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Log;
@@ -218,6 +219,7 @@ class AiNewPayCashierLogic implements CashierInterFace
                     
                     Util::WriteLog('AiNewPayEmail', [$query->UserID, $OrderId, $TakeMoney, $msg, $bonus]);
                     $withdraw_data = ['State' => 6, 'agent' => $agentID, 'remark' => @$post['errMsg'] ?: ''];
+                    WithdrawalPayoutMonitor::handleFailedCallback(self::AGENT, $post, $OrderId);
                     $notify_data = ['state' => 2];
                     break;
             }

+ 2 - 0
app/Http/logic/api/SafePayCashierLogic.php

@@ -10,6 +10,7 @@ use App\Models\RecordUserDataStatistics;
 use App\Services\SafePay;
 use App\Services\PayConfig;
 use App\Services\StoredProcedure;
+use App\Services\WithdrawalPayoutMonitor;
 use App\Util;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Log;
@@ -287,6 +288,7 @@ class SafePayCashierLogic implements CashierInterFace
                         'agent'  => $agentID,
                         'remark' => $post['result_mes'] ?? ''
                     ];
+                    WithdrawalPayoutMonitor::handleFailedCallback(self::AGENT, $post, $OrderId);
                     $notify_data['state'] = 2;
                     break;
             }

+ 2 - 0
app/Http/logic/api/SfPayCashierLogic.php

@@ -10,6 +10,7 @@ use App\Models\RecordUserDataStatistics;
 use App\Services\SfPay;
 use App\Services\PayConfig;
 use App\Services\StoredProcedure;
+use App\Services\WithdrawalPayoutMonitor;
 use App\Util;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Log;
@@ -297,6 +298,7 @@ class SfPayCashierLogic implements CashierInterFace
                         'agent'  => $agentID,
                         'remark' => $callbackData['message'] ?? ''
                     ];
+                    WithdrawalPayoutMonitor::handleFailedCallback(self::AGENT, $callbackData, $OrderId);
                     $notify_data['state'] = 2;
                     break;
             }

+ 2 - 0
app/Http/logic/api/WDPayCashierLogic.php

@@ -11,6 +11,7 @@ use App\Services\WDPay;
 use App\Services\PayConfig;
 use App\Services\PayUtils;
 use App\Services\StoredProcedure;
+use App\Services\WithdrawalPayoutMonitor;
 use App\Util;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Log;
@@ -254,6 +255,7 @@ class WDPayCashierLogic implements CashierInterFace
                     
                     Util::WriteLog('WDPayEmail', [$query->UserID, $OrderId, $TakeMoney, $msg, $bonus]);
                     $withdraw_data = ['State' => 6, 'agent' => $agentID, 'remark' => @$post['transMsg'] ?: ''];
+                    WithdrawalPayoutMonitor::handleFailedCallback(self::AGENT, $post, $OrderId);
                     $notify_data = ['state' => 2];
                     break;
             }

+ 35 - 3
app/Models/WithdrawalAgentRatioConfig.php

@@ -17,7 +17,7 @@ class WithdrawalAgentRatioConfig
         return [
             1 => 'CashApp',
             2 => 'PayPal',
-            self::PIX_TYPE_CASH_SMALL => 'CashApp小额(<50)',
+            self::PIX_TYPE_CASH_SMALL => 'CashApp small(<50)',
         ];
     }
 
@@ -66,6 +66,38 @@ class WithdrawalAgentRatioConfig
         Redis::del(self::CACHE_KEY);
     }
 
+    public static function disableAgent($agent)
+    {
+        $agent = (int)$agent;
+        $config = self::getGlobal();
+        $changed = false;
+
+        foreach (array_keys(self::pixTypeOptions()) as $pixType) {
+            $items = $config[$pixType] ?? [];
+            if (!is_array($items)) {
+                continue;
+            }
+
+            $filtered = [];
+            foreach ($items as $item) {
+                if ((int)($item['agent'] ?? 0) == $agent) {
+                    $changed = true;
+                    continue;
+                }
+
+                $filtered[] = $item;
+            }
+
+            $config[$pixType] = $filtered;
+        }
+
+        if ($changed) {
+            self::saveAll($config);
+        }
+
+        return $changed;
+    }
+
     public static function normalizeRules(array $rules)
     {
         $result = [];
@@ -105,8 +137,8 @@ class WithdrawalAgentRatioConfig
             [
                 'StatusValue' => 0,
                 'StatusString' => json_encode($config),
-                'StatusTip' => '提现免审代付比例配置',
-                'StatusDescription' => '按提现方式配置自动免审代付比例',
+                'StatusTip' => 'withdrawal auto payout ratio config',
+                'StatusDescription' => 'auto payout ratio config by withdrawal method',
             ]
         );
 

+ 60 - 0
app/Services/WithdrawalPayoutMonitor.php

@@ -0,0 +1,60 @@
+<?php
+
+namespace App\Services;
+
+use App\Models\WithdrawalAgentRatioConfig;
+use App\Notification\TelegramBot;
+use App\Util;
+use Illuminate\Support\Facades\DB;
+
+class WithdrawalPayoutMonitor
+{
+    public static function handleFailedCallback($agent, $callback, $orderId = '')
+    {
+        $message = self::callbackText($callback);
+        if (!self::isInsufficientBalance($message)) {
+            return false;
+        }
+
+        $changed = WithdrawalAgentRatioConfig::disableAgent($agent);
+        if ($changed) {
+            self::sendInsufficientBalanceNotice($agent, $orderId, $message);
+        }
+
+        return $changed;
+    }
+
+    private static function isInsufficientBalance($message)
+    {
+        return preg_match('/insufficient\s*(balance|funds)|balance\s*(is\s*)?(not\s*)?enough|not\s*enough\s*balance|\x{4F59}\x{989D}\x{4E0D}\x{8DB3}/iu', $message) === 1;
+    }
+
+    private static function callbackText($callback)
+    {
+        if (is_array($callback) || is_object($callback)) {
+            return json_encode($callback, JSON_UNESCAPED_UNICODE);
+        }
+
+        return strval($callback);
+    }
+
+    private static function sendInsufficientBalanceNotice($agent, $orderId, $message)
+    {
+        $agentName = DB::table('agent.dbo.admin_configs')
+            ->where('type', 'cash')
+            ->where('config_value', strval($agent))
+            ->value('name');
+
+        $content = "Insufficient balance\n"
+            . "Payout channel: " . ($agentName ?: $agent) . "({$agent})\n"
+            . "Order ID: " . ($orderId ?: '-') . "\n"
+            . "Auto payout ratio for this channel has been set to 0\n"
+            . "Callback: " . mb_substr($message, 0, 800);
+
+        try {
+            TelegramBot::getDefault()->sendProgramNotify('Insufficient balance', $content);
+        } catch (\Exception $exception) {
+            Util::WriteLog('WithdrawalPayoutMonitor', 'Telegram notify failed: ' . $exception->getMessage());
+        }
+    }
+}

+ 1 - 1
resources/views/admin/Withdrawal/verify_finish.blade.php

@@ -293,7 +293,7 @@
                                                 </a>
                                             @endif
 
-                                            @if($item->State == 5 || ($item->State == 6 && $item->WithDraw<40))
+                                            @if($item->State == 5 || ($item->State == 6 && (!empty($isSuperAdmin) || $item->WithDraw < 40)))
                                                 <br>
                                                 <a class="layer-switch"
                                                    data-remind="{{ __('auto.你确定要重制茶叶状态么?') }}"

+ 18 - 1
resources/views/admin/mail/list.blade.php

@@ -68,6 +68,7 @@
                                     <th>{{ __('auto.附件内容') }}</th>
                                     <th>{{ __('auto.文本内容') }}</th>
                                     <th>{{ __('auto.领取状态') }}</th>
+                                    <th>{{ __('auto.操作') }}</th>
                                 </tr>
                                 </thead>
                                 <tbody>
@@ -79,7 +80,12 @@
                                         <td style="width: 15%">{{ $v->TitleString}}</td>
                                         <td style="width: 10%">{{ $v->BonusString}}</td>
                                         <td style="width: 35%">{{ $v->TextString}}</td>
-                                        <td style="width: 35%">{{ ['','','', __('auto.已领取') , __('auto.已删除')][$v->MailStatus]}}</td>
+                                        <td style="width: 35%">{{ isset($v->MailStatus) ? (['','','', __('auto.已领取') , __('auto.已删除')][$v->MailStatus] ?? '') : '' }}</td>
+                                        <td style="width: 5%">
+                                            <button type="button" class="btn btn-sm btn-gradient-danger btn-icon-text" onclick="delMail({{ $type }}, {{ $v->MailID }})">
+                                                {{ __('auto.删除') }}
+                                            </button>
+                                        </td>
                                     </tr>
                                 @endforeach
                                 </tbody>
@@ -105,5 +111,16 @@
                 content: '/admin/mail/add'
             });
         }
+
+        function delMail(type, id) {
+            myConfirm("{{ __('auto.删除操作不可逆,是否继续') }}?", function () {
+                myRequest("/admin/mail/delete/" + type + "/" + id, "post", {}, function (res) {
+                    layer.msg(res.msg)
+                    setTimeout(function () {
+                        window.location.reload();
+                    }, 1500)
+                });
+            });
+        }
     </script>
 @endsection

+ 1 - 0
routes/web.php

@@ -414,6 +414,7 @@ Route::group([
         $route->get('/mail/list', 'Admin\MailController@mailList');
         $route->get('/mail/add', 'Admin\MailController@mailAddView');
         $route->post('/mail/add', 'Admin\MailController@mailAdd');
+        $route->post('/mail/delete/{type}/{id}', 'Admin\MailController@mailDelete');
         $route->get('/recharge/record', 'Admin\MailController@mailRecord');
         $route->get('/recharge/back_record', 'Admin\MailController@back_mailRecord');