feat : meal catering

This commit is contained in:
2025-03-25 09:44:52 +08:00
parent 6d66843c38
commit 374257f06a
4 changed files with 196 additions and 2 deletions

View File

@@ -18,10 +18,15 @@ use App\Model\OrderGood;
use App\Model\OrderMealCateringLog;
use App\Model\Site;
use App\Service\Admin\Catering\CateringBaseService;
use App\Service\ServiceTrait\Admin\Catering\PrintTrait;
use Hyperf\Di\Annotation\Inject;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
class CateringService extends CateringBaseService
{
use PrintTrait;
/**
* @var OrderMealCateringLog
*/
@@ -55,8 +60,15 @@ class CateringService extends CateringBaseService
*/
protected int $resCount = 0;
/**
* @var int 关闭站点标识 0 未关闭 1 关闭
*/
protected int $closeSiteFlag = 0;
/**
* @return array
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function handle(): array
{
@@ -70,17 +82,44 @@ class CateringService extends CateringBaseService
// 检测数据
$this->check();
// 生成 key
$this->__initMealRedisKey();
// 配餐
$this->catering();
// todo
// 加缓存
$this->joinMealCateringCache();
// 查询该点所有套餐是否已经配餐 如果是就缓存关闭该点
$this->isCloseMealSite();
// 关闭线路
if ($this->closeSiteFlag == 1) $this->closeMealWholeLine();
return $this->return->success('success',['num' => $this->resCount]);
}
/**
* @return void
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
private function isCloseMealSite(): void
{
$res = $this->orderMealCateringLogModel
->where('site_id', $this->siteInfo->id)
->where('cycle_id', $this->logInfo->cycle_id)
->where('quantity','>',0)
->count() ?? 0;
if ($res > 0) return; // 证明还没完结 配餐 跳出
$this->closeMealSite();
$this->closeSiteFlag = 1;
}
/**
* @return void
*/