pull/1/head
wanghousheng 10 months ago
parent 246a091bb3
commit d68234686c
  1. 5
      app/api/model/Goods.php
  2. 3
      app/api/model/GoodsBrowseLog.php

@ -153,11 +153,12 @@ class Goods extends GoodsModel
$userId = UserService::getCurrentLoginUserId();
$model = new GoodsBrowseLog;
$end_time = date('Y-m-d');
$start_time = date('Y-m-d', strtotime($end_time . ' - 3 days'));
$start_time = date('Y-m-d', strtotime($end_time . ' - 2 days'));
$list = $model->with(['sku', 'goods'])
->withoutField(['content'])
->where('ctime', '>=', $start_time)
->where('ctime', '<=', $end_time)
->order('ctime', 'desc')
->where(['user_id' => $userId])
->select();
$data = [];
@ -168,7 +169,7 @@ class Goods extends GoodsModel
$data[$value['ctime']]['week'] = $array[date("w", strtotime($value['ctime']))];
$data[$value['ctime']]['list'][] = [
'goods' => $value['goods'],
'sku_list' => $value['sku'],
'sku' => $value['sku'][0],
'log_id' => $value['id'],
];
}

@ -33,12 +33,13 @@ class GoodsBrowseLog extends GoodsSpecRelModel
public function sku(): HasMany
{
return $this->hasMany(GoodsSku::class, 'goods_id', 'goods_id');
return $this->hasMany(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']);
}

Loading…
Cancel
Save