seven 1 ay önce
ebeveyn
işleme
307a8c46d0

+ 34 - 0
app/Http/Controllers/admin/Issue.php

@@ -62,4 +62,38 @@ class Issue extends Controller
         return $this->success([], $ret['msg']);
 
     }
+
+    /**
+     * @description: 开始
+     * @return {*}
+     */    
+    public function betting()
+    {
+        $id = request()->input('id');
+        if (!$id) {
+            return $this->error(HttpStatus::VALIDATION_FAILED, '参数错误');
+        }
+        $ret = IssueService::betting($id);
+        if ($ret['code'] == IssueService::NOT) {
+            return $this->error($ret['code'], $ret['msg']);
+        }
+        return $this->success([], $ret['msg']);
+    }
+
+    /**
+     * @description: 关闭
+     * @return {*}
+     */    
+    public function close()
+    {
+        $id = request()->input('id');
+        if (!$id) {
+            return $this->error(HttpStatus::VALIDATION_FAILED, '参数错误');
+        }
+        $ret = IssueService::closeBetting($id);
+        if ($ret['code'] == IssueService::NOT) {
+            return $this->error($ret['code'], $ret['msg']);
+        }
+        return $this->success([], $ret['msg']);
+    }
 }

+ 43 - 1
app/Services/IssueService.php

@@ -89,7 +89,7 @@ class IssueService extends BaseService
         return ['total' => $paginator->total(), 'data' => $paginator->items()];
     }
 
-        /**
+    /**
      * @description: 
      * @param {*} $params
      * @return {*}
@@ -127,6 +127,48 @@ class IssueService extends BaseService
         return $msg;
     }
 
+    /**
+     * @description: 开始下注
+     * @param {*} $id
+     * @return {*}
+     */
+    public static function betting($id)
+    {
+        $info = self::findOne(['id'=>$id]);
+        if(!$info){
+            return ['code'=>self::NOT, 'msg'=>'期号不存在'];
+        }
+
+        if(!in_array($info->status, [self::model()::STATUS_DRAFT,self::model()::STATUS_BETTING])){
+            return ['code'=>self::NOT, 'msg'=>'期号状态不正确'];
+        }
+
+        $info->status = self::model()::STATUS_BETTING;
+        $info->save();
+        return ['code'=>self::YES, 'msg'=>'开始下注'];
+    } 
+
+    /**
+     * @description: 封盘
+     * @param {*} $id
+     * @return {*}
+     */
+    public static function closeBetting($id)
+    {
+        $info = self::findOne(['id'=>$id]);
+        if(!$info){
+            return ['code'=>self::NOT, 'msg'=>'期号不存在'];
+        }
+
+        if($info->status != self::model()::STATUS_BETTING){
+            return ['code'=>self::NOT, 'msg'=>'期号状态不正确'];
+        }
+
+        $info->status = self::model()::STATUS_CLOSED;
+        $info->save();
+        return ['code'=>self::YES, 'msg'=>'封盘成功'];
+    }
+
     /**
      * @description: 获取中奖的奖项
      * @param {*} $winning_numbers

+ 2 - 0
routes/admin.php

@@ -46,6 +46,8 @@ Route::middleware(['admin.jwt'])->group(function () {
         Route::prefix('/issue')->group(function () {
             Route::get('/', [Issue::class, 'index']);
             Route::post('/submit', [Issue::class, 'store']);
+            Route::post('/betting', [Issue::class, 'betting']);
+            Route::post('/close', [Issue::class, 'close']);
         });