소스 검색

Merge branch 'Haozi' into zzd

# Conflicts:
#	bootstrap/cache/packages.php
#	bootstrap/cache/services.php
zhouzhendong 4 년 전
부모
커밋
cfd0f6b4c7

+ 9 - 3
app/Http/ApiControllers/WaybillController.php

@@ -10,6 +10,7 @@ use App\Http\Requests\Api\WaybillDispatch;
 use App\Services\WaybillService;
 use App\Waybill;
 use Illuminate\Database\Eloquent\Collection;
+use Illuminate\Support\Facades\DB;
 
 class WaybillController
 {
@@ -72,11 +73,16 @@ class WaybillController
         if ($deliverAt)$query->where("deliver_at","like",$deliverAt."%");
         /** @var Collection $waybills */
         $waybills = $query->paginate($paginate,'*', 'page',$page)->append(["carrier_name","amount_unit_name","remove_relation"]);
-        $result = null;
+        $result = [];
         if ($waybills->count()>0){
             $startDate = substr($waybills->first()->deliver_at,0,10);
             $endDate = substr($waybills->last()->deliver_at,0,10);
-            $result = ["2021-10-08"=>2];
+            $sql = <<<sql
+select sum(pick_up_fee) sum,date_format(deliver_at, '%Y-%m-%d') date from waybills where deliver_at between '{$startDate}' and '{$endDate}' group by date
+sql;
+            foreach (DB::select(DB::raw($sql)) as $item){
+                $result[$item->date] = $item->sum!==null ? round((double)$item->sum) : 0.0;
+            }
         }
         $this->response(["waybills"=>$waybills,"mapping"=>$result]);
     }
@@ -143,7 +149,7 @@ class WaybillController
         if (!$deliverAt || !$fee || !is_numeric($fee) || !$fee<0)
             $this->response(false,400,"非法参数或不满足需求");
         $param=array('screenDate'=>$deliverAt,'billing'=>$fee);
-        $waybills=app('waybillService')->dailyBilling($param);
+        $waybills=app('waybillService')->dailyBilling($param,true);
         if ($waybills===0 || $waybills===1 || !isset($waybills)) $this->response(false);
         $this->response(true);
     }

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

@@ -63,6 +63,7 @@ use App\Services\AuthorityService;
 use App\Services\BatchService;
 use App\Services\CacheShelfService;
 use App\Services\ForeignHaiRoboticsService;
+use App\Services\ForeignZhenCangService;
 use App\Services\LogisticService;
 use App\Services\NotificationService;
 use App\Services\OracleDOCOrderHeaderService;
@@ -762,4 +763,12 @@ sql;
         $service = app('OwnerStoreOutFeeReportService');
         $service->recordReport(null, [2]);
     }
+
+    public function testZhenCang()
+    {
+        $batches=Batch::query()->with(['orders.orderCommodities.commodity.barcodes'])->find(161071);
+        /** @var ForeignZhenCangService  $foreignZhenCangService */
+       $foreignZhenCangService=app('ForeignZhenCangService');;
+       $foreignZhenCangService->broadcastBatch($batches);
+    }
 }

+ 16 - 13
app/Services/CommodityService.php

@@ -540,19 +540,21 @@ class CommodityService
             $map = [];
             $BasSKUs->each(function ($basSku) use (&$map, $owner_map) {
                 $key = $basSku['sku'].$owner_map[$basSku['customerid']];
-                $map[$key] = [
-                    'owner_id' => $owner_map[$basSku['customerid']] ?? '',
-                    'sku' => $basSku->sku,
-                    'name' => $basSku->descr_c,
-                    'length' => $basSku->skulength,
-                    'width' => $basSku->skuwidth,
-                    'height' => $basSku->skuhigh,
-                    'volumn' => $basSku->cube,
-                    'created_at' => $basSku->addtime,
-                    'updated_at' => $basSku->edittime,
-                    'pack_spec' => $basSku->packid == 'STANDARD' ? 0 : explode("/", $basSku->packid)[1],
-                    'remark' => $basSku->notes,
-                ];
+                if ($basSku->sku&&$basSku->descr_c&&$basSku->customerid){ //只添加有sku 有name 有货主的商品
+                    $map[$key] = [
+                        'owner_id' => $owner_map[$basSku['customerid']] ?? '',
+                        'sku' => $basSku->sku,
+                        'name' => $basSku->descr_c,
+                        'length' => $basSku->skulength,
+                        'width' => $basSku->skuwidth,
+                        'height' => $basSku->skuhigh,
+                        'volumn' => $basSku->cube,
+                        'created_at' => $basSku->addtime,
+                        'updated_at' => $basSku->edittime,
+                        'pack_spec' => $basSku->packid == 'STANDARD' ? 0 : explode("/", $basSku->packid)[1],
+                        'remark' => $basSku->notes,
+                    ];
+                }
             });
             return $map;
         })();
@@ -606,6 +608,7 @@ class CommodityService
             $commodity = Cache::get("owner_code_{$basSku['customerid']}_sku_{$basSku['sku']}");
             if (!$commodity) $commodity = $dataHandlerService->getKeyValue(['owner_id' => $owner_map[$basSku['customerid']], 'sku' => $basSku['sku']], $commodities_map);
                 if (!$commodity) {
+                    if (!$basSku->sku||! $basSku->descr_c ||!$basSku->customerid)continue;//只添加有sku 有name 有货主的商品
                     $updateBasSkus->add($basSku);
                     $key = $basSku['sku'].$owner_map[$basSku['customerid']];
                     $insert_params[$key] = [

+ 5 - 1
app/Services/ForeignZhenCangService.php

@@ -3,7 +3,6 @@
 namespace App\Services;
 
 use App\Traits\ServiceAppAop;
-use App\ForeignZhenCang;
 use Carbon\Carbon;
 use Illuminate\Support\Facades\Http;
 
@@ -38,4 +37,9 @@ class ForeignZhenCangService
             'Host' => 'zc-it.com',
         ])->post('http://1.116.164.201:8080/api/createBatch',$body);
     }
+
+    public function broadcastBatchByFlux()
+    {
+
+    }
 }

+ 4 - 3
app/Services/WaybillService.php

@@ -149,7 +149,7 @@ class WaybillService
         $waybills = $this->conditionQuery($param);
         return $waybills->get();
     }
-    public function dailyBilling(array $param){
+    public function dailyBilling(array $param, bool $isOnlyLogistic = false){
         if (($param['screenDate']??false)==false || ($param['billing']??false)==false) return 0; //入参错误
         $waybills = Waybill::query()->with(['owner','logistic','originationCity','destinationCity.parent',
             'uploadFiles','amountUnit','warehouseWeightUnit','carrierWeightUnit','district','order',
@@ -161,8 +161,9 @@ class WaybillService
             ->orderBy('waybills.id','desc')
             ->where('waybills.type','专线')
             ->where('waybills.amount','>',0)
-            ->where('waybills.deliver_at','like',$param['screenDate'].'%')
-            ->get();
+            ->where('waybills.deliver_at','like',$param['screenDate'].'%');
+        if ($isOnlyLogistic)$waybills->whereIn("logistic_id",app("LogisticService")->getQuery());
+        $waybills = $waybills->get();
         if ($waybills->isEmpty()) return 1;//无数据
         foreach ($waybills as $waybill){
             if (!$waybill['carrier_weight_other'] && !$waybill['carrier_weight']) return null;