feat : config
This commit is contained in:
@@ -27,4 +27,10 @@ class GoodCode
|
|||||||
*/
|
*/
|
||||||
CONST INT LISTING = 1;
|
CONST INT LISTING = 1;
|
||||||
CONST INT DELIST = 2;
|
CONST INT DELIST = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int 加主食 1=是 2=否
|
||||||
|
*/
|
||||||
|
CONST INT IS_ADD_STAPLE_FOOD = 1;
|
||||||
|
CONST INT IS_NOT_ADD_STAPLE_FOOD = 2;
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Controller\Api;
|
namespace App\Controller\Api;
|
||||||
|
|
||||||
use App\Controller\AbstractController;
|
use App\Controller\AbstractController;
|
||||||
|
use App\Service\Api\Good\AddStapleFoodInfoService;
|
||||||
use App\Service\Api\Good\MealListService;
|
use App\Service\Api\Good\MealListService;
|
||||||
use App\Service\Api\Good\OptionalListService;
|
use App\Service\Api\Good\OptionalListService;
|
||||||
use Hyperf\HttpServer\Annotation\Controller;
|
use Hyperf\HttpServer\Annotation\Controller;
|
||||||
@@ -34,4 +35,15 @@ class GoodController extends AbstractController
|
|||||||
{
|
{
|
||||||
return (new MealListService)->handle();
|
return (new MealListService)->handle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
|
*/
|
||||||
|
#[RequestMapping(path: 'add_staple_food',methods: 'GET')]
|
||||||
|
public function add_staple_food()
|
||||||
|
{
|
||||||
|
return (new AddStapleFoodInfoService)->handle();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -11,6 +11,7 @@ use App\Service\Api\Login\LogOutService;
|
|||||||
use App\Service\Api\User\BindPhoneByWxService;
|
use App\Service\Api\User\BindPhoneByWxService;
|
||||||
use App\Service\Api\User\InviteListService;
|
use App\Service\Api\User\InviteListService;
|
||||||
use App\Service\Api\User\SiteService;
|
use App\Service\Api\User\SiteService;
|
||||||
|
use App\Service\Api\User\UnBindPhoneService;
|
||||||
use Hyperf\HttpServer\Annotation\Controller;
|
use Hyperf\HttpServer\Annotation\Controller;
|
||||||
use Hyperf\HttpServer\Annotation\Middlewares;
|
use Hyperf\HttpServer\Annotation\Middlewares;
|
||||||
use Hyperf\HttpServer\Annotation\RequestMapping;
|
use Hyperf\HttpServer\Annotation\RequestMapping;
|
||||||
@@ -37,6 +38,11 @@ class UserController extends AbstractController
|
|||||||
return (new BindPhoneByWxService)->handle();
|
return (new BindPhoneByWxService)->handle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function unbind_phone()
|
||||||
|
{
|
||||||
|
return (new UnBindPhoneService)->handle();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ use Hyperf\DbConnection\Model\Model;
|
|||||||
* @property int $saleable
|
* @property int $saleable
|
||||||
* @property int $sort
|
* @property int $sort
|
||||||
* @property int $is_del
|
* @property int $is_del
|
||||||
|
* @property int $code_number
|
||||||
|
* @property int $is_add_staple_food
|
||||||
* @property string $create_time
|
* @property string $create_time
|
||||||
* @property string $update_time
|
* @property string $update_time
|
||||||
*/
|
*/
|
||||||
@@ -46,7 +48,7 @@ class Sku extends Model
|
|||||||
/**
|
/**
|
||||||
* The attributes that should be cast to native types.
|
* The attributes that should be cast to native types.
|
||||||
*/
|
*/
|
||||||
protected array $casts = ['id' => 'integer', 'spu_id' => 'integer', 'total_stock' => 'integer', 'surplus_stock' => 'integer', 'sales_num' => 'integer', 'order_num' => 'integer', 'cancel_num' => 'integer', 'refund_num' => 'integer', 'saleable' => 'integer','sort' => 'integer'];
|
protected array $casts = ['id' => 'integer', 'spu_id' => 'integer', 'total_stock' => 'integer', 'surplus_stock' => 'integer', 'sales_num' => 'integer', 'order_num' => 'integer', 'cancel_num' => 'integer', 'refund_num' => 'integer', 'saleable' => 'integer','sort' => 'integer','is_add_staple_food' => 'integer','code_number' => 'integer'];
|
||||||
|
|
||||||
const string CREATED_AT = 'create_time';
|
const string CREATED_AT = 'create_time';
|
||||||
const string UPDATED_AT = 'update_time';
|
const string UPDATED_AT = 'update_time';
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ class Spu extends Model
|
|||||||
->where('type',$type)
|
->where('type',$type)
|
||||||
->where('saleable',GoodCode::LISTING)
|
->where('saleable',GoodCode::LISTING)
|
||||||
->orderBy('sort')
|
->orderBy('sort')
|
||||||
->select(['id','cycle_id','chef_id','title','title','sub_title','category_id'])
|
->select(['id','cycle_id','chef_id','title','title','sub_title','category_id','is_add_staple_food'])
|
||||||
->get();
|
->get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,6 +104,8 @@ class SkuService extends BaseService
|
|||||||
$insertModel->refund_num = 0;
|
$insertModel->refund_num = 0;
|
||||||
// $insertModel->behind_refund_num = 0;
|
// $insertModel->behind_refund_num = 0;
|
||||||
$insertModel->saleable = $this->request->input('saleable');
|
$insertModel->saleable = $this->request->input('saleable');
|
||||||
|
$insertModel->is_add_staple_food = $this->request->input('is_add_staple_food');
|
||||||
|
$insertModel->code_number = $this->request->input('code_number');
|
||||||
$insertModel->sort = $this->request->input('sort');
|
$insertModel->sort = $this->request->input('sort');
|
||||||
|
|
||||||
if (!$insertModel->save()) throw new ErrException('添加失败');
|
if (!$insertModel->save()) throw new ErrException('添加失败');
|
||||||
@@ -165,6 +167,8 @@ class SkuService extends BaseService
|
|||||||
$skuInfo->saleable = $this->request->input('saleable');
|
$skuInfo->saleable = $this->request->input('saleable');
|
||||||
$skuInfo->title = $this->request->input('title');
|
$skuInfo->title = $this->request->input('title');
|
||||||
$skuInfo->sort = $this->request->input('sort');
|
$skuInfo->sort = $this->request->input('sort');
|
||||||
|
$skuInfo->is_add_staple_food = $this->request->input('is_add_staple_food');
|
||||||
|
$skuInfo->code_number = $this->request->input('code_number');
|
||||||
|
|
||||||
if (!$skuInfo->save()) throw new ErrException('修改失败');
|
if (!$skuInfo->save()) throw new ErrException('修改失败');
|
||||||
|
|
||||||
|
|||||||
67
app/Service/Api/Good/AddStapleFoodInfoService.php
Normal file
67
app/Service/Api/Good/AddStapleFoodInfoService.php
Normal 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]);
|
||||||
|
}
|
||||||
|
}
|
||||||
39
app/Service/Api/User/UnBindPhoneService.php
Normal file
39
app/Service/Api/User/UnBindPhoneService.php
Normal 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('解绑成功');
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user