diff --git a/app/admin/lists/store_order/StoreOrderLists.php b/app/admin/lists/store_order/StoreOrderLists.php index 87f49f57..c81d96f9 100644 --- a/app/admin/lists/store_order/StoreOrderLists.php +++ b/app/admin/lists/store_order/StoreOrderLists.php @@ -9,6 +9,7 @@ use app\common\enum\PayEnum; use app\common\model\store_order\StoreOrder; use app\common\lists\ListsSearchInterface; use app\common\model\store_branch_product\StoreBranchProduct; +use app\common\model\store_order_cart_info\StoreOrderCartInfo; /** * 订单列表列表 @@ -45,9 +46,7 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface */ public function lists(): array { - return StoreOrder::with(['user', 'staff', 'product' => function ($query) { - $query->field(['id', 'oid', 'product_id', 'cart_info']); - }])->where($this->searchWhere) + return StoreOrder::with(['user', 'staff'])->where($this->searchWhere) ->when(!empty($this->request->adminInfo['store_id']), function ($query) { $query->where('store_id', $this->request->adminInfo['store_id']); }) @@ -68,13 +67,13 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface if ($item['paid'] == 0) { $item['status_name'] = '待支付'; } - $product_count = count($item['product']) >= 3 ? 3 : count($item['product']); - for ($i = 0; $i < $product_count; $i++) { - $find = StoreBranchProduct::where('product_id', $item['product'][$i]['product_id'])->field('store_name,image')->find(); - $item['product'][$i]['store_name'] = $find['store_name']; - $item['product'][$i]['image'] = $find['image']; + $product = StoreOrderCartInfo::where('oid', $item['id'])->field(['id', 'oid', 'product_id', 'cart_info']) + ->limit(3)->select(); + foreach ($product as &$items) { + $items['store_name'] = $items['cart_info']['name']; + $items['image'] = $items['cart_info']['image']; } - + $item['product'] = $product; return $item; }) ->toArray(); diff --git a/app/admin/logic/statistic/ProductStatisticLogic.php b/app/admin/logic/statistic/ProductStatisticLogic.php index 948538b9..74e18244 100644 --- a/app/admin/logic/statistic/ProductStatisticLogic.php +++ b/app/admin/logic/statistic/ProductStatisticLogic.php @@ -32,7 +32,7 @@ class ProductStatisticLogic extends BaseLogic 'SUM(collect_num) as collect', 'ROUND((COUNT(distinct(pay_uid))-1)/COUNT(distinct(uid)),2) as changes', 'COUNT(distinct(pay_uid))-1 as repeats' - ])->group('product_id')->order('pay'.' desc')->limit(20)->select()->toArray(); + ])->group('product_id')->order('pay'.' desc')->limit(10)->select()->toArray(); foreach ($list as $key => &$item) { $find=StoreProduct::where('id',$item['product_id'])->field('store_name,image')->find(); $item['store_name']=$find['store_name'];