hu hao 4 лет назад
Родитель
Сommit
801b7d6a8e

+ 2 - 0
app/Http/Controllers/TestController.php

@@ -17,6 +17,7 @@ use App\Http\Controllers\api\thirdPart\haiq\PickStationController;
 use App\Http\Controllers\api\thirdPart\hengli\PackageController;
 use App\Http\Controllers\api\thirdPart\weight\WeightBaseController;
 use App\Jobs\DeleteRepetitionSkuItem;
+use App\Jobs\LogisticAliJiSuSync;
 use App\Jobs\LogisticYTOSync;
 use App\Jobs\OrderCreateInstantBill;
 use App\Jobs\OrderFreeze;
@@ -106,6 +107,7 @@ use Mockery\Mock;
 use Oursdreams\Export\Export;
 use Overtrue\LaravelPinyin\Facades\Pinyin;
 use PhpMyAdmin\Server\Status\Data;
+use PhpParser\Node\Stmt\DeclareDeclare;
 use Ramsey\Collection\Collection;
 use Zttp\Zttp;
 

+ 21 - 1
app/Services/OrderPackageReceivedSyncService.php

@@ -89,7 +89,7 @@ class OrderPackageReceivedSyncService
             ->select(['logistic_number', 'order_id'])
             ->whereIn('order_id',function ($query){
                 $query->from('orders')->selectRaw('id')->whereIn('logistic_id',function ($builder){
-                    $builder->from('logistics')->selectRaw('id')->where('type','!=','物流')->whereNotIn('belong_company',['顺丰','中通','韵达','圆通']);
+                    $builder->from('logistics')->selectRaw('id')->where('type','!=','物流')->whereNotIn('belong_company',['顺丰','中通','韵达','圆通','京东']);
                 });
             });
         $query = $query->where('sent_at', '>=', now()->subDays(20))
@@ -99,6 +99,26 @@ class OrderPackageReceivedSyncService
                 if ($orderPackage && $orderPackage->logistic_number)LogisticAliJiSuSync::dispatch($orderPackage->logistic_number);
             }
         });
+        $this->syncLogisticRouteJD();
+    }
+    public function syncLogisticRouteJD(){
+        ini_set('max_execution_time', 60);
+        $query = OrderPackage::query()
+            ->select(['logistic_number', 'order_id'])
+            ->whereIn('order_id',function ($query){
+                $query->from('orders')->selectRaw('id')->whereIn('logistic_id',function ($builder){
+                    $builder->from('logistics')->selectRaw('id')->where('type','!=','物流')->where('belong_company','京东');
+                });
+            });
+        $query = $query->where('created_at', '>=', now()->subDays(20))
+            ->whereNull('received_at');
+        $query->chunk(200, function ($orderPackages) {
+            foreach ($orderPackages as $orderPackage){
+                if ($orderPackage
+                    && $orderPackage->logistic_number
+                    && strpos($orderPackage->logistic_number,'JD')!==false)LogisticAliJiSuSync::dispatch($orderPackage->logistic_number);
+            }
+        });
     }
     /**
      * 根据传递的承运商与快递单号更新快递信息

+ 3 - 3
tests/Services/LogisticAliJiSuApiService/FormatTest.php

@@ -2,6 +2,7 @@
 
 namespace Tests\Services\LogisticAliJiSuApiService;
 
+use App\Services\LogisticAliJiSuApiService;
 use App\Services\LogisticYDService;
 use App\Services\LogisticYTOService;
 use BeyondCode\DumpServer\DumpServerServiceProvider;
@@ -13,7 +14,7 @@ class FormatTest extends TestCase
 {
     use TestMockSubServices;
 
-    /** @var LogisticYTOService $service */
+    /** @var LogisticAliJiSuApiService $service */
     public $service;
     private $data;
     private $amount = 2;
@@ -29,10 +30,9 @@ class FormatTest extends TestCase
      */
     public function format_test()
     {
-        $response=$this->service->query('9882749294945');
+        $response=$this->service->query('JDVB09919778923');
         if ($response && $response->status==0){
             $result = $this->service->format($response);
-//            dd($result);
             $this->assertNotEmpty($result);
         }