|
|
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\admin;
|
|
|
|
|
|
use App\Constants\HttpStatus;
|
|
|
use App\Http\Controllers\Controller;
|
|
|
+use App\Services\BaseService;
|
|
|
use App\Services\IssueService;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
use Illuminate\Validation\ValidationException;
|
|
|
@@ -20,7 +21,7 @@ class Issue extends Controller
|
|
|
/**
|
|
|
* @description: 分页数据
|
|
|
* @return {*}
|
|
|
- */
|
|
|
+ */
|
|
|
function index()
|
|
|
{
|
|
|
try {
|
|
|
@@ -42,7 +43,7 @@ class Issue extends Controller
|
|
|
/**
|
|
|
* @description: 异常分页数据
|
|
|
* @return {*}
|
|
|
- */
|
|
|
+ */
|
|
|
function abnormal()
|
|
|
{
|
|
|
try {
|
|
|
@@ -65,25 +66,25 @@ class Issue extends Controller
|
|
|
/**
|
|
|
* @description: 修改|新增
|
|
|
* @return {*}
|
|
|
- */
|
|
|
+ */
|
|
|
public function store()
|
|
|
{
|
|
|
- return $this->error(HttpStatus::CUSTOM_ERROR,'禁止编辑');
|
|
|
+ return $this->error(HttpStatus::CUSTOM_ERROR, '禁止编辑');
|
|
|
// try {
|
|
|
- $params = request()->all();
|
|
|
+ $params = request()->all();
|
|
|
|
|
|
- $validator = [
|
|
|
- 'issue_no' => 'required|string|max:50|alpha_dash|unique:issues,issue_no',
|
|
|
- 'winning_numbers' => 'nullable|string|max:100',
|
|
|
- 'status' => 'nullable|string',
|
|
|
- ];
|
|
|
+ $validator = [
|
|
|
+ 'issue_no' => 'required|string|max:50|alpha_dash|unique:issues,issue_no',
|
|
|
+ 'winning_numbers' => 'nullable|string|max:100',
|
|
|
+ 'status' => 'nullable|string',
|
|
|
+ ];
|
|
|
|
|
|
- request()->validate($validator);
|
|
|
+ request()->validate($validator);
|
|
|
|
|
|
- $ret = IssueService::submit($params);
|
|
|
- if ($ret['code'] == IssueService::NOT) {
|
|
|
- return $this->error($ret['code'], $ret['msg']);
|
|
|
- }
|
|
|
+ $ret = IssueService::submit($params);
|
|
|
+ if ($ret['code'] == IssueService::NOT) {
|
|
|
+ return $this->error($ret['code'], $ret['msg']);
|
|
|
+ }
|
|
|
// } catch (ValidationException $e) {
|
|
|
// return $this->error(HttpStatus::VALIDATION_FAILED, '', $e->errors());
|
|
|
// } catch (Exception $e) {
|
|
|
@@ -110,7 +111,7 @@ class Issue extends Controller
|
|
|
/**
|
|
|
* @description: 开始
|
|
|
* @return {*}
|
|
|
- */
|
|
|
+ */
|
|
|
public function betting()
|
|
|
{
|
|
|
$id = request()->input('id');
|
|
|
@@ -127,7 +128,7 @@ class Issue extends Controller
|
|
|
/**
|
|
|
* @description: 关闭
|
|
|
* @return {*}
|
|
|
- */
|
|
|
+ */
|
|
|
public function close()
|
|
|
{
|
|
|
$id = request()->input('id');
|
|
|
@@ -140,27 +141,29 @@ class Issue extends Controller
|
|
|
}
|
|
|
return $this->success([], $ret['msg']);
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* @description: 开奖
|
|
|
* @return {*}
|
|
|
- */
|
|
|
+ */
|
|
|
public function lotteryDraw()
|
|
|
{
|
|
|
$id = request()->input('id');
|
|
|
$winning_numbers = request()->input('winning_numbers');
|
|
|
- $image = request()->input('image');
|
|
|
- $combo = request()->input('combo');
|
|
|
+ $winArr = array_map('intval', explode(',', $winning_numbers));
|
|
|
+ $combo = IssueService::getCombo($winArr);
|
|
|
+ $image = null;
|
|
|
if (!$id) {
|
|
|
- return $this->error(HttpStatus::VALIDATION_FAILED, '参数错误');
|
|
|
+ return $this->error(HttpStatus::CUSTOM_ERROR, '参数错误');
|
|
|
}
|
|
|
if (!$winning_numbers) {
|
|
|
- return $this->error(HttpStatus::VALIDATION_FAILED, '参数错误');
|
|
|
+ return $this->error(HttpStatus::CUSTOM_ERROR, '参数错误');
|
|
|
}
|
|
|
- if(explode(',', $winning_numbers) < 3){
|
|
|
- return $this->error(HttpStatus::VALIDATION_FAILED, '开奖号码格式错误');
|
|
|
+ if (explode(',', $winning_numbers) < 3) {
|
|
|
+ return $this->error(HttpStatus::CUSTOM_ERROR, '开奖号码格式错误');
|
|
|
}
|
|
|
- $ret = IssueService::lotteryDraw($id,$winning_numbers,$combo,$image);
|
|
|
- if ($ret['code'] == IssueService::NOT) {
|
|
|
+ $ret = IssueService::lotteryDraw($id, $winning_numbers, $combo, $image);
|
|
|
+ if ($ret['code'] == BaseService::NOT) {
|
|
|
return $this->error($ret['code'], $ret['msg']);
|
|
|
}
|
|
|
return $this->success([], $ret['msg']);
|
|
|
@@ -171,7 +174,7 @@ class Issue extends Controller
|
|
|
*/
|
|
|
public function destroy()
|
|
|
{
|
|
|
- return $this->error(HttpStatus::CUSTOM_ERROR,'禁止删除');
|
|
|
+ return $this->error(HttpStatus::CUSTOM_ERROR, '禁止删除');
|
|
|
$id = request()->post('id');
|
|
|
// 示例:通过 ID 删除
|
|
|
$info = IssueService::findOne(['id' => $id]);
|