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

Merge branch 'Haozi' of ssh://was.baoshi56.com:10022/var/git/bswas

LD 5 лет назад
Родитель
Сommit
b8e8505e5a

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

@@ -1601,4 +1601,35 @@ TEXT;
         $service = app('OrderPackageExceptionTypeCountingRecordService');
         $service->updateOrCreate(30);
     }
+    public function testForeignZhenCang($batches)
+    {
+
+        $batches=Batch::query()
+            ->with(['orders.orderCommodities.commodity.barcodes'])
+            ->find(111953);
+        $body=[];
+        $body['id']=$batches->code;
+        $body['orders'] = [];
+        foreach ($batches->orders as $order){
+            $orderArr = [];
+            $orderArr['id']=$order->code??'';
+            $orderArr['createdAt']=Carbon::parse($order->created_at)->toDateTimeString()??'';
+            $orderArr['barcodes'] = [];
+            foreach ($order->orderCommodities as $orderCommodity){
+                $barcode=[];
+                $barcode['id']=$orderCommodity->id;
+                $barcode['barcode']=$orderCommodity->commodity ? ($orderCommodity->commodity->barcodes?$orderCommodity->commodity->barcodes->first()['code']:'') : '';
+                $barcode['name']=$orderCommodity->commodity->name??'';
+                $barcode['sku']=$orderCommodity->commodity->sku??'';
+                $barcode['amount']=$orderCommodity->amount??'';
+                $barcode['location']=$orderCommodity->location??'';
+                $orderArr['barcodes'][]=$barcode;
+            }
+            $body['orders'][] = $orderArr;
+        }
+        $response = Http::withHeaders([
+            'Host' => 'zc-it.com',
+        ])->post('http://1.116.164.201:8080/api/createBatch',$body);
+        dd(json_decode($response->body()));
+    }
 }

+ 2 - 1
app/Http/Controllers/WaybillController.php

@@ -947,10 +947,11 @@ class WaybillController extends Controller
         if(!Gate::allows('运输管理-运单-按日计算专线费')){return ['success'=>false,'message'=>'没有权限'];}
         $dailyBilling=$request->input('param');
         $waybills=app('waybillService')->dailyBilling($dailyBilling);
+        if ($waybills==false)return ['success'=>false,'message'=>'当前选定发货日期没有任何记录'];
         if (!isset($waybills))return ['success'=>false,'message'=>'该日有记录未填写重量'];
         return ['success'=>true,'data'=>$waybills];
     }
-    public function countPickUpFee(Request $request)
+    public function countPickUpFee(Request $request): array
     {
         if(!Gate::allows('运输管理-运单-查询')){ return ['success'=>false,'message'=>'没有权限'];  }
         $param=$request->input('param');

+ 2 - 0
app/Providers/AppServiceProvider.php

@@ -115,6 +115,7 @@ use App\Services\SupplierService;
 use App\Services\OrderPackageCommoditySerialNumberService;
 use App\Services\OrderPackageExceptionTypeCountingRecordService;
 use App\Services\LogisticYDService;
+use App\Services\ForeignZhenCangService;
 
 class AppServiceProvider extends ServiceProvider
 {
@@ -182,6 +183,7 @@ class AppServiceProvider extends ServiceProvider
         app()->singleton('FacilitatorService',FacilitatorService::class);
         app()->singleton('FeatureService',FeatureService::class);
         app()->singleton('ForeignHaiRoboticsService',ForeignHaiRoboticsService::class);
+        app()->singleton('ForeignZhenCangService',ForeignZhenCangService::class);
         app()->singleton('InventoryAccountMissionService',InventoryAccountMissionService::class);
         app()->singleton('InventoryCompareService',InventoryCompareService::class);
         app()->singleton('InventoryDailyLogService',InventoryDailyLogService::class);

+ 41 - 0
app/Services/ForeignZhenCangService.php

@@ -0,0 +1,41 @@
+<?php
+
+namespace App\Services;
+
+use App\Traits\ServiceAppAop;
+use App\ForeignZhenCang;
+use Carbon\Carbon;
+use Illuminate\Support\Facades\Http;
+
+class ForeignZhenCangService
+{
+    use ServiceAppAop;
+//    protected $modelClass=ForeignZhenCang::class;
+
+    public function broadcastBatch($batches)
+    {
+        $body=[];
+        $body['id']=$batches->code;
+        $body['orders'] = [];
+        foreach ($batches->orders as $order){
+            $orderArr = [];
+            $orderArr['id']=$order->code??'';
+            $orderArr['createdAt']=Carbon::parse($order->created_at)->toDateTimeString()??'';
+            $orderArr['barcodes'] = [];
+            foreach ($order->orderCommodities as $orderCommodity){
+                $barcode=[];
+                $barcode['id']=$orderCommodity->id;
+                $barcode['barcode']=$orderCommodity->commodity ? ($orderCommodity->commodity->barcodes?$orderCommodity->commodity->barcodes->first()['code']:'') : '';
+                $barcode['name']=$orderCommodity->commodity->name??'';
+                $barcode['sku']=$orderCommodity->commodity->sku??'';
+                $barcode['amount']=$orderCommodity->amount??'';
+                $barcode['location']=$orderCommodity->location??'';
+                $orderArr['barcodes'][]=$barcode;
+            }
+            $body['orders'][] = $orderArr;
+        }
+        $response = Http::withHeaders([
+            'Host' => 'zc-it.com',
+        ])->post('http://1.116.164.201:8080/api/createBatch',$body);
+    }
+}

+ 1 - 1
app/Services/LogisticYTOService.php

@@ -48,7 +48,7 @@ class LogisticYTOService
         if (is_object($response) && $response->code=='1001') {return [];}
         else {
             try {
-                $result['logistic_number'] = $response[0]->waybill_No;
+                if (is_array($response))$result['logistic_number'] = $response[0]->waybill_No;
             } catch (\Exception $e) {
                 LogService::log(LogisticYTOService::class, "YTO快递信息异常", $response);
             }

+ 1 - 0
app/Services/StationRuleBatchService.php

@@ -74,6 +74,7 @@ class StationRuleBatchService
             Cache::tags([ '波次防重叠'.$batch['id']])->put($batch['id'],true,config('haiRou.波次防重叠时间_秒'));
         }
         LogService::log(__METHOD__,'shouldProcess','波次任务分配1.3:'.json_encode($batches_toProcess));
+        dump($batches_toProcess);
         return $batches_toProcess;
     }
 }

+ 4 - 3
app/Services/WaybillService.php

@@ -161,13 +161,14 @@ class WaybillService
             ->whereNull('waybill_on_tops.deleted_at')
             ->orderBy('waybill_on_tops.updated_at','desc')
             ->orderBy('waybills.id','desc')
-            ->where('waybills.created_at','like',$param['screenDate'].'%')
+//            ->where('waybills.created_at','like',$param['screenDate'].'%')
             ->where('waybills.type','专线')
-            ->whereNotNull('waybills.deliver_at')
+            ->where('waybills.deliver_at','like',$param['screenDate'].'%')
             ->get();
+        if ($waybills->isEmpty()) return false;
         foreach ($waybills as $waybill){
             if (!$waybill['carrier_weight_other'] && !$waybill['carrier_weight']) return null;
-            if (!$waybill['carrier_weight_other']) $waybill['carrier_weight_other']=($waybill['carrier_weight']/0.4);
+            if (!$waybill['carrier_weight_other']) $waybill['carrier_weight_other']=($waybill['carrier_weight']/0.004);
         }
         $daily_total_weight=$waybills->sum('carrier_weight_other');
         $updateParams = [['id','pick_up_fee','updated_at']];

+ 1 - 1
resources/views/transport/waybill/_dailyBilling.blade.php

@@ -9,7 +9,7 @@
             </div>
             <div class="modal-body">
                 <div class="form-group row">
-                    <label for="screenDate" class="col-2 col-form-label text-right">选定日期</label>
+                    <label for="screenDate" class="col-2 col-form-label text-right">选定发货日期</label>
                     <div class="col-8">
                         <input type="date" class="form-control" :class="error.screenDate ? 'is-invalid' : ''" name="screenDate" autocomplete="off"  v-model="dailyBilling.screenDate" >
                         <span class="invalid-feedback" role="alert" v-if="error.screenDate">

+ 1 - 1
tests/Services/StationTaskBatchService/CreateByBatchesTest.php

@@ -71,10 +71,10 @@ class CreateByBatchesTest extends TestCase
     public function tearDown(): void
     {
         Batch::query()->whereIn('id',data_get($this->data['batches'],'*.id')??[])->delete();
+        StationRuleBatch::query()->where('owner_id',$this->data['owner']['id']??'')->delete();
         StationTask::query()->whereIn('id',data_get($this->data['stationTask'],'*.id')??[])->delete();
         StationTaskBatch::query()->whereIn('id',data_get($this->data['stationTaskBatches'],'*.id')??[])->delete();
         StationTaskChild::query()->whereIn('station_task_id',data_get($this->data['stationTask'],'*.id')??[])->delete();
-        $this->data['stationRuleBatch']->delete();
         Owner::query()->where('id',$this->data['owner']['id']??'')->delete();
         parent::tearDown();
     }

+ 0 - 1
tests/Services/StationTaskBatchService/RunManyTest.php

@@ -74,7 +74,6 @@ class RunManyTest extends TestCase
         $this->data['stationTaskMaterialBoxes']=$this->stationTaskMaterialBoxService->createByBatches($this->data['batches'],$this->data['stationTask']); //注册料箱任务
         $this->data['stationTaskBathes']=$this->stationTaskBatchService->createByBatches($this->data['batches'],$this->data['stationTask']); //注册波次任务
 
-
     }
 
     public function testReturned()

+ 6 - 4
tests/Services/StationTaskCommodityService/CreateByBatchTest.php

@@ -67,8 +67,8 @@ class CreateByBatchTest extends TestCase
             ]
         ]);
 
-        $this->data['stationTaskCommodities']
-            =(function(){
+//        $this->data['stationTaskCommodities']
+//            =(function(){
             if(!isset($this->data['stationTaskCommodities']))
                 $this->data['stationTaskCommodities'] = collect();
             foreach($this->data['batches'] as $batch){
@@ -77,8 +77,10 @@ class CreateByBatchTest extends TestCase
                     $this->service->createByBatch($batch)
                 );
             }
-            return $this->data['stationTaskCommodities'];
-        })();
+//            return $this->data['stationTaskCommodities'];
+//        })();
+
+        $this->data['stationTaskCommodities']=StationTaskCommodity::query()->whereIn('order_id',data_get($this->data['orders'],'*.id')??[])->get();
         $this->assertEquals($this->orderCommodityAmount, $this->data['stationTaskCommodities']->count());
     }
 

+ 3 - 0
tests/Services/StationTaskMaterialBoxService/CreateByBatchesTest.php

@@ -79,6 +79,9 @@ class CreateByBatchesTest extends TestCase
         StationTask::query()
             ->whereIn('id',data_get($this->data['stationTask'],'*.id')??[])
             ->delete();
+        Batch::query()
+            ->whereIn('id',data_get( $this->data['batches'],'*.id')??[])
+            ->delete();
         parent::tearDown();
     }
 }