Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
ai
/
ai-workflow
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 3d2c5503
authored
Jul 22, 2026
by
sunqi02
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix: 更新企业微信群机器人 webhook URL 配置
1 parent
d457ba85
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
7 deletions
workspace/agent-admin/backend/.env.example
workspace/agent-admin/backend/app/customer_info/service.py
workspace/agent-admin/backend/app/customer_info/weekly_report_service.py
workspace/agent-admin/backend/.env.example
View file @
3d2c550
...
@@ -15,7 +15,7 @@ COURSE_BASE_URL=http://lessonjump.test.glsx.com.cn/
...
@@ -15,7 +15,7 @@ COURSE_BASE_URL=http://lessonjump.test.glsx.com.cn/
QUERY_URL=http://192.168.1.71:8104/wiki/query/json
QUERY_URL=http://192.168.1.71:8104/wiki/query/json
# 企业微信群机器人 webhook(周报推送)
# 企业微信群机器人 webhook(周报推送)
WECOM_WEBHOOK_URL=https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=
your_webhook_key_here
WECOM_WEBHOOK_URL=https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=
6a4a519c-db14-41c9-8ef7-8ab780c4ec0b
# 数据库
# 数据库
DB_HOST=192.168.3.92
DB_HOST=192.168.3.92
...
...
workspace/agent-admin/backend/app/customer_info/service.py
View file @
3d2c550
from
__future__
import
annotations
from
__future__
import
annotations
import
logging
import
logging
from
datetime
import
timedelta
from
typing
import
Optional
from
typing
import
Optional
from
sqlalchemy
import
func
,
text
from
sqlalchemy
import
func
,
text
...
@@ -86,7 +87,8 @@ class CustomerInfoService:
...
@@ -86,7 +87,8 @@ class CustomerInfoService:
"""获取需要推送的记录。
"""获取需要推送的记录。
mode='sync': 同步触发推送, 仅 last_pushed_at IS NULL 的新记录。
mode='sync': 同步触发推送, 仅 last_pushed_at IS NULL 的新记录。
mode='daily': 每日推送, 包含从未推送或上次推送日期非今日的记录。
mode='daily': 每日推送, 仅推送创建时间在近 3 天内的记录(t, t+1, t+2),
且从未推送或上次推送日期非今日。
"""
"""
now
=
china_now
()
now
=
china_now
()
today
=
now
.
date
()
today
=
now
.
date
()
...
@@ -99,9 +101,13 @@ class CustomerInfoService:
...
@@ -99,9 +101,13 @@ class CustomerInfoService:
if
mode
==
"sync"
:
if
mode
==
"sync"
:
candidates
=
base_query
.
filter
(
CustomerGroupPhone
.
last_pushed_at
.
is_
(
None
))
.
all
()
candidates
=
base_query
.
filter
(
CustomerGroupPhone
.
last_pushed_at
.
is_
(
None
))
.
all
()
elif
mode
==
"daily"
:
elif
mode
==
"daily"
:
window_start
=
today
-
timedelta
(
days
=
2
)
candidates
=
base_query
.
filter
(
candidates
=
base_query
.
filter
(
(
CustomerGroupPhone
.
last_pushed_at
.
is_
(
None
))
(
|
(
func
.
date
(
CustomerGroupPhone
.
last_pushed_at
)
<
today
)
(
CustomerGroupPhone
.
last_pushed_at
.
is_
(
None
))
|
(
func
.
date
(
CustomerGroupPhone
.
last_pushed_at
)
<
today
)
),
func
.
date
(
CustomerGroupPhone
.
create_time
)
.
between
(
window_start
,
today
),
)
.
all
()
)
.
all
()
else
:
else
:
raise
ValueError
(
f
"Unknown push mode: {mode}"
)
raise
ValueError
(
f
"Unknown push mode: {mode}"
)
...
...
workspace/agent-admin/backend/app/customer_info/weekly_report_service.py
View file @
3d2c550
...
@@ -15,7 +15,7 @@ logger = logging.getLogger(__name__)
...
@@ -15,7 +15,7 @@ logger = logging.getLogger(__name__)
WECOM_WEBHOOK_URL
=
os
.
getenv
(
WECOM_WEBHOOK_URL
=
os
.
getenv
(
"WECOM_WEBHOOK_URL"
,
"WECOM_WEBHOOK_URL"
,
"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=
6a4a519c-db14-41c9-8ef7-8ab780c4ec0b
"
,
"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=
c1357c4b-c802-4b93-93d9-e871301a4015
"
,
)
)
...
@@ -33,25 +33,29 @@ class WeeklyReportService:
...
@@ -33,25 +33,29 @@ class WeeklyReportService:
new_groups: 过去7天新增的群数
new_groups: 过去7天新增的群数
bound_groups: 已绑定手机号的群数
bound_groups: 已绑定手机号的群数
pass_rate: 认证通过率(已绑定 / 总群数 * 100)
pass_rate: 认证通过率(已绑定 / 总群数 * 100)
overdue_unbound_groups: 创建超过3天仍未绑定手机号的群数
"""
"""
now
=
china_now
()
now
=
china_now
()
seven_days_ago
=
now
-
timedelta
(
days
=
7
)
seven_days_ago
=
now
-
timedelta
(
days
=
7
)
three_days_ago
=
now
-
timedelta
(
days
=
3
)
row
=
self
.
db
.
execute
(
row
=
self
.
db
.
execute
(
text
(
"""
text
(
"""
SELECT
SELECT
COUNT(*) AS total_groups,
COUNT(*) AS total_groups,
SUM(CASE WHEN create_time >= :seven_days_ago THEN 1 ELSE 0 END) AS new_groups,
SUM(CASE WHEN create_time >= :seven_days_ago THEN 1 ELSE 0 END) AS new_groups,
SUM(CASE WHEN phone IS NOT NULL THEN 1 ELSE 0 END) AS bound_groups
SUM(CASE WHEN phone IS NOT NULL THEN 1 ELSE 0 END) AS bound_groups,
SUM(CASE WHEN phone IS NULL AND create_time < :three_days_ago THEN 1 ELSE 0 END) AS overdue_unbound_groups
FROM customer_group_phones
FROM customer_group_phones
WHERE group_status != 'deleted'
WHERE group_status != 'deleted'
"""
),
"""
),
{
"seven_days_ago"
:
seven_days_ago
},
{
"seven_days_ago"
:
seven_days_ago
,
"three_days_ago"
:
three_days_ago
},
)
.
fetchone
()
)
.
fetchone
()
total_groups
=
int
(
row
.
total_groups
or
0
)
total_groups
=
int
(
row
.
total_groups
or
0
)
new_groups
=
int
(
row
.
new_groups
or
0
)
new_groups
=
int
(
row
.
new_groups
or
0
)
bound_groups
=
int
(
row
.
bound_groups
or
0
)
bound_groups
=
int
(
row
.
bound_groups
or
0
)
overdue_unbound_groups
=
int
(
row
.
overdue_unbound_groups
or
0
)
pass_rate
=
(
bound_groups
/
total_groups
*
100
)
if
total_groups
>
0
else
0.0
pass_rate
=
(
bound_groups
/
total_groups
*
100
)
if
total_groups
>
0
else
0.0
return
{
return
{
...
@@ -59,6 +63,7 @@ class WeeklyReportService:
...
@@ -59,6 +63,7 @@ class WeeklyReportService:
"new_groups"
:
new_groups
,
"new_groups"
:
new_groups
,
"bound_groups"
:
bound_groups
,
"bound_groups"
:
bound_groups
,
"pass_rate"
:
round
(
pass_rate
,
2
),
"pass_rate"
:
round
(
pass_rate
,
2
),
"overdue_unbound_groups"
:
overdue_unbound_groups
,
}
}
def
build_markdown_content
(
self
,
stats
:
Dict
[
str
,
int
|
float
])
->
str
:
def
build_markdown_content
(
self
,
stats
:
Dict
[
str
,
int
|
float
])
->
str
:
...
@@ -71,6 +76,7 @@ class WeeklyReportService:
...
@@ -71,6 +76,7 @@ class WeeklyReportService:
f
"**绑定手机号的群数:** {stats['bound_groups']} 个
\n
"
f
"**绑定手机号的群数:** {stats['bound_groups']} 个
\n
"
f
"**认证通过率:** {stats['pass_rate']}
%
\n
"
f
"**认证通过率:** {stats['pass_rate']}
%
\n
"
f
"**当前总群数:** {stats['total_groups']} 个
\n
"
f
"**当前总群数:** {stats['total_groups']} 个
\n
"
f
"**超过3天未认证群数:** {stats['overdue_unbound_groups']} 个
\n
"
)
)
def
send_report
(
self
,
content
:
str
)
->
Dict
[
str
,
Any
]:
def
send_report
(
self
,
content
:
str
)
->
Dict
[
str
,
Any
]:
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment