Compare commits
7 Commits
20250714-0
...
20250724-0
| Author | SHA1 | Date | |
|---|---|---|---|
| 0a1610fc42 | |||
| a296a30080 | |||
| 4d0e3907b2 | |||
| 408a2bfa2b | |||
| b108151165 | |||
| 50fa24269d | |||
| 039b36f955 |
@@ -168,6 +168,7 @@ class GoodCache
|
|||||||
private function buildData(&$list): mixed
|
private function buildData(&$list): mixed
|
||||||
{
|
{
|
||||||
$spuIds = array_column($list, 'id');
|
$spuIds = array_column($list, 'id');
|
||||||
|
$spuImage = array_column($list, 'image_id');
|
||||||
|
|
||||||
$skuList = $this->skuModel->getListBySpuIds($spuIds);
|
$skuList = $this->skuModel->getListBySpuIds($spuIds);
|
||||||
|
|
||||||
@@ -176,7 +177,7 @@ class GoodCache
|
|||||||
$skuList = $skuList->toArray();
|
$skuList = $skuList->toArray();
|
||||||
|
|
||||||
$imageIdArr = array_column($skuList,'image_ids');
|
$imageIdArr = array_column($skuList,'image_ids');
|
||||||
$imageList = $this->getOssObjects($imageIdArr);
|
$imageList = $this->getOssObjects(array_merge($spuImage,$imageIdArr));
|
||||||
|
|
||||||
$chefIds = array_column($skuList,'chef_id');
|
$chefIds = array_column($skuList,'chef_id');
|
||||||
$chefList = $this->adminUserModel->getDataByIds($chefIds);
|
$chefList = $this->adminUserModel->getDataByIds($chefIds);
|
||||||
@@ -209,6 +210,7 @@ class GoodCache
|
|||||||
|
|
||||||
foreach ($list as &$item) {
|
foreach ($list as &$item) {
|
||||||
$item['sku_list'] = $skuListArr[$item['id']] ?? [];
|
$item['sku_list'] = $skuListArr[$item['id']] ?? [];
|
||||||
|
$item['spu_image_url'] = $imageList[$item['image_id']] ?? '';
|
||||||
$item['image_list'] = $imageArr[$item['id']] ?? [];
|
$item['image_list'] = $imageArr[$item['id']] ?? [];
|
||||||
$item['price'] = !empty($price[$item['id']]) ? (min($price[$item['id']]) ?? 0) : 0;
|
$item['price'] = !empty($price[$item['id']]) ? (min($price[$item['id']]) ?? 0) : 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,17 +97,17 @@ class SiteCache
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $siteId
|
* @param int $siteId
|
||||||
* @return array|false|\Redis|null
|
* @return array|false|\Redis
|
||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
*/
|
*/
|
||||||
public function getSiteInfo(int $siteId): false|array|\Redis|null
|
public function getSiteInfo(int $siteId): false|array|\Redis
|
||||||
{
|
{
|
||||||
$siteKey = CommonRedisKey::siteInfoKey($siteId);
|
$siteKey = CommonRedisKey::siteInfoKey($siteId);
|
||||||
|
|
||||||
if (!$this->redis->exists($siteKey,RedisCode::SYSTEM_DB)) $this->setSiteInfo($siteId);
|
if (!$this->redis->exists($siteKey,RedisCode::SYSTEM_DB)) $this->setSiteInfo($siteId);
|
||||||
|
|
||||||
return $this->redis->hGetAll($siteKey,RedisCode::SYSTEM_DB) ?? null;
|
return $this->redis->hGetAll($siteKey,RedisCode::SYSTEM_DB) ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ class Sku extends Model
|
|||||||
->where('saleable',GoodCode::LISTING)
|
->where('saleable',GoodCode::LISTING)
|
||||||
// ->where('is_add_staple_food',GoodCode::IS_NOT_ADD_STAPLE_FOOD)
|
// ->where('is_add_staple_food',GoodCode::IS_NOT_ADD_STAPLE_FOOD)
|
||||||
->orderBy('sort')
|
->orderBy('sort')
|
||||||
->select(['id','spu_id','title','image_ids','price','param','extra','total_stock','surplus_stock','order_num','is_add_staple_food','occupied','chef_id','origin_sku_id'])
|
->select(['id','spu_id','title','image_ids','price','param','extra','total_stock','surplus_stock','order_num','is_add_staple_food','occupied','chef_id','origin_sku_id','sub_title'])
|
||||||
->get();
|
->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ use Hyperf\DbConnection\Model\Model;
|
|||||||
* @property int $kitchen_id
|
* @property int $kitchen_id
|
||||||
* @property int $chef_id
|
* @property int $chef_id
|
||||||
* @property int $caterer_id
|
* @property int $caterer_id
|
||||||
|
* @property int $image_id
|
||||||
* @property string $title
|
* @property string $title
|
||||||
* @property string $sub_title
|
* @property string $sub_title
|
||||||
* @property int $category_id
|
* @property int $category_id
|
||||||
@@ -85,7 +86,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','favorable'])
|
->select(['id','cycle_id','chef_id','title','title','sub_title','category_id','favorable','image_id'])
|
||||||
->get();
|
->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -156,6 +156,9 @@ class SpuService extends BaseService
|
|||||||
|
|
||||||
if (!empty($info)) throw new ErrException('该菜品在当前城市已存在');
|
if (!empty($info)) throw new ErrException('该菜品在当前城市已存在');
|
||||||
|
|
||||||
|
$imageId = $this->request->input('image_id');
|
||||||
|
|
||||||
|
$this->updateOssObjects([$imageId]);
|
||||||
|
|
||||||
$insertModel = new Spu();
|
$insertModel = new Spu();
|
||||||
|
|
||||||
@@ -170,6 +173,7 @@ class SpuService extends BaseService
|
|||||||
$insertModel->saleable = $this->request->input('saleable');
|
$insertModel->saleable = $this->request->input('saleable');
|
||||||
$insertModel->type = $this->request->input('type');
|
$insertModel->type = $this->request->input('type');
|
||||||
$insertModel->sort = $this->request->input('sort');
|
$insertModel->sort = $this->request->input('sort');
|
||||||
|
$insertModel->image_id = $imageId;
|
||||||
$insertModel->favorable = GoodCode::NOT_FAVORABLE;
|
$insertModel->favorable = GoodCode::NOT_FAVORABLE;
|
||||||
|
|
||||||
if (!$insertModel->save()) throw new ErrException('添加菜品失败');
|
if (!$insertModel->save()) throw new ErrException('添加菜品失败');
|
||||||
@@ -233,6 +237,8 @@ class SpuService extends BaseService
|
|||||||
|
|
||||||
$this->checkInfo();
|
$this->checkInfo();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$kitchenId = (int)$this->request->input('kitchen_id');
|
$kitchenId = (int)$this->request->input('kitchen_id');
|
||||||
$oldKitchenId = (int)$info->kitchen_id;
|
$oldKitchenId = (int)$info->kitchen_id;
|
||||||
|
|
||||||
@@ -245,6 +251,12 @@ class SpuService extends BaseService
|
|||||||
$info->saleable = $this->request->input('saleable');
|
$info->saleable = $this->request->input('saleable');
|
||||||
$info->type = $this->request->input('type');
|
$info->type = $this->request->input('type');
|
||||||
$info->sort = $this->request->input('sort');
|
$info->sort = $this->request->input('sort');
|
||||||
|
$requestOssId = $this->request->input('image_id',0);
|
||||||
|
if ($requestOssId != $info->image_id) {
|
||||||
|
$info->image_id = $requestOssId;
|
||||||
|
$this->updateOssObjects([$requestOssId]);
|
||||||
|
$this->updateOssObjectsDisable([$info->image_ids]);
|
||||||
|
}
|
||||||
|
|
||||||
if (!$info->save()) throw new ErrException('修改菜品失败');
|
if (!$info->save()) throw new ErrException('修改菜品失败');
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ use App\Service\ServiceTrait\Common\OssTrait;
|
|||||||
use Hyperf\Di\Annotation\Inject;
|
use Hyperf\Di\Annotation\Inject;
|
||||||
use Psr\Container\ContainerExceptionInterface;
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
use Psr\Container\NotFoundExceptionInterface;
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
|
use function Hyperf\Config\config;
|
||||||
|
|
||||||
class OptionalListService extends BaseService
|
class OptionalListService extends BaseService
|
||||||
{
|
{
|
||||||
@@ -54,6 +55,12 @@ class OptionalListService extends BaseService
|
|||||||
#[Inject]
|
#[Inject]
|
||||||
protected Category $categoryModel;
|
protected Category $categoryModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 默认地址
|
||||||
|
* @var array|false
|
||||||
|
*/
|
||||||
|
private array|false $siteInfo = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
@@ -66,11 +73,13 @@ class OptionalListService extends BaseService
|
|||||||
if (empty($cycleId)) return $this->return->success('success', ['list' => []]);
|
if (empty($cycleId)) return $this->return->success('success', ['list' => []]);
|
||||||
|
|
||||||
$this->goodCache->cycleId = (int)$cycleId;
|
$this->goodCache->cycleId = (int)$cycleId;
|
||||||
$siteInfo = $this->siteCache->getSiteInfo((int)$this->request->input('site_id'));
|
|
||||||
|
|
||||||
if (empty($siteInfo) || empty($siteInfo['kitchen_id'])) return $this->return->success('success', ['list' => []]);
|
if (!empty($this->request->input('site_id'))){
|
||||||
|
$this->siteInfo = $this->siteCache->getSiteInfo((int)$this->request->input('site_id'));
|
||||||
|
}
|
||||||
|
if (empty($this->siteInfo) || empty($this->siteInfo['kitchen_id'])) $this->siteInfo['kitchen_id'] = config('system.default_kitchen_id');
|
||||||
|
|
||||||
$this->goodCache->kitchenId = (int)$siteInfo['kitchen_id'];
|
$this->goodCache->kitchenId = (int)$this->siteInfo['kitchen_id'];
|
||||||
$data = $this->goodCache->getOptionalGoodList();
|
$data = $this->goodCache->getOptionalGoodList();
|
||||||
|
|
||||||
if (empty($data)) return $this->return->success('success', ['list' => []]);
|
if (empty($data)) return $this->return->success('success', ['list' => []]);
|
||||||
|
|||||||
@@ -29,4 +29,6 @@ return [
|
|||||||
'api_url' => env('DEFAULT_API_URL','http://127.0.0.1:9501'),
|
'api_url' => env('DEFAULT_API_URL','http://127.0.0.1:9501'),
|
||||||
// upload_dir
|
// upload_dir
|
||||||
'upload_dir' => BASE_PATH.'/uploads/',
|
'upload_dir' => BASE_PATH.'/uploads/',
|
||||||
|
// 默认的厨房 id
|
||||||
|
'default_kitchen_id' => env('DEFAULT_KITCHEN_ID',''),
|
||||||
];
|
];
|
||||||
1
env.pre
1
env.pre
@@ -6,6 +6,7 @@ JWT_KEY=hhl@shenzhen
|
|||||||
JWT_EXPIRE=2592000
|
JWT_EXPIRE=2592000
|
||||||
ADMIN_JWT_EXPIRE=86400
|
ADMIN_JWT_EXPIRE=86400
|
||||||
DEFAULT_API_URL=https://new-api-pre.hehele.cc
|
DEFAULT_API_URL=https://new-api-pre.hehele.cc
|
||||||
|
DEFAULT_KITCHEN_ID=1
|
||||||
|
|
||||||
# [wxLogin]
|
# [wxLogin]
|
||||||
WX_APPID=wxc2bc0e47e212d831
|
WX_APPID=wxc2bc0e47e212d831
|
||||||
|
|||||||
62
env.prod
62
env.prod
@@ -0,0 +1,62 @@
|
|||||||
|
# [app] -- 集群配置需一致
|
||||||
|
APP_NAME=hhl_meal
|
||||||
|
APP_ENV=dev
|
||||||
|
API_RETURN_KEY=hch@shenzhen
|
||||||
|
JWT_KEY=hch@shenzhen
|
||||||
|
JWT_EXPIRE=2592000
|
||||||
|
ADMIN_JWT_EXPIRE=86400
|
||||||
|
DEFAULT_API_URL=https://hch-api.hehele.cc
|
||||||
|
DEFAULT_KITCHEN_ID=1
|
||||||
|
|
||||||
|
# [wxLogin]
|
||||||
|
WX_APPID=wxc0edbbd0ff0fe7ed
|
||||||
|
WX_SECRET=2d6f5aa5bfcff36f26b89a26e2b5a1a4
|
||||||
|
|
||||||
|
# [crontab] -- 集群配置 仅需一台true即可 其他都是false 根据 restart_pre.sh 自动生成
|
||||||
|
CRONTAB_ENABLE=true
|
||||||
|
|
||||||
|
# [mysql] -- 集群配置需一致
|
||||||
|
DB_DRIVER=mysql
|
||||||
|
DB_HOST=localhost
|
||||||
|
DB_PORT=13106
|
||||||
|
DB_DATABASE=hhl_meal
|
||||||
|
DB_USERNAME=hhlsz
|
||||||
|
DB_PASSWORD=nh75a8yv
|
||||||
|
DB_CHARSET=utf8mb4
|
||||||
|
DB_COLLATION=utf8mb4_unicode_ci
|
||||||
|
DB_PREFIX=app_
|
||||||
|
|
||||||
|
# [redis] -- 集群配置需一致
|
||||||
|
REDIS_HOST=localhost
|
||||||
|
REDIS_AUTH=nh75a8yv
|
||||||
|
REDIS_PORT=13697
|
||||||
|
REDIS_DB=0
|
||||||
|
SYSTEM_REDIS_DB=1
|
||||||
|
LOCK_REDIS_DB=2
|
||||||
|
|
||||||
|
# [rabbitmq] -- 集群配置需一致
|
||||||
|
AMQP_HOST=localhost
|
||||||
|
AMQP_PORT=5672
|
||||||
|
AMQP_USER=admin
|
||||||
|
AMQP_PASSWORD=nh75a8yv
|
||||||
|
AMQP_VHOST=/
|
||||||
|
|
||||||
|
# [ali] -- 集群配置需一致
|
||||||
|
ALI_ACCESS_KEY_ID=LTAI5tFsBsKskcrRmkjpMXay
|
||||||
|
ALI_ACCESS_KEY_SECRET=YSIMtOGLu7W8tpQLKdgioTUYmgXB8M
|
||||||
|
ALI_BUCKET=hhl-catering
|
||||||
|
ALI_REGION=cn-shenzhen
|
||||||
|
ALI_CALLBACK_URL=https://hch-api.hehele.cc/common/oss/ossCallBack
|
||||||
|
ALI_OSS_URL=https://hhl-catering.oss-cn-shenzhen.aliyuncs.com/
|
||||||
|
ALI_STS_ENDPOINT=sts.cn-shenzhen.aliyuncs.com
|
||||||
|
ALI_ROLE_ARN=acs:ram::1644087445786901:role/oss
|
||||||
|
ALI_OSS_ENDPOINT=oss-cn-shenzhen.aliyuncs.com
|
||||||
|
|
||||||
|
# [wxPay]
|
||||||
|
WX_PAYMENT_MCH_ID=1656097281
|
||||||
|
WX_PAYMENT_MCH_SECRET_KEY=075cf77f5b57cc84ba59e9df3b86eda1
|
||||||
|
WX_PAYMENT_MCH_SECRET_CERT=__DIR__/config/pay/wx/apiclient_key.pem
|
||||||
|
WX_PAYMENT_MCH_PUBLIC_CERT_PATH=__DIR__/config/pay/wx/apiclient_cert.pem
|
||||||
|
WX_PAYMENT_MINI_APP_ID=wx444b711b6101f25b
|
||||||
|
WX_PAYMENT_SUB_MINI_APP_ID=wxc2bc0e47e212d831
|
||||||
|
WX_PAYMENT_SUB_MCH_ID=1656142874
|
||||||
@@ -1,21 +1,25 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
HomeDir=/home/production/api_server
|
HomeDir=/home/production/api_service
|
||||||
|
|
||||||
|
rm -rf $HomeDir/.env
|
||||||
|
cp $HomeDir/env.prod $HomeDir/.env
|
||||||
|
|
||||||
|
env_file=$HomeDir/.env
|
||||||
#先判断是否存在某个文件构建配置文件
|
#先判断是否存在某个文件构建配置文件
|
||||||
if [ -e $HomeDir/../cron_true.txt ]; then
|
if [ -e $HomeDir/../cron_true.txt ]; then
|
||||||
|
sed -i 's/^CRONTAB_ENABLE=.*/CRONTAB_ENABLE=true/' "$env_file"
|
||||||
rm -rf $HomeDir/.env
|
|
||||||
cp $HomeDir/env.prod $HomeDir/.env
|
|
||||||
|
|
||||||
else
|
else
|
||||||
|
sed -i 's/^CRONTAB_ENABLE=.*/CRONTAB_ENABLE=false/' "$env_file"
|
||||||
rm -rf $HomeDir/.env
|
|
||||||
cp $HomeDir/env.prod $HomeDir/.env
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#杀死进程并重启进程
|
#杀死进程并重启进程
|
||||||
sudo lsof -i:9501|grep -v PID|awk '{print $2}'|sudo xargs kill -9
|
sudo lsof -i:9501|grep -v PID|awk '{print $2}'|sudo xargs kill -9
|
||||||
|
|
||||||
echo 'kill success';
|
echo 'kill success';
|
||||||
|
|
||||||
|
source /etc/profile
|
||||||
|
|
||||||
|
/bin/nohup php $HomeDir/bin/hyperf.php start > /home/log/hyperf_run.log 2>&1 &
|
||||||
|
|
||||||
|
echo '!!!The service restart success!!!';
|
||||||
|
|||||||
Reference in New Issue
Block a user