Ken vor 4 Tagen
Ursprung
Commit
2dadd73fba

+ 16 - 9
app/Http/Controllers/admin/PcIssue.php

@@ -51,23 +51,30 @@ class PcIssue extends Controller
     {
         try {
             request()->validate([
-                'he' => ['required', 'integer','min:0','max:27'],
+                'issue_no' => ['required', 'string'],
+                'he' => ['required', 'integer', 'min:0', 'max:27'],
             ]);
+            $issueNo = request()->input('issue_no');
             $he = request()->input('he');
             $he = intval($he);
-            $result['keno'] = PcIssueService::getMatchingNumbers($he);
-            $result['winning_numbers'] = PcIssueService:: getWinningNumbers($result['keno']);
-            $result['winning_numbers'][] = $he;
-            $result['keno'] = implode(',', $result['keno']);
-            $result['winning_numbers'] = $result['winning_numbers'][0] . "+"
-                . $result['winning_numbers'][1] . '+' . $result['winning_numbers'][2] . '=' . $result['winning_numbers'][3];
-
+            $pcIssue = PcIssueModel::where('issue_no', $issueNo)->first();
+            if (!$pcIssue) throw new Exception('期号错误', HttpStatus::CUSTOM_ERROR);
+            if (!in_array($pcIssue->status, [PcIssueModel::STATUS_BETTING, PcIssueModel::STATUS_CLOSE])) {
+                throw new Exception('预开奖失败;状态不正确', HttpStatus::CUSTOM_ERROR);
+            }
+            $keno = PcIssueService::getMatchingNumbers($he);
+            $pcIssue->advance_keno = json_encode($keno);
+            $pcIssue->advance_code = $he;
+            $pcIssue->save();
         } catch (ValidationException $e) {
             return $this->error(HttpStatus::CUSTOM_ERROR, $e->validator->errors()->first());
         } catch (Exception $e) {
+            if ($e->getCode() == HttpStatus::CUSTOM_ERROR) {
+                return $this->error(HttpStatus::CUSTOM_ERROR, $e->getMessage());
+            }
             return $this->error(intval($e->getCode()));
         }
-        return $this->success($result);
+        return $this->success();
 
     }
 }

+ 1 - 1
app/Models/PcIssue.php

@@ -15,7 +15,7 @@ class PcIssue extends BaseModel
 
 
     protected $table = 'pc_issues';
-    protected $fillable = ['issue_no', 'start_time', 'end_time', 'winning_numbers', 'status', 'combo', 'extreme', 'image','keno'];
+    protected $fillable = ['issue_no', 'start_time', 'end_time', 'winning_numbers', 'status', 'combo', 'extreme', 'image', 'keno', 'advance_keno', 'advance_code'];
     protected $appends = [
         'award',
         'winning_array',

+ 30 - 0
database/migrations/2025_12_12_152641_update_pc_issues.php

@@ -0,0 +1,30 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration {
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('pc_issues', function (Blueprint $table) {
+            $table->text('advance_keno')->nullable()->comment('20个随机数');
+            $table->integer('advance_code')->nullable()->comment('预开奖号码');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        //
+    }
+};