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