feat: 更新支付模块 (Stripe/PayPal/PingPong) 和 uni-app 配置
This commit is contained in:
@@ -23,6 +23,11 @@ class AnalyzeRequest(BaseModel):
|
||||
product_description: str
|
||||
|
||||
|
||||
class MarketIntelRequest(BaseModel):
|
||||
product_description: str
|
||||
target_market: str = "US"
|
||||
|
||||
|
||||
class OutreachRequest(BaseModel):
|
||||
company: Dict[str, Any]
|
||||
product: Dict[str, Any]
|
||||
@@ -102,6 +107,33 @@ async def analyze_company(
|
||||
raise HTTPException(status_code=500, detail="分析失败,请稍后重试")
|
||||
|
||||
|
||||
@router.post("/market-intel")
|
||||
async def market_intel(
|
||||
req: MarketIntelRequest,
|
||||
user_id: str = Depends(get_current_user_id),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
if not req.product_description.strip():
|
||||
raise HTTPException(status_code=400, detail="请填写产品描述")
|
||||
|
||||
credit_svc = CreditService(db)
|
||||
ok, balance = await credit_svc.deduct(user_id, "market_intel")
|
||||
if not ok:
|
||||
raise HTTPException(
|
||||
status_code=402,
|
||||
detail=f"次数不足 (剩余 {balance:.1f}, 需要 20)"
|
||||
)
|
||||
|
||||
svc = DiscoveryService(db=db)
|
||||
try:
|
||||
result = await svc.market_intel(req.product_description, req.target_market)
|
||||
return {"success": True, "data": result, "credits_remaining": balance - 20}
|
||||
except Exception as e:
|
||||
await credit_svc.add_credits(user_id, 20, "refund", "市场分析失败退回次数")
|
||||
logger.error(f"Market intel failed: {e}")
|
||||
raise HTTPException(status_code=500, detail="分析失败,请稍后重试")
|
||||
|
||||
|
||||
@router.post("/outreach")
|
||||
async def generate_outreach(
|
||||
req: OutreachRequest,
|
||||
|
||||
Reference in New Issue
Block a user