forked from a07061625/swooleyaf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
helper_sytask.php
107 lines (97 loc) · 2.93 KB
/
helper_sytask.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
require_once __DIR__ . '/helper_load.php';
function sendSyGetReq(string $url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT_MS, 2000);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);
curl_close($ch);
}
$container = new \SyTask\SyModuleTaskContainer();
$modules = [
\Constant\Server::MODULE_NAME_API => [
'projects' => [
0 => [
'host' => '127.0.0.1',
'port' => 7100,
],
],
],
\Constant\Server::MODULE_NAME_ORDER => [
'projects' => [
0 => [
'host' => '127.0.0.1',
'port' => 7120,
],
],
],
\Constant\Server::MODULE_NAME_USER => [
'projects' => [
0 => [
'host' => '127.0.0.1',
'port' => 7140,
],
],
],
\Constant\Server::MODULE_NAME_SERVICE => [
'projects' => [
0 => [
'host' => '127.0.0.1',
'port' => 7160,
],
],
],
];
$timeArr = explode('-', date('H-i'));
$minute = (int)$timeArr[1];
$hour = (int)$timeArr[0];
$needMinute1 = $minute % 5;
$clearApiSign = $needMinute1 == 1 ? true : false;
$clearLocalUser = $needMinute1 == 2 ? true : false;
$wxTag = \Tool\Tool::getClientOption('-refreshwx');
if($wxTag > 0){
$wxRefreshMinute = -1;
} else if(($hour % 2) == 0){
$wxRefreshMinute = $minute;
} else {
$wxRefreshMinute = $minute + 60;
}
$refreshWx = in_array($wxRefreshMinute, [-1, 33, 73, 113]);
$taskParams = [
'task_minute' => $minute,
'task_hour' => $hour,
'wxcache_refresh' => $refreshWx,
'clear_apisign' => $clearApiSign,
'clear_localuser' => $clearLocalUser,
];
if($refreshWx){
$shopConfigs = \DesignPatterns\Singletons\WxConfigSingleton::getInstance()->getShopConfigs();
$taskParams['wxcaches'] = [];
foreach ($shopConfigs as $eAppId => $shopConfig) {
$wxAccessToken = \Wx\WxUtil::refreshAccessToken($eAppId);
$wxJsTicket = \Wx\WxUtil::refreshJsTicket($eAppId, $wxAccessToken);
$taskParams['wxcaches'][] = [
'appid' => $eAppId,
'accesstoken' => $wxAccessToken,
'jsticket' => $wxJsTicket,
];
}
}
foreach ($modules as $moduleTag => $eModule) {
$taskParams['projects'] = $eModule['projects'];
$task = $container->getObj($moduleTag);
$task->handleTask($taskParams);
}
$apiDomain = 'http://api3.xxx.cn';
//发送投票报名通知短信
$url = $apiDomain . '/Index/VoteSmsUser/sendEnterSmsTask';
\Request\RequestSign::makeSignUrl($url);
sendSyGetReq($url);
//检测投票报名通知短信
$url = $apiDomain . '/Index/VoteSmsUser/checkEnterSmsTask';
\Request\RequestSign::makeSignUrl($url);
sendSyGetReq($url);