mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-22 03:32:47 +08:00
优化task查询
This commit is contained in:
parent
fa1a713c60
commit
b45cfa2279
@ -248,12 +248,12 @@ class DeliverTask extends Task
|
||||
{
|
||||
$itemType = TaskModel::TYPE_DELIVER;
|
||||
$status = TaskModel::STATUS_PENDING;
|
||||
$tryCount = self::TRY_COUNT;
|
||||
$createTime = strtotime('-3 days');
|
||||
|
||||
return TaskModel::query()
|
||||
->where('item_type = :item_type:', ['item_type' => $itemType])
|
||||
->andWhere('status = :status:', ['status' => $status])
|
||||
->andWhere('try_count < :try_count:', ['try_count' => $tryCount + 1])
|
||||
->andWhere('create_time > :create_time:', ['create_time' => $createTime])
|
||||
->orderBy('priority ASC')
|
||||
->limit($limit)
|
||||
->execute();
|
||||
|
@ -125,12 +125,12 @@ class NoticeTask extends Task
|
||||
|
||||
$status = TaskModel::STATUS_PENDING;
|
||||
|
||||
$tryCount = self::TRY_COUNT;
|
||||
$createTime = strtotime('-1 days');
|
||||
|
||||
return TaskModel::query()
|
||||
->inWhere('item_type', $itemTypes)
|
||||
->andWhere('status = :status:', ['status' => $status])
|
||||
->andWhere('try_count < :try_count:', ['try_count' => $tryCount + 1])
|
||||
->andWhere('create_time > :create_time:', ['create_time' => $createTime])
|
||||
->orderBy('priority ASC')
|
||||
->limit($limit)
|
||||
->execute();
|
||||
|
@ -296,12 +296,12 @@ class RefundTask extends Task
|
||||
{
|
||||
$itemType = TaskModel::TYPE_REFUND;
|
||||
$status = TaskModel::STATUS_PENDING;
|
||||
$tryCount = self::TRY_COUNT;
|
||||
$createTime = strtotime('-3 days');
|
||||
|
||||
return TaskModel::query()
|
||||
->where('item_type = :item_type:', ['item_type' => $itemType])
|
||||
->andWhere('status = :status:', ['status' => $status])
|
||||
->andWhere('try_count < :try_count:', ['try_count' => $tryCount + 1])
|
||||
->andWhere('create_time > :create_time:', ['create_time' => $createTime])
|
||||
->orderBy('priority ASC')
|
||||
->limit($limit)
|
||||
->execute();
|
||||
|
16
db/migrations/20210105023511_schema_202101051030.php
Normal file
16
db/migrations/20210105023511_schema_202101051030.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
class Schema202101051030 extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
|
||||
public function change()
|
||||
{
|
||||
$this->table('kg_task')
|
||||
->addIndex(['create_time'], [
|
||||
'name' => 'create_time',
|
||||
'unique' => false,
|
||||
])
|
||||
->save();
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user