lqmac 4 months ago
parent 5d26b4c21d
commit 536443de7c
  1. 2
      app/api/model/PaymentTrade.php
  2. 3
      app/api/service/cashier/Payment.php
  3. 3
      app/api/service/order/Checkout.php
  4. 3
      app/store/controller/Home.php
  5. 1
      app/store/controller/Store.php
  6. 4
      app/store/model/Goods.php
  7. 26
      app/store/service/Home.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'],
]);
}
}

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

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

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

@ -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('添加成功');
}

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

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

Loading…
Cancel
Save