1.是否已经配置好新版发货单里面的商品查询,如无则回到新版发货单按照步骤1把商品查询方案完善

2.新增集线器选择退货单查询2.0

image.png

3.特别需要注意,新版退货单只返回商品id,需要在加工厂关联查询出商品编码,,以下是加工厂示例代码,可以复制使用,复制后需要替换方案id,即$accountStrategyId = ‘f1e6ac6a-46bf-30ca-80a1-c98aa54be247’; 替换为$accountStrategyId = ‘商品查询的方案id’;。

image.png

关联查询物料编码示例代码:

  1. <?php
  2. use Domain\Datahub\Instance\Storage\LogStatus;
  3. use Domain\Datahub\Instance\Storage\DataStorage;
  4. class AfterSourceInvoke
  5. {
  6. protected $response;
  7. protected $adapter;
  8. /**
  9. * 构造函数
  10. *
  11. * @param array $response 引用传递,调用接口返回的原始响应数组
  12. * @param Adapter:class $adapter 适配器类
  13. */
  14. public function __construct(&$response, $adapter)
  15. {
  16. $this->response = &$response;
  17. $this->adapter = $adapter;
  18. }
  19. /**
  20. * 工厂事件执行函数
  21. *
  22. * @return void
  23. */
  24. public function run()
  25. {
  26. if ($this->response['success'] != true) {
  27. return;
  28. }
  29. foreach ($this->response['details'] as $key=>&$col) {
  30. //$this->adapter->getLogStorage()->insertOne(['text' => 'data', 'data' => $col], LogStatus::NOTICE);
  31. $accountStrategyId = 'f1e6ac6a-46bf-30ca-80a1-c98aa54be247';//此处方案id需替换成对应组户商品查询的方案ID
  32. $storage = new DataStorage($this->adapter->strategy->lessee_id, $accountStrategyId);
  33. $where = ['content.goods_id' => ['$eq' => $col['goods_id']]];
  34. $query = $storage->find($where);
  35. $col['goods_code'] = '';
  36. if ($query) {
  37. $content = $query[0]['content'];
  38. $col['goods_code'] = $content['code'];
  39. }
  40. }
  41. }
  42. }

4.最后再根据新版接口返回的字段完成替换配置,新版接口和旧版接口有些字段不一样,特别需要留意检查,加工厂里面的符号都是要英文符号,如无特殊要求,建议直接复制文档示例做修改。(需留意源平台配置源码是否有condition过滤,或者beatFlat拍扁,或者其他函数,字段记得相应替换新版接口的;目标配置源码同理,是否有merge合并等函数,函数配置里面的字段也要相应替换成新版的字段)