feat: 新增用车需求服务及线索管理全功能
- 新增后台用车服务配置模块,支持维护服务简介、优势与使用流程 - 新增需求线索管理页面,支持筛选、查看与更新用车线索状态 - 新增小程序用车需求页面,优化登录路径与回跳逻辑 - 优化车型卡片跳转与用车需求提交功能 - 新增服务端API与数据处理逻辑,完善权限校验 - 更新全站配置与API文档,新增相关测试用例
This commit is contained in:
1 parent
b7a81964c9
commit
d42f69bd47
36 files changed
+1290
-33
No files matched your search
@@ -1,8 +1,9 @@
|
||||
from datetime import datetime, time
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.orm import Session, selectinload
|
||||
from .shared import site_config
|
||||
from ..auth import create_customer_token, require_customer
|
||||
from ..auth import create_customer_token, optional_customer, require_customer
|
||||
from ..api_response import success_response
|
||||
from ..database import get_db
|
||||
from ..models import ConciergeAdvisor, Customer, DetailRecord, HomeTeamBuilding, HomeWanfaRecommendation, HomeWildArchive, Lead, WanfaCategory
|
||||
@@ -170,8 +171,27 @@ def current_customer(customer: Customer = Depends(require_customer)):
|
||||
|
||||
|
||||
@router.post("/api/public/leads", status_code=status.HTTP_201_CREATED)
|
||||
def create_lead(body: LeadCreateIn, db: Session = Depends(get_db)):
|
||||
lead = Lead(**body.model_dump(exclude_none=True), status="new")
|
||||
def create_lead(
|
||||
body: LeadCreateIn,
|
||||
customer: Customer | None = Depends(optional_customer),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
if body.leadType == "vehicle" and customer is None:
|
||||
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="用车需求提交前请先登录")
|
||||
|
||||
payload = body.model_dump(exclude_none=True, exclude={"vehicleDemand"})
|
||||
if body.leadType == "vehicle" and body.vehicleDemand:
|
||||
demand = body.vehicleDemand
|
||||
payload.update(
|
||||
{
|
||||
"customerId": customer.id if customer else None,
|
||||
"destination": demand.dropoffLocation,
|
||||
"travelDate": datetime.combine(demand.travelDate, time.min),
|
||||
"peopleCount": demand.peopleCount,
|
||||
"vehicleDemand": demand.model_dump(mode="json"),
|
||||
}
|
||||
)
|
||||
lead = Lead(**payload, status="new")
|
||||
db.add(lead)
|
||||
db.commit()
|
||||
db.refresh(lead)
|
||||
|
||||
Reference in new issue
Block a user