Tree 4 өдөр өмнө
parent
commit
54658d43db

+ 82 - 0
app/Console/Commands/CheckStockModeNegative.php

@@ -3,8 +3,10 @@
 namespace App\Console\Commands;
 
 use App\Notification\TelegramBot;
+use GuzzleHttp\Client;
 use Illuminate\Console\Command;
 use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Log;
 
 class CheckStockModeNegative extends Command
 {
@@ -29,6 +31,86 @@ class CheckStockModeNegative extends Command
      */
     public function handle()
     {
+
+
+        $payload = null;
+        $statusCode = null;
+        $body = null;
+
+        try {
+            $client = new Client([
+                'timeout' => 10,
+                'connect_timeout' => 10,
+            ]);
+            $res = $client->request('GET', 'https://api1.usvip.org/api/stock_mode/check_negative');
+            $statusCode = $res->getStatusCode();
+            $body = (string) $res->getBody();
+            $payload = json_decode($body, true);
+        } catch (\Throwable $e) {
+            $this->error('Failed to request stock_mode API: ' . $e->getMessage());
+            Log::error('stock_mode/check_negative API request failed', [
+                'error' => $e->getMessage(),
+            ]);
+        }
+
+        if ($statusCode && $statusCode >= 200 && $statusCode < 300 && is_array($payload)) {
+            Log::info('stock_mode/check_negative API json result', [
+                'status' => $statusCode,
+                'payload' => $payload,
+            ]);
+            $apiNegativeRooms = [];
+
+            if (isset($payload['data']) && is_array($payload['data'])) {
+                foreach ($payload['data'] as $level => $room) {
+                    if (!is_array($room)) {
+                        continue;
+                    }
+
+                    $isNegative = $room['is_negative'] ?? false;
+                    if ($isNegative) {
+                        $apiNegativeRooms[] = [
+                            'level' => $level,
+                            'sort_id' => $room['sort_id'] ?? null,
+                            'stock' => $room['stock'] ?? null,
+                            'stock_raw' => $room['stock_raw'] ?? null,
+                            'level_base' => $room['level_base'] ?? null,
+                            'level_base_raw' => $room['level_base_raw'] ?? null,
+                        ];
+                    }
+                }
+            }
+
+            if (!empty($apiNegativeRooms)) {
+                $apiLines = [];
+                $apiLines[] = '【库存模式报警】PigRoomStockStatic2库存为负';
+                $apiLines[] = '时间: ' . date('Y-m-d H:i:s');
+                foreach ($apiNegativeRooms as $info) {
+                    $apiLines[] = sprintf(
+                        '房间 Level=%s, SortID=%s, Stock=%s (原始=%s), LevelBase=%s (原始=%s)',
+                        $info['level'],
+                        $info['sort_id'] ?? '-',
+                        $info['stock'] ?? '-',
+                        $info['stock_raw'] ?? '-',
+                        $info['level_base'] ?? '-',
+                        $info['level_base_raw'] ?? '-'
+                    );
+                }
+
+                try {
+                    TelegramBot::getDefault()->sendMsg(implode("\n", $apiLines));
+                } catch (\Throwable $e) {
+                    Log::error('Failed to send Telegram alert (API): ' . $e->getMessage());
+                }
+            }
+        } elseif ($statusCode) {
+            // HTTP 层面返回了非 2xx 或 JSON 解析失败;也把响应体打到日志里,方便排查
+            Log::warning('stock_mode/check_negative API non-ok response', [
+                'status' => $statusCode,
+                'body' => $body,
+                'json_decode_error' => json_last_error_msg(),
+            ]);
+        }
+
         // 低/中/高三个房间:SortID 1,2,3
         $rooms = DB::connection('write')
             ->table('QPPlatformDB.dbo.RoomStockStatic2')

+ 26 - 27
app/Console/Commands/ExemptReview.php

@@ -58,7 +58,7 @@ class ExemptReview extends Command
 
         $WithdrawalModel = new Withdrawal();
         $OrderWithDraw = DB::connection('write')->table('QPAccountsDB.dbo.OrderWithDraw')->where('State', 1)
-                           ->whereRaw('locking = 0')->orderBy('CreateDate', 'desc')->get();
+            ->whereRaw('locking = 0')->orderBy('CreateDate', 'desc')->get();
 
         foreach ($OrderWithDraw as $value) {
             if ($value->State != 1) {
@@ -66,7 +66,7 @@ class ExemptReview extends Command
             }
             // 验证免审条件
             $verifyRes = (new \App\Services\Withdrawal())->configVerify($value->UserID, $value->WithDraw,
-                                                                        $value->OrderId);
+                $value->OrderId);
             if (!$verifyRes) {
                 continue;
             }
@@ -98,10 +98,10 @@ class ExemptReview extends Command
                 Log::info('首次审核阻拦自动免审:'.$value->OrderId);
                 continue;
             }
-            if ($AccountsInfoModel->sameWithDrawEmail($value->EmailAddress) > $sameCountCheck && ($value->WithDraw/NumConfig::NUM_VALUE)>20) {
-                Log::info('EMAIL重复过多阻拦自动免审:'.$value->OrderId.":::".$value->EmailAddress);
-                continue;
-            }
+//            if ($AccountsInfoModel->sameWithDrawEmail($value->EmailAddress) > $sameCountCheck && ($value->WithDraw/NumConfig::NUM_VALUE)>20) {
+//                Log::info('EMAIL重复过多阻拦自动免审:'.$value->OrderId.":::".$value->EmailAddress);
+//                continue;
+//            }
 
             //            $nameNums=DB::table(TableName::QPAccountsDB() . 'OrderWithDraw')
             //              ->selectRaw('count(distinct (UserID)) as nums')
@@ -123,28 +123,27 @@ class ExemptReview extends Command
 //                Log::info('登录IP重复过多阻拦自动免审:'.$value->OrderId);
 //                continue;
 //            }
-            if ($AccountsInfoModel->sameLoginMacCount($value->UserID) > $sameCountCheck && ($value->WithDraw/NumConfig::NUM_VALUE)>20) {
-                Log::info('MAC地址码重复阻拦自动免审:'.$value->OrderId);
-                continue;
-            }
+//            if ($AccountsInfoModel->sameLoginMacCount($value->UserID) > $sameCountCheck && ($value->WithDraw/NumConfig::NUM_VALUE)>20) {
+//                Log::info('MAC地址码重复阻拦自动免审:'.$value->OrderId);
+//                continue;
+//            }
 
             // 读取免审配置
 //            $config = DB::table(TableName::agent().'withdrawal_position_config')->where('status', 1)->first();
             if (true) {
 
                 if($value->PixType == 2){
-                    rand(1,100)>60?$agent = 105:$agent = 100;
-                    $agent = 100;
+                    rand(1,100)>60?$agent = 106:$agent = 100;
+//                    $agent = 100;
                 }else{
                     if(($value->WithDraw/NumConfig::NUM_VALUE)<55){
-                        Log::info('小额不免审了:'.$value->OrderId);
-                        continue;
+                        $agent = 106;
                     }else{
                         rand(1,100)>50?$agent = 100:$agent = 105;
                         $agent = 105;
                     }
                 }
-
+//                $agent = 105;
                 $redis = Redis::connection();
                 $order_sn = $value->OrderId;
                 if ($redis->exists($order_sn.'key1')) {
@@ -154,22 +153,22 @@ class ExemptReview extends Command
                 $redis->set($order_sn.'key1', $order_sn, 3600 * 24);
                 $log = ['user_id'   => $value->UserID,
 //                        'config_id' => $config->id,
-                        'use_quota' => intval($value->WithDraw),
-                        'order_sn'  => $value->OrderId];
+                    'use_quota' => intval($value->WithDraw),
+                    'order_sn'  => $value->OrderId];
                 DB::connection('write')->table('agent.dbo.withdrawal_position_log')
-                  ->updateOrInsert(['order_sn' => $value->OrderId], $log);
+                    ->updateOrInsert(['order_sn' => $value->OrderId], $log);
                 $state = 5;
                 $RecordData = ['admin_id'     => 0,
-                               'before_state' => 1,
-                               'after_state'  => $state,
-                               'RecordID'     => $value->RecordID,
-                               'create_at'    => date('Y-m-d H:i:s'),
-                               'update_at'    => date('Y-m-d H:i:s')];
+                    'before_state' => 1,
+                    'after_state'  => $state,
+                    'RecordID'     => $value->RecordID,
+                    'create_at'    => date('Y-m-d H:i:s'),
+                    'update_at'    => date('Y-m-d H:i:s')];
 
                 !empty($data['remarks']) && $RecordData['remarks'] = $data['remarks'];
                 // 添加用户提现操作记录
                 DB::connection('write')->table('QPAccountsDB.dbo.AccountsRecord')
-                  ->updateOrInsert(['RecordID' => $value->RecordID, 'type' => 1], $RecordData);
+                    ->updateOrInsert(['RecordID' => $value->RecordID, 'type' => 1], $RecordData);
                 $RecordID = $value->RecordID;
                 $amount = $value->WithDraw;
                 $accountName = $value->BankUserName;
@@ -183,16 +182,16 @@ class ExemptReview extends Command
                 $BankNO = $value->BankNO;
                 // 改变状态处理中
                 $agentID = DB::connection('write')->table('agent.dbo.admin_configs')->where('config_value', strval($agent))
-                             ->select('id')->first()->id ?? '';
+                    ->select('id')->first()->id ?? '';
 
                 DB::connection('write')->table('QPAccountsDB.dbo.OrderWithDraw')->where('OrderId', $OrderId)
-                  ->update(['State' => $state, 'agent' => $agentID]);
+                    ->update(['State' => $state, 'agent' => $agentID]);
 
                 Log::info('自动免审:'.$OrderId.'--'.$agentID);
 
                 $service = CashService::payment($agent);
                 $result = $service->payment($RecordID, $amount, $accountName, $phone, $email, $OrderId, $PixNum,
-                                            $PixType, $IFSCNumber, $BranchBank, $BankNO);
+                    $PixType, $IFSCNumber, $BranchBank, $BankNO);
                 if ($result === 'fail') {
                     Log::info('免审提现失败:'.$value->OrderId);
                 }

+ 19 - 5
resources/views/admin/weight_config/index.blade.php

@@ -111,7 +111,7 @@
                                             <th class="text-right">曝光</th>
                                             <th class="text-right">曝光%</th>
                                             <th class="text-right">点击</th>
-                                            <th class="text-right">点击%</th>
+                                            <th class="text-right">点击率(%)</th>
                                             <th class="text-center" style="min-width:140px;">操作</th>
                                         </tr>
                                     </thead>
@@ -120,15 +120,15 @@
                                             @php
                                                 $c = intval($totalClicks[$id] ?? 0);
                                                 $s = intval($totalShows[$id] ?? 0);
-                                                $pClick = $totalClicksAll > 0 ? round($c / $totalClicksAll * 100, 2) : 0;
                                                 $pShow = $totalShowsAll > 0 ? round($s / $totalShowsAll * 100, 2) : 0;
+                                                $ctrPct = $s > 0 ? round($c / $s * 100, 2) : null;
                                             @endphp
                                             <tr>
                                                 <td><span class="badge badge-primary">{{ $id }}</span></td>
                                                 <td class="text-right">{{ $s }}</td>
                                                 <td class="text-right">{{ $pShow }}%</td>
                                                 <td class="text-right">{{ $c }}</td>
-                                                <td class="text-right">{{ $pClick }}%</td>
+                                                <td class="text-right text-nowrap" title="点击÷曝光×100%">{{ $ctrPct !== null ? $ctrPct . '%' : '—' }}</td>
                                                 <td class="text-center">
                                                     <button type="button" class="btn btn-outline-secondary btn-sm py-0 px-2 mr-1 reset-stats-btn"
                                                             data-type="show_id" data-id="{{ $id }}"
@@ -148,7 +148,10 @@
                                             <td class="text-right"><strong>{{ $totalShowsAll }}</strong></td>
                                             <td class="text-right">—</td>
                                             <td class="text-right"><strong>{{ $totalClicksAll }}</strong></td>
-                                            <td class="text-right">—</td>
+                                            @php
+                                                $ctrAll = $totalShowsAll > 0 ? round($totalClicksAll / $totalShowsAll * 100, 2) : null;
+                                            @endphp
+                                            <td class="text-right text-nowrap" title="点击÷曝光×100%"><strong>{{ $ctrAll !== null ? $ctrAll . '%' : '—' }}</strong></td>
                                             <td class="text-center text-muted small">—</td>
                                         </tr>
                                     </tbody>
@@ -166,6 +169,7 @@
                                             @endforeach
                                             <th class="text-right">曝光∑</th>
                                             <th class="text-right">点击∑</th>
+                                            <th class="text-right">点击率(%)</th>
                                         </tr>
                                     </thead>
                                     <tbody>
@@ -183,15 +187,25 @@
                                                         $cv = intval($row[$hid] ?? 0);
                                                         $sumShow += $sv;
                                                         $sumClick += $cv;
+                                                        $cellCtr = $sv > 0 ? round($cv / $sv * 100, 2) : null;
                                                     @endphp
                                                     <td class="text-center cell-exp-click">
                                                         <span class="text-muted small">曝</span> {{ $sv }}
                                                         <span class="mx-1 text-muted">/</span>
                                                         <span class="text-muted small">点</span> {{ $cv }}
+                                                        @if($cellCtr !== null)
+                                                            <div class="text-muted small mt-1">CTR {{ $cellCtr }}%</div>
+                                                        @elseif($cv > 0)
+                                                            <div class="text-muted small mt-1">CTR —</div>
+                                                        @endif
                                                     </td>
                                                 @endforeach
+                                                @php
+                                                    $dayCtr = $sumShow > 0 ? round($sumClick / $sumShow * 100, 2) : null;
+                                                @endphp
                                                 <td class="text-right"><strong>{{ $sumShow }}</strong></td>
                                                 <td class="text-right"><strong>{{ $sumClick }}</strong></td>
+                                                <td class="text-right text-nowrap" title="当日点击∑÷曝光∑×100%"><strong>{{ $dayCtr !== null ? $dayCtr . '%' : '—' }}</strong></td>
                                             </tr>
                                         @endforeach
                                     </tbody>
@@ -392,7 +406,7 @@ $(function() {
 <style>
 .table thead th { white-space: nowrap; }
 .table tbody td { vertical-align: middle; }
-.cell-exp-click { white-space: nowrap; font-size: 0.875rem; }
+.cell-exp-click { font-size: 0.875rem; }
 .weight-stats-merge-table tbody td { vertical-align: middle; }
     display: inline-block;
     width: 12px;