|
@@ -3,6 +3,10 @@
|
|
namespace Task\Lib;
|
|
namespace Task\Lib;
|
|
|
|
|
|
use Dever;
|
|
use Dever;
|
|
|
|
+# 放到计划任务中的:
|
|
|
|
+# task/lib/cron.clearTask 一天一次 86400
|
|
|
|
+# task/lib/cron.task_commit 任务报告完成 1个小时1次 3600
|
|
|
|
+# task/lib/cron.cash_commit 兑现审核完成 1个小时1次 3600
|
|
|
|
|
|
class Cron
|
|
class Cron
|
|
{
|
|
{
|
|
@@ -13,7 +17,19 @@ class Cron
|
|
*/
|
|
*/
|
|
public function clearTask_api()
|
|
public function clearTask_api()
|
|
{
|
|
{
|
|
- echo 11;die;
|
|
|
|
|
|
+ $data = Dever::db('task/info')->gets();
|
|
|
|
+ $time = time();
|
|
|
|
+ foreach ($data as $k => $v) {
|
|
|
|
+ # 未开始的变成进行中
|
|
|
|
+ $update['where_id'] = $v['id'];
|
|
|
|
+ if ($v['status'] == 2 && $v['sdate'] >= $time) {
|
|
|
|
+ $update['status'] = 1;
|
|
|
|
+ Dever::db('task/info')->update($update);
|
|
|
|
+ } elseif ($v['status'] == 1 && $v['edate'] < $time) {
|
|
|
|
+ $update['status'] = 3;
|
|
|
|
+ Dever::db('task/info')->update($update);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -48,6 +64,8 @@ class Cron
|
|
|
|
|
|
$this->updateScoreLog($v['uid'], $v['score'], 4, 2, $v['task_id'], $v['id']);
|
|
$this->updateScoreLog($v['uid'], $v['score'], 4, 2, $v['task_id'], $v['id']);
|
|
|
|
|
|
|
|
+ $this->updateMsg($v['uid'], $v['score'], 4, $v['task_id']);
|
|
|
|
+
|
|
$this->group($v['uid'], $v['group_score'], $v['task_id'], $v['id']);
|
|
$this->group($v['uid'], $v['group_score'], $v['task_id'], $v['id']);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -60,7 +78,7 @@ class Cron
|
|
*
|
|
*
|
|
* @return mixed
|
|
* @return mixed
|
|
*/
|
|
*/
|
|
- public function cash_commit()
|
|
|
|
|
|
+ public function cash_commit_api()
|
|
{
|
|
{
|
|
# 成功
|
|
# 成功
|
|
$where['status'] = 3;
|
|
$where['status'] = 3;
|
|
@@ -75,6 +93,8 @@ class Cron
|
|
|
|
|
|
|
|
|
|
$this->updateScoreLog($v['uid'], $v['score'], 2, 1, -1, -1, $v['type'], $v['cash'], $v['cdate']);
|
|
$this->updateScoreLog($v['uid'], $v['score'], 2, 1, -1, -1, $v['type'], $v['cash'], $v['cdate']);
|
|
|
|
+
|
|
|
|
+ $this->updateMsg($v['uid'], $v['score'], 2, false, false, $v['type'], $v['cash'], $v['cdate']);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -94,17 +114,7 @@ class Cron
|
|
|
|
|
|
$this->updateScoreLog($v['uid'], $v['score'], 3, 1, -1, -1, $v['type'], $v['cash'], $v['cdate'], $v['status_desc']);
|
|
$this->updateScoreLog($v['uid'], $v['score'], 3, 1, -1, -1, $v['type'], $v['cash'], $v['cdate'], $v['status_desc']);
|
|
|
|
|
|
- # 记录日志
|
|
|
|
- $insert = array();
|
|
|
|
- $insert['type'] = 3;
|
|
|
|
- $insert['status'] = 1;
|
|
|
|
- $insert['cash_type'] = $v['type'];
|
|
|
|
- $insert['cash'] = $v['cash'];
|
|
|
|
- $insert['score'] = $v['score'];
|
|
|
|
- $insert['uid'] = $v['uid'];
|
|
|
|
-
|
|
|
|
- $insert['cash_date'] = $v['cdate'];
|
|
|
|
- Dever::db('task/user_score_log')->insert($insert);
|
|
|
|
|
|
+ $this->updateMsg($v['uid'], $v['score'], 3, false, false, $v['type'], $v['cash'], $v['cdate'], $v['status_desc']);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -125,7 +135,9 @@ class Cron
|
|
|
|
|
|
$this->updateUserScore($group_info['uid'], $score);
|
|
$this->updateUserScore($group_info['uid'], $score);
|
|
|
|
|
|
- $this->updateScoreLog($group_info['uid'], $score, 5, 2, $task_id, $report_id);
|
|
|
|
|
|
+ $this->updateScoreLog($group_info['uid'], $score, 5, 2, $task_id, $report_id, 1, 0, 0, '', $uid);
|
|
|
|
+
|
|
|
|
+ $this->updateMsg($group_info['uid'], $score, 5, $task_id, $uid);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -147,13 +159,14 @@ class Cron
|
|
*
|
|
*
|
|
* @return mixed
|
|
* @return mixed
|
|
*/
|
|
*/
|
|
- private function updateScoreLog($uid, $score, $type, $status, $task_id = -1, $report_id = -1, $cash_type = 1, $cash = 0, $cash_date = 0, $type_desc = '')
|
|
|
|
|
|
+ private function updateScoreLog($uid, $score, $type, $status, $task_id = -1, $report_id = -1, $cash_type = 1, $cash = 0, $cash_date = 0, $type_desc = '', $group_uid = false)
|
|
{
|
|
{
|
|
$insert = array();
|
|
$insert = array();
|
|
$insert['type'] = $type;
|
|
$insert['type'] = $type;
|
|
$insert['status'] = $status;
|
|
$insert['status'] = $status;
|
|
$insert['score'] = $score;
|
|
$insert['score'] = $score;
|
|
$insert['uid'] = $uid;
|
|
$insert['uid'] = $uid;
|
|
|
|
+ $insert['group_uid'] = $group_uid;
|
|
$insert['task_id'] = $task_id;
|
|
$insert['task_id'] = $task_id;
|
|
$insert['report_id'] = $report_id;
|
|
$insert['report_id'] = $report_id;
|
|
|
|
|
|
@@ -168,4 +181,57 @@ class Cron
|
|
|
|
|
|
Dever::db('task/user_score_log')->insert($insert);
|
|
Dever::db('task/user_score_log')->insert($insert);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 日志记录
|
|
|
|
+ *
|
|
|
|
+ * @return mixed
|
|
|
|
+ */
|
|
|
|
+ private function updateMsg($uid, $score, $type, $task_id = -1, $group_uid = false, $cash_type = 1, $cash = 0, $cash_date = 0, $desc = '')
|
|
|
|
+ {
|
|
|
|
+ $config = Dever::db('main/config')->one();
|
|
|
|
+ if ($type == 4 || $type == 5) {
|
|
|
|
+ $task = Dever::db('task/info')->one($task_id);
|
|
|
|
+ # 完成任务
|
|
|
|
+ $desc = '';
|
|
|
|
+ if ($type == 5) {
|
|
|
|
+ $desc = '提成';
|
|
|
|
+ $user = Dever::db('passport/user')->one($group_uid);
|
|
|
|
+ } else {
|
|
|
|
+ $user = Dever::db('passport/user')->one($uid);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $name = $config['score_name'] . '入账通知';
|
|
|
|
+ $content = '入账'.$config['score_name'].':'.$score.$config['score_name'].'
|
|
|
|
+ <br /> '.$config['score_name'].'来源:'.$user['username'].'完成任务#'.$task['name'].'的'.$desc.'奖励
|
|
|
|
+ <br /> 入账时间:' . date('Y-m-d H:i');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ($cash_type == 1) {
|
|
|
|
+ $cash_type = '微信';
|
|
|
|
+ } else {
|
|
|
|
+ $cash_type = '支付宝';
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ($type == 2) {
|
|
|
|
+ $name = $config['score_name'].'兑现成功通知';
|
|
|
|
+ $content = '本次兑现:'.$score.$config['score_name'].'
|
|
|
|
+ <br />兑现途径:'.$cash_type.'
|
|
|
|
+ <br />申请兑现时间:' . date('Y-m-d H:i', $cash_date).'
|
|
|
|
+ <br />兑现完成时间:' . date('Y-m-d H:i');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ($type == 3) {
|
|
|
|
+ $name = $config['score_name'].'兑现失败通知';
|
|
|
|
+ $content = '本次兑现:'.$score.$config['score_name'].'
|
|
|
|
+ <br />兑现途径:'.$cash_type.'
|
|
|
|
+ <br />申请兑现时间:' . date('Y-m-d H:i', $cash_date).'
|
|
|
|
+ <br />'.$desc;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $type = 11;
|
|
|
|
+ if (isset($name)) {
|
|
|
|
+ Dever::load('message/lib/data.push', -1, $uid, $name, $content, $type);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|