feat : catering
This commit is contained in:
@@ -95,6 +95,17 @@ class AdminRedisKey
|
|||||||
return 'catering:option:is:cycle_id:'.$cycleId;
|
return 'catering:option:is:cycle_id:'.$cycleId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 套餐配餐点位顺序
|
||||||
|
* @param int $cycleId
|
||||||
|
* @param int $kitchenId
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function mealSiteOrderByKitchenId(int $cycleId,int $kitchenId): string
|
||||||
|
{
|
||||||
|
return 'meal:site:order:cycle_id:'.$cycleId.':kitchen_id:'.$kitchenId;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -5,9 +5,11 @@ declare(strict_types=1);
|
|||||||
namespace App\Controller\Admin;
|
namespace App\Controller\Admin;
|
||||||
|
|
||||||
use App\Middleware\Admin\JwtAuthMiddleware;
|
use App\Middleware\Admin\JwtAuthMiddleware;
|
||||||
use App\Service\Admin\Catering\Meal\CycleListService as MealCycleListService;
|
use App\Service\Admin\Catering\Meal\CheckService;
|
||||||
use App\Service\Admin\Catering\Option\CompleteListService;
|
use App\Service\Admin\Catering\Option\CompleteListService;
|
||||||
use App\Service\Admin\Catering\Option\CompletePrintService;
|
use App\Service\Admin\Catering\Option\CompletePrintService;
|
||||||
|
use App\Service\Admin\Catering\Meal\CycleListService as MealCycleListService;
|
||||||
|
use APP\Service\Admin\Catering\Meal\CateringService as MealCateringService;
|
||||||
use App\Service\Admin\Catering\Option\CycleListService as OptionCycleListService;
|
use App\Service\Admin\Catering\Option\CycleListService as OptionCycleListService;
|
||||||
use App\Service\Admin\Catering\Option\CateringService as OptionCateringService;
|
use App\Service\Admin\Catering\Option\CateringService as OptionCateringService;
|
||||||
use App\Service\Admin\Catering\Option\PrintService;
|
use App\Service\Admin\Catering\Option\PrintService;
|
||||||
@@ -24,6 +26,12 @@ use Psr\Container\NotFoundExceptionInterface;
|
|||||||
])]
|
])]
|
||||||
class CateringController
|
class CateringController
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* 套餐周期配餐列表
|
||||||
|
* @return array
|
||||||
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
|
*/
|
||||||
#[RequestMapping(path: "meal/cycle_list", methods: "GET")]
|
#[RequestMapping(path: "meal/cycle_list", methods: "GET")]
|
||||||
#[Scene(scene: "meal_cycle_list")]
|
#[Scene(scene: "meal_cycle_list")]
|
||||||
public function getMealCycleList()
|
public function getMealCycleList()
|
||||||
@@ -31,6 +39,12 @@ class CateringController
|
|||||||
return (new MealCycleListService)->handle();
|
return (new MealCycleListService)->handle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自选周期配餐列表
|
||||||
|
* @return array
|
||||||
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
|
*/
|
||||||
#[RequestMapping(path: "option/cycle_list", methods: "GET")]
|
#[RequestMapping(path: "option/cycle_list", methods: "GET")]
|
||||||
#[Scene(scene: "option_cycle_list")]
|
#[Scene(scene: "option_cycle_list")]
|
||||||
public function getOptionCycleList()
|
public function getOptionCycleList()
|
||||||
@@ -38,6 +52,10 @@ class CateringController
|
|||||||
return(new OptionCycleListService)->handle();
|
return(new OptionCycleListService)->handle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 套餐剩余数量
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
#[RequestMapping(path: "meal/remain_count", methods: "GET")]
|
#[RequestMapping(path: "meal/remain_count", methods: "GET")]
|
||||||
#[Scene(scene: "meal_remain_count")]
|
#[Scene(scene: "meal_remain_count")]
|
||||||
public function remainMealCateringCount()
|
public function remainMealCateringCount()
|
||||||
@@ -45,6 +63,10 @@ class CateringController
|
|||||||
return (new MealCycleListService)->remainCount();
|
return (new MealCycleListService)->remainCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自选剩余数量
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
#[RequestMapping(path: "option/remain_count", methods: "GET")]
|
#[RequestMapping(path: "option/remain_count", methods: "GET")]
|
||||||
#[Scene(scene: "option_remain_count")]
|
#[Scene(scene: "option_remain_count")]
|
||||||
public function remainOptionCateringCount()
|
public function remainOptionCateringCount()
|
||||||
@@ -52,14 +74,28 @@ class CateringController
|
|||||||
return (new OptionCycleListService)->remainCount();
|
return (new OptionCycleListService)->remainCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
#[RequestMapping(path: "meal/spu_list", methods: "GET")]
|
||||||
|
#[Scene(scene: "meal_spu_list")]
|
||||||
public function getMealGoodsList()
|
public function getMealGoodsList()
|
||||||
{
|
{
|
||||||
return (new MealCycleListService)->skuList();
|
return (new MealCycleListService)->skuList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[RequestMapping(path: "meal/catering", methods: "GET")]
|
||||||
|
#[Scene(scene: "meal_catering")]
|
||||||
public function mealCatering()
|
public function mealCatering()
|
||||||
{
|
{
|
||||||
|
return (new MealCateringService)->handle();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[RequestMapping(path: "meal/catering/finish_check", methods: "GET")]
|
||||||
|
#[Scene(scene: "meal_catering_finish_check")]
|
||||||
|
public function mealFinishCheck()
|
||||||
|
{
|
||||||
|
return (new CheckService)->handle();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
37
app/Model/Caterer.php
Normal file
37
app/Model/Caterer.php
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Model;
|
||||||
|
|
||||||
|
use Hyperf\DbConnection\Model\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property int $id
|
||||||
|
* @property int $user_id
|
||||||
|
* @property int $type
|
||||||
|
* @property int $kitchen_id
|
||||||
|
* @property string $create_time
|
||||||
|
* @property string $update_time
|
||||||
|
*/
|
||||||
|
class Caterer extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The table associated with the model.
|
||||||
|
*/
|
||||||
|
protected ?string $table = 'caterer';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*/
|
||||||
|
protected array $fillable = [];
|
||||||
|
protected array $guarded = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that should be cast to native types.
|
||||||
|
*/
|
||||||
|
protected array $casts = ['id' => 'integer', 'user_id' => 'integer', 'type' => 'integer', 'kitchen_id' => 'integer'];
|
||||||
|
|
||||||
|
const string CREATED_AT = 'create_time';
|
||||||
|
const string UPDATED_AT = 'update_time';
|
||||||
|
}
|
||||||
@@ -111,4 +111,19 @@ class Site extends Model
|
|||||||
|
|
||||||
return $res->toArray();
|
return $res->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $kitchenId
|
||||||
|
* @return Builder[]|Collection
|
||||||
|
*/
|
||||||
|
public function getListByKitchenId(int $kitchenId): Collection|array
|
||||||
|
{
|
||||||
|
return $this
|
||||||
|
->where('kitchen_id',$kitchenId)
|
||||||
|
->where('is_del',SiteCode::SITE_NO_DEL)
|
||||||
|
->where('status',SiteCode::SITE_ENABLE)
|
||||||
|
->orderBy('sequence')
|
||||||
|
->select(['name','id','delivered_id','sequence'])
|
||||||
|
->get();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ use Hyperf\DbConnection\Model\Model;
|
|||||||
* @property int $city_id
|
* @property int $city_id
|
||||||
* @property int $kitchen_id
|
* @property int $kitchen_id
|
||||||
* @property int $chef_id
|
* @property int $chef_id
|
||||||
|
* @property int $caterer_id
|
||||||
* @property string $title
|
* @property string $title
|
||||||
* @property string $sub_title
|
* @property string $sub_title
|
||||||
* @property int $category_id
|
* @property int $category_id
|
||||||
@@ -42,7 +43,7 @@ class Spu extends Model
|
|||||||
/**
|
/**
|
||||||
* The attributes that should be cast to native types.
|
* The attributes that should be cast to native types.
|
||||||
*/
|
*/
|
||||||
protected array $casts = ['id' => 'integer', 'cycle_id' => 'integer', 'city_id' => 'integer', 'kitchen_id' => 'integer','chef_id' => 'integer', 'category_id' => 'integer', 'saleable' => 'integer','type' => 'integer','sort' => 'integer'];
|
protected array $casts = ['id' => 'integer', 'cycle_id' => 'integer', 'city_id' => 'integer', 'kitchen_id' => 'integer','chef_id' => 'integer','caterer_id' => 'integer','category_id' => 'integer', 'saleable' => 'integer','type' => 'integer','sort' => 'integer'];
|
||||||
|
|
||||||
const string CREATED_AT = 'create_time';
|
const string CREATED_AT = 'create_time';
|
||||||
const string UPDATED_AT = 'update_time';
|
const string UPDATED_AT = 'update_time';
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ use App\Cache\Redis\Common\ConfigCache;
|
|||||||
use App\Constants\Common\RoleCode;
|
use App\Constants\Common\RoleCode;
|
||||||
use App\Exception\ErrException;
|
use App\Exception\ErrException;
|
||||||
use App\Model\AdminUser;
|
use App\Model\AdminUser;
|
||||||
|
use App\Model\Caterer;
|
||||||
use App\Model\DriverSequence;
|
use App\Model\DriverSequence;
|
||||||
use App\Model\Site;
|
use App\Model\Site;
|
||||||
use App\Model\Sku;
|
use App\Model\Sku;
|
||||||
@@ -76,6 +77,12 @@ abstract class CateringBaseService extends BaseService
|
|||||||
#[Inject]
|
#[Inject]
|
||||||
protected AdminUser $adminUserModel;
|
protected AdminUser $adminUserModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Caterer
|
||||||
|
*/
|
||||||
|
#[Inject]
|
||||||
|
protected Caterer $catererModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
@@ -118,10 +125,14 @@ abstract class CateringBaseService extends BaseService
|
|||||||
$this->cycleId = (int)$cycleId;
|
$this->cycleId = (int)$cycleId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
private function getKitchenId(): void
|
private function getKitchenId(): void
|
||||||
{
|
{
|
||||||
//todo 自选配餐员工要绑定厨房 套餐配餐员工要绑定每日套餐
|
$caterInfo = $this->catererModel->where('user_id',$this->adminId)->first();
|
||||||
$this->kitchenId = 1;
|
if (empty($caterInfo) || empty($caterInfo->kitchen_id)) throw new ErrException('账号异常/该账号没有绑定厨房');
|
||||||
|
$this->kitchenId = $caterInfo->kitchen_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -8,12 +8,14 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
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()
|
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\Exception\ErrException;
|
||||||
use App\Model\OrderMealCateringLog;
|
use App\Model\OrderMealCateringLog;
|
||||||
use App\Model\Sku;
|
use App\Model\Sku;
|
||||||
|
use App\Model\Spu;
|
||||||
use App\Service\Admin\Catering\CateringBaseService;
|
use App\Service\Admin\Catering\CateringBaseService;
|
||||||
use Hyperf\Di\Annotation\Inject;
|
use Hyperf\Di\Annotation\Inject;
|
||||||
use Psr\Container\ContainerExceptionInterface;
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
@@ -70,20 +71,25 @@ class CycleListService extends CateringBaseService
|
|||||||
return $this->return->success('success',['count' => $count]);
|
return $this->return->success('success',['count' => $count]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Spu
|
||||||
|
*/
|
||||||
|
#[Inject]
|
||||||
|
protected Spu $spuModel;
|
||||||
|
|
||||||
public function skuList()
|
public function skuList()
|
||||||
{
|
{
|
||||||
$res = [
|
$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' => []]);
|
||||||
'id' => 1,
|
$spuList = $spuList->toArray();
|
||||||
'name' => 'spu_name'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'id' => 2,
|
|
||||||
'name' => 'spu2_name'
|
|
||||||
]
|
|
||||||
];
|
|
||||||
|
|
||||||
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::DRIVER => $this->addDriver($model->id,$model->chinese_name),
|
||||||
RoleCode::CHEF => $this->addChef($model->id),
|
RoleCode::CHEF => $this->addChef($model->id),
|
||||||
RoleCode::WAREHOUSE => $this->addWarehouseKeeper($model->id),
|
RoleCode::WAREHOUSE => $this->addWarehouseKeeper($model->id),
|
||||||
|
RoleCode::OPTION_CATERING, RoleCode::MEAL_CATERING => $this->addCaterer($model->id,$model->role_id),
|
||||||
default => true,
|
default => true,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -148,6 +149,7 @@ class EmployeeService extends BaseService
|
|||||||
RoleCode::DRIVER => $this->delDriver($info->id),
|
RoleCode::DRIVER => $this->delDriver($info->id),
|
||||||
RoleCode::CHEF => $this->delChef($info->id),
|
RoleCode::CHEF => $this->delChef($info->id),
|
||||||
RoleCode::WAREHOUSE => $this->delWarehouseKeeper($info->id),
|
RoleCode::WAREHOUSE => $this->delWarehouseKeeper($info->id),
|
||||||
|
RoleCode::OPTION_CATERING, RoleCode::MEAL_CATERING => $this->delCaterer($info->id),
|
||||||
default => true,
|
default => true,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -155,6 +157,7 @@ class EmployeeService extends BaseService
|
|||||||
RoleCode::DRIVER => $this->addDriver($info->id,$info->chinese_name),
|
RoleCode::DRIVER => $this->addDriver($info->id,$info->chinese_name),
|
||||||
RoleCode::CHEF => $this->addChef($info->id),
|
RoleCode::CHEF => $this->addChef($info->id),
|
||||||
RoleCode::WAREHOUSE => $this->addWarehouseKeeper($info->id),
|
RoleCode::WAREHOUSE => $this->addWarehouseKeeper($info->id),
|
||||||
|
RoleCode::OPTION_CATERING, RoleCode::MEAL_CATERING => $this->addCaterer($info->id,$roleId),
|
||||||
default => true,
|
default => true,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -195,6 +198,7 @@ class EmployeeService extends BaseService
|
|||||||
RoleCode::DRIVER => $this->delDriver($info->id),
|
RoleCode::DRIVER => $this->delDriver($info->id),
|
||||||
RoleCode::CHEF => $this->delChef($info->id),
|
RoleCode::CHEF => $this->delChef($info->id),
|
||||||
RoleCode::WAREHOUSE => $this->delWarehouseKeeper($info->id),
|
RoleCode::WAREHOUSE => $this->delWarehouseKeeper($info->id),
|
||||||
|
RoleCode::OPTION_CATERING, RoleCode::MEAL_CATERING => $this->delCaterer($info->id),
|
||||||
default => true,
|
default => true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Service\ServiceTrait\Admin;
|
namespace App\Service\ServiceTrait\Admin;
|
||||||
|
|
||||||
|
use App\Model\Caterer;
|
||||||
use App\Model\Chef;
|
use App\Model\Chef;
|
||||||
use App\Model\DriverSequence;
|
use App\Model\DriverSequence;
|
||||||
use App\Model\WarehouseKeeper;
|
use App\Model\WarehouseKeeper;
|
||||||
@@ -27,6 +28,12 @@ trait RoleMembersTrait
|
|||||||
#[Inject]
|
#[Inject]
|
||||||
protected WarehouseKeeper $warehouseKeeperModel;
|
protected WarehouseKeeper $warehouseKeeperModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Caterer
|
||||||
|
*/
|
||||||
|
#[Inject]
|
||||||
|
protected Caterer $catererModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $id
|
* @param int $id
|
||||||
* @param string $name
|
* @param string $name
|
||||||
@@ -64,6 +71,19 @@ trait RoleMembersTrait
|
|||||||
return $warehouseKeeper->save();
|
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
|
* @param int $id
|
||||||
* @return bool
|
* @return bool
|
||||||
@@ -93,4 +113,12 @@ trait RoleMembersTrait
|
|||||||
return $this->warehouseKeeperModel->where('user_id', $id)->delete();
|
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