feat : catering

This commit is contained in:
2025-03-11 10:16:18 +08:00
parent e3ecd93b2d
commit d9f52ac755
7 changed files with 69 additions and 12 deletions

View File

@@ -67,6 +67,8 @@ abstract class CateringBaseService extends BaseService
$this->checkRole();
$this->getCycleId();
$this->getKitchenId();
}
/**
@@ -96,6 +98,12 @@ abstract class CateringBaseService extends BaseService
$this->cycleId = (int)$cycleId;
}
private function getKitchenId(): void
{
//todo 自选配餐员工要绑定厨房 套餐配餐员工要绑定每日套餐
$this->kitchenId = 1;
}
/**
* @param array $data
* @return array

View File

@@ -69,4 +69,21 @@ class CycleListService extends CateringBaseService
return $this->return->success('success',['count' => $count]);
}
public function skuList()
{
$res = [
[
'id' => 1,
'name' => 'spu_name'
],
[
'id' => 2,
'name' => 'spu2_name'
]
];
return $this->return->success('success',$res);
}
}

View File

@@ -34,6 +34,7 @@ class CycleListService extends CateringBaseService
{
$cycleCateringLogs = $this->orderOptionCateringLogModel
->where('cycle_id',$this->cycleId)
->where('kitchen_id',$this->kitchenId)
->select(['site_id','quantity','status','id'])
->get();
@@ -51,6 +52,7 @@ class CycleListService extends CateringBaseService
{
$count = $this->orderOptionCateringLogModel
->where('cycle_id',$this->cycleId)
->where('kitchen_id',$this->kitchenId)
->sum('quantity') ?? 0;
return $this->return->success('success',['count' => $count]);

View File

@@ -25,7 +25,7 @@ trait CouponDispenseTrait
$this->cycleId = $cycleInfo->id;
$appointValue = json_encode($this->request->input('appoint_value'));
$appointValue = $this->request->input('appoint_value');
// if ($this->groupType == CouponCode::DISPENSE_APPOINT_GROUP_DESIGNATED_SITES_AND_GOODS) {
// $this->appointValue = [
// 'site' => explode(',', $appointValue['site']),
@@ -152,7 +152,7 @@ trait CouponDispenseTrait
{
$this->checkAppointValue();
$appointValue = json_encode($this->request->input('appoint_value'));
$appointValue = $this->request->input('appoint_value');
return explode(',', $appointValue['user_ids']);
}

View File

@@ -2,6 +2,7 @@
namespace App\Service\ServiceTrait;
use App\Cache\Redis\Api\SiteCache;
use App\Constants\Common\OrderCode;
use App\Model\OrderMealCateringLog;
use App\Model\OrderOptionCateringLog;
@@ -23,8 +24,16 @@ trait CateringTrait
#[Inject]
protected OrderMealCateringLog $orderMealCateringLogModel;
/**
* @var SiteCache
*/
#[Inject]
protected SiteCache $siteCache;
/**
* @return bool 添加失败需要退款
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
private function manageAddCateringLog(): bool
{
@@ -46,8 +55,6 @@ trait CateringTrait
OrderCode::ORDER_TYPE_MEAL => $this->manageSubMealCateringLog(),
OrderCode::ORDER_TYPE_OPTIONAL => $this->manageSubOptionCateringLog(),
};
}
/**
@@ -60,8 +67,10 @@ trait CateringTrait
// todo 减少可以不减少根据订单 cycle_id 获取加一碗米饭 的数量 减少查询压力
// $addStapleFoodNum = 0;
//todo 需要绑定一个 kitchen_id
$logInfo = $this->orderOptionCateringLogModel->getInfoBySiteIdAndCycleId($this->orderInfo->site_id, $this->orderInfo->cycle_id);
$siteInfo = $this->siteCache->getSiteInfo($this->orderInfo->site_id);
//需要绑定一个 kitchen_id
$logInfo = $this->orderOptionCateringLogModel->getInfoBySiteIdAndCycleIdAndSiteId($this->orderInfo->site_id, $this->orderInfo->cycle_id, (int)$siteInfo['kitchen_id']);
if (empty($logInfo)) {
$this->log->error(__CLASS__.':Function:refundCallBackHandle:manageSubOptionCateringLog:订单套餐配餐记录不存在,订单信息:'.json_encode($this->orderInfo->toArray()));
@@ -114,20 +123,24 @@ trait CateringTrait
/**
* 添加自选配餐数据
* @return bool
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
private function manageAddOptionCateringLog(): bool
{
//todo 根据订单 cycle_id 获取加一碗米饭 的数量
$addStapleFoodNum = 0;
//todo 需要绑定一个 kitchen_id
$logInfo = $this->orderOptionCateringLogModel->getInfoBySiteIdAndCycleId($this->orderInfo->site_id, $this->orderInfo->cycle_id);
$siteInfo = $this->siteCache->getSiteInfo($this->orderInfo->site_id);
//需要绑定一个 kitchen_id
$logInfo = $this->orderOptionCateringLogModel->getInfoBySiteIdAndCycleIdAndSiteId($this->orderInfo->site_id, $this->orderInfo->cycle_id,(int)$siteInfo['kitchen_id']);
if (empty($logInfo)) {
$logInfo = new OrderOptionCateringLog();
$logInfo->site_id = $this->orderInfo->site_id;
$logInfo->cycle_id = $this->orderInfo->cycle_id;
$logInfo->kitchen_id = (int)$siteInfo['kitchen_id'];
$logInfo->quantity = 0;
$logInfo->add_staple_food_num = 0;
$logInfo->status = 1;