|
@@ -0,0 +1,137 @@
|
|
|
|
|
+<?php
|
|
|
|
|
+
|
|
|
|
|
+namespace App\Http\Controllers\admin;
|
|
|
|
|
+
|
|
|
|
|
+use App\Http\Controllers\Controller;
|
|
|
|
|
+use App\Models\RechargeChannel as RechargeChannelModel;
|
|
|
|
|
+use App\Models\RechargeChannelGroup;
|
|
|
|
|
+use Exception;
|
|
|
|
|
+use App\Constants\HttpStatus;
|
|
|
|
|
+
|
|
|
|
|
+class RechargeChannel extends Controller
|
|
|
|
|
+{
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 充值通道组合列表
|
|
|
|
|
+ */
|
|
|
|
|
+ public function groupList()
|
|
|
|
|
+ {
|
|
|
|
|
+ try {
|
|
|
|
|
+ $page = request()->input('page', 1);
|
|
|
|
|
+ $limit = request()->input('limit', 15);
|
|
|
|
|
+
|
|
|
|
|
+ $query = new RechargeChannelGroup();
|
|
|
|
|
+ $count = $query->count();
|
|
|
|
|
+ $list = $query->with(['rechargeChannel'])
|
|
|
|
|
+ ->forPage($page, $limit)
|
|
|
|
|
+ ->get();
|
|
|
|
|
+ } catch (Exception $e) {
|
|
|
|
|
+ return $this->error(HttpStatus::CUSTOM_ERROR,$e->getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ return $this->success(['total' => $count, 'data' => $list]);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 充值通道组合管理更新
|
|
|
|
|
+ */
|
|
|
|
|
+ public function updateGroup()
|
|
|
|
|
+ {
|
|
|
|
|
+ try {
|
|
|
|
|
+ $params = request()->validate([
|
|
|
|
|
+ 'id' => ['nullable','integer'],
|
|
|
|
|
+ 'name' => ['nullable','string'],
|
|
|
|
|
+ 'channel_ids' => ['nullable','string'],
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ if (empty($params['id'])) {
|
|
|
|
|
+ RechargeChannelGroup::create($params);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $info = RechargeChannelGroup::where('id', $params['id'])->first();
|
|
|
|
|
+ if (!$info) throw new Exception('数据不存在');
|
|
|
|
|
+ $info->update($params);
|
|
|
|
|
+ $info->save();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return $this->success();
|
|
|
|
|
+ } catch (Exception $e) {
|
|
|
|
|
+ return $this->error(HttpStatus::CUSTOM_ERROR,$e->getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 充值通道管理列表
|
|
|
|
|
+ */
|
|
|
|
|
+ public function list()
|
|
|
|
|
+ {
|
|
|
|
|
+ try {
|
|
|
|
|
+ $params = request()->validate([
|
|
|
|
|
+ 'page' => ['nullable', 'integer', 'min:1'],
|
|
|
|
|
+ 'limit' => ['nullable', 'integer', 'min:1'],
|
|
|
|
|
+ 'type' => ['nullable', 'string'],
|
|
|
|
|
+ 'from' => ['nullable', 'integer'],
|
|
|
|
|
+ 'key' => ['nullable', 'string'],
|
|
|
|
|
+ 'name' => ['nullable', 'string'],
|
|
|
|
|
+ ]);
|
|
|
|
|
+ $page = request()->input('page', 1);
|
|
|
|
|
+ $limit = request()->input('limit', 15);
|
|
|
|
|
+
|
|
|
|
|
+ $query = new RechargeChannelModel();
|
|
|
|
|
+ if (!empty($params['type'])) {
|
|
|
|
|
+ $query = $query->where('type', $params['type']);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (isset($params['from'])) {
|
|
|
|
|
+ $query = $query->where('from', $params['from']);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!empty($params['key'])) {
|
|
|
|
|
+ $query = $query->where('key', $params['key']);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!empty($params['name'])) {
|
|
|
|
|
+ $query = $query->where('name', 'like', '%'.$params['name'].'%');
|
|
|
|
|
+ }
|
|
|
|
|
+ $count = $query->count();
|
|
|
|
|
+ $list = $query
|
|
|
|
|
+ ->forPage($page, $limit)
|
|
|
|
|
+ ->orderBy('sort', 'asc')
|
|
|
|
|
+ ->get();
|
|
|
|
|
+ } catch (Exception $e) {
|
|
|
|
|
+ return $this->error(HttpStatus::CUSTOM_ERROR,$e->getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ return $this->success(['total' => $count, 'data' => $list]);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 充值通道管理更新
|
|
|
|
|
+ */
|
|
|
|
|
+ public function update()
|
|
|
|
|
+ {
|
|
|
|
|
+ try {
|
|
|
|
|
+ $params = request()->validate([
|
|
|
|
|
+ 'id' => ['nullable','integer'],
|
|
|
|
|
+ 'from' => ['nullable','integer'],
|
|
|
|
|
+ 'key' => ['nullable','string'],
|
|
|
|
|
+ 'name' => ['nullable','string'],
|
|
|
|
|
+ 'type' => ['required','string'],
|
|
|
|
|
+ 'rate' => ['required','numeric'],
|
|
|
|
|
+ 'min_amount' => ['nullable','integer'],
|
|
|
|
|
+ 'max_amount' => ['nullable','integer'],
|
|
|
|
|
+ 'fixed_amounts' => ['nullable','string'],
|
|
|
|
|
+ 'status' => ['nullable','integer'],
|
|
|
|
|
+ 'sort' => ['nullable','integer'],
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ if (empty($params['id'])) {
|
|
|
|
|
+ RechargeChannelModel::create($params);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $info = RechargeChannelModel::where('id', $params['id'])->first();
|
|
|
|
|
+ if (!$info) throw new Exception('数据不存在');
|
|
|
|
|
+ $info->update($params);
|
|
|
|
|
+ $info->save();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return $this->success();
|
|
|
|
|
+ } catch (Exception $e) {
|
|
|
|
|
+ return $this->error(HttpStatus::CUSTOM_ERROR,$e->getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|