1 概述
为了方便Saas合作伙伴可以直接在其平台上使用商米提供的巡店服务业务数据,平台提供了巡店统计数据接口。Saas合作伙伴可以通过接口调用获取巡店业务的统计数据。
2 接口规范
2.1 协议说明
对接的openAPI接口目前只开放HTTPS方式,所有的消息一律采用POST方式。
注:消息体大小不得超过1M,超过1M的请求,直接拒绝!
Content-Type | application/x-www-form-urlencoded |
---|
数据格式 | 返回为JSON格式 |
---|
字符编码 | UTF-8字符编码 |
---|
签名算法 | MD5 |
---|
签名规则 | 参考2.2 签名规则 |
---|
2.2 签名规则
参考《鉴权认证》文档。
2.3 公共参数
参数名 | 必填 | 类型 | 说明 |
---|
app_id | 是 | string | 唯一标识接入身份,联系商米数字店铺提供 |
random | 是 | string | 随机字符串,由数字和字母组成,长度范围为6-10位 |
timestamp | 是 | int | 当前的unix timestamp,精度到秒级,10位数字 |
sign | 是 | string | 签名信息,详见2.2 |
3 巡店数据统计接口
3.1 接口描述
巡店数据统计接口用于Saas合作方获取巡店服务的各种数据统计。
3.2 接口列表
接口名称 | 接口描述 |
---|
/service/patrol/stat/groupByInspector | 获取巡检人巡查工作情况统计 |
/service/patrol/stat/groupByShop | 获取门店下巡查工作数据统计 |
/service/patrol/stat/groupByTemplate | 获取模板使用情况数据统计 |
/service/patrol/stat/groupByCheckItem | 获取模板-检查项使用情况数据统计 |
3.3 接口详情
3.3.1 获取巡检人巡查工作数据统计
接口描述:通过本接口调用,可以获取到指定门店下基于巡检人统计的巡检人工作数据统计
接口链接:/service/patrol/stat/groupByInspector
接口版本:v2.0
接口参数:
参数名称 | 是否必须 | 类型 | 说明 | 示例 |
sunmi_shop_no | 是 | string | 店铺编号 | 560279010307 |
period | 是 | int | 统计周期 | 1 |
period参数说明:
参数取值 | 说明 |
1 | 近7天数据统计 |
2 | 近30天数据统计 |
3 | 近90天数据统计 |
4 | 近180天数据统计 |
5 | 近365天数据统计 |
请求示例:
"method": "POST",
"url": "https://store.uat.sunmi.com/openapi/service/patrol/stat/groupByInspector",
"headers": {
"Content-Type": "application/x-www-form-urlencoded"
},
formData: {
"sunmi_shop_no": "560279010307",
"app_id": "LMWWQVTW4QGCC",
"timestamp": 1581383983,
"random": "5dsf6698",
"sign": "33C18A18282733A71F998BB5A5E4319D"
}
返回值:
{
"data": {
"patrol_inspector_summary_list": [
{
"inspection_user_name": "小明",
"plan_task_undone_count": 0,
"plan_task_done_count": 7,
"plan_task_doing_count": 0,
"plan_task_total_count": 28,
"check_total_count": 349,
"check_done_count": 2,
"total_time_duration": 295645,
"task_normal_count": 7,
"task_non_count": 1602,
"task_total_count": 1609,
"task_realtime_count": 699,
"task_snapshot_count": 523,
"task_evaluate_count": 40,
"last_inspection_time": 1600867095
},
{
"inspection_user_name": "xiaohong",
"plan_task_undone_count": 0,
"plan_task_done_count": 3,
"plan_task_doing_count": 0,
"plan_task_total_count": 12,
"check_total_count": 9,
"check_done_count": 4,
"total_time_duration": 2101,
"task_normal_count": 3,
"task_non_count": 81,
"task_total_count": 84,
"task_realtime_count": 26,
"task_snapshot_count": 42,
"task_evaluate_count": 7,
"last_inspection_time": 1599535469
},
{
"inspection_user_name": "kunkun",
"plan_task_undone_count": 0,
"plan_task_done_count": 0,
"plan_task_doing_count": 0,
"plan_task_total_count": 0,
"check_total_count": 0,
"check_done_count": 0,
"total_time_duration": 21,
"task_normal_count": 0,
"task_non_count": 2,
"task_total_count": 2,
"task_realtime_count": 0,
"task_snapshot_count": 0,
"task_evaluate_count": 2,
"last_inspection_time": 1597661382
},
{
"inspection_user_name": "小白",
"plan_task_undone_count": 0,
"plan_task_done_count": 0,
"plan_task_doing_count": 0,
"plan_task_total_count": 0,
"check_total_count": 14,
"check_done_count": 0,
"total_time_duration": 13994,
"task_normal_count": 0,
"task_non_count": 48,
"task_total_count": 48,
"task_realtime_count": 0,
"task_snapshot_count": 0,
"task_evaluate_count": 48,
"last_inspection_time": 1599542974
}
]
},
"code": 0,
"msg": "succeed"
}
返回参数说明:
参数名 | 类型 | 说明 |
inspection_user_name | string | 巡检人姓名 |
plan_task_undone_count | int | 计划任务过期未执行数 |
plan_task_done_count | int | 计划任务已完成数 |
plan_task_doing_count | int | 计划任务待执行数 |
plan_task_total_count | int | 计划任务总数 |
check_total_count | int | 应审核问题总数 |
check_done_count | int | 审核完成数 |
total_time_duration | int | 巡检时长(秒) |
task_normal_count | int | 任务巡店次数 |
task_non_count | int | 非任务巡店次数 |
task_total_count | int | 巡店总次数 |
task_realtime_count | int | 实时巡店次数 |
task_snapshot_count | int | 抓拍巡店次数 |
task_evaluate_count | int | 门店考评次数 |
last_inspection_time | int | 最后一次巡检时间(秒) |
错误码:
错误码 | 说明 |
5041 | 请求中未找到shop_id参数 |
3.3.2 获取门店下巡查工作数据统计
接口描述:通过本接口调用,可以获取到指定门店下基于门店统计的巡检工作数据统计
接口链接: /service/patrol/stat/groupByShop
接口版本:v2.0
接口参数:
参数名称 | 是否必须 | 类型 | 说明 | 示例 |
sunmi_shop_no | 是 | string | 店铺编号列表 | 560279010307 |
period | 是 | int | 统计周期 | 1 |
period参数:
参数取值 | 说明 |
1 | 近7天数据统计 |
2 | 近30天数据统计 |
3 | 近90天数据统计 |
4 | 近180天数据统计 |
5 | 近365天数据统计 |
请求示例:
"method": "POST",
"url": "https://store.uat.sunmi.com/openapi/service/patrol/stat/groupByShop",
"headers": {
"Content-Type": "application/x-www-form-urlencoded"
},
formData: {
"sunmi_shop_no": "560279010307",
"app_id": "LMWWQVTW4QGCC",
"timestamp": 1581383983,
"random": "5dsf6698",
"sign": "33C18A18282733A71F998BB5A5E4319D"
}
返回值:
{
"data": {
"patrol_shop_summary_list": [
{
"check_total_count": 0,
"scoreless_total_count": 0,
"avg_score": 5.58,
"rectify_count": 438,
"rectify_done_count": 398,
"realtime_need_count": 393,
"realtime_total_count": 777,
"snapshot_problem_count": 286,
"snapshot_total_count": 645,
"evaluate_need_count": 45,
"evaluate_total_count": 126
}
]
},
"code": 0,
"msg": "succeed"
}
返回参数说明:
参数名 | 类型 | 说明 |
check_total_count | int | 考评检查项总数 |
scoreless_total_count | int | 有问题检查项数 |
avg_score | float | 考评得分,百分制 |
rectify_count | int | 应整改问题数 |
rectify_done_count | int | 整改完成数 |
realtime_need_count | int | 实时巡店需整改数 |
realtime_total_count | int | 实时巡店总次数 |
snapshot_problem_count | int | 抓拍巡检有问题数 |
snapshot_total_count | int | 抓拍巡检总次数 |
evaluate_need_count | int | 门店考评需整改数 |
evaluate_total_count | int | 门店考评总次数 |
错误码:
错误码 | 说明 |
5041 | 请求中未找到shop_id参数 |
3.3.3 获取模板使用情况数据统计
接口描述: 通过本接口调用,可以获取到指定门店下基于门店统计的巡检工作数据统计
接口链接: /service/patrol/stat/groupByTemplate
接口版本:v2.0
接口参数:
参数名称 | 是否必须 | 类型 | 说明 | 示例 |
sunmi_shop_no | 是 | string | 店铺编号列表 | 560279010307 |
period | 是 | int | 统计周期 | 1 |
period参数说明:
参数取值 | 说明 |
1 | 近7天数据统计 |
2 | 近30天数据统计 |
3 | 近90天数据统计 |
4 | 近180天数据统计 |
5 | 近365天数据统计 |
请求示例:
"method": "POST",
"url": "https://store.uat.sunmi.com/openapi/service/patrol/stat/groupByTemplate",
"headers": {
"Content-Type": "application/x-www-form-urlencoded"
},
formData: {
"sunmi_shop_no": "560279010307",
"app_id": "LMWWQVTW4QGCC",
"timestamp": 1581383983,
"random": "5dsf6698",
"sign": "33C18A18282733A71F998BB5A5E4319D"
}
返回值:
{
"data": {
"patrol_template_summary_list": [
{
"template_id": "549755813846",
"template_name": "你好世界",
"total_score": 3925,
"total_full_score": 5240,
"total_count": 126
}
]
},
"code": 0,
"msg": "succeed"
}
参数名 | 类型 | 说明 |
template_id | int | 模板id |
template_name | string | 模板名称 |
total_score | int | 门店下模板累计得分 |
total_full_score | int | 门店下模板累计总分 |
total_count | int | 总共使用次数 |
错误码:
错误码 | 说明 |
5041 | 请求中未找到shop_id参数 |
3.3.4 获取模板-检查项使用情况数据统计
接口描述: 通过本接口调用,可以获取到指定门店下基于模板统计的巡检工作数据统计
接口链接: /service/patrol/stat/groupByCheckItem
接口版本:v2.0
接口参数:
参数名称 | 是否必须 | 类型 | 说明 | 示例 |
sunmi_shop_no | 是 | string | 店铺编号列表 | 560279010307 |
period | 是 | int | 统计周期 | 1 |
period参数说明:
参数取值 | 说明 |
1 | 近7天数据统计 |
2 | 近30天数据统计 |
3 | 近90天数据统计 |
4 | 近180天数据统计 |
5 | 近365天数据统计 |
请求示例:
"method": "POST",
"url": "https://store.uat.sunmi.com/openapi/service/patrol/stat/groupByCheckItem",
"headers": {
"Content-Type": "application/x-www-form-urlencoded"
},
formData: {
"sunmi_shop_no": "560279010307",
"app_id": "LMWWQVTW4QGCC",
"timestamp": 1581383983,
"random": "5dsf6698",
"sign": "33C18A18282733A71F998BB5A5E4319D"
}
返回值:
{
"data": {
"patrol_check_item_summary_list": [
{
"template_id": "549755813846",
"check_item_name": "1",
"check_score_count": 9,
"check_total_count": 12
},
{
"template_id": "549755813846",
"check_item_name": "2dada方式方法将老豆腐江东父老的肌肤豆腐煎豆腐",
"check_score_count": 1,
"check_total_count": 1
},
{
"template_id": "549755813846",
"check_item_name": "调料归类正确",
"check_score_count": 3,
"check_total_count": 5
},
{
"template_id": "549755813846",
"check_item_name": "食品归类正确",
"check_score_count": 4,
"check_total_count": 5
},
{
"template_id": "549755813846",
"check_item_name": "食品细菌含量未超标",
"check_score_count": 3,
"check_total_count": 5
},
{
"template_id": "549755813846",
"check_item_name": "食材未过期",
"check_score_count": 5,
"check_total_count": 5
},
{
"template_id": "549755813846",
"check_item_name": "食材清洗干净",
"check_score_count": 4,
"check_total_count": 5
}
]
},
"code": 0,
"msg": "succeed"
}
返回参数说明:
参数名 | 类型 | 说明 |
template_id | int | 模板id |
check_item_name | string | 检查项名称 |
check_score_count | int | 检查得分次数 |
check_total_count | int | 检查次数 |
错误码:
错误码 | 说明 |
5041 | 请求中未找到shop_id参数 |