feat : catering
This commit is contained in:
@@ -36,13 +36,13 @@ class CateringController
|
||||
#[Scene(scene: "meal_remain_count")]
|
||||
public function remainMealCateringCount()
|
||||
{
|
||||
|
||||
return (new MealCycleListService)->remainCount();
|
||||
}
|
||||
|
||||
#[RequestMapping(path: "option/remain_count", methods: "GET")]
|
||||
#[Scene(scene: "option_remain_count")]
|
||||
public function remainOptionCateringCount()
|
||||
{
|
||||
|
||||
return (new OptionCycleListService)->remainCount();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ abstract class CateringBaseService extends BaseService
|
||||
protected int $cycleId;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
* @var int todo 厨房id 自选的需要
|
||||
*/
|
||||
protected int $kitchenId;
|
||||
|
||||
|
||||
19
app/Service/Admin/Catering/CycleOrderCountService.php
Normal file
19
app/Service/Admin/Catering/CycleOrderCountService.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* This service file is part of item.
|
||||
*
|
||||
* @author ctexthuang
|
||||
* @contact ctexthuang@qq.com
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Service\Admin\Catering;
|
||||
|
||||
class CycleOrderCountService extends
|
||||
{
|
||||
public function handle()
|
||||
{
|
||||
//todo Write logic
|
||||
}
|
||||
}
|
||||
@@ -11,9 +11,7 @@ declare(strict_types=1);
|
||||
namespace App\Service\Admin\Catering\Meal;
|
||||
|
||||
use App\Exception\ErrException;
|
||||
use App\Model\DriverSequence;
|
||||
use App\Model\OrderMealCateringLog;
|
||||
use App\Model\Site;
|
||||
use App\Model\Sku;
|
||||
use App\Service\Admin\Catering\CateringBaseService;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
@@ -56,4 +54,19 @@ class CycleListService extends CateringBaseService
|
||||
|
||||
return $this->return->success('success',['list' => array_values($res)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function remainCount(): array
|
||||
{
|
||||
$skuInfo = $this->skuModel->getInfoById((int)$this->request->input('sku_id'));
|
||||
if (empty($skuInfo)) throw new ErrException('该套餐不存在,请刷新后重试');
|
||||
$count = $this->orderMealCateringLogModel
|
||||
->where('cycle_id',$this->cycleId)
|
||||
->where('sku_id',$skuInfo->id)
|
||||
->sum('quantity') ?? 0;
|
||||
|
||||
return $this->return->success('success',['count' => $count]);
|
||||
}
|
||||
}
|
||||
@@ -43,4 +43,16 @@ class CycleListService extends CateringBaseService
|
||||
|
||||
return $this->return->success('success',['list' => array_values($res)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function remainCount(): array
|
||||
{
|
||||
$count = $this->orderOptionCateringLogModel
|
||||
->where('cycle_id',$this->cycleId)
|
||||
->sum('quantity') ?? 0;
|
||||
|
||||
return $this->return->success('success',['count' => $count]);
|
||||
}
|
||||
}
|
||||
@@ -44,17 +44,6 @@ trait GoodOrderTrait
|
||||
#[Inject]
|
||||
protected OrderGood $orderGoodModel;
|
||||
|
||||
/**
|
||||
* @var OrderOptionCateringLog
|
||||
*/
|
||||
#[Inject]
|
||||
protected OrderOptionCateringLog $orderOptionCateringLogModel;
|
||||
|
||||
/**
|
||||
* @var OrderMealCateringLog
|
||||
*/
|
||||
#[Inject]
|
||||
protected OrderMealCateringLog $orderMealCateringLogModel;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
|
||||
@@ -5,12 +5,23 @@ namespace App\Service\ServiceTrait;
|
||||
use App\Constants\Common\OrderCode;
|
||||
use App\Model\OrderMealCateringLog;
|
||||
use App\Model\OrderOptionCateringLog;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
trait CateringTrait
|
||||
{
|
||||
/**
|
||||
* @var OrderOptionCateringLog
|
||||
*/
|
||||
#[Inject]
|
||||
protected OrderOptionCateringLog $orderOptionCateringLogModel;
|
||||
|
||||
/**
|
||||
* @var OrderMealCateringLog
|
||||
*/
|
||||
#[Inject]
|
||||
protected OrderMealCateringLog $orderMealCateringLogModel;
|
||||
|
||||
/**
|
||||
* @return bool 添加失败需要退款
|
||||
@@ -49,6 +60,7 @@ trait CateringTrait
|
||||
// todo 减少可以不减少根据订单 cycle_id 获取加一碗米饭 的数量 减少查询压力
|
||||
// $addStapleFoodNum = 0;
|
||||
|
||||
//todo 需要绑定一个 kitchen_id
|
||||
$logInfo = $this->orderOptionCateringLogModel->getInfoBySiteIdAndCycleId($this->orderInfo->site_id, $this->orderInfo->cycle_id);
|
||||
|
||||
if (empty($logInfo)) {
|
||||
@@ -108,6 +120,7 @@ trait CateringTrait
|
||||
//todo 根据订单 cycle_id 获取加一碗米饭 的数量
|
||||
$addStapleFoodNum = 0;
|
||||
|
||||
//todo 需要绑定一个 kitchen_id
|
||||
$logInfo = $this->orderOptionCateringLogModel->getInfoBySiteIdAndCycleId($this->orderInfo->site_id, $this->orderInfo->cycle_id);
|
||||
|
||||
if (empty($logInfo)) {
|
||||
|
||||
Reference in New Issue
Block a user