正在显示
4 个修改的文件
包含
102 行增加
和
0 行删除
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Controllers\Bside\Aicc; | ||
| 4 | + | ||
| 5 | +use App\Enums\Common\Code; | ||
| 6 | +use App\Http\Controllers\Bside\BaseController; | ||
| 7 | +use App\Http\Logic\Aside\Aicc\AiccV6Logic; | ||
| 8 | + | ||
| 9 | +class AiccV6Controller extends BaseController | ||
| 10 | +{ | ||
| 11 | + public function save(AiccV6Logic $aiccV6Logic) | ||
| 12 | + { | ||
| 13 | + $aiccV6Logic->saveData(); | ||
| 14 | + $this->response('success'); | ||
| 15 | + } | ||
| 16 | +} |
app/Http/Logic/Aside/Aicc/AiccV6Logic.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Logic\Aside\Aicc; | ||
| 4 | + | ||
| 5 | +use App\Enums\Common\Code; | ||
| 6 | +use App\Http\Logic\Logic; | ||
| 7 | +use App\Models\AICC\V6Aicc; | ||
| 8 | +use Illuminate\Support\Facades\DB; | ||
| 9 | +use function Symfony\Component\String\b; | ||
| 10 | + | ||
| 11 | +class AiccV6Logic extends Logic | ||
| 12 | +{ | ||
| 13 | + public function saveData() | ||
| 14 | + { | ||
| 15 | + $v6_project_id = (int)request()->post('project_id', 0); | ||
| 16 | + if (empty($v6_project_id)) { | ||
| 17 | + $this->fail('请选择项目!', Code::USER_PARAMS_ERROE); | ||
| 18 | + } | ||
| 19 | + $status = (bool)request()->post('status', 1); # 1 - 正常, 0 - 禁用 | ||
| 20 | + $aicc_user_id = (int)request()->post('aicc_user_id', 0); | ||
| 21 | + if (empty($aicc_user_id) && $status) { | ||
| 22 | + $this->fail('请选择要绑定的AICC用户!', Code::USER_PARAMS_ERROE); | ||
| 23 | + } | ||
| 24 | + $aicc_project_id = (int)request()->post('aicc_project_id', 0); | ||
| 25 | + if (empty($aicc_project_id) && $status) { | ||
| 26 | + $this->fail('请选择要绑定的AICC项目!', Code::USER_PARAMS_ERROE); | ||
| 27 | + } | ||
| 28 | + $aicc_nickname = request()->post('aicc_nickname', ''); | ||
| 29 | + $aicc_user_name = request()->post('aicc_user_name', ''); | ||
| 30 | + $aicc_image = request()->post('aicc_image', ''); | ||
| 31 | + $data = compact('v6_project_id', 'aicc_project_id', 'aicc_nickname', 'aicc_user_id', 'aicc_user_name', 'aicc_image'); | ||
| 32 | + $aicc = new V6Aicc(); | ||
| 33 | + DB::beginTransaction(); | ||
| 34 | + try { | ||
| 35 | + $status = $aicc->saveData($data); | ||
| 36 | + DB::commit(); | ||
| 37 | + } catch (\Exception $e) { | ||
| 38 | + DB::rollBack(); | ||
| 39 | + $this->fail('请检查操作是否正确!', Code::SERVER_MYSQL_ERROR); | ||
| 40 | + } | ||
| 41 | + return $this->success($status); | ||
| 42 | + } | ||
| 43 | +} |
app/Models/AICC/V6Aicc.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Models\AICC; | ||
| 4 | + | ||
| 5 | +use Illuminate\Database\Eloquent\Builder; | ||
| 6 | +use Illuminate\Database\Eloquent\Model; | ||
| 7 | + | ||
| 8 | +class V6Aicc extends Model | ||
| 9 | +{ | ||
| 10 | + protected $table = 'gl_v6_aicc'; | ||
| 11 | + | ||
| 12 | + /** | ||
| 13 | + * 保存|修改数据 | ||
| 14 | + * @param array $data | ||
| 15 | + * @return bool | ||
| 16 | + */ | ||
| 17 | + public function saveData(array $data): bool | ||
| 18 | + { | ||
| 19 | + $project_id = (int)$data['v6_project_id'] ?? 0; | ||
| 20 | + $isRes = self::query()->where('v6_project_id', $project_id)->first(); | ||
| 21 | + if (!$isRes) { | ||
| 22 | + $isRes = new self(); | ||
| 23 | + $isRes->v6_project_id = $project_id; | ||
| 24 | + } | ||
| 25 | + $isRes->aicc_project_id = $data['aicc_project_id']; | ||
| 26 | + $isRes->aicc_nickname = $data['aicc_nickname']; | ||
| 27 | + $isRes->aicc_user_id = $data['aicc_user_id']; | ||
| 28 | + $isRes->aicc_user_name = $data['aicc_user_name']; | ||
| 29 | + $isRes->aicc_image = $data['aicc_image']; | ||
| 30 | + return $isRes->save(); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + /** | ||
| 34 | + * 检查项目是否存在 | ||
| 35 | + * @param $project_id | ||
| 36 | + * @return Builder|Model|object|null | ||
| 37 | + */ | ||
| 38 | + public function check($project_id) | ||
| 39 | + { | ||
| 40 | + return self::query()->where('v6_project_id', $project_id)->first(); | ||
| 41 | + } | ||
| 42 | +} |
| @@ -13,6 +13,7 @@ Route::middleware(['aloginauth'])->group(function () { | @@ -13,6 +13,7 @@ Route::middleware(['aloginauth'])->group(function () { | ||
| 13 | Route::any('/editPassword', [Aside\Com\IndexController::class, 'editPassword'])->name('admin.editPassword.white'); | 13 | Route::any('/editPassword', [Aside\Com\IndexController::class, 'editPassword'])->name('admin.editPassword.white'); |
| 14 | Route::get('/logout', [Aside\LoginController::class, 'logout'])->name('admin.logout.white'); | 14 | Route::get('/logout', [Aside\LoginController::class, 'logout'])->name('admin.logout.white'); |
| 15 | Route::any('/getAccessAddress', [Aside\LoginController::class, 'getAccessAddress'])->name('admin.getAccessAddress');//获取B端地址 | 15 | Route::any('/getAccessAddress', [Aside\LoginController::class, 'getAccessAddress'])->name('admin.getAccessAddress');//获取B端地址 |
| 16 | + Route::post('/v6_aicc', [\App\Http\Controllers\Bside\Aicc\AiccV6Controller::class, 'save'])->name('admin.v6_aicc'); | ||
| 16 | //会员相关 | 17 | //会员相关 |
| 17 | Route::prefix('user')->group(function () { | 18 | Route::prefix('user')->group(function () { |
| 18 | //会员管理 | 19 | //会员管理 |
-
请 注册 或 登录 后发表评论