# 积分

# 成员积分

详见【成员-获取单个成员数据】文档。

# 调整积分

# 接口调用说明:

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

# 请求document

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

# 参数说明:

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

# SDK封装方法使用示例:

$attributes = [
    "op_type" => 1,
    "point" => 10,
    "reason" => "参加活动加分",
    "is_notify" => 1,
    "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 员工账号
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": "67507",
            "attributes": {
                "rule_name": "create_thread",
                "point": 20,
                "op_type": 1,
                "reason": "",
                "created_at": "2022-07-11 16:11:05"
            },
            "relationships": {
                "staff": {
                    "data": {
                        "type": "staff",
                        "id": "zhangsan"
                    }
                },
                "target": {
                    "data": {
                        "type": "thread",
                        "id": "010a439400f111ed81a67aef757e9477"
                    }
                }
            }
        },
        {
            "type": "point",
            "id": "67488",
            "attributes": {
                "rule_name": "delete_document",
                "point": 20,
                "op_type": 2,
                "reason": "",
                "created_at": "2022-07-11 14:58:33"
            },
            "relationships": {
                "staff": {
                    "data": {
                        "type": "staff",
                        "id": "mistcheng"
                    }
                }
            }
        }
    ],
    "links": {
        "first": "https://lxapi.lexiangla.com/cgi-bin/v1/points?staff_id=zhangsan&started_at=2018-12-01&ended_at=2022-08-01&per_page=2&page=1",
        "last": "https://lxapi.lexiangla.com/cgi-bin/v1/points?staff_id=zhangsan&started_at=2018-12-01&ended_at=2022-08-01&per_page=2&page=2704",
        "prev": null,
        "next": "https://lxapi.lexiangla.com/cgi-bin/v1/points?staff_id=zhangsan&started_at=2018-12-01&ended_at=2022-08-01&per_page=2&page=2"
    },
    "meta": {
        "current_page": 1,
        "from": 1,
        "last_page": 2704,
        "path": "https://lxapi.lexiangla.com/cgi-bin/v1/points",
        "per_page": 2,
        "to": 2,
        "total": 5408
    },
    "included": [
        {
            "type": "staff",
            "id": "zhangsan",
            "attributes": {
                "name": "zhangsan",
                "english_name": null,
                "organization": "2 "
            }
        },
        {
            "type": "thread",
            "id": "010a439400f111ed81a67aef757e9477",
            "attributes": {
                "title": "test",
                "content": "<p>test</p>",
                "summary": "test",
                "read_count": 1,
                "post_count": 0,
                "like_count": 0,
                "is_anonymous": false,
                "created_at": "2022-07-11 16:11:02",
                "updated_at": "2022-07-11 16:11:02"
            },
            "links": {
                "platform": "https://km.lexiangla.com/threads/010a439400f111ed81a67aef757e9477"
            }
        }
    ]
}

rule_name对应的积分事件名称如下所示:

{
    "create_document": "创建文档",
    "delete_document": "删除文档",
    "comment_document": "评论文档",
    "delete_comment_document": "删除文档评论",
    "like_document": "点赞文档",
    "delete_like_document": "取消文档点赞",
    "favorite_document": "收藏文档",
    "delete_favorite_document": "取消文档收藏",
    "reward_document": "赞赏文档",
    "star_document": "文档被管理员设置星标",
    "recommend_document": "文档被管理员推荐",
    "create_question": "创建问题",
    "delete_question": "删除问题",
    "answer_question": "回答问题",
    "delete_answer_question": "删除回答",
    "like_answer_question": "回答被点赞",
    "delete_like_answer_question": "取消乐问回答点赞",
    "recommend_question": "问题被推荐",
    "pin_answer_question": "回答被置顶",
    "create_thread": "发帖",
    "delete_thread": "删除发帖",
    "create_post": "回帖",
    "delete_post": "删除回帖",
    "like_thread": "点赞帖子",
    "delete_like_thread": "取消点赞帖子",
    "global_pin_thread": "主贴被全论坛置顶",
    "category_pin_thread": "主贴被板块置顶",
    "recommend_thread": "主贴被推荐",
    "pin_post": "回帖被置顶",
    "study_required_course": "学习必修课",
    "finish_required_course": "完成必修课",
    "study_elective_course": "学习选修课",
    "finish_elective_course": "完成选修课",
    "comment_course": "评论课程",
    "delete_comment_course": "删除课程评论",
    "join_exam": "参加考试",
    "finish_exam": "完成考试",
    "pass_exam": "通过考试",
    "create_survey": "创建投票",
    "delete_survey": "删除投票",
    "join_survey": "参加投票",
    "comment_survey": "评论投票",
    "delete_comment_survey": "删除投票评论",
    "create_event": "创建活动",
    "delete_event": "删除活动",
    "join_event": "参加活动",
    "attend_event": "签到活动",
    "comment_event": "评论活动",
    "delete_comment_event": "删除活动评论",
    "start_roadmap": "参加学习地图",
    "succeed_roadmap": "完成学习地图",
    "birthday": "祝福-生日积分",
    "entry_anniversary": "祝福-入职周年积分",
    "send_wish": "祝福-送祝福积分",
    "check_in": "签到",
    "certificate_reward": "证书颁发",
    "delete_certificate_reward": "证书收回",
    "create_share": "发布轻享",
    "delete_share": "删除轻享",
    "create_share_reply": "发布轻享评论",
    "delete_share_reply": "删除轻享评论",
    "create_share_like": "轻享发表表情",
    "delete_share_like": "删除轻享表情",
    "set_top_share": "轻享被置顶",
    "cancel_top_share": "轻享被取消置顶"
}
# 400 Bad Request 状态码

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

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

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

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