work/checkin.pm untested

filter: Statementstmt 0.0% 0 / 151 Branchbran 0.0% 0 / 52 Conditioncond 0.0% 0 / 78 MC/DCmcdc 0.0% 0 / 39 Subroutinesub 0.0% 0 / 19 Podpod 0.0% 0 / 13 totaltotal 0.0% 0 / 352 CC 27 SCAR 23.7
CC
27
Cov
0%
getcorpcheckinoption
12.0
getcheckinoption
12.0
getcheckindata
12.0
CRAP 10.7
1 package QQ::weixin::work::checkin;
2
3 =encoding utf8
4
5 =head1 Name
6
7 QQ::weixin::work::checkin
8
9 =head1 DESCRIPTION
10
11 打卡
12
13 =cut
14
15 use strict;
16 use base qw(QQ::weixin::work);
17 use Encode;
18 use LWP::UserAgent;
19 use JSON;
20 use utf8;
21
22 our $VERSION = '0.10';
23 our @EXPORT = qw/ getcorpcheckinoption getcheckinoption getcheckindata
24 getcheckin_daydata getcheckin_monthdata
25 getcheckinschedulist setcheckinschedulist
26 punch_correction addcheckinuserface
27 add_checkin_option update_checkin_option clear_checkin_option_array_field
28 del_checkin_option /;
29
30 =head1 FUNCTION
31
32 =head2 getcorpcheckinoption(access_token, hash);
33
34 获取企业所有打卡规则
35 最后更新:2023/11/30
36
37 =head2 SYNOPSIS
38
39 L<https://developer.work.weixin.qq.com/document/path/93384>
40
41 =head3 请求说明:
42
43 自建应用、代开发应用可用此接口,获取企业内所有打卡规则。
44
45 =head4 请求包结构体为:
46
47 {}
48
49 =head4 参数说明:
50
51 参数 必须 说明
52 access_token 是 调用接口凭证。必须使用打卡应用的Secret获取access_token,获取方式参考:文档-获取access_token
53
54 =head4 调用频率:
55
56 接口调用频率限制为60次/分钟。
57
58 =head3 权限说明
59
60 应用类型 权限要求
61 自建应用 配置到「打卡 - 可调用接口的应用」中
62 代开发应用 具有「打卡」权限
63 第三方应用 暂不支持
64
65 注: 从2023年12月1日0点起,不再支持通过系统应用secret调用接口,存量企业暂不受影响 查看详情
66
67 =head3 RETURN 返回结果
68
69 {
70 "errcode": 0,
71 "errmsg": "ok",
72 "group": [{
73 "grouptype": 1,
74 "groupid": 69,
75 "checkindate": [{
76 "workdays": [
77 1,
78 2,
79 3,
80 4,
81 5
82 ],
83 "checkintime": [{
84 "work_sec": 36000,
85 "off_work_sec": 43200,
86 "remind_work_sec": 35400,
87 "remind_off_work_sec": 43200
88 },
89 {
90 "work_sec": 50400,
91 "off_work_sec": 72000,
92 "remind_work_sec": 49800,
93 "remind_off_work_sec": 72000
94 }
95 ],
96 "noneed_offwork": true,
97 "limit_aheadtime": 10800000,
98 "flex_on_duty_time": 0,
99 "flex_off_duty_time": 0,
100 }],
101 "spe_workdays": [{
102 "timestamp": 1512144000,
103 "notes": "必须打卡的日期",
104 "checkintime": [{
105 "work_sec": 32400,
106 "off_work_sec": 61200,
107 "remind_work_sec": 31800,
108 "remind_off_work_sec": 61200
109 }]
110 }],
111 "spe_offdays": [{
112 "timestamp": 1512057600,
113 "notes": "不需要打卡的日期",
114 "checkintime": []
115 }],
116 "sync_holidays": true,
117 "groupname": "打卡规则1",
118 "need_photo": true,
119 "wifimac_infos": [{
120 "wifiname": "Tencent-WiFi-1",
121 "wifimac": "c0:7b:bc:37:f8:d3",
122 },
123 {
124 "wifiname": "Tencent-WiFi-2",
125 "wifimac": "70:10:5c:7d:f6:d5",
126 }
127 ],
128 "note_can_use_local_pic": false,
129 "allow_checkin_offworkday": true,
130 "allow_apply_offworkday": true,
131 "loc_infos": [{
132 "lat": 30547030,
133 "lng": 104062890,
134 "loc_title": "腾讯成都大厦",
135 "loc_detail": "四川省成都市武侯区高新南区天府三街",
136 "distance": 300
137 },
138 {
139 "lat": 23097490,
140 "lng": 113323750,
141 "loc_title": "T.I.T创意园",
142 "loc_detail": "广东省广州市海珠区新港中路397号",
143 "distance": 300
144 }
145 ],
146 "range": {
147 "party_id": []
148 "userid": ["icef", "LiJingZhong"]
149 "tagid": [2]
150 },
151 "create_time": 1606204343,
152 "white_users": ["canno"],
153 "type": 0,
154 "reporterinfo": {
155 "reporters": [{
156 "userid": "brant"
157 }],
158 "updatetime": 1606305508
159 },
160 "ot_info": {
161 "type": 2,
162 "allow_ot_workingday": true,
163 "allow_ot_nonworkingday": false,
164 "otcheckinfo": {
165 "ot_workingday_time_start": 1800,
166 "ot_workingday_time_min": 1800,
167 "ot_workingday_time_max": 14400,
168 "ot_nonworkingday_time_min": 1800,
169 "ot_nonworkingday_time_max": 14400,
170 "ot_workingday_restinfo": {
171 "type": 2,
172 "fix_time_rule": {
173 "fix_time_begin_sec": 43200,
174 "fix_time_end_sec": 46800
175 },
176 "cal_ottime_rule": {
177 "items": [{
178 "ot_time": 18000,
179 "rest_time": 3600
180 }]
181 }
182 },
183 "ot_nonworkingday_restinfo": {
184 "type": 2,
185 "fix_time_rule": {
186 "fix_time_begin_sec": 43200,
187 "fix_time_end_sec": 46800
188 },
189 "cal_ottime_rule": {
190 "items": [{
191 "ot_time": 18000,
192 "rest_time": 3600
193 }]
194 }
195 },
196 "ot_nonworkingday_spanday_time": 0
197 },
198 "uptime": 1606275664,
199 "otapplyinfo": {
200 "allow_ot_workingday": true "allow_ot_nonworkingday": true "uptime": 1606275664,
201 "ot_workingday_restinfo": {
202 "type": 2,
203 "fix_time_rule": {
204 "fix_time_begin_sec": 43200,
205 "fix_time_end_sec": 46800
206 },
207 "cal_ottime_rule": {
208 "items": [{
209 "ot_time": 18000,
210 "rest_time": 3600
211 }]
212 }
213 },
214 "ot_nonworkingday_restinfo": {
215 "type": 2,
216 "fix_time_rule": {
217 "fix_time_begin_sec": 43200,
218 "fix_time_end_sec": 46800
219 },
220 "cal_ottime_rule": {
221 "items": [{
222 "ot_time": 18000,
223 "rest_time": 3600
224 }]
225 }
226 },
227 "ot_nonworkingday_spanday_time": 0
228 }
229 },
230 "allow_apply_bk_cnt": -1,
231 "option_out_range": 0,
232 "create_userid": "gaogao",
233 "use_face_detect": false,
234 "allow_apply_bk_day_limit": -1,
235 "update_userid": "sandy",
236 "schedulelist": [{
237 "schedule_id": 221,
238 "schedule_name": "2",
239 "time_section": [{
240 "time_id": 1,
241 "work_sec": 32400,
242 "off_work_sec": 61200,
243 "remind_work_sec": 31800,
244 "remind_off_work_sec": 61200,
245 "rest_begin_time": 43200,
246 "rest_end_time": 46800,
247 "allow_rest": false
248 }],
249 "limit_aheadtime": 14400000,
250 "noneed_offwork": false,
251 "limit_offtime": 14400,
252 "flex_on_duty_time": 0,
253 "flex_off_duty_time": 0,
254 "allow_flex": false,
255 "late_rule": {
256 "allow_offwork_after_time": false,
257 "timerules": [{
258 "offwork_after_time": 3600,
259 "onwork_flex_time": 3600
260 }]
261 },
262 "max_allow_arrive_early": 0,
263 "max_allow_arrive_late": 0
264 }],
265 "offwork_interval_time": 300
266 }]
267 }
268
269 =head4 RETURN 参数说明
270
271 参数 类型 说明
272 errcode int32 错误码,详情见错误码说明
273 errmsg string 错误码对应的错误信息提示
274 group obj[] 企业规则信息列表
275 group.grouptype uint32 打卡规则类型,1:固定时间上下班;2:按班次上下班;3:自由上下班
276 group.groupid uint32 打卡规则id
277 group.groupname string 打卡规则名称
278 group.checkindate obj[] 打卡时间,当规则类型为排班时没有意义
279 group.checkindate.workdays uint32[] 工作日。若为固定时间上下班或自由上下班,则1到6分别表示星期一到星期六,0表示星期日
280 group.checkindate.checkintime uint32 工作日上下班打卡时间信息
281 group.checkindate.checkintime.work_sec uint32 上班时间,表示为距离当天0点的秒数。
282 group.checkindate.checkintime.off_work_sec uint32 下班时间,表示为距离当天0点的秒数。
283 group.checkindate.checkintime.remind_work_sec uint32 上班提醒时间,表示为距离当天0点的秒数。
284 group.checkindate.checkintime.remind_off_work_sec uint32 下班提醒时间,表示为距离当天0点的秒数。
285 group.checkindate.noneed_offwork bool 下班不需要打卡,true为下班不需要打卡,false为下班需要打卡
286 group.checkindate.limit_aheadtime uint32 打卡时间限制(毫秒)
287 group.checkindate.flex_on_duty_time int32 允许迟到时间(秒)
288 group.checkindate.flex_off_duty_time int32 允许早退时间(秒)
289 group.spe_workdays obj[] 特殊日期-必须打卡日期信息,timestamp表示具体时间
290 group.spe_workdays.timestamp uint32 特殊日期-必须打卡日期时间戳
291 group.spe_workdays.notes string 特殊日期备注
292 group.spe_workdays.checkintime obj[] 特殊日期-必须打卡日期-上下班打卡时间,内部参数同group.checkindate.checkintime
293 group.spe_offdays obj[] 特殊日期-不用打卡日期信息, timestamp表示具体时间
294 group.spe_offdays.timestamp uint32 特殊日期-不用打卡日期时间戳
295 group.spe_offdays.notes string 特殊日期备注
296 group.sync_holidays bool 是否同步法定节假日,true为同步,false为不同步,当前排班不支持
297 group.need_photo bool 是否打卡必须拍照,true为必须拍照,false为不必须拍照
298 group.note_can_use_local_pic bool 是否备注时允许上传本地图片,true为允许,false为不允许
299 group.allow_checkin_offworkday bool 是否非工作日允许打卡,true为允许,false为不允许
300 group.allow_apply_offworkday bool 是否允许提交补卡申请,true为允许,false为不允许
301 group.wifimac_infos obj[] 打卡地点-WiFi打卡信息
302 group.wifimac_infos.wifiname string WiFi打卡地点名称
303 group.wifimac_infos.wifimac string WiFi打卡地点MAC地址/bssid
304 group.loc_infos obj[] 打卡地点-位置打卡信息
305 group.loc_infos.lat int64 位置打卡地点纬度,是实际纬度的1000000倍,与腾讯地图一致采用GCJ-02坐标系统标准
306 group.loc_infos.lng int64 位置打卡地点经度,是实际经度的1000000倍,与腾讯地图一致采用GCJ-02坐标系统标准
307 group.loc_infos.loc_title string 位置打卡地点名称
308 group.loc_infos.loc_detail string 位置打卡地点详情
309 group.loc_infos.distance uint32 允许打卡范围(米)
310 group.range obj 打卡人员信息
311 group.range.userid string 打卡人员中,单个打卡人员节点的userid
312 group.range.party_id string[] 打卡人员中,部门节点的id
313 group.range.tagid uint32[] 打卡人员中,标签节点的标签id
314 group.create_time uint32 创建打卡规则时间,为unix时间戳
315 group.white_users string[] 打卡人员白名单,即不需要打卡人员,需要有设置白名单才能查看
316 group.type uint32 打卡方式,0:手机;2:智慧考勤机;3:手机+智慧考勤机
317 group.reporterinfo obj 汇报对象信息
318 group.reporterinfo.reporters obj[] 汇报对象,每个汇报人用userid表示
319 group.reporterinfo.updatetime uint32 汇报对象更新时间
320 group.ot_info obj 加班信息,相关信息需要设置后才能显示
321 group.ot_info.type int32 加班类型 0:以加班申请核算打卡记录(根据打卡记录和加班申请核算),1:以打卡时间为准(根据打卡时间计算),2: 以加班申请审批为准(只根据加班申请计算)
322 group.ot_info.allow_ot_workingday bool 允许工作日加班,true为允许,false为不允许
323 group.ot_info.allow_ot_nonworkingday bool 允许非工作日加班,true为允许,flase为不允许
324 group.ot_info.otcheckinfo obj 以打卡时间为准-加班时长计算规则信息
325 group.ot_info.otcheckinfo.ot_workingday_time_start uint32 允许工作日加班-加班开始时间:下班后xx秒开始计算加班,距离最晚下班时间的秒数,例如,1800(30分钟 乘以 60秒),默认值30分钟
326 group.ot_info.otcheckinfo.ot_workingday_time_min uint32 允许工作日加班-最短加班时长:不足xx秒视为未加班,单位秒,默认值30分钟
327 group.ot_info.otcheckinfo.ot_workingday_time_max uint32 允许工作日加班-最长加班时长:超过则视为加班xx秒,单位秒,默认值240分钟
328 group.ot_info.otcheckinfo.ot_nonworkingday_time_min uint32 允许非工作日加班-最短加班时长:不足xx秒视为未加班,单位秒,默认值30分钟
329 group.ot_info.otcheckinfo.ot_nonworkingday_time_max uint32 允许非工作日加班-最长加班时长:超过则视为加班xx秒 单位秒,默认值240分钟
330 group.ot_info.otcheckinfo.ot_nonworkingday_spanday_time uint32 非工作日加班,跨天时间,距离当天00:00的秒数
331 group.ot_info.otcheckinfo.ot_workingday_restinfo obj 工作日加班-休息扣除配置信息
332 uptime uint32 更新时间 |
333 group.ot_info.otcheckinfo.ot_workingday_restinfo.type uint32 工作日加班-休息扣除类型:0-不开启扣除;1-指定休息时间扣除;2-按加班时长扣除休息时间
334 group.ot_info.otcheckinfo.ot_workingday_restinfo.fix_time_rule obj 工作日加班-指定休息时间配置信息,当group.ot_info.otcheckinfo.ot_workingday_restinfo.type为1时有意义
335 group.ot_info.otcheckinfo.ot_workingday_restinfo.fix_time_rule.fix_time_begin_sec uint32 工作日加班-指定休息时间的开始时间, 距离当天00:00的秒数
336 group.ot_info.otcheckinfo.ot_workingday_restinfo.fix_time_rule.fix_time_end_sec uint32 工作日加班-指定休息时间的结束时间, 距离当天00:00的秒数
337 group.ot_info.otcheckinfo.ot_workingday_restinfo.cal_ottime_rule obj 工作日加班-按加班时长扣除配置信息,当group.ot_info.otcheckinfo.ot_workingday_restinfo.type为2时有意义
338 group.ot_info.otcheckinfo.ot_workingday_restinfo.cal_ottime_rule.items obj 工作日加班-按加班时长扣除条件信息
339 group.ot_info.otcheckinfo.ot_workingday_restinfo.cal_ottime_rule.items.ot_time uint32 加班满-时长(秒)
340 group.ot_info.otcheckinfo.ot_workingday_restinfo.cal_ottime_rule.items.rest_time uint32 对应扣除-时长(秒)
341 group.ot_info.otcheckinfo.ot_nonworkingday_restinfo obj 非工作日加班-休息扣除配置信息,参数信息与group.ot_info.otcheckinfo.ot_workingday_restinfo一致
342 otapplyinfo obj 以加班申请核算打卡记录相关信息,根据加班申请核算加班时长,只有有设置相关信息时且以以加班申请核算打卡才有相关信息;内含参数释义基本同group.ot_info.otcheckinfo,但只包含加班休息扣除、跨天时间等参数
343 group.allow_apply_bk_cnt int32 每月最多补卡次数,默认-1表示不限制
344 group.option_out_range uint32 范围外打卡处理方式,0-视为范围外异常,默认值;1-视为正常外勤;2:不允许范围外打卡
345 group.create_userid string 规则创建人userid
346 group.use_face_detect bool 人脸识别打卡开关,true为启用,false为不启用
347 group.allow_apply_bk_day_limit int32 允许补卡时限,默认-1表示不限制。单位天
348 group.update_userid string 规则最近编辑人userid
349 group.schedulelist obj[] 排班信息,只有规则为按班次上下班打卡时才有该配置
350 group.schedulelist.schedule_id uint32 班次id
351 group.schedulelist.schedule_name string 班次名称
352 group.schedulelist.time_section obj[] 班次上下班时段信息
353 group.schedulelist.time_section.time_id uint32 时段id,为班次中某一堆上下班时间组合的id
354 group.schedulelist.time_section.work_sec uint32 上班时间,表示为距离当天0点的秒数。
355 group.schedulelist.time_section.off_work_sec uint32 下班时间,表示为距离当天0点的秒数。
356 group.schedulelist.time_section.remind_work_sec uint32 上班提醒时间,表示为距离当天0点的秒数。
357 group.schedulelist.time_section.remind_off_work_sec uint32 下班提醒时间,表示为距离当天0点的秒数。
358 group.schedulelist.time_section.rest_begin_time uint32 休息开始时间,仅单时段支持,距离0点的秒
359 group.schedulelist.time_section.rest_end_time uint32 休息结束时间,仅单时段支持,距离0点的秒
360 group.schedulelist.time_section.allow_rest bool 是否允许休息
361 group.schedulelist.limit_aheadtime uint32 允许提前打卡时间
362 group.schedulelist.limit_offtime uint32 下班xx秒后不允许打下班卡
363 group.schedulelist.noneed_offwork bool 下班不需要打卡
364 group.schedulelist.allow_flex bool 是否允许弹性时间
365 group.schedulelist.flex_on_duty_time uint32 允许迟到时间(秒)
366 group.schedulelist.flex_off_duty_time uint32 允许早退时间(秒)
367 group.schedulelist.late_rule obj 晚走晚到时间规则信息
368 group.schedulelist.late_rule.allow_offwork_after_time bool 是否允许超时下班(下班晚走次日晚到)允许时onwork_flex_time,offwork_after_time才有意义
369 group.schedulelist.late_rule.timerules obj[] 迟到规则时间
370 group.schedulelist.late_rule.timerules.offwork_after_time uint32 晚走的时间 距离最晚一个下班的时间单位:秒
371 group.schedulelist.late_rule.timerules.onwork_flex_time uint32 第二天第一个班次允许迟到的弹性时间单位:秒
372 group.schedulelist.max_allow_arrive_early uint32 最早可打卡时间限制
373 group.schedulelist.max_allow_arrive_late uint32 最晚可打卡时间限制,max_allow_arrive_early、max_allow_arrive_early与flex_on_duty_time、flex_off_duty_time互斥,当设置其中一组时,另一组数值置0
374 group.offwork_interval_time uint32 自由签到,上班打卡后xx秒可打下班卡
375 group.buka_restriction uint64 补卡指定异常类型,按比特位设置,大端模式,某位bit置位为1表示关闭某类型。从低到高四个比特位分别表示缺卡类型、迟到类型、早退类型、其他异常类型。为默认值0表示所有异常类型均允许补卡。
376
377 =cut
378
379 sub getcorpcheckinoption {
380 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
381 my $access_token = $_[0];
382 my $json = $_[1];
383 my $ua = LWP::UserAgent->new;
384 $ua->timeout(30);
385 $ua->env_proxy;
386
387 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/checkin/getcorpcheckinoption?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
388 if ($response->is_success) {
389 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
390 }
391
392 }
393 return 0;
394 }
395
396 =head2 getcheckinoption(access_token, hash);
397
398 获取员工打卡规则
399 最后更新:2023/11/30
400
401 =head2 SYNOPSIS
402
403 L<https://developer.work.weixin.qq.com/document/path/90263>
404
405 =head3 请求说明:
406
407 自建应用、第三方应用和代开发应用可使用此接口,获取可见范围内指定员工指定日期的打卡规则。
408
409 =head4 请求包结构体为:
410
411 {
412 "datetime": 1511971200,
413 "useridlist": ["james","paul"]
414 }
415
416 =head4 参数说明:
417
418 参数 必须 说明
419 access_token 是 调用接口凭证。必须使用打卡应用的Secret获取access_token,获取方式参考:文档-获取access_token
420 datetime 是 需要获取规则的日期当天0点的Unix时间戳
421 useridlist 是 需要获取打卡规则的用户列表
422
423 1. 用户列表不超过100个,若用户超过100个,请分批获取。
424 2. 用户在不同日期的规则不一定相同,请按天获取。
425
426 =head3 权限说明
427
428 应用类型 权限要求
429 自建应用 配置到「打卡 - 可调用接口的应用」中
430 代开发应用 具有「打卡」权限
431 第三方应用 具有「打卡」权限
432
433 注: 从2023年12月1日0点起,不再支持通过系统应用secret调用接口,存量企业暂不受影响 查看详情
434
435 =head3 RETURN 返回结果
436
437 {
438 "errcode": 0,
439 "errmsg": "ok",
440 "info": [
441 {
442 "userid": "james",
443 "group": {
444 "grouptype": 1,
445 "groupid": 69,
446 "checkindate": [
447 {
448 "workdays": [
449 1,
450 2,
451 3,
452 4,
453 5
454 ],
455 "checkintime": [
456 {
457 "work_sec": 36000,
458 "off_work_sec": 43200,
459 "remind_work_sec": 35400,
460 "remind_off_work_sec": 43200
461 },
462 {
463 "work_sec": 50400,
464 "off_work_sec": 72000,
465 "remind_work_sec": 49800,
466 "remind_off_work_sec": 72000
467 }
468 ],
469 "flex_time": 300000,
470 "noneed_offwork": true,
471 "limit_aheadtime": 10800000,
472 "flex_on_duty_time":0,
473 "flex_off_duty_time":0,
474 }
475 ],
476 "spe_workdays": [
477 {
478 "timestamp": 1512144000,
479 "notes": "必须打卡的日期",
480 "checkintime": [
481 {
482 "work_sec": 32400,
483 "off_work_sec": 61200,
484 "remind_work_sec": 31800,
485 "remind_off_work_sec": 61200
486 }
487 ]
488 }
489 ],
490 "spe_offdays": [
491 {
492 "timestamp": 1512057600,
493 "notes": "不需要打卡的日期",
494 "checkintime": []
495 }
496 ],
497 "sync_holidays": true,
498 "groupname": "打卡规则1",
499 "need_photo": true,
500 "wifimac_infos": [
501 {
502 "wifiname": "Tencent-WiFi-1",
503 "wifimac": "c0:7b:bc:37:f8:d3",
504 },
505 {
506 "wifiname": "Tencent-WiFi-2",
507 "wifimac": "70:10:5c:7d:f6:d5",
508 }
509 ],
510 "note_can_use_local_pic": false,
511 "allow_checkin_offworkday": true,
512 "allow_apply_offworkday": true,
513 "loc_infos": [
514 {
515 "lat": 30547030,
516 "lng": 104062890,
517 "loc_title": "腾讯成都大厦",
518 "loc_detail": "四川省成都市武侯区高新南区天府三街",
519 "distance": 300
520 },
521 {
522 "lat": 23097490,
523 "lng": 113323750,
524 "loc_title": "T.I.T创意园",
525 "loc_detail": "广东省广州市海珠区新港中路397号",
526 "distance": 300
527 }
528 ],
529 "schedulelist": [
530 {
531 "schedule_id":221,
532 "schedule_name":"2",
533 "time_section": [
534 {
535 "time_id":1,
536 "work_sec":32400,
537 "off_work_sec":61200,
538 "remind_work_sec":31800,
539 "remind_off_work_sec":61200,
540 "rest_begin_time":43200,
541 "rest_end_time":46800,
542 "allow_rest":false
543 }
544 ],
545 "limit_aheadtime":14400000,
546 "noneed_offwork":false,
547 "limit_offtime":14400,
548 "flex_on_duty_time":0,
549 "flex_off_duty_time":0,
550 "allow_flex":false,
551 "late_rule":
552 {
553 "allow_offwork_after_time":false,
554 "timerules":[
555 {
556 "offwork_after_time":3600,
557 "onwork_flex_time":3600
558 }
559 ]
560 },
561 "max_allow_arrive_early":0,
562 "max_allow_arrive_late":0
563 }
564 ]
565 }
566 }
567 ]
568 }
569
570 =head4 RETURN 参数说明
571
572 参数 类型 说明
573 errcode int32 错误码,详情见错误码说明
574 errmsg string 错误码对应的错误信息提示
575 info obj[] 返回的打卡规则列表
576 userid string 打卡人员userid
577 group obj 打卡规则相关信息
578 group.grouptype uint32 打卡规则类型。1:固定时间上下班;2:按班次上下班;3:自由上下班 。
579 group.groupname string 打卡规则名称
580 groupid uint32 打卡规则id
581 group.checkindate obj[] 打卡时间配置
582 group.checkindate.workdays uint32[] 工作日。若为固定时间上下班或自由上下班,则1到6分别表示星期一到星期六,0表示星期日;若为按班次上下班,则表示拉取班次的日期。
583 group.checkindate.checkintime obj[] 工作日上下班打卡时间信息
584 group.checkindate.checkintime.work_sec uint32 上班时间,表示为距离当天0点的秒数。
585 group.checkindate.checkintime.off_work_sec uint32 下班时间,表示为距离当天0点的秒数。
586 group.checkindate.checkintime.remind_work_sec uint32 上班提醒时间,表示为距离当天0点的秒数。
587 group.checkindate.checkintime.remind_off_work_sec uint32 下班提醒时间,表示为距离当天0点的秒数。
588 group.checkindate.noneed_offwork bool 下班不需要打卡,true为下班不需要打卡,false为下班需要打卡
589 group.checkindate.limit_aheadtime uint32 打卡时间限制(毫秒)
590 group.checkindate.flex_time uint32 弹性时间(毫秒)只有flex_on_duty_time,flex_off_duty_time不生效时(值为-1)才有意义
591 group.checkindate.flex_on_duty_time int32 允许迟到时间(秒),值为-1使用flex_time
592 group.checkindate.flex_off_duty_time int32 允许早退时间(秒),值为-1使用flex_time
593 group.spe_workdays obj[] 特殊日期-必须打卡日期,timestamp表示具体时间
594 group.spe_workdays.timestamp uint32 特殊日期-必须打卡日期时间戳
595 group.spe_workdays.notes string 特殊日期备注
596 group.spe_workdays.checkintime string 特殊日期打卡时间配置,参数同checkindate.checkintime
597 group.spe_offdays obj[] 特殊日期-不用打卡日期, timestamp表示具体时间
598 group.spe_offdays.timestamp uint32 特殊日期-不用打卡日期时间戳
599 group.spe_offdays.notes string 特殊日期备注
600 group.sync_holidays bool 是否同步法定节假日,true为同步,false为不同步,当前排班不支持
601 group.need_photo bool 是否打卡必须拍照,true为必须拍照,false为不必须拍照
602 group.note_can_use_local_pic bool 是否备注时允许上传本地图片,true为允许,false为不允许
603 group.allow_checkin_offworkday bool 是否非工作日允许打卡,true为允许,false为不允许
604 group.allow_apply_offworkday bool 是否允许提交补卡申请,true为允许,false为不允许
605 group.wifimac_infos obj[] 打卡地点-WiFi打卡信息
606 group.wifimac_infos.wifiname string WiFi打卡地点名称
607 group.wifimac_infos.wifimac string WiFi打卡地点MAC地址/bssid
608 group.loc_infos obj[] 打卡地点-位置打卡信息
609 group.loc_infos.lat int64 位置打卡地点纬度,是实际纬度的1000000倍,与腾讯地图一致采用GCJ-02坐标系统标准
610 group.loc_infos.lng int64 位置打卡地点经度,是实际经度的1000000倍,与腾讯地图一致采用GCJ-02坐标系统标准
611 group.loc_infos.loc_title string 位置打卡地点名称
612 group.loc_infos.loc_detail string 位置打卡地点详情
613 group.loc_infos.distance uint32 允许打卡范围(米)
614 group.schedulelist obj[] 排班信息,只有规则为按班次上下班打卡时才有该配置
615 group.schedulelist.schedule_id uint32 班次id
616 group.schedulelist.schedule_name string 班次名称
617 group.schedulelist.time_section obj[] 班次上下班时段信息
618 group.schedulelist.time_section.time_id uint32 时段id,为班次中某一堆上下班时间组合的id
619 group.schedulelist.time_section.work_se uint32 上班时间,表示为距离当天0点的秒数。
620 group.schedulelist.time_section.offwork_sec uint3 下班时间,表示为距离当天0点的秒数。
621 group.schedulelist.time_section.remind_work_sec uint32 上班提醒时间,表示为距离当天0点的秒数。
622 group.schedulelist.time_section.remind_offwork_sec uint32 下班提醒时间,表示为距离当天0点的秒数。
623 group.schedulelist.time_section.rest_begin_time uint32 休息开始时间,仅单时段支持,距离0点的秒
624 group.schedulelist.time_section.rest_end_time uint32 休息结束时间,仅单时段支持,距离0点的秒
625 group.schedulelist.time_section.allow_rest bool 是否允许休息
626 group.schedulelist.limit_aheadtime uint32 允许提前打卡时间
627 group.schedulelist.limit_offtime uint32 下班xx秒后不允许打下班卡
628 group.schedulelist.noneed_offwork bool 下班不需要打卡
629 group.schedulelist.allow_flex uint32 是否允许弹性时间
630 group.schedulelist.flex_on_duty_time uint32 允许迟到时间(秒),值为-1使用flex_time
631 group.schedulelist.flex_off_duty_time uint32 允许早退时间(秒),值为-1使用flex_time
632 group.schedulelist.late_rule obj 晚走晚到时间规则信息
633 group.schedulelist.late_rule.allow_offwork_after_time bool 是否允许超时下班(下班晚走次日晚到)允许时onwork_flex_time,offwork_after_time才有意义
634 group.schedulelist.late_rule.timerules obj[] 迟到规则时间
635 group.schedulelist.late_rule.timerules.offwork_after_time uint32 晚走的时间 距离最晚一个下班的时间单位:秒
636 group.schedulelist.late_rule.timerules.onwork_flex_time uint32 第二天第一个班次允许迟到的弹性时间单位:秒
637 group.schedulelist.max_allow_arrive_early uint32 最早可打卡时间限制
638 group.schedulelist.max_allow_arrive_late uint32 最晚可打卡时间限制,max_allow_arrive_early、max_allow_arrive_early与flex_on_duty_time、flex_off_duty_time互斥,当设置其中一组时,另一组数值置0
639 group.buka_restriction uint64 补卡指定异常类型,按比特位设置,大端模式,某位bit置位为1表示关闭某类型。从低到高四个比特位分别表示缺卡类型、迟到类型、早退类型、其他异常类型。为默认值0表示所有异常类型均允许补卡。
640
641 =cut
642
643 sub getcheckinoption {
644 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
645 my $access_token = $_[0];
646 my $json = $_[1];
647 my $ua = LWP::UserAgent->new;
648 $ua->timeout(30);
649 $ua->env_proxy;
650
651 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/checkin/getcheckinoption?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
652 if ($response->is_success) {
653 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
654 }
655
656 }
657 return 0;
658 }
659
660 =head2 getcheckindata(access_token, hash);
661
662 获取打卡记录数据
663 最后更新:2023/12/18
664
665 =head2 SYNOPSIS
666
667 L<https://developer.work.weixin.qq.com/document/path/90262>
668
669 =head3 请求说明:
670
671 应用可通过本接口,获取可见范围内员工指定时间段内的打卡记录数据。
672
673 =head4 请求包结构体为:
674
675 {
676 "opencheckindatatype": 3,
677 "starttime": 1492617600,
678 "endtime": 1492790400,
679 "useridlist": ["james","paul"]
680 }
681
682 =head4 参数说明:
683
684 参数 必须 说明
685 access_token 是 调用接口凭证,获取方式参考:文档-获取access_token
686 opencheckindatatype 是 打卡类型。1:上下班打卡;2:外出打卡;3:全部打卡
687 starttime 是 获取打卡记录的开始时间。Unix时间戳
688 endtime 是 获取打卡记录的结束时间。Unix时间戳
689 useridlist 是 需要获取打卡记录的用户列表
690
691 1. 获取记录时间跨度不超过30天
692 2. 用户列表不超过100个。若用户超过100个,请分批获取
693 3. 有打卡记录即可获取打卡数据,与当前"打卡应用"是否开启无关
694 4. 标准打卡时间只对于固定排班和自定义排班两种类型有效
695 5. 接口调用频率限制为600次/分钟
696
697 =head3 权限说明
698
699 应用类型 权限要求
700 自建应用 配置到「打卡 - 可调用接口的应用」中
701 代开发应用 具有「打卡」权限
702 第三方应用 具有「打卡」权限
703
704 注: 从2023年12月1日0点起,不再支持通过系统应用secret调用接口,存量企业暂不受影响 查看详情
705
706 =head3 RETURN 返回结果
707
708 {
709 "errcode":0,
710 "errmsg":"ok",
711 "checkindata": [{
712 "userid" : "james",
713 "groupname" : "打卡一组",
714 "checkin_type" : "上班打卡",
715 "exception_type" : "地点异常",
716 "checkin_time" : 1492617610,
717 "location_title" : "依澜府",
718 "location_detail" : "四川省成都市武侯区益州大道中段784号附近",
719 "wifiname" : "办公一区",
720 "notes" : "路上堵车,迟到了5分钟",
721 "wifimac" : "3c:46:d8:0c:7a:70",
722 "mediaids":["WWCISP_G8PYgRaOVHjXWUWFqchpBqqqUpGj0OyR9z6WTwhnMZGCPHxyviVstiv_2fTG8YOJq8L8zJT2T2OvTebANV-2MQ"],
723 "sch_checkin_time" : 1492617610,
724 "groupid" : 1,
725 "schedule_id" : 0,
726 "timeline_id" : 2
727 },{
728 "userid" : "paul",
729 "groupname" : "打卡二组",
730 "checkin_type" : "外出打卡",
731 "exception_type" : "时间异常",
732 "checkin_time" : 1492617620,
733 "location_title" : "重庆出口加工区",
734 "location_detail" : "重庆市渝北区金渝大道101号金渝大道",
735 "wifiname" : "办公室二区",
736 "notes" : "",
737 "wifimac" : "3c:46:d8:0c:7a:71",
738 "mediaids":["WWCISP_G8PYgRaOVHjXWUWFqchpBqqqUpGj0OyR9z6WTwhnMZGCPHxyviVstiv_2fTG8YOJq8L8zJT2T2OvTebANV-2MQ"],
739 "lat": 30547645,
740 "lng": 104063236,
741 "deviceid":"E5FA89F6-3926-4972-BE4F-4A7ACF4701E2",
742 "sch_checkin_time" : 1492617610,
743 "groupid" : 2,
744 "schedule_id" : 3,
745 "timeline_id" : 1
746 }]
747 }
748
749 =head4 RETURN 参数说明
750
751 参数 说明
752 userid 用户id
753 groupname 打卡规则名称
754 checkin_type 打卡类型。字符串,目前有:上班打卡,下班打卡,外出打卡
755 exception_type 异常类型,字符串,包括:时间异常,地点异常,未打卡,wifi异常,非常用设备。如果有多个异常,以分号间隔
756 checkin_time 打卡时间。Unix时间戳
757 location_title 打卡地点title
758 location_detail 打卡地点详情
759 wifiname 打卡wifi名称
760 notes 打卡备注
761 wifimac 打卡的MAC地址/bssid
762 mediaids 打卡的附件media_id,可使用media/get获取附件
763 lat 位置打卡地点纬度,是实际纬度的1000000倍,与腾讯地图一致采用GCJ-02坐标系统标准
764 lng 位置打卡地点经度,是实际经度的1000000倍,与腾讯地图一致采用GCJ-02坐标系统标准
765 deviceid 打卡设备id
766 sch_checkin_time 标准打卡时间,指此次打卡时间对应的标准上班时间或标准下班时间
767 groupid 规则id,表示打卡记录所属规则的id
768 schedule_id 班次id,表示打卡记录所属规则中,所属班次的id
769 timeline_id 时段id,表示打卡记录所属规则中,某一班次中的某一时段的id,如上下班时间为9:00-12:00、13:00-18:00的班次中,9:00-12:00为其中一组时段
770
771 =cut
772
773 sub getcheckindata {
774 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
775 my $access_token = $_[0];
776 my $json = $_[1];
777 my $ua = LWP::UserAgent->new;
778 $ua->timeout(30);
779 $ua->env_proxy;
780
781 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/checkin/getcheckindata?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
782 if ($response->is_success) {
783 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
784 }
785
786 }
787 return 0;
788 }
789
790 =head2 getcheckin_daydata(access_token, hash);
791
792 获取打卡日报数据
793 最后更新:2023/12/18
794
795 =head2 SYNOPSIS
796
797 L<https://developer.work.weixin.qq.com/document/path/93374>
798
799 =head3 请求说明:
800
801 企业可通过具有调用权限的应用,获取应用可见范围内指定员工指定日期内的打卡日报统计数据。
802
803 =head4 请求包结构体为:
804
805 {
806 "starttime": 1599062400,
807 "endtime": 1599062400,
808 "useridlist": [
809 "ZhangSan"
810 ]
811 }
812
813 =head4 参数说明:
814
815 参数 必须 类型 说明
816 access_token 是 string 调用接口凭证,获取方式参考:文档-获取access_token。
817 starttime 是 uint32 获取日报的开始时间。0点Unix时间戳
818 endtime 是 uint32 获取日报的结束时间。0点Unix时间戳
819 useridlist 是 string[] 获取日报的userid列表。
820 单个userid不少于1字节,不多于64字节
821 可填充个数:1 ~ 100
822
823 =head4 调用频率:
824
825 接口调用频率限制为100次/分钟。
826
827 =head3 权限说明
828
829 应用类型 权限要求
830 自建应用 配置到「打卡 - 可调用接口的应用」中
831 代开发应用 具有「打卡」权限
832 第三方应用 具有「打卡」权限
833
834 注: 从2023年12月1日0点起,不再支持通过系统应用secret调用接口,存量企业暂不受影响 查看详情
835
836 =head3 RETURN 返回结果
837
838 {
839 "errcode":0,
840 "errmsg":"ok",
841 "datas":[
842 {
843 "base_info":{
844 "date":1599062400,
845 "record_type":1,
846 "name":"张三",
847 "name_ex":"Three Zhang",
848 "departs_name":"有家企业/realempty;有家企业;有家企业/部门A4",
849 "acctid":"ZhangSan",
850 "rule_info":{
851 "groupid":10,
852 "groupname":"规则测试",
853 "scheduleid":0,
854 "schedulename":"",
855 "checkintime":[
856 {
857 "work_sec":38760,
858 "off_work_sec":38880
859 }
860 ]
861 },
862 "day_type":0
863 },
864 "summary_info":{
865 "checkin_count":2,
866 "regular_work_sec":31,
867 "standard_work_sec":120,
868 "earliest_time":38827,
869 "lastest_time":38858
870 },
871 "holiday_infos":[
872 {
873 "sp_description":{
874 "data":[
875 {
876 "lang":"zh_CN",
877 "text":"09/03 10:00~09/03 10:01"
878 }
879 ]
880 },
881 "sp_number":"202009030002",
882 "sp_title":{
883 "data":[
884 {
885 "lang":"zh_CN",
886 "text":"请假0.1小时"
887 }
888 ]
889 }
890 },
891 {
892 "sp_description":{
893 "data":[
894 {
895 "lang":"zh_CN",
896 "text":"08/25 14:37~09/10 14:37"
897 }
898 ]
899 },
900 "sp_number":"202008270004",
901 "sp_title":{
902 "data":[
903 {
904 "lang":"zh_CN",
905 "text":"加班17.0小时"
906 }
907 ]
908 }
909 }
910 ],
911 "exception_infos":[
912 {
913 "count":1,
914 "duration":60,
915 "exception":1
916 },
917 {
918 "count":1,
919 "duration":60,
920 "exception":2
921 }
922 ],
923 "ot_info":{
924 "ot_status":1,
925 "ot_duration":3600,
926 "exception_duration":[],
927 "workday_over_as_money": 54000
928 },
929 "sp_items":[
930 {
931 "count":1,
932 "duration":360,
933 "time_type":0,
934 "type":1,
935 "vacation_id":2,
936 "name":"年假",
937 },
938 {
939 "count":0,
940 "duration":0,
941 "time_type":0,
942 "type":100,
943 "vacation_id":0,
944 "name":"外勤次数"
945 }
946 ]
947 }
948 ]
949 }
950
951 =head4 RETURN 参数说明
952
953 参数 类型 说明
954 errcode int32 返回码
955 errmsg string 错误码描述
956 datas obj[] 日报数据列表
957 datas.base_info obj 基础信息
958 datas.base_info.date uint32 日报日期
959 datas.base_info.record_type uint32 记录类型:1-固定上下班;2-外出(此报表中不会出现外出打卡数据);3-按班次上下班;4-自由签到;5-加班;7-无规则
960 datas.base_info.name string 打卡人员姓名
961 datas.base_info.name_ex string 打卡人员别名
962 datas.base_info.departs_name string 打卡人员所在部门,会显示所有所在部门
963 datas.base_info.acctid string 打卡人员账号,即userid
964 datas.base_info.rule_info obj 打卡人员所属规则信息
965 datas.base_info.rule_info.groupid int32 所属规则的id
966 datas.base_info.rule_info.groupname string 打卡规则名
967 datas.base_info.rule_info.scheduleid int32 当日所属班次id,仅按班次上下班才有值,显示在打卡日报-班次列
968 datas.base_info.rule_info.schedulename string 当日所属班次名称,仅按班次上下班才有值,显示在打卡日报-班次列
969 datas.base_info.rule_info.checkintime obj[] 当日打卡时间,仅固定上下班规则有值,显示在打卡日报-班次列
970 datas.base_info.rule_info.checkintime.work_sec uint32 上班时间,为距离0点的时间差
971 datas.base_info.rule_info.checkintime.off_work_sec uint32 下班时间,为距离0点的时间差
972 datas.base_info.day_type uint32 日报类型:0-工作日日报;1-休息日日报
973 datas.summary_info obj 汇总信息
974 datas.summary_info.checkin_count int32 当日打卡次数
975 datas.summary_info.regular_work_sec int32 当日实际工作时长,单位:秒
976 datas.summary_info.standard_work_sec int32 当日标准工作时长,单位:秒
977 datas.summary_info.earliest_time int32 当日最早打卡时间
978 datas.summary_info.lastest_time int32 当日最晚打卡时间
979 datas.holiday_infos obj[] 假勤相关信息
980 datas.holiday_infos.sp_number string 假勤申请id,即当日关联的假勤审批单id
981 datas.holiday_infos.sp_title obj 假勤信息摘要-标题信息
982 datas.holiday_infos.sp_title.data obj[] 多种语言描述,目前只有中文一种
983 datas.holiday_infos.sp_title.data.text string 假勤信息摘要-标题文本
984 datas.holiday_infos.sp_title.data.lang string 语言类型:"zh_CN"
985 datas.holiday_infos.sp_description obj 假勤信息摘要-描述信息
986 datas.holiday_infos.sp_description.data obj[] 多种语言描述,目前只有中文一种
987 datas.holiday_infos.sp_description.data.text string 假勤信息摘要-描述文本
988 datas.holiday_infos.sp_description.data.lang string 语言类型:"zh_CN"
989 datas.exception_infos obj[] 校准状态信息
990 datas.exception_infos.exception uint32 校准状态类型:1-迟到;2-早退;3-缺卡;4-旷工;5-地点异常;6-设备异常
991 datas.exception_infos.count int32 当日此异常的次数
992 datas.exception_infos.duration int32 当日此异常的时长(迟到/早退/旷工才有值)
993 datas.ot_info obj 加班信息
994 datas.ot_info.ot_status uint32 状态:0-无加班;1-正常;2-缺时长
995 datas.ot_info.ot_duration uint32 加班时长
996 datas.ot_info.exception_duration uint32[] ot_status为2下,加班不足的时长
997 datas.ot_info.workday_over_as_vacation int32 工作日加班记为调休,单位秒
998 datas.ot_info.workday_over_as_money int32 工作日加班记为加班费,单位秒
999 datas.ot_info.restday_over_as_vacation int32 休息日加班记为调休,单位秒
1000 datas.ot_info.restday_over_as_money int32 休息日加班记为加班费,单位秒
1001 datas.ot_info.holiday_over_as_vacation int32 节假日加班记为调休,单位秒
1002 datas.ot_info.holiday_over_as_money int32 节假日加班记为加班费,单位秒
1003 datas.sp_items obj[] 假勤统计信息
1004 datas.sp_items.type uint32 类型:1-请假;2-补卡;3-出差;4-外出;100-外勤
1005 datas.sp_items.vacation_id uint32 具体请假类型,当type为1请假时,具体的请假类型id,可通过审批相关接口获取假期详情
1006 datas.sp_items.count uint32 当日假勤次数
1007 datas.sp_items.duration uint32 当日假勤时长秒数,时长单位为天直接除以86400即为天数,单位为小时直接除以3600即为小时数
1008 datas.sp_items.time_type uint32 时长单位:0-按天 1-按小时
1009 datas.sp_items.name string 统计项名称
1010
1011 =cut
1012
1013 sub getcheckin_daydata {
1014 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
1015 my $access_token = $_[0];
1016 my $json = $_[1];
1017 my $ua = LWP::UserAgent->new;
1018 $ua->timeout(30);
1019 $ua->env_proxy;
1020
1021 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/checkin/getcheckin_daydata?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
1022 if ($response->is_success) {
1023 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
1024 }
1025
1026 }
1027 return 0;
1028 }
1029
1030 =head2 getcheckin_monthdata(access_token, hash);
1031
1032 获取打卡月报数据
1033 最后更新:2023/12/18
1034
1035 =head2 SYNOPSIS
1036
1037 L<https://developer.work.weixin.qq.com/document/path/93387>
1038
1039 =head3 请求说明:
1040
1041 企业可通过具有调用权限的应用,获取应用可见范围内指定员工指定日期内的打卡月报统计数据。
1042
1043 =head4 请求包结构体为:
1044
1045 {
1046 "starttime": 1599062400,
1047 "endtime": 1599408000,
1048 "useridlist": [
1049 "ZhangSan"
1050 ]
1051 }
1052
1053 =head4 参数说明:
1054
1055 参数 必须 类型 说明
1056 access_token 是 string 调用接口凭证,使用自建应用的Secret获取access_token,获取方式参考:文档-获取access_token
1057 starttime 是 uint32 获取月报的开始时间。0点Unix时间戳
1058 endtime 是 uint32 获取月报的结束时间。0点Unix时间戳
1059 useridlist 是 string[] -
1060 不少于1字节
1061 不多于64字节
1062 可填充个数:1 ~ 100
1063
1064 =head3 权限说明
1065
1066 应用类型 权限要求
1067 自建应用 配置到「打卡 - 可调用接口的应用」中
1068 代开发应用 具有「打卡」权限
1069 第三方应用 具有「打卡」权限
1070
1071 注: 从2023年12月1日0点起,不再支持通过系统应用secret调用接口,存量企业暂不受影响 查看详情
1072
1073 =head4 调用频率:
1074
1075 接口调用频率限制为60次/分钟。
1076
1077 =head3 RETURN 返回结果
1078
1079 {
1080 "errcode": 0,
1081 "errmsg": "ok",
1082 "datas": [
1083 {
1084 "base_info": {
1085 "record_type": 1,
1086 "name": "张三",
1087 "name_ex": "Three Zhang",
1088 "departs_name": "有家企业/realempty;有家企业;有家企业/部门A4",
1089 "rule_info": {
1090 "groupid": 10,
1091 "groupname": "规则测试",
1092 },
1093 "acctid": "ZhangSan"
1094 },
1095 "summary_info":{
1096 "except_days":3,
1097 "regular_work_sec":31,
1098 "standard_work_sec":29040,
1099 "work_days":3
1100 },
1101 "exception_infos":[
1102 {
1103 "count":2,
1104 "duration":28920,
1105 "exception":4
1106 },
1107 {
1108 "count":1,
1109 "duration":60,
1110 "exception":1
1111 },
1112 {
1113 "count":1,
1114 "duration":60,
1115 "exception":2
1116 }
1117 ],
1118 "sp_items":[
1119 {
1120 "count":0,
1121 "duration":0,
1122 "time_type":0,
1123 "type":100,
1124 "vacation_id":0,
1125 "name": "外勤次数"
1126 },
1127 {
1128 "count":1,
1129 "duration":0,
1130 "time_type":0,
1131 "type":1,
1132 "vacation_id":2,
1133 "name": "年假"
1134 }
1135 ],
1136 "overwork_info": {
1137 "workday_over_sec": 54000,
1138 "restdays_over_sec": 205560,
1139 "workdays_over_as_vacation": 0,
1140 "workdays_over_as_money": 54000,
1141 "restdays_over_as_vacation": 0,
1142 "restdays_over_as_money": 172800,
1143 "holidays_over_as_vacation": 0,
1144 "holidays_over_as_money": 0
1145 }
1146 }
1147 ]
1148 }
1149
1150 =head4 RETURN 参数说明
1151
1152 参数 类型 说明
1153 errcode int32 返回码
1154 errmsg string 错误码描述
1155 datas obj[] 月报数据列表
1156 datas.base_info obj 基础信息
1157 datas.base_info.record_type uint32 记录类型:1-固定上下班;2-外出(此报表中不会出现外出打卡数据);3-按班次上下班;4-自由签到;5-加班;7-无规则
1158 datas.base_info.name string 打卡人员姓名
1159 datas.base_info.name_ex string 打卡人员别名
1160 datas.base_info.departs_name string 打卡人员所在部门,会显示所有所在部门
1161 datas.base_info.acctid string 打卡人员账号,即userid
1162 datas.base_info.rule_info obj 打卡人员所属规则信息
1163 datas.base_info.rule_info.groupid int32 所属规则的id
1164 datas.base_info.rule_info.groupname string 打卡规则名
1165 datas.summary_info obj 汇总信息
1166 datas.summary_info.work_days int32 应打卡天数
1167 datas.summary_info.regular_days int32 正常天数
1168 datas.summary_info.except_days int32 异常天数
1169 datas.summary_info.regular_work_sec int32 实际工作时长,为统计周期每日实际工作时长之和, 单位: 秒
1170 datas.summary_info.standard_work_sec int32 标准工作时长,为统计周期每日标准工作时长之和, 单位: 秒
1171 datas.exception_infos obj[] 异常状态统计信息
1172 datas.exception_infos.exception uint32 异常类型:1-迟到;2-早退;3-缺卡;4-旷工;5-地点异常;6-设备异常
1173 datas.exception_infos.count int32 异常次数,为统计周期内每日此异常次数之和
1174 datas.exception_infos.duration int32 异常时长(迟到/早退/旷工才有值),为统计周期内每日此异常时长之和
1175 datas.sp_items obj[] 假勤统计信息
1176 datas.sp_items.type uint32 假勤类型:1-请假;2-补卡;3-出差;4-外出;100-外勤
1177 datas.sp_items.vacation_id uint32 具体请假类型,当type为1请假时,具体的请假类型id,可通过审批相关接口获取假期详情
1178 datas.sp_items.count uint32 假勤次数,为统计周期内每日此假勤发生次数之和
1179 datas.sp_items.duration uint32 假勤时长,为统计周期内每日此假勤发生时长之和,时长单位为天直接除以86400即为天数,单位为小时直接除以3600即为小时数
1180 datas.sp_items.time_type uint32 时长单位:0-按天 1-按小时
1181 datas.sp_items.name string 统计项名称
1182 datas.overwork_info obj 加班情况
1183 datas.overwork_info.workday_over_sec int32 工作日加班时长
1184 datas.overwork_info.holidays_over_sec int32 节假日加班时长
1185 datas.overwork_info.restdays_over_sec int32 休息日加班时长
1186 datas.overwork_info.workdays_over_as_vacation int32 工作日加班记为调休,单位秒
1187 datas.overwork_info.workdays_over_as_money int32 工作日加班记为加班费,单位秒
1188 datas.overwork_info.restdays_over_as_vacation int32 休息日加班记为调休,单位秒
1189 datas.overwork_info.restdays_over_as_money int32 休息日加班记为加班费,单位秒
1190 datas.overwork_info.holidays_over_as_vacation int32 节假日加班记为调休,单位秒
1191 datas.overwork_info.holidays_over_as_money int32 节假日加班记为加班费,单位秒
1192
1193 =cut
1194
1195 sub getcheckin_monthdata {
1196 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
1197 my $access_token = $_[0];
1198 my $json = $_[1];
1199 my $ua = LWP::UserAgent->new;
1200 $ua->timeout(30);
1201 $ua->env_proxy;
1202
1203 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/checkin/getcheckin_monthdata?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
1204 if ($response->is_success) {
1205 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
1206 }
1207
1208 }
1209 return 0;
1210 }
1211
1212 =head2 getcheckinschedulist(access_token, hash);
1213
1214 获取打卡人员排班信息
1215 最后更新:2023/12/18
1216
1217 =head2 SYNOPSIS
1218
1219 L<https://developer.work.weixin.qq.com/document/path/93380>
1220
1221 =head3 请求说明:
1222
1223 应用可通过此接口,获取应用可见范围内、打卡规则为“按班次上下班”规则的指定员工指定时间段内的排班信息。
1224
1225 =head4 请求包结构体为:
1226
1227 {
1228 "starttime": 1492617600,
1229 "endtime": 1492790400,
1230 "useridlist": [
1231 "james",
1232 "paul"
1233 ]
1234 }
1235
1236 =head4 参数说明:
1237
1238 参数 必须 类型 说明
1239 access_token 是 string 调用接口凭证,获取方式参考:文档-获取access_token
1240 useridlist 是 string[] 需要获取排班信息的用户列表(不超过100个)
1241 starttime 是 uint32 获取排班信息的开始时间。Unix时间戳
1242 endtime 是 uint32 获取排班信息的结束时间。Unix时间戳(与starttime跨度不超过一个月)
1243
1244 =head3 权限说明
1245
1246 应用类型 权限要求
1247 自建应用 配置到「打卡 - 可调用接口的应用」中
1248 代开发应用 具有「打卡」权限
1249 第三方应用 具有「打卡」权限
1250
1251 注: 从2023年12月1日0点起,不再支持通过系统应用secret调用接口,存量企业暂不受影响 查看详情
1252
1253 =head4 调用频率:
1254
1255 接口调用频率限制为60次/分钟。
1256
1257 =head3 RETURN 返回结果
1258
1259 {
1260 "schedule_list":[
1261 {
1262 "userid":"james",
1263 "yearmonth":202011,
1264 "groupid":11,
1265 "groupname":"排班",
1266 "schedule":{
1267 "scheduleList":[
1268 {
1269 "day":25,
1270 "schedule_info":{
1271 "schedule_id":229,
1272 "schedule_name":"早班",
1273 "time_section":[
1274 {
1275 "id":1,
1276 "work_sec":32400,
1277 "off_work_sec":43200,
1278 "remind_work_sec":32400, "remind_off_work_sec":43200
1279 }
1280 ]
1281 }
1282 },
1283 {
1284 "day":26,
1285 "schedule_info":{
1286 "schedule_id":171,
1287 "schedule_name":"晚班",
1288 "time_section":[
1289 {
1290 "id":2,
1291 "work_sec":64800,
1292 "off_work_sec":79200,
1293 "remind_work_sec":64800,
1294 "remind_off_work_sec":79200
1295 }
1296 ]
1297 }
1298 },
1299 {
1300 "day":30,
1301 "schedule_info":{
1302 "schedule_id":0,
1303 "schedule_name":"休息",
1304 "time_section":[
1305
1306 ]
1307 }
1308 }
1309 ]
1310 }
1311 }
1312 ],
1313 "errcode":0,
1314 "errmsg":"ok"
1315 }
1316
1317 =head4 RETURN 参数说明
1318
1319 参数 类型 说明
1320 errcode int32 返回码
1321 errmsg string 错误码描述
1322 schedule_list obj[] 排班表信息
1323 schedule_list.userid string 打卡人员userid
1324 schedule_list.yearmonth uint32 排班表月份,格式为年月,如202011
1325 schedule_list.groupid uint32 打卡规则id
1326 schedule_list.groupname string 打卡规则名
1327 schedule_list.schedule obj 个人排班信息
1328 schedule_list.schedule.scheduleList obj[] 个人排班表信息
1329 schedule_list.schedule.scheduleList.day uint32 排班日期,为表示当月第几天的数字
1330 schedule_list.schedule.scheduleList.schedule_info obj 个人当日排班信息
1331 schedule_list.schedule.scheduleList.schedule_info.schedule_id uint32 当日安排班次id,班次id也可在打卡规则中查询获得
1332 schedule_list.schedule.scheduleList.schedule_info.schedule_name string 班次名称
1333 schedule_list.schedule.scheduleList.schedule_info.time_section obj[] 班次上下班时段信息
1334 schedule_list.schedule.scheduleList.schedule_info.time_section.id uint32 时段id,为班次中某一堆上下班时间组合的id
1335 schedule_list.schedule.scheduleList.schedule_info.time_section.work_sec uint32 上班时间。距当天00:00的秒数
1336 schedule_list.schedule.scheduleList.schedule_info.time_section.off_work_sec uint32 下班时间。距当天00:00的秒数
1337 schedule_list.schedule.scheduleList.schedule_info.time_section.remind_work_sec uint32 上班提醒时间。距当天00:00的秒数
1338 schedule_list.schedule.scheduleList.schedule_info.time_section.remind_off_work_sec uint32 下班提醒时间。距当天00:00的秒数
1339
1340 =head4 RETURN 错误说明
1341
1342 错误码 说明
1343 301021 userid错误
1344 301070 系统错误,请稍后再试
1345 301075 输入参数错误
1346
1347 =cut
1348
1349 sub getcheckinschedulist {
1350 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
1351 my $access_token = $_[0];
1352 my $json = $_[1];
1353 my $ua = LWP::UserAgent->new;
1354 $ua->timeout(30);
1355 $ua->env_proxy;
1356
1357 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/checkin/getcheckinschedulist?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
1358 if ($response->is_success) {
1359 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
1360 }
1361
1362 }
1363 return 0;
1364 }
1365
1366 =head2 setcheckinschedulist(access_token, hash);
1367
1368 为打卡人员排班
1369 最后更新:2023/12/18
1370
1371 =head2 SYNOPSIS
1372
1373 L<https://developer.work.weixin.qq.com/document/path/93385>
1374
1375 =head3 请求说明:
1376
1377 企业可通过具有调用权限的应用,为打卡规则为“按班次上下班”规则的指定员工排班。
1378
1379 =head4 请求包结构体为:
1380
1381 {
1382 "groupid": 226,
1383 "items": [
1384 {
1385 "userid": "james",
1386 "day": 5,
1387 "schedule_id": 234
1388 }
1389 ],
1390 "yearmonth": 202012
1391 }
1392
1393 =head4 参数说明:
1394
1395 参数 必须 说明
1396 access_token 是 调用接口凭证。获取方式参考:文档-获取access_token
1397 items 是 排班表信息
1398 groupid 是 打卡规则的规则id,可通过“获取打卡规则”、“获取打卡数据”、“获取打卡人员排班信息”等相关接口获取
1399 userid 是 打卡人员userid
1400 day 是 要设置的天日期,取值在1-31之间。联合yearmonth组成唯一日期 比如20201205
1401 schedule_id 是 对应groupid规则下的班次id,通过预先拉取规则信息获取,0代表休息
1402 yearmonth 是 排班表月份,格式为年月,如202011
1403
1404 =head3 权限说明
1405
1406 仅支持为打卡规则为“按班次上下班”
1407
1408 应用类型 权限要求
1409 自建应用 配置到「打卡 - 可调用接口的应用」中
1410 代开发应用 具有「打卡」权限
1411 第三方应用 具有「打卡」权限
1412
1413 注: 从2023年12月1日0点起,不再支持通过系统应用secret调用接口,存量企业暂不受影响 查看详情
1414
1415 =head4 调用频率:
1416
1417 接口调用频率限制为60次/分钟。
1418
1419 =head3 RETURN 返回结果
1420
1421 {
1422 "errcode": 0,
1423 "errmsg": "ok"
1424 }
1425
1426 =head4 RETURN 参数说明
1427
1428 参数 类型 说明
1429 errcode int32 返回码
1430 errmsg string 错误码描述
1431
1432 =cut
1433
1434 sub setcheckinschedulist {
1435 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
1436 my $access_token = $_[0];
1437 my $json = $_[1];
1438 my $ua = LWP::UserAgent->new;
1439 $ua->timeout(30);
1440 $ua->env_proxy;
1441
1442 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/checkin/setcheckinschedulist?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
1443 if ($response->is_success) {
1444 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
1445 }
1446
1447 }
1448 return 0;
1449 }
1450
1451 =head2 punch_correction(access_token, hash);
1452
1453 为打卡人员补卡
1454 最后更新:2023/11/30
1455
1456 =head2 SYNOPSIS
1457
1458 L<https://developer.work.weixin.qq.com/document/path/95803>
1459
1460 =head3 请求说明:
1461
1462 =head4 请求包结构体为:
1463
1464 {
1465 "userid": "zhangsan",
1466 "schedule_date_time": 1654444800,
1467 "schedule_checkin_time": 32400,
1468 "checkin_time": 1654486827,
1469 "remark": "备注信息"
1470 }
1471
1472 =head4 参数说明:
1473
1474 参数 类型 是否必须 说明
1475 access_token string 是 调用接口凭证
1476 userid string 是 需要补卡的成员userid
1477 schedule_date_time uint32 是 应打卡日期,为当天0点的Unix时间戳。
1478 schedule_checkin_time uint32 否 应打卡时间点,相对应打卡日期0点的偏移秒数,如9点整则为32400。可通过获取员工打卡规则获取对应的规则打卡时间点,如work_sec/off_work_sec。
1479 对于没有规则对应的打卡时间点,如休息日打卡、无规则打卡、自由上下班,该参数不用填。
1480 checkin_time uint32 是 实际打卡时间,Unix时间戳。相对于schedule_checkin_time的实际打卡时间,具体可以表现为正常/迟到/早退
1481 remark string 否 备注信息
1482 不超过512字节
1483
1484 =head3 权限说明
1485
1486 应用类型 权限要求
1487 自建应用 配置到「打卡 - 可调用接口的应用」中
1488 代开发应用 暂不支持
1489 第三方应用 暂不支持
1490
1491 注: 从2023年12月1日0点起,不再支持通过系统应用secret调用接口,存量企业暂不受影响 查看详情
1492
1493 =head4 调用频率:
1494
1495 接口调用频率限制为600次/分钟
1496
1497 =head3 RETURN 返回结果
1498
1499 {
1500 "errcode": 0,
1501 "errmsg": "ok"
1502 }
1503
1504 =head4 RETURN 参数说明
1505
1506 参数 类型 说明
1507 errcode int32 返回码
1508 errmsg string 错误码描述
1509
1510 =cut
1511
1512 sub punch_correction {
1513 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
1514 my $access_token = $_[0];
1515 my $json = $_[1];
1516 my $ua = LWP::UserAgent->new;
1517 $ua->timeout(30);
1518 $ua->env_proxy;
1519
1520 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/checkin/punch_correction?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
1521 if ($response->is_success) {
1522 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
1523 }
1524
1525 }
1526 return 0;
1527 }
1528
1529 =head2 addcheckinuserface(access_token, hash);
1530
1531 录入打卡人员人脸信息
1532 最后更新:2023/11/30
1533
1534 =head2 SYNOPSIS
1535
1536 L<https://developer.work.weixin.qq.com/document/path/93378>
1537
1538 =head3 请求说明:
1539
1540 企业可通过自建应用,为企业打卡人员录入人脸信息,人脸信息仅用于人脸打卡。
1541
1542 =head4 请求包结构体为:
1543
1544 {
1545 "userid": "james",
1546 "userface": "PLACE_HOLDER"
1547 }
1548
1549 =head4 参数说明:
1550
1551 参数 必须 类型 说明
1552 access_token 是 string 调用接口凭证,获取方式参考:文档-获取access_token
1553 userid 否 string 需要录入的用户id
1554 userface 否 string 需要录入的人脸图片数据,需要将图片数据base64处理后填入,对已录入的人脸会进行更新处理
1555
1556 注意:对于已有人脸的用户,使用此接口将使用传入的人脸覆盖原有人脸,请谨慎操作。
1557
1558 =head3 权限说明
1559
1560 应用类型 权限要求
1561 自建应用 配置到「打卡 - 可调用接口的应用」中
1562 代开发应用 暂不支持
1563 第三方应用 暂不支持
1564
1565 注: 从2023年12月1日0点起,不再支持通过系统应用secret调用接口,存量企业暂不受影响 查看详情
1566
1567 =head4 调用频率:
1568
1569 接口调用频率限制为10次/分钟。
1570
1571 =head3 RETURN 返回结果
1572
1573 {
1574 "errcode": 0,
1575 "errmsg": "ok"
1576 }
1577
1578 =head4 RETURN 参数说明
1579
1580 参数 类型 说明
1581 errcode int32 返回码
1582 errmsg string 错误码描述
1583
1584 =head4 RETURN 错误说明
1585
1586 错误码 说明
1587 301021 输入参数错误
1588 301069 输入userid无对应成员
1589 301070 系统错误,请稍后再试
1590 301071 企业内有其他人员有相似人脸,此情况下人脸仍然会录入成功
1591 301072 人脸图像数据错误请更换图片
1592
1593 =cut
1594
1595 sub addcheckinuserface {
1596 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
1597 my $access_token = $_[0];
1598 my $json = $_[1];
1599 my $ua = LWP::UserAgent->new;
1600 $ua->timeout(30);
1601 $ua->env_proxy;
1602
1603 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/checkin/addcheckinuserface?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
1604 if ($response->is_success) {
1605 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
1606 }
1607
1608 }
1609 return 0;
1610 }
1611
1612 =head2 Name
1613
1614 管理打卡规则
1615 最后更新:2023/11/30
1616
1617 =head2 SYNOPSIS
1618
1619 L<https://developer.work.weixin.qq.com/document/path/98041>
1620
1621 =head2 add_checkin_option(access_token, hash);
1622
1623 创建打卡规则
1624
1625 =head2 SYNOPSIS
1626
1627 L<https://developer.work.weixin.qq.com/document/path/98041#创建打卡规则>
1628
1629 =head3 请求说明:
1630
1631 企业可通过自建应用或授权的代开发应用,为企业添加打卡规则。
1632
1633 =head4 请求包结构体为:
1634
1635 {
1636 "effective_now": true,
1637 "group": {
1638 "grouptype": 1,
1639 "groupname": "打卡规则1",
1640 "checkindate": [
1641 {
1642 "workdays": [
1643 1,
1644 2,
1645 3,
1646 4,
1647 5
1648 ],
1649 "checkintime": [
1650 {
1651 "time_id": 1,
1652 "work_sec": 36000,
1653 "off_work_sec": 43200,
1654 "remind_work_sec": 35400,
1655 "remind_off_work_sec": 43200,
1656 "earliest_work_sec": 35040,
1657 "latest_work_sec": 37020,
1658 "earliest_off_work_sec": 43140,
1659 "latest_off_work_sec": 43800
1660 }
1661 ],
1662 "flex_on_duty_time": 0,
1663 "flex_off_duty_time": 0
1664 }
1665 ],
1666 "sync_holidays": true,
1667 "need_photo": true,
1668 "note_can_use_local_pic": false,
1669 "wifimac_infos": [
1670 {
1671 "wifiname": "Tencent-WiFi-1",
1672 "wifimac": "c0:7b:bc:37:f8:d3"
1673 }
1674 ],
1675 "allow_checkin_offworkday": true,
1676 "allow_apply_offworkday": true,
1677 "loc_infos": [
1678 {
1679 "lat": 30547030,
1680 "lng": 104062890,
1681 "loc_title": "腾讯成都大厦",
1682 "loc_detail": "四川省成都市武侯区高新南区天府三街",
1683 "distance": 300
1684 }
1685 ],
1686 "range": {
1687 "party_id": [],
1688 "userid": [
1689 "xiaoxioa"
1690 ],
1691 "tagid": []
1692 },
1693 "white_users": [
1694 "xiaoxioa"
1695 ],
1696 "type": 0,
1697 "reporterinfo": {
1698 "reporters": [
1699 {
1700 "userid": "xiaoxioa"
1701 }
1702 ]
1703 },
1704 "ot_info_v2": {
1705 "workdayconf": {
1706 "allow_ot": true,
1707 "type": 0
1708 }
1709 },
1710 "allow_apply_bk_cnt": -1,
1711 "option_out_range": 0,
1712 "use_face_detect": true,
1713 "allow_apply_bk_day_limit": -1,
1714 "open_face_live_detect": true,
1715 "buka_limit_next_month": -1,
1716 "sync_out_checkin": true,
1717 "buka_remind": {
1718 "open_remind": true,
1719 "buka_remind_day": 28,
1720 "buka_remind_month": 0
1721 },
1722 "buka_restriction":0
1723 }
1724 }
1725
1726 =head4 参数说明:
1727
1728 参数 是否必填 说明
1729 access_token 是 调用接口凭证。自建应用或代开发应用的access_token
1730 group 视情况而定 打卡规则详细定义,具体见打卡规则字段说明
1731 effective_now 否 是否立即生效, 默认为false
1732
1733 注意:
1734 1.创建打卡规则时,groupid无需传入,该字段会被忽略。
1735 2.附常见错误信息列表
1736
1737 =head3 权限说明
1738
1739 应用类型 权限要求
1740 自建应用 配置到「打卡 - 可调用接口的应用」中
1741 代开发应用 具有「打卡」权限
1742 第三方应用 暂不支持
1743
1744 注: 从2023年12月1日0点起,不再支持通过系统应用secret调用接口,存量企业暂不受影响 查看详情
1745
1746 =head3 RETURN 返回结果
1747
1748 {
1749 "errcode": 0,
1750 "errmsg": "ok"
1751 }
1752
1753 =head4 RETURN 参数说明
1754
1755 参数 类型 说明
1756 errcode int32 返回码
1757 errmsg string 错误码描述
1758
1759 =cut
1760
1761 sub add_checkin_option {
1762 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
1763 my $access_token = $_[0];
1764 my $json = $_[1];
1765 my $ua = LWP::UserAgent->new;
1766 $ua->timeout(30);
1767 $ua->env_proxy;
1768
1769 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/checkin/add_checkin_option?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
1770 if ($response->is_success) {
1771 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
1772 }
1773
1774 }
1775 return 0;
1776 }
1777
1778 =head2 获取打卡规则
1779
1780 同获取企业所有打卡规则
1781
1782 =head2 SYNOPSIS
1783
1784 L<https://developer.work.weixin.qq.com/document/path/93384>
1785
1786 =head2 update_checkin_option(access_token, hash);
1787
1788 修改打卡规则
1789
1790 =head2 SYNOPSIS
1791
1792 L<https://developer.work.weixin.qq.com/document/path/98041#修改打卡规则>
1793
1794 =head3 请求说明:
1795
1796 企业可通过自建应用或授权的代开发应用,修改该应用为企业创建的打卡规则。
1797
1798 =head4 请求包结构体为:
1799
1800 {
1801 "effective_now": true,
1802 "group": {
1803 "groupid": 1,
1804 "grouptype": 1,
1805 "groupname": "打卡规则1",
1806 "checkindate": [
1807 {
1808 "workdays": [
1809 1,
1810 2,
1811 3,
1812 4,
1813 5
1814 ],
1815 "checkintime": [
1816 {
1817 "time_id": 1,
1818 "work_sec": 36000,
1819 "off_work_sec": 43200,
1820 "remind_work_sec": 35400,
1821 "remind_off_work_sec": 43200,
1822 "earliest_work_sec": 35040,
1823 "latest_work_sec": 37020,
1824 "earliest_off_work_sec": 43140,
1825 "latest_off_work_sec": 43800
1826 }
1827 ],
1828 "flex_on_duty_time": 0,
1829 "flex_off_duty_time": 0
1830 }
1831 ],
1832 "sync_holidays": true,
1833 "need_photo": true,
1834 "note_can_use_local_pic": false,
1835 "wifimac_infos": [
1836 {
1837 "wifiname": "Tencent-WiFi-1",
1838 "wifimac": "c0:7b:bc:37:f8:d3"
1839 }
1840 ],
1841 "allow_checkin_offworkday": true,
1842 "allow_apply_offworkday": true,
1843 "loc_infos": [
1844 {
1845 "lat": 30547030,
1846 "lng": 104062890,
1847 "loc_title": "腾讯成都大厦",
1848 "loc_detail": "四川省成都市武侯区高新南区天府三街",
1849 "distance": 300
1850 }
1851 ],
1852 "range": {
1853 "party_id": [],
1854 "userid": [
1855 "xiaoxioa"
1856 ],
1857 "tagid": []
1858 },
1859 "white_users": [
1860 "xiaoxioa"
1861 ],
1862 "type": 0,
1863 "reporterinfo": {
1864 "reporters": [
1865 {
1866 "userid": "xiaoxioa"
1867 }
1868 ]
1869 },
1870 "ot_info_v2": {
1871 "workdayconf": {
1872 "allow_ot": true,
1873 "type": 0
1874 }
1875 },
1876 "allow_apply_bk_cnt": -1,
1877 "option_out_range": 0,
1878 "use_face_detect": true,
1879 "allow_apply_bk_day_limit": -1,
1880 "open_face_live_detect": true,
1881 "buka_limit_next_month": -1,
1882 "sync_out_checkin": true,
1883 "buka_remind": {
1884 "open_remind": true,
1885 "buka_remind_day": 28,
1886 "buka_remind_month": 0
1887 }
1888 }
1889 }
1890
1891 =head4 参数说明:
1892
1893 参数 是否必填 说明
1894 access_token 是 调用接口凭证。自建应用或代开发应用的access_token
1895 group 视情况而定 打卡规则详细定义,具体见打卡规则字段说明
1896 effective_now 否 是否立即生效, 默认false
1897
1898 注意:
1899 1.修改打卡规则时,groupid须传入,否则会报错。
1900 2.打卡规则仅可由该规则的创建应用修改。
1901 3.group定义存在多层结构体嵌套,对于group.*一级的字段:
1902  a.若该字段为数组且调用端无传入或传入空元素数组,则理解为不更新该数组字段;
1903  b.若该字段为数组且调用端有传入,理解为覆盖该数组字段( 即清空原有数组,保留传入的数组 );
1904  c.若该字段非数组且调用端有传入,理解为覆盖该字段,及递归的所有字段;
1905  d.若该字段非数组且调用端无传入,理解为不更新该字段。
1906 4.若想清空group.*一级的字段:
1907  a.若该字段为数组,可以使用清空规则数组元素接口;
1908  b.若该字段非数组,则直接传入空元素即可;
1909 5.附常见错误信息列表。
1910
1911 =head3 权限说明
1912
1913 应用类型 权限要求
1914 自建应用 配置到「打卡 - 可调用接口的应用」中
1915 代开发应用 具有「打卡」权限
1916 第三方应用 暂不支持
1917
1918 注: 从2023年12月1日0点起,不再支持通过系统应用secret调用接口,存量企业暂不受影响 查看详情
1919
1920 =head3 RETURN 返回结果
1921
1922 {
1923 "errcode": 0,
1924 "errmsg": "ok"
1925 }
1926
1927 =head4 RETURN 参数说明
1928
1929 参数 类型 说明
1930 errcode int32 返回码
1931 errmsg string 错误码描述
1932
1933 =cut
1934
1935 sub update_checkin_option {
1936 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
1937 my $access_token = $_[0];
1938 my $json = $_[1];
1939 my $ua = LWP::UserAgent->new;
1940 $ua->timeout(30);
1941 $ua->env_proxy;
1942
1943 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/checkin/update_checkin_option?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
1944 if ($response->is_success) {
1945 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
1946 }
1947
1948 }
1949 return 0;
1950 }
1951
1952 =head2 clear_checkin_option_array_field(access_token, hash);
1953
1954 清空打卡规则数组元素
1955
1956 =head2 SYNOPSIS
1957
1958 L<https://developer.work.weixin.qq.com/document/path/98041#清空打卡规则数组元素>
1959
1960 =head3 请求说明:
1961
1962 企业可通过自建应用或授权的代开发应用,修改该应用为企业创建的打卡规则。
1963
1964 =head4 请求包结构体为:
1965
1966 {
1967 "groupid":1,
1968 "clear_field":[1,2,3],
1969 "effective_now":true
1970 }
1971
1972 =head4 参数说明:
1973
1974 参数 是否必填 说明
1975 access_token 是 调用接口凭证。自建应用或代开发应用的access_token
1976 groupid 是 打卡规则id
1977 clear_field 是 清空的字段标识:
1978 1-清空spe_workdays字段; 2-清空spe_offdays字段; 3-清空wifimac_infos字段; 4-清空loc_infos字段( wifimac_infos和loc_infos不可同时为空 )
1979 effective_now 否 是否立即生效,默认false
1980
1981 1.打卡规则仅可由该规则的创建应用修改。
1982
1983 =head3 权限说明
1984
1985 应用类型 权限要求
1986 自建应用 配置到「打卡 - 可调用接口的应用」中
1987 代开发应用 具有「打卡」权限
1988 第三方应用 暂不支持
1989
1990 注: 从2023年12月1日0点起,不再支持通过系统应用secret调用接口,存量企业暂不受影响 查看详情
1991
1992 =head3 RETURN 返回结果
1993
1994 {
1995 "errcode": 0,
1996 "errmsg": "ok"
1997 }
1998
1999 =head4 RETURN 参数说明
2000
2001 参数 类型 说明
2002 errcode int32 返回码
2003 errmsg string 错误码描述
2004
2005 =cut
2006
2007 sub clear_checkin_option_array_field {
2008 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
2009 my $access_token = $_[0];
2010 my $json = $_[1];
2011 my $ua = LWP::UserAgent->new;
2012 $ua->timeout(30);
2013 $ua->env_proxy;
2014
2015 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/checkin/clear_checkin_option_array_field?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
2016 if ($response->is_success) {
2017 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
2018 }
2019
2020 }
2021 return 0;
2022 }
2023
2024 =head2 del_checkin_option(access_token, hash);
2025
2026 删除打卡规则
2027
2028 =head2 SYNOPSIS
2029
2030 L<https://developer.work.weixin.qq.com/document/path/98041#删除打卡规则>
2031
2032 =head3 请求说明:
2033
2034 企业可通过自建应用或授权的代开发应用,删除该应用为企业创建的打卡规则。
2035
2036 =head4 请求包结构体为:
2037
2038 {
2039 "groupid":1,
2040 "effective_now":true
2041 }
2042
2043 =head4 参数说明:
2044
2045 参数 是否必填 说明
2046 access_token 是 调用接口凭证。自建应用或代开发应用的access_token
2047 groupid 是 删除的打卡规则id
2048 effective_now 否 是否立即生效,默认false
2049
2050 1.打卡规则仅可由该规则的创建应用删除。
2051
2052 =head3 权限说明
2053
2054 应用类型 权限要求
2055 自建应用 配置到「打卡 - 可调用接口的应用」中
2056 代开发应用 具有「打卡」权限
2057 第三方应用 暂不支持
2058
2059 注: 从2023年12月1日0点起,不再支持通过系统应用secret调用接口,存量企业暂不受影响 查看详情
2060
2061 =head3 RETURN 返回结果
2062
2063 {
2064 "errcode": 0,
2065 "errmsg": "ok"
2066 }
2067
2068 =head4 RETURN 参数说明
2069
2070 参数 类型 说明
2071 errcode int32 返回码
2072 errmsg string 错误码描述
2073
2074 =head3 打卡规则字段说明
2075
2076 L<https://developer.work.weixin.qq.com/document/path/98041#打卡规则字段说明>
2077
2078 =head3 错误信息列表
2079
2080 L<https://developer.work.weixin.qq.com/document/path/98041#错误信息列表>
2081
2082 =cut
2083
2084 sub del_checkin_option {
2085 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
2086 my $access_token = $_[0];
2087 my $json = $_[1];
2088 my $ua = LWP::UserAgent->new;
2089 $ua->timeout(30);
2090 $ua->env_proxy;
2091
2092 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/checkin/del_checkin_option?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
2093 if ($response->is_success) {
2094 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
2095 }
2096
2097 }
2098 return 0;
2099 }
2100
2101 1;
2102 __END__