积分

成员积分

详见【成员-获取成员列表】文档。

调整积分

接口调用说明:

POST https://lxapi.lexiangla.com/cgi-bin/v1/points

请求document

{
    "data": {
        "type": "point",
        "attributes": {
            "op_type": 1,
            "point": 10,
            "reason": "参加活动加分",
            "is_notify": true
        },
        "relationships":{
            "recipient":{
                "data":{
                    "type":"staff",
                    "id":"ThreeZhang"
                }
            }
        }
    }
}

参数说明:

参数 是否必须 默认值 说明
point.op_type 1 积分操作类型;1:增加;2:扣减
point.point 0 分值
point.reason 备注说明
point.is_notify false 是否通过企业微信消息推送积分调整通知
point.recipient 关联的资源对象,类型为staff,表示被调整积分的员工

SDK封装方法使用示例:

$attributes = [
    "op_type" => 1,
    "point" => 10,
    "reason" => "参加活动加分",
    "is_notify" => true,
    "staff_id" => 'ThreeZhang',
];
$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->postPoint(StaffID, $attributes);

响应document

403 Forbidden 状态码
{
    "errors": [
        {
            "detail": "积分不足扣减"
        }
    ]
}
201 Created 状态码
{
    "data": {
        "type": "point",
        "id": 1980,
        "attributes": {
            "rule_name": "admin",
            "point": 10,
            "op_type": 1,
            "reason": "参加活动加分",
            "created_at": "2019-12-25 15:19:27"
        }
    }
}

获取积分明细

接口调用说明:

GET https://lxapi.lexiangla.com/cgi-bin/v1/points

参数说明:

参数 是否必须 默认值 说明
staff_id 员工的企业微信ID
started_at 起始日期,如 2019-12-12
ended_at 截止日期,如 2019-12-24
page 1 当前页数
per_page 20 每页返回的数量

SDK封装方法使用示例:

$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->get('points',[
    'staff_id' => 'ThreeZhang',
    'started_at' => '2019-12-12',
    'ended_at' => '2019-12-24',
    'page' => 1,
    'per_page' => 20
]);

响应document

200 OK 状态码
{
    "data": [
        {
            "type": "point",
            "id": 1976,
            "attributes": {
                "rule_name": "create_question",
                "point": 5,
                "op_type": 1,
                "reason": "",
                "created_at": "2019-12-25 14:52:21"
            },
            "relationships": {
                "staff": {
                    "data": {
                        "type": "staff",
                        "id": "ThreeZhang"
                    }
                }
            }
        }
    ],
    "links": {
        "first": "https://lxapi.lexiangla.com/cgi-bin/v1/points?staff_id=ThreeZhang&started_at=2019-12-12&ended_at=2019-12-24&per_page=20&page=1",
        "last": "https://lxapi.lexiangla.com/cgi-bin/v1/points?staff_id=ThreeZhang&started_at=2019-12-12&ended_at=2019-12-24&per_page=20&page=11",
        "prev": null,
        "next": "https://lxapi.lexiangla.com/cgi-bin/v1/points?staff_id=ThreeZhang&started_at=2019-12-12&ended_at=2019-12-24&per_page=20&page=2"
    },
    "meta": {
        "current_page": 1,
        "from": 1,
        "last_page": 11,
        "path": "https://lxapi.lexiangla.com/cgi-bin/v1/points",
        "per_page": 20,
        "to": 15,
        "total": 164
    },
    "included": [
         {
             "type":"staff",
             "id":"ThreeZhang",
             "attributes":{
                 "name":"张三",
                 "english_name":null,
                 "organization":"开发组\乐享开发 "
             }
         }
    ]
}
400 Bad Request 状态码

当员工的企业微信ID不存在时,会返回400状态码,且响应体如下所示:

{
    "errors": [
        {
            "detail": "该员工不存在"
        }
    ]
}

当没有传递必须参数时,会返回400状态码,且响应体如下所示:

{
    "errors":[
        {
            "detail":"{"started_at":["不能为空"],"ended_at":["不能为空"]}"
        }
    ]
}