新增自动完成服务包订单延迟队列

This commit is contained in:
2024-04-17 17:52:33 +08:00
parent f040795d9a
commit 581111bdbe
3 changed files with 286 additions and 1 deletions
@@ -4,14 +4,16 @@ declare(strict_types=1);
namespace App\Command;
use App\Amqp\Producer\AutoCompleteServicePackageDelayDirectProducer;
use App\Model\OrderServicePackage;
use Hyperf\Amqp\Producer;
use Hyperf\Command\Command as HyperfCommand;
use Hyperf\Command\Annotation\Command;
use Hyperf\DbConnection\Db;
use Psr\Container\ContainerInterface;
#[Command]
class AddServicePackageFinishQueueCommand extends HyperfCommand
class AddServicePackageCompleteQueueCommand extends HyperfCommand
{
public function __construct(protected ContainerInterface $container)
{
@@ -47,6 +49,21 @@ class AddServicePackageFinishQueueCommand extends HyperfCommand
$this->putAddFinishStatus($order_service_package['order_service_id'],1);
// 添加服务包订单完成延迟队列
$finish_time = strtotime($order_service_package['finish_time']);
$time = $finish_time - time();
$queue_data = array();
$queue_data['order_no'] = $order_service_package['order_service_no'];
$message = new AutoCompleteServicePackageDelayDirectProducer($queue_data);
$message->setDelayMs(1000 * $time);
$producer = $this->container->get(Producer::class);
$res = $producer->produce($message);
if (!$res) {
Db::rollBack();
$this->line("添加队列失败");
}
Db::commit();
}catch (\Throwable $e){