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

@ -33,12 +33,13 @@ class GoodsBrowseLog extends GoodsSpecRelModel
public function sku(): HasMany 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 public function goods(): HasOne
{ {
return $this->hasOne(Goods::class, 'goods_id', 'goods_id') return $this->hasOne(Goods::class, 'goods_id', 'goods_id')
->with(['images.file'])
->withoutField(['content']); ->withoutField(['content']);
} }

Loading…
Cancel
Save