|
@@ -6,6 +6,7 @@ use Illuminate\Http\JsonResponse;
|
|
|
use App\Constants\HttpStatus;
|
|
use App\Constants\HttpStatus;
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Controllers\Controller;
|
|
|
use App\Models\Config as ConfigModel;
|
|
use App\Models\Config as ConfigModel;
|
|
|
|
|
+use Illuminate\Support\Facades\Cache;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
use Illuminate\Validation\ValidationException;
|
|
use Illuminate\Validation\ValidationException;
|
|
|
use Exception;
|
|
use Exception;
|
|
@@ -16,18 +17,58 @@ use App\Services\ConfigService;
|
|
|
|
|
|
|
|
class Config extends Controller
|
|
class Config extends Controller
|
|
|
{
|
|
{
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @api {post} /admin/config/pc28Switch 游戏切换(0:pc28 1:急速28)
|
|
|
|
|
+ * @apiGroup 配置
|
|
|
|
|
+ * @apiUse result
|
|
|
|
|
+ * @apiUse header
|
|
|
|
|
+ * @apiVersion 1.0.0
|
|
|
|
|
+ *
|
|
|
|
|
+ * @apiParam {int=0,1} val (0:pc28 1:极速28)
|
|
|
|
|
+ */
|
|
|
|
|
+ public function pc28Switch()
|
|
|
|
|
+ {
|
|
|
|
|
+ try {
|
|
|
|
|
+ $params = request()->validate([
|
|
|
|
|
+ 'val' => ['required', 'integer', 'min:0', 'in:0,1']
|
|
|
|
|
+ ]);
|
|
|
|
|
+ Cache::put('pc28_switch', $params['val']);
|
|
|
|
|
+ } catch (ValidationException $e) {
|
|
|
|
|
+ return $this->error(HttpStatus::VALIDATION_FAILED, $e->validator->errors()->first());
|
|
|
|
|
+ } catch (Exception $e) {
|
|
|
|
|
+ return $this->error(intval($e->getCode()));
|
|
|
|
|
+ }
|
|
|
|
|
+ return $this->success();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @api {get} /admin/config/pcConfig 极速PC28相关配置
|
|
|
|
|
+ * @apiGroup 配置
|
|
|
|
|
+ * @apiUse result
|
|
|
|
|
+ * @apiUse header
|
|
|
|
|
+ * @apiVersion 1.0.0
|
|
|
|
|
+ *
|
|
|
|
|
+ * @apiParam {int} [page=1]
|
|
|
|
|
+ * @apiParam {int} [limit=15]
|
|
|
|
|
+ */
|
|
|
public function pcConfig(): JsonResponse
|
|
public function pcConfig(): JsonResponse
|
|
|
{
|
|
{
|
|
|
try {
|
|
try {
|
|
|
$search['group_id'] = 4;
|
|
$search['group_id'] = 4;
|
|
|
$result = ConfigService::paginate($search);
|
|
$result = ConfigService::paginate($search);
|
|
|
|
|
+ foreach ($result['data'] as $item) {
|
|
|
|
|
+ if ($item['field'] == 'pc28_switch') {
|
|
|
|
|
+ $item['val'] = Cache::get('pc28_switch', $item['val']);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
} catch (ValidationException $e) {
|
|
} catch (ValidationException $e) {
|
|
|
return $this->error(HttpStatus::VALIDATION_FAILED, $e->validator->errors()->first());
|
|
return $this->error(HttpStatus::VALIDATION_FAILED, $e->validator->errors()->first());
|
|
|
- } catch (Exception $e) {
|
|
|
|
|
|
|
+ } catch
|
|
|
|
|
+ (Exception $e) {
|
|
|
return $this->error(intval($e->getCode()));
|
|
return $this->error(intval($e->getCode()));
|
|
|
}
|
|
}
|
|
|
return $this->success($result);
|
|
return $this->success($result);
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -165,8 +206,7 @@ class Config extends Controller
|
|
|
* ]
|
|
* ]
|
|
|
*
|
|
*
|
|
|
*/
|
|
*/
|
|
|
- public
|
|
|
|
|
- function get()
|
|
|
|
|
|
|
+ public function get()
|
|
|
{
|
|
{
|
|
|
try {
|
|
try {
|
|
|
request()->validate([
|
|
request()->validate([
|
|
@@ -268,8 +308,7 @@ class Config extends Controller
|
|
|
* //更多行...
|
|
* //更多行...
|
|
|
* ]
|
|
* ]
|
|
|
*/
|
|
*/
|
|
|
- public
|
|
|
|
|
- function sendChannelMessage()
|
|
|
|
|
|
|
+ public function sendChannelMessage()
|
|
|
{
|
|
{
|
|
|
set_time_limit(0);
|
|
set_time_limit(0);
|
|
|
DB::beginTransaction();
|
|
DB::beginTransaction();
|
|
@@ -418,8 +457,7 @@ class Config extends Controller
|
|
|
* @apiParam {string} receiving_type 收款方式 1-自动 2-手动
|
|
* @apiParam {string} receiving_type 收款方式 1-自动 2-手动
|
|
|
*
|
|
*
|
|
|
*/
|
|
*/
|
|
|
- public
|
|
|
|
|
- function set()
|
|
|
|
|
|
|
+ public function set()
|
|
|
{
|
|
{
|
|
|
DB::beginTransaction();
|
|
DB::beginTransaction();
|
|
|
try {
|
|
try {
|