作者 lyh

gx

... ... @@ -112,13 +112,14 @@ class ProjectLogic extends BaseLogic
public function getProjectInfo($id){
$info = Common::get_user_cache($this->model->getTable(),$id);
if(empty($info)){
$info = $this->model->with('payment')->with('deploy_build')
->with('deploy_optimize')->with('online_check')
$info = $this->model->with('payment')->with('deploy_build')->with('deploy_optimize')->with('online_check')
->with('project_after')->where(['id'=>$id])->first()->toArray();
if(!empty($info['online_check']['created_manage_id'])){
$info['online_check']['name'] = (new Manage())->read(['id'=>$info['online_check']['created_manage_id']])['name'] ?? '';
}
$info['deploy_optimize']['minor_keywords'] = json_decode($info['deploy_optimize']['minor_keywords']) ?? '';
if(isset($info['deploy_optimize']['minor_keywords']) && !empty($info['deploy_optimize']['minor_keywords'])){
$info['deploy_optimize']['minor_keywords'] = json_decode($info['deploy_optimize']['minor_keywords']) ?? '';
}
if($info['extend_type'] != 0){
$info['type'] = $info['extend_type'];
}
... ... @@ -135,10 +136,10 @@ class ProjectLogic extends BaseLogic
* @time :2023/8/17 14:19
*/
public function save($param){
// DB::beginTransaction();
// try {
if($param['type'] == 5){
$param['extend_type'] == 5;
DB::beginTransaction();
try {
if($param['type'] == Project::TYPE_FIVE){
$param['extend_type'] == Project::TYPE_FIVE;
unset($param['type']);
}
$res = parent::save($param);
... ... @@ -148,12 +149,12 @@ class ProjectLogic extends BaseLogic
$this->saveDeployBuild($param);
$this->saveDeployOptimize($param);
$this->saveAfter($param);
// DB::commit();
// }catch (\Exception $e){
// DB::rollBack();
// errorLog('项目保存失败', $param, $e);
// $this->fail('保存失败');
// }
DB::commit();
}catch (\Exception $e){
DB::rollBack();
errorLog('项目保存失败', $param, $e);
$this->fail('保存失败');
}
return $this->success();
}
... ... @@ -291,11 +292,11 @@ class ProjectLogic extends BaseLogic
public function channelSource($param){
switch ($param['type']){
case 1:
case Project::TYPE_ONE:
return Zone::pluck('title', 'id')->toArray();
case 2:
case Project::TYPE_TWO:
return Channel::where('zone_id', $param['zone_id']??0)->pluck('alias', 'id')->toArray();
case 3:
case Project::TYPE_THREE:
return User::where('channel_id', $param['channel_id']??0)->pluck('name', 'id')->toArray();
}
return [];
... ... @@ -378,9 +379,9 @@ class ProjectLogic extends BaseLogic
*/
public function setPostId($plan,$id){
$length = strlen((string)$id); // 获取变量的位数
$paddingLength = 5 - $length; // 计算填充前面的 0 的位数
$paddingLength = Project::TYPE_FIVE - $length; // 计算填充前面的 0 的位数
$zeros = str_repeat("0", $paddingLength);
$number = '6'.$plan.$zeros.$id;
$number = Project::TYPE_SIX.$plan.$zeros.$id;
$projectModel = new Project();
$projectModel->edit(['post_id'=>$number],['id'=>$id]);
return true;
... ...