MerchantAnalysisService.java
11.5 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
package com.glsk.service;
import com.glsk.component.HttpUtil;
import io.swagger.v3.oas.annotations.Parameter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.ai.tool.annotation.ToolParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
/**
* 门店分析
*/
@Service
@Slf4j
public class MerchantAnalysisService {
final String HOST_URL = "https://glsx-bi-report.glsx.com.cn/merchant/";
// 字段描述
final String BUSINESS_TYPE_DESC = "业务场景:quanyi/yanbao/qinggai其中一个,权益-quanyi 延保-yanbao 轻该-qinggai";
final String QUERY_TYPE_DESC = "查询维度:day/week/month/self其中之一,日-day、周-week、月-month,自定义-self";
final String RANK_FIELD_DESC = "排序字段:output/atv/yinliulv/zhuanhualv/shentoulv其中之一,产值-output、客单价-atv、引流率-yinliulv、转化率-zhuanhualv、渗透率-shentoulv";
final String RANK_FIELD_TYPE_DESC = "升降序:asc/desc其中之一,升序-asc,desc-降序";
@Autowired
private HttpUtil httpUtil;
@Tool(description = "获取门店列表")
public String getMerchantList(@ToolParam(description = BUSINESS_TYPE_DESC) String business_type,
@ToolParam(description = "门店名称模糊匹配") String merchantname,
@ToolParam(description = "门店id列表,逗号分隔") String ids
) {
String method = "getMerchantList";
String url = HOST_URL + method;
Map<String, Object> params = new HashMap<>();
params.put("business_type", business_type);
params.put("merchantname", merchantname);
params.put("ids", ids);
try {
String response = httpUtil.doGet(url, params);
log.info("返回成功: {}", response);
return response;
} catch (Exception e) {
log.error("返回失败", e);
throw new RuntimeException("返回失败", e);
}
}
@Tool(description = "查询门店总产值和客单价")
public String queryMerchantOutputAndAtv(@ToolParam(description = BUSINESS_TYPE_DESC) String business_type,
@ToolParam(description = QUERY_TYPE_DESC) String queryType,
@ToolParam(description = "开始时间") String startDay,
@ToolParam(description = "结束时间") String endDay,
@ToolParam(description = "门店Id") String merchantid
) {
String method = "queryMerchantOutputAndAtv";
String url = HOST_URL + method;
Map<String, Object> params = new HashMap<>();
params.put("business_type", business_type);
params.put("queryType", queryType);
params.put("startDay", startDay);
params.put("endDay", endDay);
params.put("merchantid", merchantid);
try {
String response = httpUtil.doGet(url, params);
log.info("返回成功: {}", response);
return response;
} catch (Exception e) {
log.error("返回失败", e);
throw new RuntimeException("返回失败", e);
}
}
@Tool(description = "查询门店产值趋势")
public String queryMerchantOutputTrend(@ToolParam(description = BUSINESS_TYPE_DESC) String business_type,
@ToolParam(description = QUERY_TYPE_DESC) String queryType,
@ToolParam(description = "开始时间") String startDay,
@ToolParam(description = "结束时间") String endDay,
@ToolParam(description = "门店Id") String merchantid
) {
String method = "queryMerchantOutputTrend";
String url = HOST_URL + method;
Map<String, Object> params = new HashMap<>();
params.put("business_type", business_type);
params.put("queryType", queryType);
params.put("startDay", startDay);
params.put("endDay", endDay);
params.put("merchantid", merchantid);
try {
String response = httpUtil.doGet(url, params);
log.info("返回成功: {}", response);
return response;
} catch (Exception e) {
log.error("返回失败", e);
throw new RuntimeException("返回失败", e);
}
}
@Tool(description = "查询门店新车交付数、新车到店流量、售后到店流量、成交量")
public String queryMerchantBuyAndTostore(@ToolParam(description = BUSINESS_TYPE_DESC) String business_type,
@ToolParam(description = QUERY_TYPE_DESC) String queryType,
@ToolParam(description = "开始时间") String startDay,
@ToolParam(description = "结束时间") String endDay,
@ToolParam(description = "门店Id") String merchantid
) {
String method = "queryMerchantBuyAndTostore";
String url = HOST_URL + method;
Map<String, Object> params = new HashMap<>();
params.put("business_type", business_type);
params.put("queryType", queryType);
params.put("startDay", startDay);
params.put("endDay", endDay);
params.put("merchantid", merchantid);
try {
String response = httpUtil.doGet(url, params);
log.info("返回成功: {}", response);
return response;
} catch (Exception e) {
log.error("返回失败", e);
throw new RuntimeException("返回失败", e);
}
}
@Tool(description = "查询门店内部员工排名")
public String queryStaffRanking(@ToolParam(description = BUSINESS_TYPE_DESC) String business_type,
@ToolParam(description = QUERY_TYPE_DESC) String queryType,
@ToolParam(description = "开始时间") String startDay,
@ToolParam(description = "结束时间") String endDay,
@ToolParam(description = "门店Id") String merchantid,
@ToolParam(description = RANK_FIELD_DESC) String rankfield,
@ToolParam(description = RANK_FIELD_TYPE_DESC) String rankType
) {
String method = "queryStaffRanking";
String url = HOST_URL + method;
Map<String, Object> params = new HashMap<>();
params.put("business_type", business_type);
params.put("queryType", queryType);
params.put("startDay", startDay);
params.put("endDay", endDay);
params.put("merchantid", merchantid);
params.put("rankfield", rankfield);
params.put("rankType", rankType);
try {
String response = httpUtil.doGet(url, params);
log.info("返回成功: {}", response);
return response;
} catch (Exception e) {
log.error("返回失败", e);
throw new RuntimeException("返回失败", e);
}
}
@Tool(description = "查询门店内部流量贡献排行")
public String queryFlowContributeRanking(@ToolParam(description = BUSINESS_TYPE_DESC) String business_type,
@ToolParam(description = QUERY_TYPE_DESC) String queryType,
@ToolParam(description = "开始时间") String startDay,
@ToolParam(description = "结束时间") String endDay,
@ToolParam(description = "门店Id") String merchantid,
@ToolParam(description = RANK_FIELD_TYPE_DESC) String rankType
) {
String method = "queryFlowContributeRanking";
String url = HOST_URL + method;
Map<String, Object> params = new HashMap<>();
params.put("business_type", business_type);
params.put("queryType", queryType);
params.put("startDay", startDay);
params.put("endDay", endDay);
params.put("merchantid", merchantid);
params.put("rankType", rankType);
try {
String response = httpUtil.doGet(url, params);
log.info("返回成功: {}", response);
return response;
} catch (Exception e) {
log.error("返回失败", e);
throw new RuntimeException("返回失败", e);
}
}
@Tool(description = "通过门店与业务场景,查询所属服务商老板、区域督导、销售名称")
public String queryServiceSupervisionSale(@ToolParam(description = BUSINESS_TYPE_DESC) String business_type,
@ToolParam(description = "开始时间") String startDay,
@ToolParam(description = "结束时间") String endDay,
@ToolParam(description = "门店Id") String merchantid
) {
String method = "queryServiceSupervisionSale";
String url = HOST_URL + method;
Map<String, Object> params = new HashMap<>();
params.put("business_type", business_type);
params.put("startDay", startDay);
params.put("endDay", endDay);
params.put("merchantid", merchantid);
try {
String response = httpUtil.doGet(url, params);
log.info("返回成功: {}", response);
return response;
} catch (Exception e) {
log.error("返回失败", e);
throw new RuntimeException("返回失败", e);
}
}
@Tool(description = "门店内部品类分析")
public String queryProductOutput(@ToolParam(description = BUSINESS_TYPE_DESC) String business_type,
@ToolParam(description = "开始时间") String startDay,
@ToolParam(description = "结束时间") String endDay,
@ToolParam(description = "门店Id") String merchantid
) {
String method = "queryProductOutput";
String url = HOST_URL + method;
Map<String, Object> params = new HashMap<>();
params.put("business_type", business_type);
params.put("startDay", startDay);
params.put("endDay", endDay);
params.put("merchantid", merchantid);
try {
String response = httpUtil.doGet(url, params);
log.info("返回成功: {}", response);
return response;
} catch (Exception e) {
log.error("返回失败", e);
throw new RuntimeException("返回失败", e);
}
}
public static void main(String[] args) {
final String HOST_URL = "https://glsx-bi-report.glsx.com.cn/merchant/";
HttpUtil httpUtil = new HttpUtil();
String method = "getMerchantList";
String url = HOST_URL + method;
Map<String, Object> params = new HashMap<>();
params.put("business_type", "yanbao");
// params.put("merchantname", null);
// params.put("ids", null);
try {
String response = httpUtil.doGet(url, params);
log.info("返回成功: {}", response);
} catch (Exception e) {
log.error("返回失败", e);
throw new RuntimeException("返回失败", e);
}
}
}