From 4574aa8c22e8d1b4bcaf6237a8fbe33bba78f7f8 Mon Sep 17 00:00:00 2001 From: wmc Date: Tue, 23 Jan 2024 16:19:08 +0800 Subject: [PATCH] 213 --- .env | 2 +- app/api/controller/Goods.php | 28 ++++++++++++++ app/api/controller/sharp/Goods.php | 1 + app/api/service/Goods.php | 62 ++++++++++++++++++++++++++++++ 4 files changed, 92 insertions(+), 1 deletion(-) diff --git a/.env b/.env index 06058927..63dd45f0 100644 --- a/.env +++ b/.env @@ -1 +1 @@ -APP_DEBUG = false [APP] DEFAULT_TIMEZONE = Asia/Shanghai [DATABASE] TYPE = mysql HOSTNAME = 127.0.0.1 DATABASE = yoshop2.0-pro USERNAME = root PASSWORD = 123456 HOSTPORT = 3306 CHARSET = utf8 DEBUG = false [CACHE] DRIVER = file [REDIS] HOSTNAME = 127.0.0.1 HOSTPORT = 6379 PASSWORD = SELECT = 0 [LANG] default_lang = zh-cn \ No newline at end of file +APP_DEBUG = true [APP] DEFAULT_TIMEZONE = Asia/Shanghai [DATABASE] TYPE = mysql HOSTNAME = rm-bp16g0z062kdo7dycmo.mysql.rds.aliyuncs.com DATABASE = ssxcx USERNAME = rdsuser PASSWORD = RtO73KKs123 HOSTPORT = 3306 CHARSET = utf8 DEBUG = false [CACHE] DRIVER = file [REDIS] HOSTNAME = 127.0.0.1 HOSTPORT = 6379 PASSWORD = SELECT = 0 [LANG] default_lang = zh-cn \ No newline at end of file diff --git a/app/api/controller/Goods.php b/app/api/controller/Goods.php index 03dbabc7..6b51e528 100644 --- a/app/api/controller/Goods.php +++ b/app/api/controller/Goods.php @@ -113,6 +113,34 @@ class Goods extends Controller return $this->renderSuccess(compact('goodsList')); } + public function brandList(): Json + { + $service = new GoodsService; + $goodsList = $service->brandList(); + return $this->renderSuccess(compact('goodsList')); + } + + public function newList(): Json + { + $service = new GoodsService; + $goodsList = $service->newList(); + return $this->renderSuccess(compact('goodsList')); + } + + public function cityInfo(): Json + { + $service = new GoodsService; + $goodsList = $service->cityInfo(); + return $this->renderSuccess($goodsList); + } + + public function panicList(): Json + { + $service = new GoodsService; + $goodsList = $service->panicList(); + return $this->renderSuccess($goodsList); + } + /** * 生成商品海报 * @param int $goodsId 商品ID diff --git a/app/api/controller/sharp/Goods.php b/app/api/controller/sharp/Goods.php index 0fc74f0b..45fc4bf6 100644 --- a/app/api/controller/sharp/Goods.php +++ b/app/api/controller/sharp/Goods.php @@ -36,6 +36,7 @@ class Goods extends Controller */ public function list(int $activeTimeId): Json { + // 获取秒杀活动会场首页数据 $service = new ActiveService; $list = $service->getGoodsListByActiveTimeId($activeTimeId); diff --git a/app/api/service/Goods.php b/app/api/service/Goods.php index 3a2f2a63..15ae4b87 100644 --- a/app/api/service/Goods.php +++ b/app/api/service/Goods.php @@ -17,6 +17,8 @@ use app\api\model\Setting as SettingModel; use app\api\model\GoodsSku as GoodsSkuModel; use app\common\enum\Setting as SettingEnum; use app\common\service\Goods as GoodsService; +use app\api\model\sharp\Active as SharpActiveModel; +use app\api\model\sharp\ActiveTime as ActiveTimeModel; /** * 商品服务类 @@ -71,6 +73,66 @@ class Goods extends GoodsService return $this->formatGoodsList($goodsList); } + //大牌正品列表 + public function brandList(): array + { + $model = new GoodsModel; + $list = $model->where([ + 'is_delete' => 0, + 'status' => 10, + 'is_brand' => 1, + 'store_id' => $_GET['store_id'] + ])->select()->toArray(); + + return $list; + } + + //新品首发 + public function newList(): array + { + $model = new GoodsModel; + $list = $model->where([ + 'is_delete' => 0, + 'status' => 10, + 'is_new' => 1, + 'store_id' => $_GET['store_id'] + ])->select()->toArray(); + + return $list; + } + + //同城信息 + public function cityInfo(): array + { + $model = new GoodsModel; + $list = $model->where([ + 'is_delete' => 0, + 'status' => 10, + 'is_brand' => 1, + 'store_id' => $_GET['store_id'] + ])->select()->toArray(); + + return $list; + } + + //抢购会场列表 + public function panicList() + { + $model = new SharpActiveModel; + $list = $model->alias('a') + ->join('sharpActiveTime', 'a.active_id = sharpActiveTime.active_id', 'left')->where([ + 'a.is_delete' => 0, + 'a.status' => 1, + 'a.store_id' => $_GET['store_id'], + 'sharpActiveTime.status' => 1, + ])->select()->toArray(); + foreach ($list as &$v) { + $v['active_date'] = date('Y-m-d H:i:s', $v['active_date']); + } + return $list; + } + + /** * 格式化商品列表 * @param $goodsList