feat : add_staple_food

This commit is contained in:
2025-03-24 16:38:37 +08:00
parent f8584d3e1a
commit 7c64a6bc09
5 changed files with 41 additions and 3 deletions

View File

@@ -8,6 +8,7 @@ class ConfigCode
* @var string BasicConfiguration|基础配置
*/
const string TODAY_CUT_OFF_TIME_KEY = 'TodayCutOffTime'; // 当日下单截止时间
const string START_OF_THE_NEW_CYCLE = 'StartOfTheNewCycle'; // 新周期开始时间
const string ORDER_CANCEL_TIME_KEY = 'OrderCancelTime'; // 订单取消时间(下单后自动取消)
const string SUNDRY_UNIT_PRICE = 'SundryUnitPrice'; // 附加费单价 (服务费)
const string SUNDRY_PRICE_COMPUTE_TYPE = 'SundryPriceComputeType'; // 附加费计算方式 1 仅自选计算(默认值) 2 仅套餐计算 3 套餐自选都计算
@@ -33,7 +34,8 @@ class ConfigCode
const array DEFAULT_VALUE = [
//BasicConfiguration
self::TODAY_CUT_OFF_TIME_KEY => '15:00:00',
self::TODAY_CUT_OFF_TIME_KEY => '10:30:00',
self::START_OF_THE_NEW_CYCLE => '15:00:00',
self::ORDER_CANCEL_TIME_KEY => 5,
self::SUNDRY_UNIT_PRICE => '3',
self::SUNDRY_PRICE_COMPUTE_TYPE => 1,

View File

@@ -15,6 +15,7 @@ use App\Cache\Redis\RedisCache;
use App\Model\CouponTemplate;
use App\Model\UserCoupon;
use App\Service\Api\BaseService;
use App\Service\ServiceTrait\Admin\Catering\PrintTrait;
use App\Service\ServiceTrait\Api\OrderTrait;
use App\Service\ServiceTrait\Common\CycleTrait;
use Hyperf\Di\Annotation\Inject;
@@ -23,7 +24,7 @@ use Psr\Container\NotFoundExceptionInterface;
abstract class BaseOrderService extends BaseService
{
use CycleTrait,OrderTrait;
use CycleTrait,OrderTrait,PrintTrait;
/**
* @var int 周期id
@@ -170,6 +171,8 @@ abstract class BaseOrderService extends BaseService
*/
public function check(): void
{
$this->checkTodayCutOffTime();
$kitchenId = $this->checkSite($this->siteId);
$this->getGoodInfo($kitchenId);

View File

@@ -104,6 +104,20 @@ trait PrintTrait
$this->redis->hSet($this->stopOrderKey, $this->logInfo->site_id, CateringCode::REDIS_FINISH_VALUE);
}
/**
* @param int $siteId
* @param int $cycleId
* @return bool
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
protected function checkIsStopOrder(int $siteId,int $cycleId): bool
{
$this->stopOrderKey = AdminRedisKey::optionCateringStopOrder($cycleId);
return CateringCode::REDIS_FINISH_VALUE == $this->redis->hGet($this->stopOrderKey, $siteId);
}
/**
* @return void
* @throws ContainerExceptionInterface

View File

@@ -124,6 +124,18 @@ trait OrderTrait
}
}
/**
* @return void
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
protected function checkTodayCutOffTime(): void
{
$todayCutOffTime = $this->configCache->getConfigValue(ConfigCode::TODAY_CUT_OFF_TIME_KEY);
if (date('H:i:s') >= $todayCutOffTime) throw new ErrException('平台已全部截止下单哦');
}
/**
* 检测地点
* @param int $siteId
@@ -139,6 +151,13 @@ trait OrderTrait
$kitchenId = (int)($siteInfo['kitchen_id'] ?? 0);
if ($kitchenId <= 0) throw new ErrException('该地点暂时不支持点餐');
$closeOrderFlag = match ($this->orderType) {
OrderCode::ORDER_TYPE_OPTIONAL => $this->checkIsStopOrder($siteId, $this->cycleId),
OrderCode::ORDER_TYPE_MEAL => true,
};
if ($closeOrderFlag) throw new ErrException('该点已经截单');
$this->orderRes['site_id'] = $siteId;
$this->orderRes['site_info'] = $siteInfo;

View File

@@ -39,7 +39,7 @@ trait CycleTrait
*/
protected function initTodayCycleId(): float|bool|Redis|int
{
$TodayCutOffTime = $this->configCache->getConfigValueByKey(ConfigCode::TODAY_CUT_OFF_TIME_KEY);
$TodayCutOffTime = $this->configCache->getConfigValueByKey(ConfigCode::START_OF_THE_NEW_CYCLE);
if (date('H:i:s') >= ($TodayCutOffTime)) {
$day = date('Y-m-d',strtotime('+1 day'));