|
|
@@ -10,6 +10,7 @@ use App\Services\common\QueryService;
|
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
|
use Illuminate\Http\Request;
|
|
|
use App\Traits\ServiceAppAop;
|
|
|
+use Illuminate\Pagination\Paginator;
|
|
|
|
|
|
|
|
|
class RejectedService
|
|
|
@@ -25,19 +26,27 @@ class RejectedService
|
|
|
$this->instant($this->cacheService,'CacheService');
|
|
|
$this->instant($this->workOrderInterceptService,'WorkOrderInterceptService');
|
|
|
}
|
|
|
- private function conditionQuery(array $param)
|
|
|
+ private function conditionQuery(array $param, array $owners = null, array $logistics = null)
|
|
|
{
|
|
|
- $owners = app("OwnerService")->getQuery()->select("id")->pluck("id")->toArray();
|
|
|
- if (count($owners)==0){
|
|
|
- $owners[] = [''];
|
|
|
+ if ($owners == null){
|
|
|
+ $owners = app("OwnerService")->getIdArr();
|
|
|
+ if (count($owners)==0){
|
|
|
+ $owners[] = [''];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($logistics == null){
|
|
|
+ $logistics = app("LogisticService")->getIdArr();
|
|
|
+ if (count($logistics)==0){
|
|
|
+ $logistics[] = [''];
|
|
|
+ }
|
|
|
}
|
|
|
$rejectedBills = RejectedBill::query()->with('user','owner', 'logistic', 'items.quality','record:logistic_number,record_at,location_at',
|
|
|
'items.packageImages','items.commodityImages','items.uploadFiles','orderIssueRejectedBill:logistic_number_return')
|
|
|
->orderBy('rejected_bills.id', 'desc')
|
|
|
- ->where(function ($query)use ($owners){
|
|
|
+ ->where(function ($query)use ($owners, $logistics){
|
|
|
/** @var Builder $query */
|
|
|
$query->whereIn('rejected_bills.id_owner', $owners)
|
|
|
- ->orWhereIn("rejected_bills.id_logistic_return",app("LogisticService")->getQuery());
|
|
|
+ ->orWhereIn("rejected_bills.id_logistic_return", $logistics);
|
|
|
});
|
|
|
if (array_search("397",$owners)!==false){
|
|
|
$rejectedBills->with(["items.barcode.commodity"=>function($query){
|
|
|
@@ -122,8 +131,13 @@ class RejectedService
|
|
|
|
|
|
public function paginate(Request $request)
|
|
|
{
|
|
|
- return $this->cacheService->getOrExecute('RejectedsPaginate'.md5(json_encode($request->toArray())),function()use($request){
|
|
|
- return $this->conditionQuery($request->input())->simplePaginate($request->paginate ?? 50);
|
|
|
+ $owners = app("OwnerService")->getIdArr();
|
|
|
+ $logistics = app("LogisticService")->getIdArr();
|
|
|
+ if (count($owners) == 0 && count($logistics) == 0){
|
|
|
+ return new Paginator([], 1);
|
|
|
+ }
|
|
|
+ return $this->cacheService->getOrExecute('RejectedsPaginate'.md5(json_encode($request->toArray())),function()use($request, $owners, $logistics){
|
|
|
+ return $this->conditionQuery($request->input(), $owners, $logistics)->simplePaginate($request->paginate ?? 50);
|
|
|
},config('cache.expirations.oftenChange'));
|
|
|
}
|
|
|
|