提交 324a8945 编写于 作者: D devil

mysql版本兼容处理

上级 d53b7410
...@@ -68,7 +68,7 @@ class PayLogService ...@@ -68,7 +68,7 @@ class PayLogService
*/ */
public static function PayLogTypeList($params = []) 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); return DataReturn('处理成功', 0, $data);
} }
......
...@@ -72,7 +72,7 @@ class RefundLogService ...@@ -72,7 +72,7 @@ class RefundLogService
*/ */
public static function RefundLogTypeList($params = []) 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); return DataReturn('处理成功', 0, $data);
} }
......
...@@ -442,17 +442,20 @@ class StatisticalService ...@@ -442,17 +442,20 @@ class StatisticalService
{ {
$data = []; $data = [];
} else { } 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)) if(!empty($data))
{ {
foreach($data as &$v) 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) if(mb_strlen($v['name'], 'utf-8') > 12)
{ {
$v['name'] = mb_substr($v['name'], 0, 12, 'utf-8').'...'; $v['name'] = mb_substr($v['name'], 0, 12, 'utf-8').'...';
} }
unset($v['goods_id']);
} }
} }
...@@ -463,6 +466,5 @@ class StatisticalService ...@@ -463,6 +466,5 @@ class StatisticalService
]; ];
return DataReturn('处理成功', 0, $result); return DataReturn('处理成功', 0, $result);
} }
} }
?> ?>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册