From 536443de7c4452d65e1e59ef7b778583f42879eb Mon Sep 17 00:00:00 2001 From: lqmac Date: Fri, 18 Oct 2024 23:43:53 +0800 Subject: [PATCH] 1 --- app/api/model/PaymentTrade.php | 2 +- app/api/service/cashier/Payment.php | 3 ++- app/api/service/order/Checkout.php | 3 ++- app/store/controller/Home.php | 3 ++- app/store/controller/Store.php | 1 + app/store/model/Goods.php | 4 ++-- app/store/service/Home.php | 26 +++++++++++++++++++------- 7 files changed, 29 insertions(+), 13 deletions(-) diff --git a/app/api/model/PaymentTrade.php b/app/api/model/PaymentTrade.php index 63ece499..dcc91cef 100644 --- a/app/api/model/PaymentTrade.php +++ b/app/api/model/PaymentTrade.php @@ -62,7 +62,7 @@ class PaymentTrade extends PaymentTradeModel 'out_trade_no' => $payment['out_trade_no'] ?? '', 'prepay_id' => $payment['prepay_id'] ?? '', 'trade_status' => TradeStatusEnum::NOTPAY, - 'store_id' => self::$storeId, + 'store_id' => self::$storeId ? self::$storeId : $orderInfo['store_id'], ]); } } diff --git a/app/api/service/cashier/Payment.php b/app/api/service/cashier/Payment.php index 89af6150..d6f3b22e 100644 --- a/app/api/service/cashier/Payment.php +++ b/app/api/service/cashier/Payment.php @@ -100,7 +100,8 @@ class Payment extends BaseService $OrderModel = new OrderModel; $orderInfo = $OrderModel->getUnpaidOrderDetail($this->orderId); //当前商户是系统自动创建的商户,自动读取商城主的支付配置 - $model = \app\store\model\Merchant::detail($orderInfo['merchant_id']); + //$model = \app\store\model\Merchant::detail($orderInfo['merchant_id']); + $model = \app\store\model\Merchant::withoutGlobalScope()->where('merchant_id', $orderInfo['merchant_id'])->find(); $merchantId = ($model && $model->channel_id > 0) ? 0 : $orderInfo['merchant_id']; $methods = $PaymentModel->getMethodsByClient($this->client, true, $orderInfo['store_id'], $merchantId); diff --git a/app/api/service/order/Checkout.php b/app/api/service/order/Checkout.php index 94406e9b..383e28d1 100644 --- a/app/api/service/order/Checkout.php +++ b/app/api/service/order/Checkout.php @@ -970,7 +970,8 @@ class Checkout extends BaseService */ private function getGoodsImageId($goods): int { - return $goods['skuInfo']['image_id'] ?: (int)current($goods['goods_images'])['file_id']; + + return $goods['skuInfo']['image_id'] ?: ($goods['goods_images'] ? (int)current($goods['goods_images'])['file_id'] : 0); } /** diff --git a/app/store/controller/Home.php b/app/store/controller/Home.php index 22ca925c..f476a6ec 100644 --- a/app/store/controller/Home.php +++ b/app/store/controller/Home.php @@ -28,9 +28,10 @@ class Home extends Controller */ public function data(): Json { + $params['storeInfo'] = $this->storeInfo->toArray(); // 获取首页数据 $model = new HomeService; - $data = $model->getData(); + $data = $model->getData($params); return $this->renderSuccess(compact('data')); } } diff --git a/app/store/controller/Store.php b/app/store/controller/Store.php index 160d9541..b0a9ad48 100644 --- a/app/store/controller/Store.php +++ b/app/store/controller/Store.php @@ -66,6 +66,7 @@ class Store extends Controller if ($store['limit_open_store_num'] <= $count) { return $this->renderError("您授权的商城数量已达到上限:".$count); } + $params['effective_time'] = time() + 365 * 86400; if ($model->add($params)) { return $this->renderSuccess('添加成功'); } diff --git a/app/store/model/Goods.php b/app/store/model/Goods.php index 6ab35921..05b1263b 100644 --- a/app/store/model/Goods.php +++ b/app/store/model/Goods.php @@ -305,7 +305,7 @@ class Goods extends GoodsModel */ public function getGoodsTotal(array $where = []): int { - return $this->where($where)->where('is_delete', '=', 0)->count(); + return self::withoutGlobalScope()->where($where)->where('is_delete', '=', 0)->count(); } /** @@ -316,7 +316,7 @@ class Goods extends GoodsModel public function getGoodsGroundingTotal(array $where = []): int { $detail = StoreModel::where('status',1)->find(); - $list = $this->where($where)->where('is_delete', '=', 0)//->whereIn('channel',$detail['open_channel']) + $list = self::withoutGlobalScope()->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 5b05e923..bac376b7 100644 --- a/app/store/service/Home.php +++ b/app/store/service/Home.php @@ -51,7 +51,7 @@ class Home extends BaseService * 后台首页数据 * @return array */ - public function getData(): array + public function getData(array $params = []): array { // 今天的日期 $today = date('Y-m-d'); @@ -86,9 +86,9 @@ class Home extends BaseService // 数据统计 'statistics' => [ // 商品总数量 - 'goodsTotal' => $this->getGoodsTotal(), + 'goodsTotal' => $this->getGoodsTotal($params['storeInfo']), //上架商品总数 - 'getGoodsGroundingTotal' => $this->getGoodsGroundingTotal(), + 'getGoodsGroundingTotal' => $this->getGoodsGroundingTotal($params['storeInfo']), // 会员总人数 'userTotal' => $this->getUserTotal(), // 付款订单总量 @@ -135,17 +135,29 @@ class Home extends BaseService * 获取商品总量 * @return string */ - private function getGoodsTotal(): string + private function getGoodsTotal(array $storeInfo = []): string { - return number_format($this->GoodsModel->getGoodsTotal()); + $storeIds = [$storeInfo['store_id']]; + if (isset($storeInfo['p_store_id']) && $storeInfo['p_store_id']) { + $storeIds[] = $storeInfo['p_store_id']; + } + + $where[] = ['store_id', 'in', $storeIds]; + return number_format($this->GoodsModel->getGoodsTotal($where)); } /** * 获取商品已上架总量 * @return string */ - private function getGoodsGroundingTotal(): string + private function getGoodsGroundingTotal(array $storeInfo = []): string { - return number_format($this->GoodsModel->getGoodsGroundingTotal()); + $storeIds = [$storeInfo['store_id']]; + if (isset($storeInfo['p_store_id']) && $storeInfo['p_store_id']) { + $storeIds[] = $storeInfo['p_store_id']; + } + + $where[] = ['store_id', 'in', $storeIds]; + return number_format($this->GoodsModel->getGoodsGroundingTotal($where)); } /**