正在显示
1 个修改的文件
包含
48 行增加
和
18 行删除
| @@ -182,6 +182,7 @@ class ProjectLogic extends BaseLogic | @@ -182,6 +182,7 @@ class ProjectLogic extends BaseLogic | ||
| 182 | $this->setAiBlog($this->param['id'],$this->param['main_lang_id'],$this->param['is_ai_blog'] ?? 0, | 182 | $this->setAiBlog($this->param['id'],$this->param['main_lang_id'],$this->param['is_ai_blog'] ?? 0, |
| 183 | $this->param['company']??"", $this->param['deploy_optimize']['company_en_name'] ?? '', | 183 | $this->param['company']??"", $this->param['deploy_optimize']['company_en_name'] ?? '', |
| 184 | $this->param['deploy_optimize']['company_en_description'] ?? '',$this->param['is_ai_video'] ?? 0,$this->param['is_related_video'] ?? 0); | 184 | $this->param['deploy_optimize']['company_en_description'] ?? '',$this->param['is_ai_video'] ?? 0,$this->param['is_related_video'] ?? 0); |
| 185 | + $this->param = $this->getPaymentRamainDay($this->param); | ||
| 185 | //保存项目信息 | 186 | //保存项目信息 |
| 186 | $this->saveProject($this->param); | 187 | $this->saveProject($this->param); |
| 187 | //保存建站部署信息 | 188 | //保存建站部署信息 |
| @@ -412,6 +413,53 @@ class ProjectLogic extends BaseLogic | @@ -412,6 +413,53 @@ class ProjectLogic extends BaseLogic | ||
| 412 | } | 413 | } |
| 413 | 414 | ||
| 414 | /** | 415 | /** |
| 416 | + * @remark :推广续费网站设置剩余服务时常 | ||
| 417 | + * @name :getPaymentRamainDay | ||
| 418 | + * @author :lyh | ||
| 419 | + * @method :post | ||
| 420 | + * @time :2025/9/22 11:13 | ||
| 421 | + */ | ||
| 422 | + public function getPaymentRamainDay($param) | ||
| 423 | + { | ||
| 424 | + // 推广续费网站单独处理 | ||
| 425 | + if ($param['type'] == Project::TYPE_FOUR) { | ||
| 426 | + // 先找到 expire_at 不为 null 的记录 | ||
| 427 | + $validRecords = array_filter( | ||
| 428 | + $param['payment']['renewal_record'] ?? [], | ||
| 429 | + fn($item) => !is_null($item['expire_at'] ?? null) | ||
| 430 | + ); | ||
| 431 | + $maxExpireAt = null; | ||
| 432 | + if ($validRecords) { | ||
| 433 | + // 取出最大日期 | ||
| 434 | + $maxExpireAt = max(array_column($validRecords, 'expire_at')); | ||
| 435 | + } | ||
| 436 | + if (!$maxExpireAt) { | ||
| 437 | + return $this->success($param); | ||
| 438 | + } | ||
| 439 | + // 遍历原始 renewal_record(用引用,方便写回) | ||
| 440 | + foreach ($param['payment']['renewal_record'] as &$record) { | ||
| 441 | + if (!is_null($record['expire_at'] ?? null) && $record['expire_at'] === $maxExpireAt) { | ||
| 442 | + // 如果 end_time 不存在或与 expire_at 不一致,则更新 | ||
| 443 | + if (!isset($record['end_time']) || $record['end_time'] != $record['expire_at']) { | ||
| 444 | + $record['end_time'] = $record['expire_at']; // ✅ 写回原数据 | ||
| 445 | + // 重新计算剩余天数 | ||
| 446 | + $diff = (strtotime($record['expire_at']) - strtotime(date('Y-m-d'))) / (60 * 60 * 24); | ||
| 447 | + if ($param['project_type'] == Project::PROJECT_TYPE_SEO) { | ||
| 448 | + $param['deploy_build']['seo_service_duration'] = $diff + $param['bm_finish_remain_day']; | ||
| 449 | + } else { | ||
| 450 | + $param['deploy_build']['service_duration'] = $diff + $param['finish_remain_day']; | ||
| 451 | + } | ||
| 452 | + } | ||
| 453 | + break; // 找到后跳出循环 | ||
| 454 | + } | ||
| 455 | + } | ||
| 456 | + unset($record); // 释放引用 | ||
| 457 | + } | ||
| 458 | + return $this->success($param); | ||
| 459 | + } | ||
| 460 | + | ||
| 461 | + | ||
| 462 | + /** | ||
| 415 | * @remark :保存项目 | 463 | * @remark :保存项目 |
| 416 | * @name :setExtendType | 464 | * @name :setExtendType |
| 417 | * @author :lyh | 465 | * @author :lyh |
| @@ -751,24 +799,6 @@ class ProjectLogic extends BaseLogic | @@ -751,24 +799,6 @@ class ProjectLogic extends BaseLogic | ||
| 751 | //改为异步 | 799 | //改为异步 |
| 752 | NoticeLog::createLog(NoticeLog::TYPE_INIT_PROJECT, ['project_id' => $param['id']]); | 800 | NoticeLog::createLog(NoticeLog::TYPE_INIT_PROJECT, ['project_id' => $param['id']]); |
| 753 | } | 801 | } |
| 754 | - //推广续费网站单独处理 | ||
| 755 | - if($param['type'] == Project::TYPE_FOUR){ | ||
| 756 | - // 提取非 null 的 expire_at 字段 | ||
| 757 | - $validDates = array_filter( | ||
| 758 | - array_column($param['payment']['renewal_record'] ?? [], 'expire_at'), | ||
| 759 | - fn($date) => !is_null($date) | ||
| 760 | - ); | ||
| 761 | - // 获取最大日期(如果有) | ||
| 762 | - $maxExpireAt = $validDates ? max($validDates) : null; | ||
| 763 | - if(!empty($maxExpireAt)){ | ||
| 764 | - $diff = (strtotime($maxExpireAt) - strtotime( date('Y-m-d'))) / (60 * 60 * 24); | ||
| 765 | - if($param['project_type'] == Project::PROJECT_TYPE_SEO){ | ||
| 766 | - $param['deploy_build']['seo_service_duration'] = $diff + $param['bm_finish_remain_day']; | ||
| 767 | - }else{ | ||
| 768 | - $param['deploy_build']['service_duration'] = $diff + $param['finish_remain_day']; | ||
| 769 | - } | ||
| 770 | - } | ||
| 771 | - } | ||
| 772 | return $this->success($param); | 802 | return $this->success($param); |
| 773 | } | 803 | } |
| 774 | 804 |
-
请 注册 或 登录 后发表评论