feat : config

This commit is contained in:
2025-03-20 16:29:59 +08:00
parent 7be642f104
commit 66632af855
8 changed files with 138 additions and 2 deletions

View File

@@ -0,0 +1,67 @@
<?php
/**
* This service file is part of item.
*
* @author ctexthuang
* @contact ctexthuang@qq.com
*/
declare(strict_types=1);
namespace App\Service\Api\Good;
use App\Cache\Redis\Api\GoodCache;
use App\Cache\Redis\Api\SiteCache;
use App\Constants\Common\GoodCode;
use App\Service\Api\BaseService;
use App\Service\ServiceTrait\Common\CycleTrait;
use Hyperf\Di\Annotation\Inject;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
class AddStapleFoodInfoService extends BaseService
{
use CycleTrait;
/**
* @var GoodCache
*/
#[Inject]
protected GoodCache $goodCache;
/**
* @var SiteCache
*/
#[Inject]
protected SiteCache $siteCache;
/**
* @return array
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function handle(): array
{
$cycleId = $this->initTodayCycleId();
if (empty($cycleId)) return $this->return->success('success', ['list' => []]);
$siteInfo = $this->siteCache->getSiteInfo((int)$this->request->input('site_id'));
if (empty($siteInfo) || empty($siteInfo['kitchen_id'])) return $this->return->success('success', ['list' => []]);
$this->goodCache->cycleId = (int)$cycleId;
$this->goodCache->kitchenId = (int)$siteInfo['kitchen_id'];
$data = $this->goodCache->getMealGoodList();
$res = [];
foreach ($data as $item) {
if ($item['is_add_staple_food'] != GoodCode::IS_ADD_STAPLE_FOOD) continue;
$res[] = $item;
break;
}
return $this->return->success('success', ['add_food_info' => $res]);
}
}

View File

@@ -0,0 +1,39 @@
<?php
/**
* This service file is part of item.
*
* @author ctexthuang
* @contact ctexthuang@qq.com
*/
declare(strict_types=1);
namespace App\Service\Api\User;
use App\Exception\ErrException;
use App\Model\User;
use App\Service\Api\BaseService;
class UnBindPhoneService extends BaseService
{
/**
* @var User
*/
protected User $userModel;
/**
* @return array
*/
public function handle()
{
$userInfo = $this->userModel->find($this->userId);
if ($userInfo->isEmpty()) throw new ErrException('用户不存在');
$userInfo->phone = '';
if (!$userInfo->save()) throw new ErrException('解绑失败');
return $this->return->success('解绑成功');
}
}