作者 李宇航

合并分支 'lyh-server' 到 'master'

Lyh server



查看合并请求 !1672
... ... @@ -95,7 +95,7 @@ class RemainDay extends Command
if($item['type'] != Project::TYPE_THREE){
$pause_days = $item['pause_days'] + 1;
}
// $this->project->edit(['pause_days'=>$pause_days],['id'=>$item['id']]);
$this->project->edit(['pause_days'=>$pause_days],['id'=>$item['id']]);
continue;
}
//白帽版本的系统
... ... @@ -110,11 +110,11 @@ class RemainDay extends Command
$seo_remain_day = 0;
}
if($deploy_build['plan'] == 0 && $seo_remain_day == 0 && $deploy_build['seo_service_duration'] != 0){//只有白帽版本的项目且剩余服务时常未0,放入未续费中
// $this->project->edit(['seo_remain_day'=>$seo_remain_day,'extend_type'=>Project::TYPE_FIVE],['id'=>$item['id']]);
$this->project->edit(['seo_remain_day'=>$seo_remain_day,'extend_type'=>Project::TYPE_FIVE],['id'=>$item['id']]);
continue;
}
//同时包括白帽版本+默认版本的项目
// $this->project->edit(['seo_remain_day'=>$seo_remain_day],['id'=>$item['id']]);
$this->project->edit(['seo_remain_day'=>$seo_remain_day],['id'=>$item['id']]);
}
//默认版本计算剩余服务时常
if($item['type'] == Project::TYPE_TWO || $item['type'] == Project::TYPE_FOUR){
... ... @@ -144,7 +144,7 @@ class RemainDay extends Command
$remain_day = 0;
$extend_type = Project::TYPE_FIVE;
}
// $this->project->edit(['remain_day'=>$remain_day,'extend_type'=>$extend_type],['id'=>$item['id']]);
$this->project->edit(['remain_day'=>$remain_day,'extend_type'=>$extend_type],['id'=>$item['id']]);
echo 'end->项目id:' . $item['id'] . '执行时间:'. date('Y-m-d H:i:s') . PHP_EOL;
}
return true;
... ...
... ... @@ -13,6 +13,7 @@ use App\Enums\Common\Code;
use App\Helper\FormGlobalsoApi;
use App\Helper\PayStripeApi;
use App\Helper\Translate;
use App\Http\Logic\Bside\Gpt\ChatLogic;
use App\Http\Logic\Bside\News\NewsLogic;
use App\Models\Ai\AiBlog;
use App\Models\Channel\Channel;
... ... @@ -41,9 +42,13 @@ class TestController extends BaseController
* @method :post
* @time :2025/2/13 16:34
*/
public function ceshi(){
//获取上一周询盘数量
$transData = Translate::tran(['heidenhain programming','heidenhain tnc 620'], 'zh');
$this->response('success',Code::SUCCESS,$transData);
public function ceshi(ChatLogic $logic){
$this->request->validate([
'message'=>['required'],
],[
'message.required' => '消息内容不能为空',
]);
$data = $logic->sendMessage();
$this->response('success',Code::SUCCESS,$data);
}
}
... ...
... ... @@ -11,6 +11,8 @@ namespace App\Http\Logic\Bside\Gpt;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Gpt\Chat;
use App\Models\Gpt\ChatItem;
use App\Services\GptService;
class ChatLogic extends BaseLogic
{
... ... @@ -18,6 +20,7 @@ class ChatLogic extends BaseLogic
{
parent::__construct();
$this->model = new Chat();
$this->itemModel = new ChatItem();
}
/**
... ... @@ -28,18 +31,37 @@ class ChatLogic extends BaseLogic
* @time :2025/4/2 10:01
*/
public function sendMessage(){
$gptService = new GptService();
if(isset($this->param['chat_id'])){
$chatInfo = $this->model->read(['id'=>$this->param['chat_id']]);
if($chatInfo === false){
$id = $this->saveChat($this->param['message']);
}else{
$id = $chatInfo['id'];
if($chatInfo !== false){
$list = $this->itemModel->list(['chat_id'=>$chatInfo['id'],'id',['*'],'desc',2]);
$message[] = ['role' => 'system', 'content' => "You are now the marketing customer service of 深圳创贸集团"];
foreach ($list as $val){
if($val['is_reply'] == 2){
$message[] = ['role' => 'user', 'content' => $val['content']];
}else{
$message[] = ['role' => 'assistant', 'content' => $val['content']];
}
}
$message[] = ['role' => 'user', 'content' => $this->param['message']];
$data = [
'message'=>$message,
];
$result = $gptService->get_ai_chat($data);
}
}else{
$id = $this->saveChat($this->param['message']);
}
// $id = $this->saveChat($this->param['message']);
// $this->saveChatItem($id,$this->param['message']);
$data = [
'message'=>[
['role' => 'system', 'content' => "You are now the marketing customer service of 深圳创贸集团"],
['role' => 'user', 'content' => $this->param['message']]
],
];
$result = $gptService->get_ai_chat($data);
$this->success($result);
}
/**
... ... @@ -57,4 +79,22 @@ class ChatLogic extends BaseLogic
];
return $this->model->addReturnId($saveData);
}
/**
* @remark :消息详情表保存一条记录
* @name :saveChatItem
* @author :lyh
* @method :post
* @time :2025/4/2 13:45
*/
public function saveChatItem($id,$message){
//创建一个会话
$saveData = [
'user_id'=>$this->user['id'],
'is_reply'=>2,
'chat_id'=>$id,
'content'=>$message,
];
return $this->itemModel->addReturnId($saveData);
}
}
... ...