feat:material
This commit is contained in:
@@ -66,4 +66,17 @@ class MaterialController
|
|||||||
return (new MaterialService())->edit();
|
return (new MaterialService())->edit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 材料库存列表
|
||||||
|
* @param MaterialRequest $request
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
#[RequestMapping(path: "materialStock_list", methods: "GET")]
|
||||||
|
#[Scene(scene: "materialStock_list")]
|
||||||
|
public function materialStockList(MaterialRequest $request): array
|
||||||
|
{
|
||||||
|
return (new MaterialService())->materialStockList();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,5 +40,6 @@ class MaterialRequest extends FormRequest
|
|||||||
'material_add' => ['category_id', 'name', 'standard', 'unit', 'bar_code', 'city_id', 'kitchen_id'],
|
'material_add' => ['category_id', 'name', 'standard', 'unit', 'bar_code', 'city_id', 'kitchen_id'],
|
||||||
'material_edit' => ['id','category_id', 'name', 'standard', 'unit', 'bar_code','status'],
|
'material_edit' => ['id','category_id', 'name', 'standard', 'unit', 'bar_code','status'],
|
||||||
'material_delete' => ['id'],
|
'material_delete' => ['id'],
|
||||||
|
'materialStock_list' => ['limit','query_name','query_depotId','query_supplierId'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ namespace App\Service\Admin\Material;
|
|||||||
use App\Constants\Common\MaterialCode;
|
use App\Constants\Common\MaterialCode;
|
||||||
use App\Exception\ErrException;
|
use App\Exception\ErrException;
|
||||||
use App\Model\Material;
|
use App\Model\Material;
|
||||||
|
use App\Model\MaterialStock;
|
||||||
use App\Service\Admin\BaseService;
|
use App\Service\Admin\BaseService;
|
||||||
use Hyperf\Di\Annotation\Inject;
|
use Hyperf\Di\Annotation\Inject;
|
||||||
|
|
||||||
@@ -18,6 +19,9 @@ class MaterialService extends BaseService{
|
|||||||
#[Inject]
|
#[Inject]
|
||||||
protected Material $MaterialModel;
|
protected Material $MaterialModel;
|
||||||
|
|
||||||
|
#[Inject]
|
||||||
|
protected MaterialStock $MaterialStockModel;
|
||||||
|
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -99,4 +103,31 @@ class MaterialService extends BaseService{
|
|||||||
|
|
||||||
return $this->return->success();
|
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
|
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
|
$list = $this
|
||||||
->adminUserModel
|
->chefModel
|
||||||
->leftJoin('chef', 'admin_user.id', '=', 'chef.user_id')
|
->leftJoin('admin_user', 'admin_user.id', '=', 'chef.user_id')
|
||||||
->where('admin_user.is_del',UserCode::IS_NO_DEL)
|
->where('admin_user.is_del',UserCode::IS_NO_DEL)
|
||||||
->where('admin_user.status',UserCode::ENABLE)
|
->where('admin_user.status',UserCode::ENABLE)
|
||||||
->where('admin_user.role_id',RoleCode::CHEF)
|
->where('admin_user.role_id',RoleCode::CHEF)
|
||||||
->when(!empty($chefId), function ($query) use ($chefId) {
|
->when(!empty($cityId), function ($query) use ($cityId) {
|
||||||
$query->where('admin_user.id', $chefId);
|
$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' => []]);
|
if (empty($list)) return $this->return->success('success',['list' => []]);
|
||||||
|
|
||||||
return $this->return->success('success',['list' => $list->toArray()]);
|
return $this->return->success('success',['list' => $list]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -90,7 +90,6 @@ class MaterialService extends BaseService{
|
|||||||
if($info->status == MaterialCode::AUDIT_REFUSE){
|
if($info->status == MaterialCode::AUDIT_REFUSE){
|
||||||
$info->status = MaterialCode::UN_AUDIT;
|
$info->status = MaterialCode::UN_AUDIT;
|
||||||
}
|
}
|
||||||
$info->operator_id = $this->userId;
|
|
||||||
|
|
||||||
if (!$info->save()) throw new ErrException('申请修改失败');
|
if (!$info->save()) throw new ErrException('申请修改失败');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user