|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Logic\Aside\Aicc;
|
|
|
|
|
|
|
|
use App\Enums\Common\Code;
|
|
|
|
use App\Http\Logic\Logic;
|
|
|
|
use App\Models\AICC\V6Aicc;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
|
|
class AiccV6Logic extends Logic
|
|
|
|
{
|
|
|
|
public function saveData()
|
|
|
|
{
|
|
|
|
$v6_project_id = (int)request()->post('project_id', 0);
|
|
|
|
if (empty($v6_project_id)) {
|
|
|
|
$this->fail('请选择项目!', Code::USER_PARAMS_ERROE);
|
|
|
|
}
|
|
|
|
$status = (bool)request()->post('status', 1); # 1 - 正常, 0 - 禁用
|
|
|
|
$aicc_user_id = (int)request()->post('aicc_user_id', 0);
|
|
|
|
if (empty($aicc_user_id) && $status) {
|
|
|
|
$this->fail('请选择要绑定的AICC用户!', Code::USER_PARAMS_ERROE);
|
|
|
|
}
|
|
|
|
$aicc_project_id = (int)request()->post('aicc_project_id', 0);
|
|
|
|
if (empty($aicc_project_id) && $status) {
|
|
|
|
$this->fail('请选择要绑定的AICC项目!', Code::USER_PARAMS_ERROE);
|
|
|
|
}
|
|
|
|
$aicc_nickname = request()->post('aicc_nickname', '');
|
|
|
|
$aicc_user_name = request()->post('aicc_user_name', '');
|
|
|
|
$aicc_image = request()->post('aicc_image', '');
|
|
|
|
$data = compact('v6_project_id', 'aicc_project_id', 'aicc_nickname', 'aicc_user_id', 'aicc_user_name', 'aicc_image');
|
|
|
|
$aicc = new V6Aicc();
|
|
|
|
DB::beginTransaction();
|
|
|
|
try {
|
|
|
|
$status = $aicc->saveData($data);
|
|
|
|
DB::commit();
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
DB::rollBack();
|
|
|
|
$e->getMessage();
|
|
|
|
errorLog('V6与AICC关联失败', $aicc, $e);
|
|
|
|
$this->fail('请检查操作是否正确!', Code::SERVER_MYSQL_ERROR);
|
|
|
|
}
|
|
|
|
return $this->success($status);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function V6AiccLists()
|
|
|
|
{
|
|
|
|
$page = (int)request()->route('page', 1);
|
|
|
|
$status = 1; # 1 - 正常, 0 - 禁用
|
|
|
|
$perPage = (int)request()->route('perPage', 15); # 分页页数
|
|
|
|
$lists = V6Aicc::query()->where('status', $status)
|
|
|
|
->whereNotNull('aicc_project_id')
|
|
|
|
->whereNotNull('aicc_user_id')
|
|
|
|
->paginate($perPage, ['v6_project_id', 'aicc_project_id', 'aicc_user_id'], 'page', $page);
|
|
|
|
$items = $lists->Items();
|
|
|
|
$totalPage = $lists->lastPage();
|
|
|
|
$total = $lists->total();
|
|
|
|
$currentPage = $lists->currentPage();
|
|
|
|
return compact('total', 'items', 'totalPage', 'currentPage');
|
|
|
|
}
|
|
|
|
} |