Blame view

项目文档相关/sql/查询绿纤明信店2025年12月毛巾成本.sql 1.66 KB
d8035736   “wangming”   Refactor project ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
  -- ============================================
  -- 查询绿纤明信店202512月毛巾总成本
  -- ============================================
  -- 门店ID: 1649328471923847187 (绿纤明信店)
  -- 月份: 202512 (202512)
  -- 
  -- 查询逻辑说明:
  -- 1. 只统计送出的记录(F_FlowType = 0
  -- 2. 只统计有效记录(F_IsEffective = 1
  -- 3. 时间优先使用送出时间(F_SendTime),如果为空则使用创建时间(F_CreateTime
  -- 4. 统计字段:F_TotalPrice(总费用)
  -- ============================================
  
  SELECT 
      F_StoreId as 门店ID,
      SUM(F_TotalPrice) as 毛巾总成本,
      COUNT(*) as 记录数量,
      MIN(COALESCE(F_SendTime, F_CreateTime)) as 最早记录时间,
      MAX(COALESCE(F_SendTime, F_CreateTime)) as 最晚记录时间
  FROM lq_laundry_flow
  WHERE F_IsEffective = 1
      AND F_FlowType = 0
      AND F_StoreId = '1649328471923847187'
      AND DATE_FORMAT(COALESCE(F_SendTime, F_CreateTime), '%Y%m') = '202512'
  GROUP BY F_StoreId;
  
  -- ============================================
  -- 详细信息查询(查看具体记录)
  -- ============================================
  SELECT 
      F_Id as 记录ID,
      F_BatchNumber as 批次号,
      F_ProductType as 产品类型,
      F_Quantity as 数量,
      F_LaundryPrice as 清洗单价,
      F_TotalPrice as 总费用,
      F_SendTime as 送出时间,
      F_CreateTime as 创建时间,
      COALESCE(F_SendTime, F_CreateTime) as 统计时间
  FROM lq_laundry_flow
  WHERE F_IsEffective = 1
      AND F_FlowType = 0
      AND F_StoreId = '1649328471923847187'
      AND DATE_FORMAT(COALESCE(F_SendTime, F_CreateTime), '%Y%m') = '202512'
  ORDER BY COALESCE(F_SendTime, F_CreateTime);