فهرست منبع

退货系统列表时间复杂度问题 O(N)

LD 5 سال پیش
والد
کامیت
3835692a77
5فایلهای تغییر یافته به همراه195 افزوده شده و 197 حذف شده
  1. 8 3
      app/Http/Controllers/RejectedController.php
  2. 3 7
      app/RejectedBill.php
  3. 1 1
      app/RejectedBillItem.php
  4. 1 1
      app/Services/RejectedService.php
  5. 182 185
      composer.lock

+ 8 - 3
app/Http/Controllers/RejectedController.php

@@ -15,12 +15,15 @@ use App\Services\QualityLabelService;
 use App\Services\RejectedService;
 use Carbon\Carbon;
 use Exception;
+use Illuminate\Contracts\Foundation\Application;
+use Illuminate\Contracts\View\Factory;
 use Illuminate\Http\Request;
 use Illuminate\Http\Response;
 use Illuminate\Support\Facades\Auth;
 use Illuminate\Support\Facades\Gate;
 use Illuminate\Support\Facades\Http;
 use Illuminate\Support\Facades\Validator;
+use Illuminate\View\View;
 use Maatwebsite\Excel\Facades\Excel;
 use function foo\func;
 
@@ -37,15 +40,17 @@ class RejectedController extends Controller
      * @param OwnerService $ownerService
      * @param QualityLabelService $qualityLabelService
      * @param LogisticService $logisticService
-     * @return void
+     * @return Application|Factory|View|void
      */
     public function index(Request $request,OwnerService $ownerService,
                           QualityLabelService $qualityLabelService,LogisticService $logisticService)
     {
         if(!Gate::allows('退货管理-查询')){ return redirect(url('/login'));  }
         $paginateParams = $request->input();
-        $rejectedBills=app('rejectedService')->paginate($request);
-        $issueIds = app('rejectedService')->返回有问题件的ID($request);
+        /** @var RejectedService $application */
+        $application = app('rejectedService');
+        $rejectedBills= $application->paginate($request);
+        $issueIds = $application->返回有问题件的ID($request);
         $owners = $ownerService->getSelection();
         $qualityLabels = $qualityLabelService->get();
         $logistics=$logisticService->getSelection();

+ 3 - 7
app/RejectedBill.php

@@ -83,14 +83,10 @@ class RejectedBill extends Model
 
 
     public function getOwnerNameAttribute(){
-        $id_owner=$this['id_owner']??0;
-        $owner=Owner::find($id_owner);
-        return $this['owner_name']=$owner['name'];
+        return $this->owner['name']??'';
     }
     public function getLogisticNameAttribute(){
-        $id_logistic=$this['id_logistic_return']??0;
-        $logistic=Logistic::find($id_logistic);
-        return $this['logistic_name']=$logistic['name'];
+        return $this->logistic['name']??'';
     }
     public function getIsLoadedStrAttribute(){
         $val=$this['is_loaded']===null?'null':$this['is_loaded'];
@@ -109,7 +105,7 @@ class RejectedBill extends Model
     }
     public function getGoodsAmountAttribute(){
         $amount=0;
-        $this->items()->get()->each(function (RejectedBillItem $item)use(&$amount){
+        $this->items->each(function (RejectedBillItem $item)use(&$amount){
             $amount+=$item['amount'];
         });
         return $amount;

+ 1 - 1
app/RejectedBillItem.php

@@ -61,7 +61,7 @@ class RejectedBillItem extends Model
         }
     }
     public function getQualityLabelAttribute(){
-        return $this['quality']['name'];
+        return $this->quality['name']??'';
     }
 
 }

+ 1 - 1
app/Services/RejectedService.php

@@ -21,7 +21,7 @@ class RejectedService
     private function conditionQuery(array $param)
     {
         $user = Auth::user();
-        $rejectedBills = RejectedBill::query()->with('user','owner', 'logistic', 'items')->orderBy('rejected_bills.id', 'desc')->whereIn('rejected_bills.id_owner',
+        $rejectedBills = RejectedBill::query()->with('user','owner', 'logistic', 'items.quality')->orderBy('rejected_bills.id', 'desc')->whereIn('rejected_bills.id_owner',
             $user ? $user->getPermittingOwnerIdsAttribute() : []);
         $columnQueryRules = [
             'created_at_start' => ['alias' => 'created_at', 'startDate' => ' 00:00:00'],

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 182 - 185
composer.lock


برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است