Przeglądaj źródła

交易市场平台(供应商)

wwh 2 tygodni temu
rodzic
commit
c3f1736d88

+ 13 - 0
baqing-admin/src/main/java/com/ruoyi/web/modules/trading/domain/dto/AppDistributorTradeSummaryDto.java

@@ -15,6 +15,9 @@ public class AppDistributorTradeSummaryDto
15 15
 
16 16
     private Long totalHeads;
17 17
 
18
+    /** 已完成订单的去重供应商数 */
19
+    private Long supplierCount;
20
+
18 21
     public Long getOrderCount()
19 22
     {
20 23
         return orderCount;
@@ -54,4 +57,14 @@ public class AppDistributorTradeSummaryDto
54 57
     {
55 58
         this.totalHeads = totalHeads;
56 59
     }
60
+
61
+    public Long getSupplierCount()
62
+    {
63
+        return supplierCount;
64
+    }
65
+
66
+    public void setSupplierCount(Long supplierCount)
67
+    {
68
+        this.supplierCount = supplierCount;
69
+    }
57 70
 }

+ 13 - 0
baqing-admin/src/main/java/com/ruoyi/web/modules/trading/domain/vo/AppDistributorTradeSummaryVo.java

@@ -22,6 +22,9 @@ public class AppDistributorTradeSummaryVo
22 22
     /** 近期交易均价(元/头,2 位小数) */
23 23
     private BigDecimal avgUnitPrice;
24 24
 
25
+    /** 成交供应商数(已完成订单去重 supplier_id) */
26
+    private long supplierCount;
27
+
25 28
     public long getOrderCount()
26 29
     {
27 30
         return orderCount;
@@ -71,4 +74,14 @@ public class AppDistributorTradeSummaryVo
71 74
     {
72 75
         this.avgUnitPrice = avgUnitPrice;
73 76
     }
77
+
78
+    public long getSupplierCount()
79
+    {
80
+        return supplierCount;
81
+    }
82
+
83
+    public void setSupplierCount(long supplierCount)
84
+    {
85
+        this.supplierCount = supplierCount;
86
+    }
74 87
 }

+ 2 - 0
baqing-admin/src/main/java/com/ruoyi/web/modules/trading/support/AppDistributorHomeSupport.java

@@ -125,6 +125,7 @@ public final class AppDistributorHomeSupport
125 125
         long orderCount = raw != null && raw.getOrderCount() != null ? raw.getOrderCount() : 0L;
126 126
         long completed = raw != null && raw.getCompletedCount() != null ? raw.getCompletedCount() : 0L;
127 127
         long heads = raw != null && raw.getTotalHeads() != null ? raw.getTotalHeads() : 0L;
128
+        long supplierCount = raw != null && raw.getSupplierCount() != null ? raw.getSupplierCount() : 0L;
128 129
         BigDecimal amount = raw != null && raw.getTotalAmount() != null
129 130
                 ? raw.getTotalAmount() : BigDecimal.ZERO;
130 131
 
@@ -132,6 +133,7 @@ public final class AppDistributorHomeSupport
132 133
         vo.setOrderCount(orderCount);
133 134
         vo.setTotalAmount(amount);
134 135
         vo.setTotalHeads(heads);
136
+        vo.setSupplierCount(supplierCount);
135 137
         vo.setCompletionRate(ratioPercent(completed, orderCount));
136 138
         vo.setAvgUnitPrice(avgUnitPrice(amount, heads));
137 139
         return vo;

+ 2 - 1
baqing-admin/src/main/resources/mapper/trading/AppDistributorTradeMapper.xml

@@ -14,7 +14,8 @@
14 14
         select count(*) as orderCount,
15 15
                coalesce(sum(case when o.order_status = '1' then 1 else 0 end), 0) as completedCount,
16 16
                coalesce(sum(o.total_amount), 0) as totalAmount,
17
-               coalesce(sum(o.total_heads), 0) as totalHeads
17
+               coalesce(sum(o.total_heads), 0) as totalHeads,
18
+               count(distinct case when o.order_status = '1' then o.supplier_id else null end) as supplierCount
18 19
         from biz_trade_order o
19 20
         where <include refid="orderInRange"/>
20 21
     </select>

+ 2 - 0
baqing-admin/src/test/java/com/ruoyi/web/modules/trading/service/impl/AppDistributorHomeServiceImplTest.java

@@ -42,6 +42,7 @@ class AppDistributorHomeServiceImplTest
42 42
         summary.setCompletedCount(1L);
43 43
         summary.setTotalAmount(new BigDecimal("36800"));
44 44
         summary.setTotalHeads(3L);
45
+        summary.setSupplierCount(1L);
45 46
         when(appDistributorTradeMapper.selectTradeSummary(any(), any(), any())).thenReturn(summary);
46 47
         when(appDistributorTradeMapper.selectHourlyAmountTrend(any(), any(), any()))
47 48
                 .thenReturn(Collections.emptyList());
@@ -51,6 +52,7 @@ class AppDistributorHomeServiceImplTest
51 52
         assertEquals("今日", vo.getRangeName());
52 53
         assertEquals(AppDistributorHomeRules.TREND_GRANULARITY_HOUR, vo.getTrendGranularity());
53 54
         assertEquals(2L, vo.getSummary().getOrderCount());
55
+        assertEquals(1L, vo.getSummary().getSupplierCount());
54 56
         assertEquals(24, vo.getAmountTrend().size());
55 57
     }
56 58
 }

+ 2 - 0
baqing-admin/src/test/java/com/ruoyi/web/modules/trading/support/AppDistributorHomeSupportTest.java

@@ -29,9 +29,11 @@ class AppDistributorHomeSupportTest
29 29
         raw.setCompletedCount(2L);
30 30
         raw.setTotalAmount(new BigDecimal("36800"));
31 31
         raw.setTotalHeads(3L);
32
+        raw.setSupplierCount(2L);
32 33
 
33 34
         AppDistributorTradeSummaryVo vo = AppDistributorHomeSupport.buildSummary(raw);
34 35
         assertEquals(4L, vo.getOrderCount());
36
+        assertEquals(2L, vo.getSupplierCount());
35 37
         assertEquals(0, new BigDecimal("36800").compareTo(vo.getTotalAmount()));
36 38
         assertEquals(3L, vo.getTotalHeads());
37 39
         assertEquals(0, new BigDecimal("50.0").compareTo(vo.getCompletionRate()));

+ 2 - 1
doc/app/交易市场平台(承销商)/README.md

@@ -7,7 +7,7 @@
7 7
 
8 8
 | 导航 | 文档 | Base Path | 说明 |
9 9
 | --- | --- | --- | --- |
10
-| 首页 | [首页接口说明.md](./首页接口说明.md) | `/app/distributor/home` | 四时段交易统计 + 金额趋势 |
10
+| 首页 | [首页接口说明.md](./首页接口说明.md) | `/app/distributor/home` | 四时段:下单数/金额/头数/完成率/成交供应商数/均价 + 金额趋势 |
11 11
 | 订单 | [订单接口说明.md](./订单接口说明.md) | `/app/distributor/order`、`/app/distributor/yak` | 列表/详情 + 牦牛入场隔离 |
12 12
 | 行情 | [行情接口说明.md](./行情接口说明.md) | `/app/yakMarket` | **复用**牧民端牦牛行情,无独立路径 |
13 13
 
@@ -60,3 +60,4 @@
60 60
 | 版本 | 说明 |
61 61
 | --- | --- |
62 62
 | 1.0 | 汇总首页、订单、行情(复用)接口至本目录 |
63
+| 1.1 | 首页汇总增补 `supplierCount`(成交供应商数) |

+ 21 - 6
doc/app/交易市场平台(承销商)/首页接口说明.md

@@ -22,6 +22,18 @@
22 22
 
23 23
 `GET /app/distributor/home/dashboard`
24 24
 
25
+一次请求返回**当前 `range` 时段**的汇总指标与金额趋势;小程序四个 Tab(今日 / 昨日 / 7日 / 30日)分别传对应 `range` 各请求一次。
26
+
27
+| 需求项 | 实现 |
28
+| --- | --- |
29
+| 分时段查 `biz_trade_order`(承销商=本人) | `range` + 当前登录绑定的 `distributor_id` |
30
+| 累计下单数 / 采购总金额 / 已购牦牛数 | `summary.orderCount` / `totalAmount` / `totalHeads` |
31
+| 订单完成率 | `summary.completionRate`(已完成 ÷ 下单数) |
32
+| 成交供应商数 | `summary.supplierCount`(已完成订单 `supplier_id` 去重) |
33
+| 近期交易均价 | `summary.avgUnitPrice`(总金额 ÷ 头数) |
34
+| 今日/昨日金额趋势(按小时) | `trendGranularity=HOUR`,`amountTrend` 24 点 |
35
+| 7日/30日金额趋势(按天) | `trendGranularity=DAY`,连续自然日补零 |
36
+
25 37
 ### 2.1 请求
26 38
 
27 39
 | 参数 | 位置 | 必填 | 说明 |
@@ -30,9 +42,10 @@
30 42
 
31 43
 ### 2.2 统计口径
32 44
 
33
-- 仅统计 **`distributor_id` = 当前承销商** 且 **`del_flag = 0`** 的订单。
34
-- 时段按订单 **`create_time`**(下单时间)落在对应自然日区间内统计。
45
+- 仅统计 **`biz_trade_order.distributor_id` = 当前承销商** 且 **`del_flag = 0`** 的订单。
46
+- 时段按订单 **`create_time`**(下单时间)落在对应自然日区间内统计(今日/昨日为当日 00:00:00~23:59:59)
35 47
 - **7日**:`[今日-6日, 今日]` 共 7 个自然日;**30日**:`[今日-29日, 今日]` 共 30 个自然日。
48
+- **已完成**:`order_status = '1'`。
36 49
 
37 50
 ### 2.3 响应 `data`
38 51
 
@@ -49,10 +62,11 @@
49 62
 
50 63
 | 字段 | 说明 |
51 64
 | --- | --- |
52
-| `orderCount` | 累计下单数 |
53
-| `totalAmount` | 采购总金额(元) |
54
-| `totalHeads` | 已购牦牛数(头) |
55
-| `completionRate` | 订单完成率(%),已完成数 ÷ 下单数,`order_status=1` 为已完成;下单数为 0 时为 0 |
65
+| `orderCount` | 累计下单数(时段内全部订单笔数) |
66
+| `totalAmount` | 采购总金额(元,时段内 `total_amount` 合计) |
67
+| `totalHeads` | 已购牦牛数(头,时段内 `total_heads` 合计) |
68
+| `completionRate` | 订单完成率(%),已完成笔数 ÷ 下单数;下单数为 0 时为 0 |
69
+| `supplierCount` | 成交供应商数(时段内**已完成**订单的 `supplier_id` 去重计数) |
56 70
 | `avgUnitPrice` | 近期交易均价(元/头),`totalAmount / totalHeads`;头数为 0 时为 0 |
57 71
 
58 72
 **`amountTrend[]`**
@@ -85,6 +99,7 @@ GET /app/distributor/home/dashboard?range=TODAY
85 99
       "totalAmount": 36800.00,
86 100
       "totalHeads": 3,
87 101
       "completionRate": 50.0,
102
+      "supplierCount": 1,
88 103
       "avgUnitPrice": 12266.67
89 104
     },
90 105
     "amountTrend": [