33 lines
875 B
PHP
33 lines
875 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Platform\Tmall\Producer;
|
|
|
|
use Hyperf\Amqp\Annotation\Producer;
|
|
use App\Platform\OrderProducer;
|
|
|
|
#[Producer('tmall.exchange', 'order.tmall')]
|
|
class TmallOrderProducer extends OrderProducer
|
|
{
|
|
# @attention 注解的配置不会在直接 new 实例化时自动应用到对象属性上
|
|
protected string $exchange = 'tmall.exchange';
|
|
protected string|array $routingKey = 'order.tmall';
|
|
|
|
/**
|
|
* 构建消息格式
|
|
*
|
|
* @param array $data 原始订单数据
|
|
* @return array
|
|
*/
|
|
|
|
protected function buildMessage(array $data): array
|
|
{
|
|
// 根据 RabbitMQ.md 中定义的消息格式规范
|
|
$parent_meta = parent::buildMessage($data);
|
|
$parent_meta['platform'] = 'tmall';
|
|
$parent_meta['meta']['source_system'] = 'tmall_api';
|
|
|
|
return $parent_meta;
|
|
}
|
|
}; |