From 324a89459b3a0e780bfe6878bcab2a02a5960919 Mon Sep 17 00:00:00 2001 From: devil Date: Fri, 15 May 2020 13:53:24 +0800 Subject: [PATCH] =?UTF-8?q?mysql=E7=89=88=E6=9C=AC=E5=85=BC=E5=AE=B9?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/service/PayLogService.php | 2 +- application/service/RefundLogService.php | 2 +- application/service/StatisticalService.php | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/application/service/PayLogService.php b/application/service/PayLogService.php index c2829946c..28b24fb9e 100755 --- a/application/service/PayLogService.php +++ b/application/service/PayLogService.php @@ -68,7 +68,7 @@ class PayLogService */ public static function PayLogTypeList($params = []) { - $data = Db::name('PayLog')->field('any_value(payment) AS id, any_value(payment_name) AS name')->group('payment')->select(); + $data = Db::name('PayLog')->field('payment AS id, payment_name AS name')->group('id')->select(); return DataReturn('处理成功', 0, $data); } diff --git a/application/service/RefundLogService.php b/application/service/RefundLogService.php index 214ebd3e1..d598d2c91 100644 --- a/application/service/RefundLogService.php +++ b/application/service/RefundLogService.php @@ -72,7 +72,7 @@ class RefundLogService */ public static function RefundLogTypeList($params = []) { - $data = Db::name('RefundLog')->field('any_value(payment) AS id, any_value(payment_name) AS name')->group('payment')->select(); + $data = Db::name('RefundLog')->field('payment AS id, payment_name AS name')->group('id')->select(); return DataReturn('处理成功', 0, $data); } diff --git a/application/service/StatisticalService.php b/application/service/StatisticalService.php index 6a51dd9aa..9591bf697 100755 --- a/application/service/StatisticalService.php +++ b/application/service/StatisticalService.php @@ -442,17 +442,20 @@ class StatisticalService { $data = []; } else { - $data = Db::name('OrderDetail')->field('any_value(title) AS name,sum(buy_number) AS value')->where('order_id', 'IN', $order_ids)->group('goods_id')->order('value desc')->limit(10)->select(); + $data = Db::name('OrderDetail')->field('goods_id, sum(buy_number) AS value')->where('order_id', 'IN', $order_ids)->group('goods_id')->order('value desc')->limit(10)->select(); } if(!empty($data)) { foreach($data as &$v) { + // 获取商品名称(这里不一次性读取、为了兼容 mysql 5.7+版本) + $v['name'] = Db::name('OrderDetail')->where('goods_id', $v['goods_id'])->value('title'); if(mb_strlen($v['name'], 'utf-8') > 12) { $v['name'] = mb_substr($v['name'], 0, 12, 'utf-8').'...'; } + unset($v['goods_id']); } } @@ -463,6 +466,5 @@ class StatisticalService ]; return DataReturn('处理成功', 0, $result); } - } ?> \ No newline at end of file -- GitLab