From 11e0982845b0259a7280abc581a505706c11db40 Mon Sep 17 00:00:00 2001 From: fuzhongyun <15339891972@163.com> Date: Thu, 8 Jan 2026 15:44:59 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E6=97=A5=E6=8A=A5?= =?UTF-8?q?=E8=B4=A7=E6=98=93=E9=80=9A=E5=BE=AE=E4=BF=A1=E7=BE=A4=E7=BB=84?= =?UTF-8?q?=E5=8F=91=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/config.yaml | 2 +- config/config_env.yaml | 11 +++++++ config/config_test.yaml | 2 +- internal/biz/qywx_app.go | 59 +++++++++++++++++++++++++++++++++++ internal/biz/qywx_app_test.go | 3 +- 5 files changed, 74 insertions(+), 3 deletions(-) diff --git a/config/config.yaml b/config/config.yaml index 8eb23e5..37b65aa 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -165,7 +165,7 @@ qywx: chat_id_len: 16 default_config_id: 1 bot_group_id: - bbxt: 23 + bbxt: 37 default_prompt: img_recognize: diff --git a/config/config_env.yaml b/config/config_env.yaml index b571f51..d99d144 100644 --- a/config/config_env.yaml +++ b/config/config_env.yaml @@ -148,6 +148,17 @@ dingtalk: bot_group_id: bbxt: 23 +qywx: + corp_id: "ww48151f694fb8ec67" + app_secret: "uYqtdwdtdH4Uv_P4is2AChuGzBCoB6cQDyRvpbW0Vmk" + token: "zJdukry6" + aes_key: "4VLH47qRGUogc2d3QLWuUhvJlk8Y0YuRjXzeBquBq8B" + init_account: "les.,FuZhongYun" + chat_id_len: 16 + default_config_id: 1 + bot_group_id: + bbxt: 36 + default_prompt: img_recognize: diff --git a/config/config_test.yaml b/config/config_test.yaml index 461b459..c993b35 100644 --- a/config/config_test.yaml +++ b/config/config_test.yaml @@ -160,7 +160,7 @@ qywx: chat_id_len: 16 default_config_id: 1 bot_group_id: - bbxt: 35 + bbxt: 36 default_prompt: img_recognize: diff --git a/internal/biz/qywx_app.go b/internal/biz/qywx_app.go index 3f7fbe0..b77fc9e 100644 --- a/internal/biz/qywx_app.go +++ b/internal/biz/qywx_app.go @@ -3,11 +3,14 @@ package biz import ( "ai_scheduler/internal/biz/handle/qywx" "ai_scheduler/internal/data/constants" + errors "ai_scheduler/internal/data/error" "ai_scheduler/internal/data/impl" "ai_scheduler/internal/data/model" "ai_scheduler/internal/pkg" + "ai_scheduler/internal/pkg/l_request" "ai_scheduler/internal/tools/bbxt" "context" + "log" "strings" "time" @@ -105,3 +108,59 @@ func (q *QywxAppBiz) SendReport(ctx context.Context, groupInfo *model.AiBotGroup } return } + +// SendReportV2 发送到货易通指定的群聊 +func (q *QywxAppBiz) SendReportHYT(ctx context.Context, groupInfo *model.AiBotGroupQywx, report *bbxt.ReportRes) (err error) { + // 文本消息 + err = q.sendReportHYT(groupInfo, &bbxt.ReportRes{ + Title: report.Title, + }) + if err != nil { + return err + } + + time.Sleep(1 * time.Second) // 等待1秒,避免被频控 + + // 图片消息 + err = q.sendReportHYT(groupInfo, &bbxt.ReportRes{ + ReportName: report.ReportName, + Url: report.Url, + }) + if err != nil { + return err + } + + time.Sleep(1 * time.Second) // 等待1秒,避免被频控 + + return nil +} + +func (q *QywxAppBiz) sendReportHYT(groupInfo *model.AiBotGroupQywx, report *bbxt.ReportRes) (err error) { + req := l_request.Request{ + Method: "POST", + Url: "https://hyt.86698.cn/admin_upload/api/v1/sendWxCommon", + Headers: map[string]string{ + "Content-Type": "application/json", + }, + Json: map[string]interface{}{ + "room_id": groupInfo.ChatID, // 群ID + "oss_url": report.Url, // 图片URL + "file_type": 2, // 文件类型,2:图片 + "file_name": report.ReportName, // 文件名称 + "content": report.Title, // 输入文本,此处有值就走文本发送,没有就走文件发送 + }, + } + + resp, err := req.Send() + if err != nil { + return err + } + if resp.StatusCode != 200 { + return errors.SysErrf("发送到货易通群聊失败,状态码:%d", resp.StatusCode) + } + + // 记录相应结果日志 + log.Printf("发送到货易通群聊成功,状态码:%d, 响应体:%s", resp.StatusCode, resp.Text) + + return nil +} diff --git a/internal/biz/qywx_app_test.go b/internal/biz/qywx_app_test.go index 542ced5..2e40d4a 100644 --- a/internal/biz/qywx_app_test.go +++ b/internal/biz/qywx_app_test.go @@ -28,5 +28,6 @@ func run() { botGroupQywxImpl := impl.NewBotGroupQywxImpl(db) qywxAuth := qywx.NewAuth(configConfig, rdb) group := qywx.NewGroup(botGroupQywxImpl, qywxAuth) - qywxAppBiz = NewQywxAppBiz(configConfig, botGroupQywxImpl, group) + other := qywx.NewOther(qywxAuth) + qywxAppBiz = NewQywxAppBiz(configConfig, botGroupQywxImpl, group, other) }