feat : catering
This commit is contained in:
@@ -15,6 +15,7 @@ use App\Cache\Redis\Common\ConfigCache;
|
||||
use App\Constants\Common\RoleCode;
|
||||
use App\Exception\ErrException;
|
||||
use App\Model\AdminUser;
|
||||
use App\Model\Caterer;
|
||||
use App\Model\DriverSequence;
|
||||
use App\Model\Site;
|
||||
use App\Model\Sku;
|
||||
@@ -76,6 +77,12 @@ abstract class CateringBaseService extends BaseService
|
||||
#[Inject]
|
||||
protected AdminUser $adminUserModel;
|
||||
|
||||
/**
|
||||
* @var Caterer
|
||||
*/
|
||||
#[Inject]
|
||||
protected Caterer $catererModel;
|
||||
|
||||
/**
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
@@ -118,10 +125,14 @@ abstract class CateringBaseService extends BaseService
|
||||
$this->cycleId = (int)$cycleId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
private function getKitchenId(): void
|
||||
{
|
||||
//todo 自选配餐员工要绑定厨房 套餐配餐员工要绑定每日套餐
|
||||
$this->kitchenId = 1;
|
||||
$caterInfo = $this->catererModel->where('user_id',$this->adminId)->first();
|
||||
if (empty($caterInfo) || empty($caterInfo->kitchen_id)) throw new ErrException('账号异常/该账号没有绑定厨房');
|
||||
$this->kitchenId = $caterInfo->kitchen_id;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,12 +8,14 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Service\Admin\Catering;
|
||||
namespace App\Service\Admin\Catering\Meal;
|
||||
|
||||
class CycleOrderCountService extends
|
||||
use App\Service\Admin\Catering\CateringBaseService;
|
||||
|
||||
class CateringService extends CateringBaseService
|
||||
{
|
||||
public function handle()
|
||||
{
|
||||
//todo Write logic
|
||||
|
||||
}
|
||||
}
|
||||
41
app/Service/Admin/Catering/Meal/CheckService.php
Normal file
41
app/Service/Admin/Catering/Meal/CheckService.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* This service file is part of item.
|
||||
*
|
||||
* @author ctexthuang
|
||||
* @contact ctexthuang@qq.com
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Service\Admin\Catering\Meal;
|
||||
|
||||
use App\Model\OrderMealCateringLog;
|
||||
use App\Service\Admin\Catering\CateringBaseService;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
|
||||
class CheckService extends CateringBaseService
|
||||
{
|
||||
public function handle()
|
||||
{
|
||||
//todo Write logic
|
||||
}
|
||||
|
||||
/**
|
||||
* @var OrderMealCateringLog
|
||||
*/
|
||||
#[Inject]
|
||||
protected OrderMealCateringLog $orderMealCateringLog;
|
||||
|
||||
/**
|
||||
* @var OrderMealCateringLog
|
||||
*/
|
||||
protected OrderMealCateringLog $logInfo;
|
||||
|
||||
public function info()
|
||||
{
|
||||
$this->logInfo = $this->orderMealCateringLog->find($this->request->input('id'));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ namespace App\Service\Admin\Catering\Meal;
|
||||
use App\Exception\ErrException;
|
||||
use App\Model\OrderMealCateringLog;
|
||||
use App\Model\Sku;
|
||||
use App\Model\Spu;
|
||||
use App\Service\Admin\Catering\CateringBaseService;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
@@ -70,20 +71,25 @@ class CycleListService extends CateringBaseService
|
||||
return $this->return->success('success',['count' => $count]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @var Spu
|
||||
*/
|
||||
#[Inject]
|
||||
protected Spu $spuModel;
|
||||
|
||||
public function skuList()
|
||||
{
|
||||
$res = [
|
||||
[
|
||||
'id' => 1,
|
||||
'name' => 'spu_name'
|
||||
],
|
||||
[
|
||||
'id' => 2,
|
||||
'name' => 'spu2_name'
|
||||
]
|
||||
];
|
||||
$spuList = $this->spuModel->where('caterer_id',$this->adminId)->select(['title','sub_title','id as spu_id'])->get();
|
||||
if (empty($skuList)) return $this->return->success('success',['list' => []]);
|
||||
$spuList = $spuList->toArray();
|
||||
|
||||
return $this->return->success('success',$res);
|
||||
$skuList = $this->skuModel->where('spu_id',array_column($spuList,'spu_id'))->pluck('id','spu_id');
|
||||
|
||||
foreach ($spuList as &$v) {
|
||||
$v['sku_id'] = $skuList[$v['spu_id']] ?? 0;
|
||||
}
|
||||
|
||||
return $this->return->success('success',['list' => $spuList]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -113,6 +113,7 @@ class EmployeeService extends BaseService
|
||||
RoleCode::DRIVER => $this->addDriver($model->id,$model->chinese_name),
|
||||
RoleCode::CHEF => $this->addChef($model->id),
|
||||
RoleCode::WAREHOUSE => $this->addWarehouseKeeper($model->id),
|
||||
RoleCode::OPTION_CATERING, RoleCode::MEAL_CATERING => $this->addCaterer($model->id,$model->role_id),
|
||||
default => true,
|
||||
};
|
||||
|
||||
@@ -148,6 +149,7 @@ class EmployeeService extends BaseService
|
||||
RoleCode::DRIVER => $this->delDriver($info->id),
|
||||
RoleCode::CHEF => $this->delChef($info->id),
|
||||
RoleCode::WAREHOUSE => $this->delWarehouseKeeper($info->id),
|
||||
RoleCode::OPTION_CATERING, RoleCode::MEAL_CATERING => $this->delCaterer($info->id),
|
||||
default => true,
|
||||
};
|
||||
|
||||
@@ -155,6 +157,7 @@ class EmployeeService extends BaseService
|
||||
RoleCode::DRIVER => $this->addDriver($info->id,$info->chinese_name),
|
||||
RoleCode::CHEF => $this->addChef($info->id),
|
||||
RoleCode::WAREHOUSE => $this->addWarehouseKeeper($info->id),
|
||||
RoleCode::OPTION_CATERING, RoleCode::MEAL_CATERING => $this->addCaterer($info->id,$roleId),
|
||||
default => true,
|
||||
};
|
||||
|
||||
@@ -195,6 +198,7 @@ class EmployeeService extends BaseService
|
||||
RoleCode::DRIVER => $this->delDriver($info->id),
|
||||
RoleCode::CHEF => $this->delChef($info->id),
|
||||
RoleCode::WAREHOUSE => $this->delWarehouseKeeper($info->id),
|
||||
RoleCode::OPTION_CATERING, RoleCode::MEAL_CATERING => $this->delCaterer($info->id),
|
||||
default => true,
|
||||
};
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Service\ServiceTrait\Admin;
|
||||
|
||||
use App\Model\Caterer;
|
||||
use App\Model\Chef;
|
||||
use App\Model\DriverSequence;
|
||||
use App\Model\WarehouseKeeper;
|
||||
@@ -27,6 +28,12 @@ trait RoleMembersTrait
|
||||
#[Inject]
|
||||
protected WarehouseKeeper $warehouseKeeperModel;
|
||||
|
||||
/**
|
||||
* @var Caterer
|
||||
*/
|
||||
#[Inject]
|
||||
protected Caterer $catererModel;
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param string $name
|
||||
@@ -64,6 +71,19 @@ trait RoleMembersTrait
|
||||
return $warehouseKeeper->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param int $type
|
||||
* @return bool
|
||||
*/
|
||||
protected function addCaterer(int $id,int $type)
|
||||
{
|
||||
$caterer = new Caterer();
|
||||
$caterer->user_id = $id;
|
||||
$caterer->type = $type;
|
||||
return $caterer->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return bool
|
||||
@@ -93,4 +113,12 @@ trait RoleMembersTrait
|
||||
return $this->warehouseKeeperModel->where('user_id', $id)->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @return bool
|
||||
*/
|
||||
protected function delCaterer($id): bool
|
||||
{
|
||||
return $this->catererModel->where('user_id', $id)->delete();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user