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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -53,22 +53,27 @@ class ChefService extends BaseService
|
||||
|
||||
public function chefDetailList(): array
|
||||
{
|
||||
$chefId = (int)$this->request->input('chef_id');
|
||||
$limit = (int)$this->request->input('limit', 10);
|
||||
$cityId = (int)$this->request->input('query_city_id');
|
||||
$name = $this->request->input('query_chef_name');
|
||||
|
||||
$list = $this
|
||||
->adminUserModel
|
||||
->leftJoin('chef', 'admin_user.id', '=', 'chef.user_id')
|
||||
->chefModel
|
||||
->leftJoin('admin_user', 'admin_user.id', '=', 'chef.user_id')
|
||||
->where('admin_user.is_del',UserCode::IS_NO_DEL)
|
||||
->where('admin_user.status',UserCode::ENABLE)
|
||||
->where('admin_user.role_id',RoleCode::CHEF)
|
||||
->when(!empty($chefId), function ($query) use ($chefId) {
|
||||
$query->where('admin_user.id', $chefId);
|
||||
->when(!empty($cityId), function ($query) use ($cityId) {
|
||||
$query->where('admin_user.city_id', $cityId);
|
||||
})
|
||||
->get(['admin_user.id','admin_user.avatar','admin_user.chinese_name','chef.profile','chef.specialties']);
|
||||
->when(!empty($name), function ($query) use ($name) {
|
||||
$query->where('admin_user.chinese_name', 'like', "$name%");
|
||||
})
|
||||
->paginate($limit,['chef.id','admin_user.avatar','admin_user.chinese_name','chef.profile','chef.specialties'])->toArray();
|
||||
|
||||
if (empty($list)) return $this->return->success('success',['list' => []]);
|
||||
|
||||
return $this->return->success('success',['list' => $list->toArray()]);
|
||||
return $this->return->success('success',['list' => $list]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user