feat : catering

This commit is contained in:
2025-03-10 16:52:23 +08:00
parent c21fc1ef90
commit 2e67b921bd
14 changed files with 598 additions and 54 deletions

View File

@@ -21,12 +21,15 @@ use App\Model\Chef;
use App\Model\DriverSequence;
use App\Model\WarehouseKeeper;
use App\Service\Admin\BaseService;
use App\Service\ServiceTrait\Admin\RoleMembersTrait;
use Exception;
use Hyperf\Di\Annotation\Inject;
use function Hyperf\Config\config;
class EmployeeService extends BaseService
{
use RoleMembersTrait;
/**
* 注入用户模型
* @var AdminUser $adminUserModel
@@ -107,12 +110,8 @@ class EmployeeService extends BaseService
//写入关联表
$res = match ($model->role_id) {
RoleCode::DRIVER =>
(new DriverSequence)->insert([
'driver_id' => $model->id,
]),
RoleCode::CHEF =>
$this->addChef($model->id),
RoleCode::DRIVER => $this->addDriver($model->id,$model->chinese_name),
RoleCode::CHEF => $this->addChef($model->id),
RoleCode::WAREHOUSE => $this->addWarehouseKeeper($model->id),
default => true,
};
@@ -122,18 +121,6 @@ class EmployeeService extends BaseService
return $this->return->success();
}
public function addChef($id): bool
{
$chef = new Chef();
$chef->user_id = $id;
return $chef->save();
}
public function addWarehouseKeeper($id): bool
{
$warehouseKeeper = new WarehouseKeeper();
$warehouseKeeper->user_id = $id;
return $warehouseKeeper->save();
}
/**
* 修改
@@ -158,16 +145,14 @@ class EmployeeService extends BaseService
if ($info->role_id != $roleId) {
//写入关联表
$del = match ($info->role_id) {
RoleCode::DRIVER => (new DriverSequence)->where('driver_id', $info->id)->delete(),
RoleCode::CHEF => (new Chef)->where('user_id', $info->id)->delete(),
RoleCode::WAREHOUSE => (new WarehouseKeeper)->where('user_id', $info->id)->delete(),
RoleCode::DRIVER => $this->delDriver($info->id),
RoleCode::CHEF => $this->delChef($info->id),
RoleCode::WAREHOUSE => $this->delWarehouseKeeper($info->id),
default => true,
};
$add = match ($roleId) {
RoleCode::DRIVER => (new DriverSequence)->insert([
'driver_id' => $info->id,
]),
RoleCode::DRIVER => $this->addDriver($info->id,$info->chinese_name),
RoleCode::CHEF => $this->addChef($info->id),
RoleCode::WAREHOUSE => $this->addWarehouseKeeper($info->id),
default => true,
@@ -207,9 +192,9 @@ class EmployeeService extends BaseService
$info->is_del = UserCode::IS_DEL;
$del = match ($info->role_id) {
RoleCode::DRIVER => (new DriverSequence)->where('driver_id', $info->id)->update(['is_del' => UserCode::IS_DEL]),
RoleCode::CHEF => (new Chef)->where('user_id', $info->id)->update(['is_del' => UserCode::IS_DEL]),
RoleCode::WAREHOUSE => (new WarehouseKeeper)->where('user_id', $info->id)->update(['is_del' => UserCode::IS_DEL]),
RoleCode::DRIVER => $this->delDriver($info->id),
RoleCode::CHEF => $this->delChef($info->id),
RoleCode::WAREHOUSE => $this->delWarehouseKeeper($info->id),
default => true,
};