pull/1/head
wanghousheng 10 months ago
parent d68234686c
commit 5954aaa581
  1. 9
      app/api/model/Goods.php
  2. 13
      app/api/model/GoodsBrowseLog.php

@ -154,8 +154,7 @@ class Goods extends GoodsModel
$model = new GoodsBrowseLog;
$end_time = date('Y-m-d');
$start_time = date('Y-m-d', strtotime($end_time . ' - 2 days'));
$list = $model->with(['sku', 'goods'])
->withoutField(['content'])
$list = $model->with(['sku', 'goods', 'images.file'])
->where('ctime', '>=', $start_time)
->where('ctime', '<=', $end_time)
->order('ctime', 'desc')
@ -167,11 +166,7 @@ class Goods extends GoodsModel
foreach ($list as $value) {
$data[$value['ctime']]['name'] = date('m-d', strtotime($value['ctime']));
$data[$value['ctime']]['week'] = $array[date("w", strtotime($value['ctime']))];
$data[$value['ctime']]['list'][] = [
'goods' => $value['goods'],
'sku' => $value['sku'][0],
'log_id' => $value['id'],
];
$data[$value['ctime']]['list'][] = $value;
}
}
return array_values($data);

@ -31,16 +31,19 @@ class GoodsBrowseLog extends GoodsSpecRelModel
protected $updateTime = false;
public function sku(): HasMany
public function sku(): HasOne
{
return $this->hasMany(GoodsSku::class, 'goods_id', 'goods_id')->order(['id' => 'asc']);
return $this->hasOne(GoodsSku::class, 'goods_id', 'goods_id')->order(['id' => 'asc']);
}
public function goods(): HasOne
{
return $this->hasOne(Goods::class, 'goods_id', 'goods_id')
->with(['images.file'])
->withoutField(['content']);
return $this->hasOne(Goods::class, 'goods_id', 'goods_id')->withoutField(['content']);
}
public function images(): HasMany
{
return $this->hasMany(GoodsImage::class, 'goods_id', 'goods_id')->order(['id']);
}
}

Loading…
Cancel
Save