This commit is contained in:
aaron 2025-03-04 15:12:13 +08:00
parent ac945a864c
commit 847056fe05
3 changed files with 22 additions and 18 deletions

View File

@ -114,22 +114,20 @@ async def get_community_time_periods(
"""获取社区的配送时段列表"""
try:
# 查询社区的配送时段
community_time_periods = db.query(CommunityTimePeriodDB).filter(
community_time_periods = db.query(CommunityTimePeriodDB, TimePeriodDB.name.label("time_period_name"),TimePeriodDB.from_time.label("time_period_from_time"), TimePeriodDB.to_time.label("time_period_to_time")).join(TimePeriodDB).filter(
CommunityTimePeriodDB.community_id == community_id
).all()
# 获取时段详情
).order_by(TimePeriodDB.from_time).all()
result = []
for ctp in community_time_periods:
time_period = db.query(TimePeriodDB).filter(TimePeriodDB.id == ctp.time_period_id).first()
if time_period:
ctp_info = CommunityTimePeriodWithDetail.model_validate(ctp)
ctp_info.time_period = TimePeriodInfo.model_validate(time_period)
result.append(ctp_info)
# 按时段开始时间排序
result.sort(key=lambda x: x.time_period.from_time if x.time_period else None)
result.append({
"time_period_id": ctp.CommunityTimePeriodDB.time_period_id,
"time_period_name": ctp.time_period_name,
"capacity": ctp.CommunityTimePeriodDB.capacity,
"from_time": ctp.time_period_from_time,
"to_time": ctp.time_period_to_time
})
return success_response(data=result)
except Exception as e:

View File

@ -135,10 +135,8 @@ async def wechat_corp_callback(
# 处理进群事件
if update_detail == 'add_member':
userid = msg_root.find('MemChangeList')[0].find('Item').text
print(f"userid: {userid}")
unionid = await wecom_client.get_unionid_from_userid(userid)
print(f"根据userid获取unionid结果: {unionid}")
# 发送欢迎消息
await wecom_client.send_welcome_message(chat_id)
return Response(content="success", media_type="text/plain")

View File

@ -128,7 +128,15 @@ class WecomClient:
"chatid": group_id,
"msgtype": "text",
"text": {
"content": f"欢迎 @{user_info['name']} 加入群聊!\n我们为您准备了专属优惠券,请查收~"
"content": f"""🥳 欢迎您进群,在群内可以享受📦【代取快递】跑腿服务。
微信下单快递到家
🎁 新人礼包
𝟏 赠送𝟏𝟓张𝟑元跑腿券
𝟐 赠送𝟔枚鲜鸡蛋首次下单
🎊
点击小程序领券下单 &"""
}
}