Moka 系统中会根据请求的列表中每个门店信息对当前系统中的门店进行同步(新增,更新,停用,启用)。
HTTP 请求
PUT https://api.mokahr.com/api-platform/v1/stores
请求body参数
字段 | 必填 | 类型 | 描述 |
---|---|---|---|
apiCode | 是 | string | 门店的唯一id |
name | 是 | string | 门店名称 |
address | 是 | string | 门店地址 (包含省市区的地址) |
cityId | 否 | number | 门店所属行政区码,详情见 |
lat | 否 | number | 门店坐标纬度(高德地图系) |
lng | 否 | number | 门店坐标经度(高德地图系) |
relationDepartmentType | 否 | boolean | 可选值: |
departmentCode | 否 | string | 部门code |
departmentName | 否 | string | 部门名称 |
disabled | 否 | number | 门店启停状态 |
处理
我们会对数据field进行校验, 如果校验未通过, 则返回具体的错误信息:
进行校验的field:['name', 'apiCode', 'cityId', 'address']
可能的错误码:
code | 描述 |
---|---|
duplicated | 信息重复 |
invalid | 数据不正确,比如传入了不支持的cityId |
missing_field | 缺少该field,或有field值为空 |
请求样例
$ curl 'https://api.mokahr.com/api-platform/v1/stores' \
-u 'your_api_key:' \
-X PUT \
-d '[ { "apiCode": "111111", "name": "北京海淀区门店", "lat": 39.985043, "lng": 116.293914, "address": "北京海淀区花园路x号", "cityId": 110108, "departmentName": "北京海淀区门店组织" }, { "apiCode": "222222", "name": "北京朝阳区门店", "lat": 22.627981, "lng": 114.115447, "address": "北京市朝阳区麦子店街道枣营北里社区", "cityId": 110105, "departmentName": "北京朝阳区门店组织" }, ... ]'
2
3
4
操作成功:
{ "success": true, "result": { "new": 20, "update": 10, "disabled": 0 } }
操作失败:
{ "success": false, "errorMessage": "错误信息", "errors": [ {} ] }
未开启门店错误:
{ "success": false, "errorMessage": "未开启门店功能" }
validation错误:
{ "success": false, "errorMessage": "Validation Failed", "errors": [ { "field": "apiCode", "code": "duplicated", "details": "123456" }, { "field": "name", "code": "duplicated", "details": "北京朝阳区门店1" }, { "field": "cityId", "code": "invalid", "details": { "cityId": "999999", "apiCode": "123456", "name": "北京朝阳区门店1", "lat": 22.627981, "lng": 114.115447, "address": "北京朝阳区", "departmentName": "朝阳部门" }, "document_url": "http://www.mokahr.com/docs/api/#stores" }, { "field": "name,cityId", "code": "missing_field", "details": { "apiCode": "111111", "lat": 24.775118681, "lng": "115.49405445", "address": "海淀区花园路4号" } } ] }