|
@@ -25,6 +25,9 @@ class Note
|
|
|
|
|
|
public function submit($uid, $id, $type, $formid = '')
|
|
|
{
|
|
|
+ if ($formid) {
|
|
|
+ Dever::load('act/lib/form')->submit($uid, $formid, 1);
|
|
|
+ }
|
|
|
$where['uid'] = $uid;
|
|
|
$where['data_id'] = $id;
|
|
|
$where['type'] = $type;
|
|
@@ -40,6 +43,7 @@ class Note
|
|
|
if ($formid) {
|
|
|
$update['formid'] = $formid;
|
|
|
}
|
|
|
+ $update['cdate'] = time();
|
|
|
if ($info['state'] == 1) {
|
|
|
$update['state'] = 2;
|
|
|
Dever::db('act/live_note')->update($update);
|
|
@@ -52,5 +56,62 @@ class Note
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
+ public function cron()
|
|
|
+ {
|
|
|
+ $data = Dever::db('act/live_note')->getAll();
|
|
|
+
|
|
|
+ if ($data) {
|
|
|
+ $time = time();
|
|
|
+ $day = 7 * 86400;
|
|
|
+ $date = 60;
|
|
|
+ foreach ($data as $k => $v) {
|
|
|
+ $table = Dever::config('base')->type_table[$v['type']];
|
|
|
+ $info = Dever::db($table)->one($v['id']);
|
|
|
+ if ($info && $v['type'] == 3 && isset($info['sdate']) && $info['sdate'] > 0 && $info['sdate'] > $time && $info['sdate'] - $time <= $date) {
|
|
|
+
|
|
|
+ $user = Dever::db('passport/user')->one($v['uid']);
|
|
|
+ if (!$user) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Dever::db('act/live_note')->update(arary('where_id' => $v['id'], 'note' => 2));
|
|
|
+
|
|
|
+ if (Dever::project('message')) {
|
|
|
+ Dever::load('message/lib/data')->push(-1, $v['uid'], '直播提醒', $info['name'] . '直播即将开始,马上观看!', 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ $formid = Dever::load('act/lib/form')->get($v['uid'], 1);
|
|
|
+
|
|
|
+ if ($formid) {
|
|
|
+
|
|
|
+ $wechat = Dever::db('passport/wechat')->one(array('uid' => $v['uid']));
|
|
|
+ if ($wechat && Dever::project('wechat_applet')) {
|
|
|
+ $send['key'] = 'note_live';
|
|
|
+ $send['project_id'] = 1;
|
|
|
+ $send['touser'] = $wechat['openid'];
|
|
|
+ $send['page'] = Dever::config('base')->applet_index . '?scene=' . Dever::login($v['uid']) . ',' . $v['type'] . ',' . $v['id'];
|
|
|
+ $send['data'] = array
|
|
|
+ (
|
|
|
+ 'keyword1' => array('value', $info['name']),
|
|
|
+ 'keyword2' => array('value', $info['name'] . '直播即将开始,马上观看!'),
|
|
|
+ );
|
|
|
+ $send['form_id'] = $formid;
|
|
|
+ Dever::load('wechat_applet/msg.send', $send);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isset($user['mobile']) && $user['mobile'] && Dever::project('sms')) {
|
|
|
+ $send = array();
|
|
|
+ $send['name'] = $info['name'];
|
|
|
+ Dever::load('sms/api.send', 'note_live', $user['mobile'], $send);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function cron_api()
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
}
|