"""§11 经营数据补录""" import pytest pytestmark = pytest.mark.integration def test_sales_flow(api, uid): customer = api.assert_success( api.post( "/sales/customers", json={ "name": f"客户{uid}", "phone": f"139{uid[:8]}", "source": "group", "roomId": f"room-{uid}", }, ), status=201, ) cust_id = customer["id"] follow = api.assert_success( api.post( f"/sales/customers/{cust_id}/follow-ups", json={ "customerId": cust_id, "followerId": 1, "followDate": "2026-05-21", "method": "call", "content": "首次跟进", }, ), status=201, ) assert follow["customerId"] == cust_id follows = api.assert_success(api.get(f"/sales/customers/{cust_id}/follow-ups")) assert len(follows) >= 1 lead = api.assert_success( api.post( "/sales/leads", json={ "salespersonId": 1, "recordDate": "2026-05-21", "addCount": 2, "remark": uid, }, ), status=201, ) assert lead["addCount"] == 2 order = api.assert_success( api.post( "/sales/orders", json={ "salespersonId": 1, "customerId": cust_id, "amount": 100000, "orderDate": "2026-05-20", "source": "group", "roomId": f"room-{uid}", }, ), status=201, ) assert order["amount"] == 100000 live = api.assert_success( api.post( "/sales/live-stats", json={ "liveSessionId": f"live-{uid}", "title": f"直播{uid}", "liveDate": "2026-05-21", "viewerCount": 100, }, ), status=201, ) assert live["viewerCount"] == 100 api.assert_success(api.get("/sales/leads")) api.assert_success(api.get("/sales/orders")) api.assert_success(api.get("/sales/customers")) api.assert_success(api.get("/sales/live-stats"))