mirror of
https://github.com/kuaifan/dootask.git
synced 2026-03-17 11:13:26 +00:00
no message
This commit is contained in:
parent
f8644e7e39
commit
a21c3d640f
@ -3194,4 +3194,39 @@ class Base
|
|||||||
}
|
}
|
||||||
return Response::streamDownload($callback, $name);
|
return Response::streamDownload($callback, $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是否工作日
|
||||||
|
* @param string $Ymd 年月日(如:20220102)
|
||||||
|
* @return int
|
||||||
|
* 0: 工作日
|
||||||
|
* 1: 非工作日
|
||||||
|
* 2: 获取不到远程数据的非工作日(周六、日)
|
||||||
|
* 所以可以用>0来判断是否工作日
|
||||||
|
*/
|
||||||
|
public static function isHoliday($Ymd) {
|
||||||
|
$time = strtotime($Ymd . " 00:00:00");
|
||||||
|
$holidayKey = "holiday::" . date("Ym", $time);
|
||||||
|
$holidayData = Cache::remember($holidayKey, now()->addMonth(), function () use ($time) {
|
||||||
|
$apiMonth = date("Ym", $time);
|
||||||
|
$apiResult = Ihttp::ihttp_request("https://api.apihubs.cn/holiday/get?field=date&month={$apiMonth}&workday=2&size=31", [], [], 20);
|
||||||
|
if (Base::isError($apiResult)) {
|
||||||
|
info('[holiday] get error');
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
$apiResult = Base::json2array($apiResult['data']);
|
||||||
|
if ($apiResult['code'] !== 0) {
|
||||||
|
info('[holiday] result error');
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
return array_map(function ($item) {
|
||||||
|
return $item['date'];
|
||||||
|
}, $apiResult['data']['list']);
|
||||||
|
});
|
||||||
|
if (empty($holidayData)) {
|
||||||
|
Cache::forget($holidayKey);
|
||||||
|
return in_array(date("w", $time), [0, 6]) ? 2 : 0;
|
||||||
|
}
|
||||||
|
return in_array($Ymd, $holidayData) ? 1 : 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,27 +27,7 @@ class CheckinRemindTask extends AbstractTask
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 判断非工作日
|
// 判断非工作日
|
||||||
$holidayKey = "holiday::" . date("Ym");
|
if (Base::isHoliday(date("Ymd")) > 0) {
|
||||||
$holidayData = Cache::remember($holidayKey, now()->addMonth(), function () {
|
|
||||||
$apiMonth = date("Ym");
|
|
||||||
$apiResult = Ihttp::ihttp_request("https://api.apihubs.cn/holiday/get?field=date&month={$apiMonth}&workday=2&size=31", [], [], 30);
|
|
||||||
if (Base::isError($apiResult)) {
|
|
||||||
info('[holiday] get error');
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
$apiResult = Base::json2array($apiResult['data']);
|
|
||||||
if ($apiResult['code'] !== 0) {
|
|
||||||
info('[holiday] result error');
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
return array_map(function ($item) {
|
|
||||||
return $item['date'];
|
|
||||||
}, $apiResult['data']['list']);
|
|
||||||
});
|
|
||||||
if (empty($holidayData)) {
|
|
||||||
Cache::forget($holidayKey);
|
|
||||||
}
|
|
||||||
if (in_array(date("Ymd"), $holidayData)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user