Explorar o código

揽收自动回传

Zhouzhendong %!s(int64=4) %!d(string=hai) anos
pai
achega
3f07cc04d8

+ 2 - 12
app/Http/Controllers/OrderController.php

@@ -500,8 +500,9 @@ sql;
         //严格模式,校验订单与包裹状态
         /** @var OrderService $orderService */
         $orderService = app('OrderService');
+        foreach ($orderno as $no)$orderService->manualBack($no);
         $logisticNums = $orderService->getCollectUploadLogisticNumbers($strict, $orderno);
-
+        if (!$logisticNums)return ["success"=>"揽收失败","message"=>"订单不允许发起揽收"];
         //调用一键揽收
         /** @var OrderPackageService $orderPackageService */
         $orderPackageService = app('OrderPackageService');
@@ -514,17 +515,6 @@ sql;
             $error['collectUpload'] = $collectUpLoadResult['message'] ?? '';
         }
 
-        //根据快递单号查询orderno
-        $allocationOrdernos = $orderPackageService->getOrderCodesByLogisticNumbers($logisticNums);
-        //调用分配接口
-        $allocationOrdernos->each(function ($orderno) use ($orderService) {
-            $orderService->allocation($orderno);
-        });
-        if ($strict) {
-            //输入的orderno与最终可以一键揽收的orderno取差集合
-            $errorOrderno = array_diff($inOrderno, $allocationOrdernos->toArray());
-        }
-
         $result = [];
         if (!empty($error)) {
             $result['success'] = false;

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

@@ -223,25 +223,6 @@ class TestController extends Controller
     }
     public function test()
     {
-        $post = [
-            [
-                "taskMode"      => 2,
-                "bins"=>[
-                ],
-                "groupCode"     => 'g'.microtime(true),
-                "priority"      => 20,
-                "sequenceFlag"  => 1,
-            ]
-        ];
-        $post[0]['bins'][]=[
-            "taskCode"  =>Uuid::uuid4().'|'.microtime(true),
-            "binCode"   => "IDE0003571",
-            "fromLocCode" => "",
-            "toLocCode" => "BIN-OUT1",
-        ];
-        $response = Http::post(config('api.haiq.storage.moveBin'),$post);
-        $responseBody = $response->body();
-        dd($responseBody);
 
         $a = memory_get_usage();
         $tmp = str_repeat('http://blog.huachen.me/', 4000);

+ 1 - 1
app/Services/ForeignHaiRoboticsService.php

@@ -500,7 +500,7 @@ class ForeignHaiRoboticsService
             $blacklist[] = $box->id;
         }
         if ($stationCollection->count()>0){
-            if (!$this->fetchGroup_multiLocation($stationCollection,$collection,'','立架出至缓存架')) return null;
+            if (!$this->fetchGroup_multiLocation($stationCollection,$collection,'','立架出至缓存架',20,false)) return null;
             app("StationService")->locationOccupyMulti($stationCollection->toArray());
             $stationCollection->each(function ($code){
                 app("CacheShelfService")->lightUp($code,'3','0',["title"=>"机器人取箱中,禁止操作"]);

+ 12 - 4
app/Services/OrderPackageService.php

@@ -282,13 +282,15 @@ class OrderPackageService
         $update_params[] = ['id', 'sent_at'];
         foreach ($packages as $package) {
             if ($package->sent_at) continue;
+            list($allocation,$orderHeader) = $map[$package->logistic_number];
             try {
-                $checktime = $map[$package->logistic_number]->checktime;
+                $checktime = $allocation->checktime;
             } catch (\Exception $e) {
                 continue;
             }
             if ($checktime) {
-                $this->checkingAndProcess($package,$map[$package->logistic_number]->orderlineno); //检查和处理揽收
+                //EDISENDFLAG
+                $this->checkingAndProcess($package,$allocation->orderlineno,$orderHeader); //检查和处理揽收
                 $update_params[] = [
                     'id' => $package->id,
                     'sent_at' => $checktime,
@@ -302,8 +304,10 @@ class OrderPackageService
      * 检查和处理揽收
      *
      * @param OrderPackage|\stdClass $package
+     * @param int $lineNo
+     * @param \stdClass|mixed $orderHeader
      */
-    public function checkingAndProcess(OrderPackage $package, int $lineNo)
+    public function checkingAndProcess(OrderPackage $package, int $lineNo, $orderHeader)
     {
         //校验快递商 订单状态 复核标记 揽收标记
         $package->loadMissing("order.logistic");
@@ -314,6 +318,10 @@ class OrderPackageService
             Log::warning("自动揽收跳出",["status"=>$package->order->wms_status]);
             return;
         }
+        if ($orderHeader->edisendflag!='Y' && !app("OrderService")->manualBack($orderHeader->orderno)){
+            Log::warning("揽收回传失败",["status"=>$orderHeader->orderno]);
+            return;
+        }
         dispatch(new PackageCollectingAllocation($package,$lineNo));
     }
 
@@ -328,7 +336,7 @@ class OrderPackageService
             $actAllocationDetails = $orderHeader->actAllocationDetails;
             foreach ($actAllocationDetails as $actAllocationDetail) {
                 $logistic_number = $actAllocationDetail->picktotraceid;
-                $map[$logistic_number] = $actAllocationDetail;
+                $map[$logistic_number] = [$actAllocationDetail,$orderHeader];
             }
         }
         return $map;

+ 3 - 1
app/Services/OrderService.php

@@ -1640,9 +1640,11 @@ sql;
                         ->select('orderno')
                         ->whereIn('orderno', $orderno)
                         ->whereIn('carriername', ['中通(轻小包裹)', '中通', '中通速递']) // 承运商是中通
-                        ->where('sostatus', '!=', '90'); //状态 0 63
+                        ->where('sostatus', '!=', '90')
+                        ->where("edisendflag","Y");
                 })
                 ->pluck('picktotraceid');
+            if ($logisticNums->count()==0)return collect();
             $logisticNums = OrderPackage::query()
                 ->select('logistic_number')
                 ->whereIn('logistic_number', $logisticNums)