ajun 5 лет назад
Родитель
Сommit
15960cda08
1 измененных файлов с 11 добавлено и 10 удалено
  1. 11 10
      app/Imports/RejectedImport.php

+ 11 - 10
app/Imports/RejectedImport.php

@@ -2,7 +2,7 @@
 
 namespace App\Imports;
 
-use App\Http\Controllers\api\jianshang\RejectedController;
+use App\Http\Controllers\api\thirdPart\jianshang\RejectedController;
 use App\Http\Controllers\Controller;
 use App\Logistic;
 use App\Owner;
@@ -13,7 +13,9 @@ use Illuminate\Support\Collection;
 use Illuminate\Support\Facades\Session;
 use Maatwebsite\Excel\Concerns\ToCollection;
 use Maatwebsite\Excel\Concerns\WithHeadingRow;
+use Maatwebsite\Excel\Imports\HeadingRowFormatter;
 
+HeadingRowFormatter::default('none');
 class RejectedImport implements ToCollection, WithHeadingRow
 {
 //    protected $isOverride=false;
@@ -39,7 +41,6 @@ class RejectedImport implements ToCollection, WithHeadingRow
             $remark = trim($row['备注']??$row['remark']??'');
             $id_owner=Session::get('jianshangIdOwner');
 
-
             $lastReturnNumber = Session::get('jianshangLastImportedBill');
             if(!$logistic_number_return)$logistic_number_return=$lastReturnNumber;
             $lastMobile = Session::get('jianshangLastImportedMobile');
@@ -49,12 +50,12 @@ class RejectedImport implements ToCollection, WithHeadingRow
 
 
             if(!$id_owner){
-                $id_owner=Owner::where('name','like','%笕尚%')->first()['id'];
+                $id_owner=Owner::query()->where('name','like','%笕尚%')->first()['id'];
                 Session::put('jianshangIdOwner',$id_owner);
             }
-            $id_logistic_return=Logistic::where('name','like',"%{$logistic_name}%")->first()['id'];
+            $id_logistic_return=Logistic::query()->where('name','like',"%{$logistic_name}%")->first()['id'];
             if(!$id_logistic_return){
-                $id_logistic_return=Logistic::where('name','like',"%其它%")->first()['id'];
+                $id_logistic_return=Logistic::query()->where('name','like',"%其它%")->first()['id'];
             }
 
             $id_quality_label=3;
@@ -66,9 +67,9 @@ class RejectedImport implements ToCollection, WithHeadingRow
             if(!$amount)$amount=1;
 
 
-            $bill=RejectedBill::where('logistic_number_return',trim($logistic_number_return))->first();
+            $bill=RejectedBill::query()->where('logistic_number_return',trim($logistic_number_return))->first();
             if($bill){
-                $item=RejectedBillItem::where('id_rejected_bill',$bill['id'])
+                $item=RejectedBillItem::query()->where('id_rejected_bill',$bill['id'])
                     ->where('barcode_goods',trim($barcode))->where('id_quality_label',$id_quality_label)->first();
                 if($item){
                     $item['amount']+=$amount;
@@ -95,7 +96,7 @@ class RejectedImport implements ToCollection, WithHeadingRow
                 $bill->save();
                 $bill->joinOrderIssue();
                 $bill->syncOrderIssue();
-                $item=RejectedBillItem::where('id_rejected_bill',$bill['id'])
+                $item=RejectedBillItem::query()->where('id_rejected_bill',$bill['id'])
                     ->where('barcode_goods',trim($barcode))->where('id_quality_label',$id_quality_label)->first();
                 if($item){
                     $item['amount']+=$amount;
@@ -126,11 +127,11 @@ class RejectedImport implements ToCollection, WithHeadingRow
         $havingFail=0;
         if(!config('api.API_FAKING'))
             $bill->items()->get()->each(function(RejectedBillItem $item)use(&$havingFail){
-                $rejectedBill=RejectedBill::find($item['id_rejected_bill']);
+                $rejectedBill=RejectedBill::query()->find($item['id_rejected_bill']);
                 if($rejectedBill['is_loaded']!=0){
                     return false;
                 }
-                $owner = Owner::find($rejectedBill['id_owner']);
+                $owner = Owner::query()->find($rejectedBill['id_owner']);
                 if(strstr($owner->name??'','笕尚')){
                     $rejected=new Rejected();
                     app('LogService')->log(__METHOD__,'找不到表','132行');