update order parse
This commit is contained in:
@@ -383,7 +383,7 @@ class Order extends AbstractOrderParse
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 批量查询产品
|
// 批量查询产品 并使用匹配到的产品 覆写 $items product_id 字段的值
|
||||||
if (!empty($product_keys)) {
|
if (!empty($product_keys)) {
|
||||||
$products_id_map = $this->batchQueryProducts($product_keys);
|
$products_id_map = $this->batchQueryProducts($product_keys);
|
||||||
|
|
||||||
@@ -493,8 +493,8 @@ class Order extends AbstractOrderParse
|
|||||||
'platform_order_id' => $platform_order_id,
|
'platform_order_id' => $platform_order_id,
|
||||||
'sub_order_id' => $item['order_item_id'],
|
'sub_order_id' => $item['order_item_id'],
|
||||||
// @attention sku 的处理需要仅以规范和约束,确保 sku 准确
|
// @attention sku 的处理需要仅以规范和约束,确保 sku 准确
|
||||||
'sub_order_type_id' => '',
|
'sub_order_type_id' => null,
|
||||||
'product_id' => 0,
|
'product_id' => 0, // 值为 0 表示未找到产品 id, 之后会被批量查询覆盖
|
||||||
'platform_product_id' =>$item['item_id'],
|
'platform_product_id' =>$item['item_id'],
|
||||||
// @attention @TODO 需要对 运营侧的产品维护做进一步规范
|
// @attention @TODO 需要对 运营侧的产品维护做进一步规范
|
||||||
'product_sku' => $item['model_sku'] ?? $item['item_sku'] ?? null,
|
'product_sku' => $item['model_sku'] ?? $item['item_sku'] ?? null,
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?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;
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -302,7 +302,7 @@ class Order extends EntityParse
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 批量查询产品 ID 并更新 items
|
// 批量查询产品 并使用匹配到的产品 覆写 $items product_id 字段的值
|
||||||
if (!empty($product_keys)) {
|
if (!empty($product_keys)) {
|
||||||
$products_id_map = $this->batchQueryProducts($product_keys);
|
$products_id_map = $this->batchQueryProducts($product_keys);
|
||||||
foreach ($product_keys as $index => $key) {
|
foreach ($product_keys as $index => $key) {
|
||||||
@@ -384,7 +384,7 @@ class Order extends EntityParse
|
|||||||
* Tmall 订单子项映射转换
|
* Tmall 订单子项映射转换
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function tmallOrderItemMap(array $item, string $platform_order_id, int $parent_order_id, Carbon $parent_order_created_date, int $local_product_id = 0): array
|
private function tmallOrderItemMap(array $item, string $platform_order_id, int $parent_order_id, Carbon $parent_order_created_date): array
|
||||||
{
|
{
|
||||||
|
|
||||||
// $item = [
|
// $item = [
|
||||||
@@ -431,7 +431,6 @@ class Order extends EntityParse
|
|||||||
// ]
|
// ]
|
||||||
|
|
||||||
|
|
||||||
//@TODO order item 的业务映射需进一步补全
|
|
||||||
return [
|
return [
|
||||||
'company_id' => $this->getCompany()->id,
|
'company_id' => $this->getCompany()->id,
|
||||||
'platform_id' => $this->getPlatform()->id,
|
'platform_id' => $this->getPlatform()->id,
|
||||||
@@ -441,8 +440,8 @@ class Order extends EntityParse
|
|||||||
'sub_order_id' => $item['oid'],
|
'sub_order_id' => $item['oid'],
|
||||||
// @attention sku 的处理需要仅以规范和约束,确保 sku 准确
|
// @attention sku 的处理需要仅以规范和约束,确保 sku 准确
|
||||||
'sub_order_type_id' => null,
|
'sub_order_type_id' => null,
|
||||||
// @attention 表示未找到产品 id
|
// @attention 值为 0 表示未找到产品 id
|
||||||
'product_id' => $local_product_id,
|
'product_id' => 0, // 值为 0 表示未找到产品 id, 之后会被批量查询覆盖
|
||||||
'platform_product_id' =>$item['num_iid'],
|
'platform_product_id' =>$item['num_iid'],
|
||||||
// @attention @TODO 需要对 运营侧的产品维护做进一步规范
|
// @attention @TODO 需要对 运营侧的产品维护做进一步规范
|
||||||
'product_sku' => $item['outer_sku_id'] ?? null,
|
'product_sku' => $item['outer_sku_id'] ?? null,
|
||||||
|
|||||||
Reference in New Issue
Block a user