From 80bc386b553d9c16a1620a8ef66e341c2f8c3ee9 Mon Sep 17 00:00:00 2001 From: haoyuntao Date: Mon, 8 Jul 2024 17:34:24 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=9C=A8=E5=94=AE=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/store/model/Goods.php | 10 ++++++++++ app/store/service/Home.php | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/app/store/model/Goods.php b/app/store/model/Goods.php index 4ab70f10..14bf39e4 100644 --- a/app/store/model/Goods.php +++ b/app/store/model/Goods.php @@ -298,6 +298,16 @@ class Goods extends GoodsModel return $this->where($where)->where('is_delete', '=', 0)->count(); } + /** + * 获取当前商品已上架总数 + * @param array $where + * @return int + */ + public function getGoodsGroundingTotal(array $where = []): int + { + return $this->where($where)->where('is_delete', '=', 0)->where('status','=',10)->count(); + } + /** * 创建商品数据 * @param array $data diff --git a/app/store/service/Home.php b/app/store/service/Home.php index 7fb0d403..efb69f9a 100644 --- a/app/store/service/Home.php +++ b/app/store/service/Home.php @@ -87,6 +87,8 @@ class Home extends BaseService 'statistics' => [ // 商品总数量 'goodsTotal' => $this->getGoodsTotal(), + //上级商品总数 + 'getGoodsGroundingTotal' => $this->getGoodsGroundingTotal(), // 会员总人数 'userTotal' => $this->getUserTotal(), // 付款订单总量 @@ -137,6 +139,14 @@ class Home extends BaseService { return number_format($this->GoodsModel->getGoodsTotal()); } + /** + * 获取商品已上架总量 + * @return string + */ + private function getGoodsGroundingTotal(): string + { + return number_format($this->GoodsModel->getGoodsGroundingTotal()); + } /** * 会员总人数 From dc9d07cb27f250c578f826e1160e213fd5a4d753 Mon Sep 17 00:00:00 2001 From: haoyuntao Date: Tue, 9 Jul 2024 17:54:11 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=B8=A0=E9=81=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/store/model/Goods.php | 8 +++++--- app/store/service/Home.php | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/store/model/Goods.php b/app/store/model/Goods.php index 14bf39e4..dd3209f5 100644 --- a/app/store/model/Goods.php +++ b/app/store/model/Goods.php @@ -19,7 +19,7 @@ use app\common\enum\goods\Status as GoodsStatusEnum; use cores\exception\BaseException; use app\common\model\Region; use think\facade\Db; - +use app\common\model\Store as StoreModel; /** * 商品模型 * Class Goods @@ -304,8 +304,10 @@ class Goods extends GoodsModel * @return int */ public function getGoodsGroundingTotal(array $where = []): int - { - return $this->where($where)->where('is_delete', '=', 0)->where('status','=',10)->count(); + { + $detail = StoreModel::where('status',1)->find(); + $list = $this->where($where)->where('is_delete', '=', 0)->whereIn('channel',$detail['open_channel'])->where('status','=',10)->count(); + return $list; } /** diff --git a/app/store/service/Home.php b/app/store/service/Home.php index efb69f9a..5b05e923 100644 --- a/app/store/service/Home.php +++ b/app/store/service/Home.php @@ -87,7 +87,7 @@ class Home extends BaseService 'statistics' => [ // 商品总数量 'goodsTotal' => $this->getGoodsTotal(), - //上级商品总数 + //上架商品总数 'getGoodsGroundingTotal' => $this->getGoodsGroundingTotal(), // 会员总人数 'userTotal' => $this->getUserTotal(),