feat:material
This commit is contained in:
@@ -7,6 +7,7 @@ namespace App\Service\Admin\Material;
|
||||
use App\Constants\Common\MaterialCode;
|
||||
use App\Exception\ErrException;
|
||||
use App\Model\Material;
|
||||
use App\Model\MaterialStock;
|
||||
use App\Service\Admin\BaseService;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
|
||||
@@ -18,6 +19,9 @@ class MaterialService extends BaseService{
|
||||
#[Inject]
|
||||
protected Material $MaterialModel;
|
||||
|
||||
#[Inject]
|
||||
protected MaterialStock $MaterialStockModel;
|
||||
|
||||
public function handle()
|
||||
{
|
||||
|
||||
@@ -99,4 +103,31 @@ class MaterialService extends BaseService{
|
||||
|
||||
return $this->return->success();
|
||||
}
|
||||
|
||||
public function materialStockList(): array
|
||||
{
|
||||
$limit = (int)$this->request->input('limit', 10);
|
||||
$name = $this->request->input('query_name');
|
||||
$depotId = (int)$this->request->input('query_depotId');
|
||||
$supplierId = (int)$this->request->input('query_supplierId');
|
||||
$list = $this->MaterialStockModel
|
||||
->leftJoin('material', 'material_stock.material_id', '=', 'material.id')
|
||||
->leftJoin('supplier', 'material_stock.supplier_id', '=', 'supplier.id')
|
||||
->leftJoin('depot', 'material_stock.depot_id', '=', 'depot.id')
|
||||
->where('material_stock.is_del',MaterialCode::IS_NO_DEL)
|
||||
->when(!empty($name), function ($query) use ($name) {
|
||||
$query->where('material.name', 'like', "$name%");
|
||||
})
|
||||
->when(!empty($depotId), function ($query) use ($depotId) {
|
||||
$query->where('material_stock.depot_id', $depotId);
|
||||
})
|
||||
->when(!empty($supplierId), function ($query) use ($supplierId) {
|
||||
$query->where('material_stock.supplier_id', $supplierId);
|
||||
})
|
||||
->paginate($limit,['material_stock.*','material.name as material_name','supplier.name as supplier_name','depot.name as depot_name'])
|
||||
->toArray();
|
||||
|
||||
return $this->return->success('success',$list);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user