Просмотр исходного кода

fix(wuliu):修复物流更新时间判断逻辑

- 在判断物流更新时间时,使用 strtotime 函数确保时间格式正确
- 修改测试用例中的快递单号以匹配实际测试数据
- 统一处理 ExtensionWuLiuEntity 和 LogisticsService 中的时间比较逻辑
runphp 4 месяцев назад
Родитель
Сommit
65eeb2e9af

+ 1 - 1
src/Entity/ExtensionWuLiuEntity.php

@@ -19,7 +19,7 @@ class ExtensionWuLiuEntity extends BaseEntity
         $entity = $this->where('number', $no)->when($type, function (Model $query, $type) {
             $query->where('type', $type);
         })->findOrEmpty();
-        if (!$entity->isEmpty() && ($entity->is_sign == 1 || $entity->update_time > time() - 3600)) {
+        if (!$entity->isEmpty() && ($entity->is_sign == 1 || strtotime($entity->update_time) > time() - 3600)) {
             // 已签收或一小时内更新过,直接返回
             return $entity->toArray();
         }

+ 1 - 1
src/Service/LogisticsService.php

@@ -19,7 +19,7 @@ class LogisticsService implements LogisticsInterface
         $entity = $this->extensionWuLiuEntity->where('number', $number)->when($type, function (Model $query, $type) {
             $query->where('type', $type);
         })->findOrEmpty();
-        if (!$entity->isEmpty() && ($entity->is_sign == 1 || $entity->update_time > time() - 600)) {
+        if (!$entity->isEmpty() && ($entity->is_sign == 1 || strtotime( $entity->update_time) > time() - 600)) {
             // 已签收或10分钟内更新过,直接返回
         } else {
             $entity = $this->extensionWuLiuEntity->queryLogistics($number, $type, $entity);

+ 1 - 1
test/WuLiuClientTest.php

@@ -15,7 +15,7 @@ class WuLiuClientTest extends TestCase
 
     public function testKdi(): void
     {
-        $result = $this->client->kdi('DPK202576722639');
+        $result = $this->client->kdi('YT1164820926068');
         dump($result);
     }