|
@@ -0,0 +1,131 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace Main\Lib;
|
|
|
+
|
|
|
+use Dever;
|
|
|
+
|
|
|
+class Cron
|
|
|
+{
|
|
|
+
|
|
|
+ public function unpay()
|
|
|
+ {
|
|
|
+ $time = 7200;
|
|
|
+ $where['cdate'] = time() + $time;
|
|
|
+ $where['note'] = 1;
|
|
|
+ $where['type'] = '1,3';
|
|
|
+ $data = Dever::db('journal/order')->getDataByTime($where);
|
|
|
+
|
|
|
+ if ($data) {
|
|
|
+ foreach ($data as $k => $v) {
|
|
|
+ $user = Dever::db('passport/user')->one($v['uid']);
|
|
|
+ if (!$user) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Dever::db('journal/order')->update(array('where_id' => $v['id'], 'note' => 2));
|
|
|
+
|
|
|
+ $journal = Dever::db('journal/info')->one($v['product_id']);
|
|
|
+
|
|
|
+ if (Dever::project('message')) {
|
|
|
+ Dever::load('message/lib/data')->push(-1, $v['uid'], '支付提醒', '您订阅的'.$journal['name'].'尚未支付!', 11, $v['cate_id']);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (isset($user['mobile']) && $user['mobile'] && Dever::project('sms')) {
|
|
|
+ $send = array();
|
|
|
+ $send['name'] = $journal['name'];
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $wechat = Dever::db('passport/wechat')->one(array('uid' => $v['uid'], 'type' => 1, 'system_id' => $v['cate_id']));
|
|
|
+ if ($wechat && Dever::project('wechat_applet')) {
|
|
|
+ $send['key'] = 'unbuy_journal';
|
|
|
+ $send['project_id'] = $v['cate_id'];
|
|
|
+ $send['touser'] = $wechat['openid'];
|
|
|
+ $send['page'] = Dever::config('base')->applet_index . '?scene=' . Dever::login($v['uid']) . ',' . '4,' . $v['product_id'];
|
|
|
+ $send['data'] = array
|
|
|
+ (
|
|
|
+ 'keyword1' => array('value' => $journal['name']),
|
|
|
+ 'keyword2' => array('value' => $v['cash']),
|
|
|
+ 'keyword3' => array('value' => '您订阅的'.$journal['name'].'尚未支付!'),
|
|
|
+ );
|
|
|
+ $send['data'] = json_encode($send['data']);
|
|
|
+ $send['form_id'] = Dever::load('act/lib/form')->get($v['uid'], 2, $v['cate_id']);
|
|
|
+
|
|
|
+ if ($send['form_id']) {
|
|
|
+ Dever::load('wechat_applet/msg.send', $send);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return 'ok';
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function activeEnd()
|
|
|
+ {
|
|
|
+ $time = 7200;
|
|
|
+ $where['end'] = time() + $time;
|
|
|
+ $data = Dever::db('journal/active')->getDataByTime($where);
|
|
|
+
|
|
|
+ if ($data) {
|
|
|
+ foreach ($data as $ks => $vs) {
|
|
|
+
|
|
|
+ $journal = Dever::db('journal/info')->one($vs['info_id']);
|
|
|
+
|
|
|
+ $subscribe = Dever::db('act/subscribe')->state(array('note' => 1, 'type' => 4, 'data_id' => $vs['info_id']));
|
|
|
+
|
|
|
+ if ($subscribe) {
|
|
|
+ foreach ($subscribe as $k => $v) {
|
|
|
+ $user = Dever::db('passport/user')->one($v['uid']);
|
|
|
+ if (!$user) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Dever::db('act/subscribe')->update(array('where_id' => $v['id'], 'note' => 2));
|
|
|
+
|
|
|
+ $journal = Dever::db('journal/info')->one($v['product_id']);
|
|
|
+
|
|
|
+ if (Dever::project('message')) {
|
|
|
+ Dever::load('message/lib/data')->push(-1, $v['uid'], '活动结束提醒', '您参与的'.$journal['name'].'积分排行榜活动还有5小时就要结束了,想要冲榜赢奖品的要抓紧机会呀〜', 11, $journal['cate_id']);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (isset($user['mobile']) && $user['mobile'] && Dever::project('sms')) {
|
|
|
+ $send = array();
|
|
|
+ $send['name'] = $journal['name'];
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $wechat = Dever::db('passport/wechat')->one(array('uid' => $v['uid'], 'type' => 1, 'system_id' => $journal['cate_id']));
|
|
|
+ if ($wechat && Dever::project('wechat_applet')) {
|
|
|
+ $send['key'] = 'service_end_note';
|
|
|
+ $send['project_id'] = $journal['cate_id'];
|
|
|
+ $send['touser'] = $wechat['openid'];
|
|
|
+ $send['page'] = Dever::config('base')->applet_index . '?scene=' . Dever::login($v['uid']) . ',' . '4,' . $journal['id'];
|
|
|
+ $send['data'] = array
|
|
|
+ (
|
|
|
+ 'keyword1' => array('value' => $journal['name']),
|
|
|
+ 'keyword2' => array('value' => date('Y-m-d H:i', $vs['end'])),
|
|
|
+ 'keyword3' => array('value' => '您参与的'.$journal['name'].'积分排行榜活动还有5小时就要结束了,想要冲榜赢奖品的要抓紧机会呀~'),
|
|
|
+ );
|
|
|
+ $send['data'] = json_encode($send['data']);
|
|
|
+ $send['form_id'] = Dever::load('act/lib/form')->get($v['uid'], 1, $journal['cate_id']);
|
|
|
+
|
|
|
+ if (!$send['form_id']) {
|
|
|
+ $send['form_id'] = Dever::load('act/lib/form')->get($v['uid'], 2, $journal['cate_id']);
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($send['form_id']) {
|
|
|
+ Dever::load('wechat_applet/msg.send', $send);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return 'ok';
|
|
|
+ }
|
|
|
+}
|