Compare commits

...

14 Commits

Author SHA1 Message Date
573aeee8db fix : sku 2025-08-05 15:55:27 +08:00
89797d5bfc fix : sku 2025-08-05 15:51:59 +08:00
ba009f4a9d fix : sku 2025-08-05 15:35:49 +08:00
ae0d0d83ac fix : statement 2025-08-04 16:50:57 +08:00
a1668b60fc fix : change admin user info 2025-08-04 15:58:15 +08:00
356b80a653 feat : env 2025-07-30 16:39:00 +08:00
b8f583bcc7 feat : env 2025-07-30 16:23:44 +08:00
2f1c7a9b28 feat : banner 2025-07-24 17:02:07 +08:00
66666f4a3a feat : spu 2025-07-24 10:36:54 +08:00
bbcc0d054f feat : spu 2025-07-24 10:34:26 +08:00
0a1610fc42 feat : sku 2025-07-24 10:09:25 +08:00
a296a30080 feat : kitchen 2025-07-24 10:00:20 +08:00
4d0e3907b2 feat : spu 2025-07-24 09:49:00 +08:00
408a2bfa2b feat : kitchen 2025-07-23 15:36:03 +08:00
18 changed files with 125 additions and 28 deletions

View File

@@ -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,10 +177,10 @@ 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->getChefNameByIds($chefIds);
$skuListArr = []; $skuListArr = [];
$imageArr = []; $imageArr = [];
@@ -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;
} }

View File

@@ -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;
} }
/** /**

View File

@@ -107,6 +107,32 @@ class AdminUser extends Model
return $res; return $res;
} }
/**
* @param array $ids
* @return array
*/
public function getChefNameByIds(array $ids): array
{
$data = $this
->join('chef', function ($join) use ($ids) {
$join->on('chef.user_id', '=', 'admin_user.id')
->whereIn('chef.id', $ids)
->where('admin_user.is_del',UserCode::IS_NO_DEL)
->select([
'admin_user.chinese_name',
'chef.id',
'admin_user.username',
]);
})
->get();
if ($data->isEmpty()) return [];
$data = $data->toArray();
return array_column($data,null,'id');
}
/** /**
* @param array $ids * @param array $ids
* @return array * @return array

View File

@@ -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();
} }

View File

@@ -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();
} }

View File

@@ -261,7 +261,7 @@ class SkuService extends BaseService
$spuInfo = $this->spuModel->getInfoById($skuInfo->spu_id); $spuInfo = $this->spuModel->getInfoById($skuInfo->spu_id);
if (empty($spuInfo)) throw new ErrException('数据出错'); if (empty($spuInfo)) throw new ErrException('数据出错');
$purchaseInfo = $this->purchaseModel->getListByCycleIdAndKitchenId($skuInfo->cycle_id,$spuInfo->kitchen_id); $purchaseInfo = $this->purchaseModel->getListByCycleIdAndKitchenId($spuInfo->cycle_id,$spuInfo->kitchen_id);
$purchaseIds = []; $purchaseIds = [];
if (!empty($purchaseInfo)) { if (!empty($purchaseInfo)) {
foreach ($purchaseInfo->toArray() as $one) { foreach ($purchaseInfo->toArray() as $one) {

View File

@@ -88,6 +88,7 @@ class SpuService extends BaseService
if (empty($list['data'])) return $this->return->success('success', ['list' => $list]); if (empty($list['data'])) return $this->return->success('success', ['list' => $list]);
$spuIds = array_column($list['data'], 'id'); $spuIds = array_column($list['data'], 'id');
$spuImageIds = array_column($list['data'], 'image_id');
$skuList = $this->skuModel $skuList = $this->skuModel
->whereIn('spu_id',$spuIds) ->whereIn('spu_id',$spuIds)
@@ -99,7 +100,7 @@ class SpuService extends BaseService
$imageIdArr = array_column($skuList,'image_ids'); $imageIdArr = array_column($skuList,'image_ids');
$imageIds = array_unique(explode(',',implode(',',$imageIdArr))); $imageIds = array_unique(explode(',',implode(',',$imageIdArr)));
$imageList = $this->getOssObjects($imageIds); $imageList = $this->getOssObjects(array_merge($imageIds,$spuImageIds));
$skuListArr = []; $skuListArr = [];
foreach ($skuList as $sku) { foreach ($skuList as $sku) {
@@ -126,6 +127,7 @@ class SpuService extends BaseService
foreach ($list['data'] as &$item) { foreach ($list['data'] as &$item) {
$item['sku_list'] = $skuListArr[$item['id']] ?? []; $item['sku_list'] = $skuListArr[$item['id']] ?? [];
$item['image_url'] = $imageList[$item['image_id']] ?? '';
} }
return $this->return->success('success', ['list' => $list]); return $this->return->success('success', ['list' => $list]);
@@ -156,6 +158,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 +175,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 +239,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 +253,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('修改菜品失败');
@@ -311,6 +325,7 @@ class SpuService extends BaseService
$info['city_name'] = $this->systemCityModel->getCityNameById((int)$info['city_id']); $info['city_name'] = $this->systemCityModel->getCityNameById((int)$info['city_id']);
$info['kitchen_name'] = $this->kitchenModel->getNameById((int)$info['kitchen_id']); $info['kitchen_name'] = $this->kitchenModel->getNameById((int)$info['kitchen_id']);
// $info['chef_name'] = $this->chefModel->getChineseNameById((int)$info['chef_id']); // $info['chef_name'] = $this->chefModel->getChineseNameById((int)$info['chef_id']);
$info['image_url'] = $this->getOssObjectById((int)$info['image_id']) ?? '';
$info['chef_name'] = ''; $info['chef_name'] = '';
$info['category_name'] = $this->categoryModel->getNameById((int)$info['category_id']); $info['category_name'] = $this->categoryModel->getNameById((int)$info['category_id']);

View File

@@ -41,7 +41,7 @@ class DriverService extends BaseService
$list = $this->siteDriverStatementModel $list = $this->siteDriverStatementModel
->when($searchCityId, function ($query) use ($searchCityId) { ->when($searchCityId, function ($query) use ($searchCityId) {
$query->whereIn('city_id', $searchCityId); $query->where('city_id', $searchCityId);
}) })
->when($searchDriverId, function ($query) use ($searchDriverId) { ->when($searchDriverId, function ($query) use ($searchDriverId) {
$query->where('driver_id', $searchDriverId); $query->where('driver_id', $searchDriverId);

View File

@@ -41,7 +41,7 @@ class SiteService extends BaseService
$list = $this->siteDriverStatementModel $list = $this->siteDriverStatementModel
->when($searchCityId, function ($query) use ($searchCityId) { ->when($searchCityId, function ($query) use ($searchCityId) {
$query->whereIn('city_id', $searchCityId); $query->where('city_id', $searchCityId);
}) })
->when($searchSiteId, function ($query) use ($searchSiteId) { ->when($searchSiteId, function ($query) use ($searchSiteId) {
$query->where('site_id', $searchSiteId); $query->where('site_id', $searchSiteId);

View File

@@ -61,7 +61,7 @@ class EmployeeService extends BaseService
/** /**
* @var array|string[] * @var array|string[]
*/ */
private array $filed = ['id','username','avatar','chinese_name','mobile','status','last_login_ip','last_login_time','role_id']; private array $filed = ['id','username','avatar','chinese_name','mobile','status','last_login_ip','last_login_time','role_id','bind_user_id'];
/** /**
* 列表 * 列表
@@ -160,8 +160,8 @@ class EmployeeService extends BaseService
$bindUserId = (int)$this->request->input('bind_user_id', 0); $bindUserId = (int)$this->request->input('bind_user_id', 0);
if ($bindUserId > 0) { if ($bindUserId > 0) {
$oldBindUserId = $this->adminUserModel->getAdminInfoByBindUserId($bindUserId); $oldInfo = $this->adminUserModel->getAdminInfoByBindUserId($bindUserId);
if (!empty($oldBindUserId) && $info->bind_user_id != $oldBindUserId) throw new ErrException('绑定用户已存在'); if (!empty($oldBindUserId) && $info->bind_user_id != $oldInfo->bind_user_id) throw new ErrException('绑定用户已存在');
} }

View File

@@ -20,6 +20,7 @@ use App\Constants\ConfigCode;
use App\Exception\ErrException; use App\Exception\ErrException;
use App\Model\Category; use App\Model\Category;
use App\Service\Api\BaseService; use App\Service\Api\BaseService;
use App\Service\ServiceTrait\Api\BannerTrait;
use App\Service\ServiceTrait\Common\CycleTrait; use App\Service\ServiceTrait\Common\CycleTrait;
use App\Service\ServiceTrait\Common\OssTrait; use App\Service\ServiceTrait\Common\OssTrait;
use Hyperf\Di\Annotation\Inject; use Hyperf\Di\Annotation\Inject;
@@ -30,6 +31,7 @@ use function Hyperf\Config\config;
class OptionalListService extends BaseService class OptionalListService extends BaseService
{ {
use CycleTrait; use CycleTrait;
use BannerTrait;
/** /**
* @var GoodCache * @var GoodCache
@@ -55,6 +57,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
@@ -67,18 +75,20 @@ 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'])) $siteInfo['kitchen_id'] = config('system.kitchen_id'); 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' => []]);
$res = $this->buildData($data); $res = $this->buildData($data);
return $this->return->success('success', ['list' => $res]); return $this->return->success('success', ['list' => $res,'banner' => $this->getBanner((int)$this->request->input('city_id',config('system.default_city_id')))]);
} }
use OssTrait; use OssTrait;

View File

@@ -34,7 +34,7 @@ class IndexService extends BaseService
$avatar = $this->getOssObjectById($userInfo->avatar_id); $avatar = $this->getOssObjectById($userInfo->avatar_id);
$res = [ $res = [
'banner' => $this->getBanner(), // 'banner' => $this->getBanner(),
'nickname' => $userInfo->nickname, 'nickname' => $userInfo->nickname,
'avatar' => $avatar, 'avatar' => $avatar,
'point' => 0, 'point' => 0,

View File

@@ -0,0 +1,41 @@
<?php
namespace App\Service\ServiceTrait\Api;
use App\Constants\Common\BannerCode;
use App\Model\Banner;
use App\Service\ServiceTrait\Common\OssTrait;
use Hyperf\Di\Annotation\Inject;
trait BannerTrait
{
use OssTrait;
/**
* @var Banner
*/
#[Inject]
protected Banner $bannerModel;
/**
* @return array
*/
private function getBanner(int $cityId): array
{
$res = $this->bannerModel
->where('city_id',$cityId)
->where('status',BannerCode::DISPLAYED)
->orderBy('sort')
->get();
if ($res->isEmpty()) return [];
$res = $res->toArray();
$imageList = $this->getOssObjects(array_column($res, 'image_id'));
foreach ($res as &$v) {
$v['url'] = $imageList[$v['image_id']]['url'] ?? '';
}
return $res;
}
}

View File

@@ -30,5 +30,7 @@ return [
// upload_dir // upload_dir
'upload_dir' => BASE_PATH.'/uploads/', 'upload_dir' => BASE_PATH.'/uploads/',
// 默认的厨房 id // 默认的厨房 id
'default_kitchen_id' => env('DEFAULT_KITCHEN_ID',''), 'default_kitchen_id' => env('DEFAULT_KITCHEN_ID',1),
// 默认 城市 id
'default_city_id' => env('DEFAULT_CITY_ID',3),
]; ];

View File

@@ -60,5 +60,5 @@ WX_PAYMENT_MCH_SECRET_KEY=075cf77f5b57cc84ba59e9df3b86eda1
WX_PAYMENT_MCH_SECRET_CERT=__DIR__/config/pay/wx/apiclient_key.pem 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_MCH_PUBLIC_CERT_PATH=__DIR__/config/pay/wx/apiclient_cert.pem
WX_PAYMENT_MINI_APP_ID=wx444b711b6101f25b WX_PAYMENT_MINI_APP_ID=wx444b711b6101f25b
WX_PAYMENT_SUB_MINI_APP_ID=wxc2bc0e47e212d831 WX_PAYMENT_SUB_MINI_APP_ID=wxc0edbbd0ff0fe7ed
WX_PAYMENT_SUB_MCH_ID=1656142874 WX_PAYMENT_SUB_MCH_ID=1723727305

View File

@@ -55,5 +55,5 @@ WX_PAYMENT_MCH_SECRET_KEY=075cf77f5b57cc84ba59e9df3b86eda1
WX_PAYMENT_MCH_SECRET_CERT=__DIR__/config/pay/wx/apiclient_key.pem 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_MCH_PUBLIC_CERT_PATH=__DIR__/config/pay/wx/apiclient_cert.pem
WX_PAYMENT_MINI_APP_ID=wx444b711b6101f25b WX_PAYMENT_MINI_APP_ID=wx444b711b6101f25b
WX_PAYMENT_SUB_MINI_APP_ID=wxc2bc0e47e212d831 WX_PAYMENT_SUB_MINI_APP_ID=wxc0edbbd0ff0fe7ed
WX_PAYMENT_SUB_MCH_ID=1656142874 WX_PAYMENT_SUB_MCH_ID=1723727305

View File

@@ -58,5 +58,5 @@ WX_PAYMENT_MCH_SECRET_KEY=075cf77f5b57cc84ba59e9df3b86eda1
WX_PAYMENT_MCH_SECRET_CERT=__DIR__/config/pay/wx/apiclient_key.pem 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_MCH_PUBLIC_CERT_PATH=__DIR__/config/pay/wx/apiclient_cert.pem
WX_PAYMENT_MINI_APP_ID=wx444b711b6101f25b WX_PAYMENT_MINI_APP_ID=wx444b711b6101f25b
WX_PAYMENT_SUB_MINI_APP_ID=wxc2bc0e47e212d831 WX_PAYMENT_SUB_MINI_APP_ID=wxc0edbbd0ff0fe7ed
WX_PAYMENT_SUB_MCH_ID=1656142874 WX_PAYMENT_SUB_MCH_ID=1723727305

View File

@@ -58,5 +58,5 @@ WX_PAYMENT_MCH_SECRET_KEY=075cf77f5b57cc84ba59e9df3b86eda1
WX_PAYMENT_MCH_SECRET_CERT=__DIR__/config/pay/wx/apiclient_key.pem 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_MCH_PUBLIC_CERT_PATH=__DIR__/config/pay/wx/apiclient_cert.pem
WX_PAYMENT_MINI_APP_ID=wx444b711b6101f25b WX_PAYMENT_MINI_APP_ID=wx444b711b6101f25b
WX_PAYMENT_SUB_MINI_APP_ID=wxc2bc0e47e212d831 WX_PAYMENT_SUB_MINI_APP_ID=wxc0edbbd0ff0fe7ed
WX_PAYMENT_SUB_MCH_ID=1656142874 WX_PAYMENT_SUB_MCH_ID=1723727305