统计优化

feat/task1-c-wallet
gongfuxiang 2022-01-28 23:37:50 +08:00
parent 6d185497f5
commit 225b15d750
1 changed files with 2 additions and 4 deletions

View File

@ -249,7 +249,6 @@ class StatisticalService
// 上月 // 上月
$where = [ $where = [
['status', '<=', 4],
['add_time', '>=', self::$last_month_time_start], ['add_time', '>=', self::$last_month_time_start],
['add_time', '<=', self::$last_month_time_end], ['add_time', '<=', self::$last_month_time_end],
]; ];
@ -257,7 +256,6 @@ class StatisticalService
// 当月 // 当月
$where = [ $where = [
['status', '<=', 4],
['add_time', '>=', self::$this_month_time_start], ['add_time', '>=', self::$this_month_time_start],
['add_time', '<=', self::$this_month_time_end], ['add_time', '<=', self::$this_month_time_end],
]; ];
@ -718,10 +716,10 @@ class StatisticalService
if(!empty($data)) if(!empty($data))
{ {
$names = Db::name('OrderDetail')->where('goods_id', 'in', array_column($data, 'goods_id'))->group('goods_id')->column('title', 'goods_id');
foreach($data as &$v) foreach($data as &$v)
{ {
// 获取商品名称(这里不一次性读取、为了兼容 mysql 5.7+版本) $v['name'] = $names[$v['goods_id']];
$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').'...';