74 lines
2.5 KiB
PHP
74 lines
2.5 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace app\dao\syj;
|
|
|
|
use app\dao\BaseDao;
|
|
use app\model\syj\PromoteTask;
|
|
|
|
class PromoteTaskDao extends BaseDao
|
|
{
|
|
protected function setModel(): string
|
|
{
|
|
return PromoteTask::class;
|
|
}
|
|
|
|
public function getUserList(int $uid, array $where, int $page, int $limit): array
|
|
{
|
|
$model = $this->getModel()->where('uid', $uid);
|
|
if (isset($where['status']) && $where['status'] !== '') {
|
|
$model = $model->where('status', (int)$where['status']);
|
|
}
|
|
$count = (clone $model)->count();
|
|
$list = $model->order('add_time', 'desc')->page($page, $limit)->select()->toArray();
|
|
return compact('list', 'count');
|
|
}
|
|
|
|
public function getAdminList(array $where, int $page, int $limit): array
|
|
{
|
|
$model = $this->getModel()->alias('t')
|
|
->leftJoin('user u', 'u.uid = t.uid')
|
|
->field('t.*,u.nickname,u.phone');
|
|
if (!empty($where['keyword'])) {
|
|
$keyword = '%' . $where['keyword'] . '%';
|
|
$model = $model->where('t.task_no|t.source_order_no|u.nickname|u.phone|u.uid', 'like', $keyword);
|
|
}
|
|
if (isset($where['status']) && $where['status'] !== '') {
|
|
$model = $model->where('t.status', (int)$where['status']);
|
|
}
|
|
if (isset($where['reward_trigger_status']) && $where['reward_trigger_status'] !== '') {
|
|
$model = $model->where('t.reward_trigger_status', (int)$where['reward_trigger_status']);
|
|
}
|
|
if (!empty($where['start_time'])) {
|
|
$model = $model->where('t.add_time', '>=', strtotime($where['start_time']));
|
|
}
|
|
if (!empty($where['end_time'])) {
|
|
$model = $model->where('t.add_time', '<=', strtotime($where['end_time']) + 86399);
|
|
}
|
|
$count = (clone $model)->count();
|
|
$list = $model->order('t.add_time', 'desc')->page($page, $limit)->select()->toArray();
|
|
return compact('list', 'count');
|
|
}
|
|
|
|
public function getEarliestActiveTask(int $uid): ?array
|
|
{
|
|
$row = $this->getModel()
|
|
->where('uid', $uid)
|
|
->where('status', 0)
|
|
->order('add_time', 'asc')
|
|
->lock(true)
|
|
->find();
|
|
return $row ? $row->toArray() : null;
|
|
}
|
|
|
|
public function getCashoutAvailableTasks(int $uid): array
|
|
{
|
|
return $this->getModel()
|
|
->where('uid', $uid)
|
|
->where('status', 0)
|
|
->whereBetween('progress_count', [1, 3])
|
|
->select()
|
|
->toArray();
|
|
}
|
|
}
|