如何对接企业微信打卡记录

时间:2025-03-10 09:16:02
async function runProcess($model = model, $plugin = plugin, $params) { let list = $params.list; await $model.log(list.length); for (let i = 0; i < list.length; i++) { let userid = list[i]["userid"];//成员id let checkin_time = list[i]["checkin_time"];//打卡时间戳 let date = new Date(checkin_time*1000); let YY = date.getFullYear(); let MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1); let DD = (date.getDate() + 1 <= 10 ? '0' + date.getDate() : date.getDate()); let hh = (date.getHours() + 1 <= 10 ? '0' + date.getHours() : date.getHours()); let mm = date.getMinutes() + 1 <= 10 ? '0' + date.getMinutes() : date.getMinutes(); let datestr = YY + "-" + MM + DD;//打卡日期 let time = hh + ":" + mm;//打卡时间 let user = await $plugin.data.queryData("5eb9416bb75b4176eca49a19",{ "608a51b617f01720c7525723":userid });//找到成员id对应的用户 user = user.length > 0 ? user[0]._id : ""; await $plugin.data.saveData("608a540fdec57120cee5bb17",{ "608a545fdec57120cee5bb21":list[i]["exception_type"],//异常类型 "608a54886d8eaf20d45d65cb":list[i]["location_title"],//打卡地点title "608a548019c20e20c8dc5756":datestr, "608a54c06d8eaf20d45d65d1":time, "608a541f17f01720c752574f":user, "608a545717f01720c7525756":list[i]["checkin_type"]//打卡类型 }); } }