|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Created by PhpStorm.
|
|
|
|
* User: zhl
|
|
|
|
* Date: 2025/10/23
|
|
|
|
* Time: 10:23
|
|
|
|
*/
|
|
|
|
namespace App\Http\Controllers\Aside\Geo;
|
|
|
|
|
|
|
|
use App\Enums\Common\Code;
|
|
|
|
use App\Http\Controllers\Aside\BaseController;
|
|
|
|
use App\Models\Geo\GeoConf;
|
|
|
|
use App\Models\Geo\GeoConfirm;
|
|
|
|
use App\Models\Manage\ManageHr;
|
|
|
|
use App\Models\Project\KeywordPrefix;
|
|
|
|
use App\Models\Project\Project;
|
|
|
|
use App\Models\ProjectAssociation\ProjectAssociation;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class GeoController
|
|
|
|
* @package App\Http\Controllers\Aside\Geo
|
|
|
|
*/
|
|
|
|
class GeoController extends BaseController
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* 获取GEO相关配置
|
|
|
|
* @param Request $request
|
|
|
|
*/
|
|
|
|
public function getConfig(Request $request)
|
|
|
|
{
|
|
|
|
$this->request->validate([
|
|
|
|
'project_id' => 'required',
|
|
|
|
], [
|
|
|
|
'project_id.required' => '项目ID不能为空',
|
|
|
|
]);
|
|
|
|
|
|
|
|
$project_geo_conf = Project::select('title', 'version', 'geo_status', 'geo_qualify_num')->where(['project_id' => $this->param['project_id']])->first();
|
|
|
|
$geo_conf = GeoConf::where(['project_id' => $this->param['project_id']])->first();
|
|
|
|
$geo_manage_list = GeoConf::geoManage();
|
|
|
|
|
|
|
|
// geo配置管理员,已经移除管理员列表,补充管理员信息
|
|
|
|
if ($geo_conf && $geo_conf->manager_id && empty($geo_manage_list[$geo_conf->manager_id])) {
|
|
|
|
$manage = ManageHr::where(['id' => $geo_conf->manager_id])->pluck('name', 'id')->toArray();
|
|
|
|
$geo_manage_list = array_merge($geo_manage_list, $manage);
|
|
|
|
}
|
|
|
|
|
|
|
|
$result = [
|
|
|
|
'project_geo_conf' => $project_geo_conf,
|
|
|
|
'geo_conf' => $geo_conf,
|
|
|
|
'geo_manage_list' => $geo_manage_list,
|
|
|
|
'geo_keyword' => [
|
|
|
|
'prefix' => KeywordPrefix::getKeyword($this->param['project_id'], KeywordPrefix::TYPE_GEO_PREFIX),
|
|
|
|
'suffix' => KeywordPrefix::getKeyword($this->param['project_id'], KeywordPrefix::TYPE_GEO_SUFFIX),
|
|
|
|
],
|
|
|
|
];
|
|
|
|
$this->response('success', Code::SUCCESS, $result);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 保存GEO配置
|
|
|
|
* TODO 单独保存GEO开启状态, 达标数量
|
|
|
|
* @param Request $request
|
|
|
|
* @throws \App\Exceptions\AsideGlobalException
|
|
|
|
*/
|
|
|
|
public function saveConfig(Request $request)
|
|
|
|
{
|
|
|
|
$this->request->validate([
|
|
|
|
'project_id' => 'required',
|
|
|
|
'manager_id' => 'nullable|integer',
|
|
|
|
'company' => 'nullable|max:200',
|
|
|
|
'brand' => 'nullable|max:200',
|
|
|
|
'description' => 'nullable|max:500',
|
|
|
|
], [
|
|
|
|
'project_id.required' => '项目ID不能为空',
|
|
|
|
'manager_id.integer' => '管理员参数非法',
|
|
|
|
'company.max' => '公司名称不能超过200个字符',
|
|
|
|
'brand.max' => '品牌名不能超过200个字符',
|
|
|
|
'description.max' => '描述不能超过500个字符',
|
|
|
|
]);
|
|
|
|
|
|
|
|
try {
|
|
|
|
$data = GeoConf::saveConf($this->param['project_id'], $this->param['manager_id'], $this->param['company'], $this->param['brand'], $this->param['description'], $this->param['prefix'], $this->param['suffix']);
|
|
|
|
# FIXME 保存GEO状态 达标数量
|
|
|
|
$this->response('success', Code::SUCCESS, $data);
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
$this->fail('配置保存失败, error:' . $e->getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 保存确认数据, 并推送微信群
|
|
|
|
* @param Request $request
|
|
|
|
* @throws \App\Exceptions\AsideGlobalException
|
|
|
|
*/
|
|
|
|
public function saveConfirmContent(Request $request)
|
|
|
|
{
|
|
|
|
$this->request->validate([
|
|
|
|
'project_id' => 'required',
|
|
|
|
'type' => 'required|integer',
|
|
|
|
'content' => 'required',
|
|
|
|
'max_num' => 'required',
|
|
|
|
], [
|
|
|
|
'project_id.required' => '项目ID不能为空',
|
|
|
|
'type.required' => '确定数据类型不能为空',
|
|
|
|
'type.integer' => '确定数据类型不正确',
|
|
|
|
'content.required' => '确定数据不能为空',
|
|
|
|
'max_num.required' => '最大确认数量不能为空',
|
|
|
|
]);
|
|
|
|
|
|
|
|
try {
|
|
|
|
$data = GeoConfirm::saveContent($this->param['project_id'], $this->param['type'], $this->param['content'], $this->param['max_num']);
|
|
|
|
|
|
|
|
$friend = ProjectAssociation::where(['project_id' => $this->param['project_id']])->first();
|
|
|
|
if (empty($friend))
|
|
|
|
$this->fail('项目未绑定微信群, 推送消息失败!');
|
|
|
|
|
|
|
|
$data = GeoConfirm::sendConfirmMessage($data->id, $friend->friend_id);
|
|
|
|
|
|
|
|
$this->response('success', Code::SUCCESS, $data);
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
$this->fail('操作失败, error:' . $e->getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* OA后台管理员,保存确认数据
|
|
|
|
* 客户可以进行确认, OA后台也可以进行确认,以及修改
|
|
|
|
* @param Request $request
|
|
|
|
*/
|
|
|
|
public function saveConfirmData(Request $request)
|
|
|
|
{}
|
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|