增值服务-巡店服务 接口

1 概述

为了方便Saas合作伙伴可以直接在其平台上使用商米提供的巡店服务业务数据,平台提供了巡店统计数据接口。Saas合作伙伴可以通过接口调用获取巡店业务的统计数据。

2 接口规范

2.1 协议说明

对接的openAPI接口目前只开放HTTPS方式,所有的消息一律采用POST方式。

注:消息体大小不得超过1M,超过1M的请求,直接拒绝!

Content-Typeapplication/x-www-form-urlencoded
数据格式返回为JSON格式
字符编码UTF-8字符编码
签名算法MD5
签名规则参考2.2 签名规则

2.2 签名规则

参考《鉴权认证》文档。

2.3 公共参数

参数名必填类型说明
app_idstring唯一标识接入身份,联系商米数字店铺提供
randomstring随机字符串,由数字和字母组成,长度范围为6-10位
timestampint当前的unix timestamp,精度到秒级,10位数字
signstring签名信息,详见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
periodint统计周期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_namestring巡检人姓名
plan_task_undone_countint计划任务过期未执行数
plan_task_done_countint计划任务已完成数
plan_task_doing_count int计划任务待执行数
plan_task_total_count int计划任务总数
check_total_countint应审核问题总数
check_done_countint 审核完成数
total_time_durationint 巡检时长(秒)
task_normal_countint任务巡店次数
task_non_countint非任务巡店次数
task_total_countint巡店总次数
task_realtime_countint实时巡店次数
task_snapshot_countint抓拍巡店次数
task_evaluate_countint门店考评次数
last_inspection_timeint最后一次巡检时间(秒)

错误码:

错误码说明
5041 请求中未找到shop_id参数

3.3.2 获取门店下巡查工作数据统计

接口描述:通过本接口调用,可以获取到指定门店下基于门店统计的巡检工作数据统计

接口链接: /service/patrol/stat/groupByShop

接口版本:v2.0

接口参数:

参数名称是否必须类型说明示例
sunmi_shop_no string店铺编号列表560279010307
periodint统计周期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_countint考评检查项总数
scoreless_total_countint有问题检查项数
avg_scorefloat考评得分,百分制
rectify_countint应整改问题数
rectify_done_countint整改完成数
realtime_need_countint 实时巡店需整改数
realtime_total_countint 实时巡店总次数
snapshot_problem_countint抓拍巡检有问题数
snapshot_total_countint抓拍巡检总次数
evaluate_need_countint门店考评需整改数
evaluate_total_countint门店考评总次数

错误码:

错误码说明
5041 请求中未找到shop_id参数

3.3.3 获取模板使用情况数据统计

接口描述: 通过本接口调用,可以获取到指定门店下基于门店统计的巡检工作数据统计

接口链接: /service/patrol/stat/groupByTemplate

接口版本:v2.0

接口参数:

参数名称是否必须类型说明示例
sunmi_shop_no string店铺编号列表560279010307
periodint统计周期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_idint模板id
template_namestring模板名称
total_scoreint门店下模板累计得分
total_full_scoreint 门店下模板累计总分
total_countint总共使用次数

错误码:

错误码说明
5041 请求中未找到shop_id参数

3.3.4 获取模板-检查项使用情况数据统计

接口描述: 通过本接口调用,可以获取到指定门店下基于模板统计的巡检工作数据统计

接口链接: /service/patrol/stat/groupByCheckItem

接口版本:v2.0

接口参数:

参数名称是否必须类型说明示例
sunmi_shop_no string店铺编号列表560279010307
periodint统计周期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_idint模板id
check_item_namestring检查项名称
check_score_countint检查得分次数
check_total_countint 检查次数

错误码:

错误码说明
5041 请求中未找到shop_id参数