|
|
@@ -24,6 +24,7 @@ use Carbon\Traits\Date;
|
|
|
use Illuminate\Http\Request;
|
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
use Illuminate\Support\Facades\Gate;
|
|
|
+use Matrix\Builder;
|
|
|
|
|
|
class ProcurementController extends Controller
|
|
|
{
|
|
|
@@ -117,7 +118,6 @@ class ProcurementController extends Controller
|
|
|
'initiator'=>Auth::user()['id'],
|
|
|
'type'=>1,
|
|
|
'status'=>0,
|
|
|
- 'is_enquiry'=>'是',
|
|
|
'time'=>14400000,
|
|
|
]);
|
|
|
$procurement->save();
|
|
|
@@ -244,10 +244,9 @@ class ProcurementController extends Controller
|
|
|
foreach ($procurements as $procurement){
|
|
|
if ($procurement->type==2){
|
|
|
$pro=$this->newProcurement($procurement,Auth::user()['id'],$procurement->type,2);
|
|
|
- $pro->loadMissing(['initiator','ownerMaterial.material','ownerMaterial.owner.customer']);
|
|
|
- continue;
|
|
|
+ }else{
|
|
|
+ $pro=$this->newProcurement($procurement,Auth::user()['id'],$procurement->type);
|
|
|
}
|
|
|
- $pro=$this->newProcurement($procurement,Auth::user()['id'],$procurement->type);
|
|
|
$pro->loadMissing(['initiator','ownerMaterial.material','ownerMaterial.owner.customer']);
|
|
|
$collect->add($pro);
|
|
|
}
|
|
|
@@ -315,7 +314,11 @@ class ProcurementController extends Controller
|
|
|
$procurements = Procurement::query()
|
|
|
->filter($filters)
|
|
|
->with(['initiator','supplier','ownerMaterial.material','ownerMaterial.owner'=>function($query)use($owner_ids){
|
|
|
+ /** @var Builder $query */
|
|
|
$query->with('customer')->whereIn('id',$owner_ids);
|
|
|
+ },'procurementDeliveries'=>function($builder){
|
|
|
+ /** @var Builder $builder */
|
|
|
+ $builder->orderByDesc('id')->first();
|
|
|
}])
|
|
|
->where('type',0) //只取采购单
|
|
|
->paginate($param['paginate'] ?? 50);
|
|
|
@@ -360,7 +363,7 @@ class ProcurementController extends Controller
|
|
|
$procurement->quantity,
|
|
|
$procurement->unit_price,
|
|
|
'',//送货数量
|
|
|
- '',//销售总价
|
|
|
+ $procurement->unit_price*$procurement->amount,//销售总价=销售数量*销售单价
|
|
|
is_null($procurement->status) ? '' :$procurementStatus[$procurement->status],
|
|
|
$procurement->ownerMaterial->owner->customer ? $procurement->ownerMaterial->owner->customer->phone :'',
|
|
|
];
|