feat: add syj promote workflow
This commit is contained in:
73
pro_v3.5.1/app/dao/syj/PromoteTaskDao.php
Normal file
73
pro_v3.5.1/app/dao/syj/PromoteTaskDao.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user