|
|
|
@ -12,26 +12,22 @@ declare (strict_types=1); |
|
|
|
|
|
|
|
|
|
namespace app\api\model; |
|
|
|
|
|
|
|
|
|
use app\api\model\GoodsBrowseLog; |
|
|
|
|
use app\api\model\GoodsSku as GoodsSkuModel; |
|
|
|
|
use app\api\model\GoodsSpecRel as GoodsSpecRelModel; |
|
|
|
|
use app\api\model\store\Module as StoreModuleModel; |
|
|
|
|
use app\api\service\Goods as GoodsService; |
|
|
|
|
use app\api\service\User as UserService; |
|
|
|
|
use app\api\service\user\Grade as UserGradeService; |
|
|
|
|
use app\api\model\GoodsSku as GoodsSkuModel; |
|
|
|
|
use app\api\model\store\Module as StoreModuleModel; |
|
|
|
|
use app\common\model\GoodsCategoryRel as GoodsCategoryRelModel; |
|
|
|
|
use app\api\model\GoodsSpecRel as GoodsSpecRelModel; |
|
|
|
|
use app\common\enum\goods\Status as GoodsStatusEnum; |
|
|
|
|
use app\common\model\Goods as GoodsModel; |
|
|
|
|
use app\common\model\GoodsCategoryRel as GoodsCategoryRelModel; |
|
|
|
|
use app\common\model\GoodsImage as GoodsImageModel; |
|
|
|
|
use app\common\model\UploadFile as UploadFileModel; |
|
|
|
|
use app\common\enum\goods\Status as GoodsStatusEnum; |
|
|
|
|
use app\store\model\goods\GoodsPrice as GoodsPriceModel; |
|
|
|
|
use cores\exception\BaseException; |
|
|
|
|
use think\db\exception\DataNotFoundException; |
|
|
|
|
use think\db\exception\DbException; |
|
|
|
|
use think\db\exception\ModelNotFoundException; |
|
|
|
|
use app\store\model\goods\GoodsPrice as GoodsPriceModel; |
|
|
|
|
use app\api\model\PreSale; |
|
|
|
|
use app\api\model\PreSaleMessage; |
|
|
|
|
use app\api\model\PreSaleLog; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 商品模型 |
|
|
|
@ -143,6 +139,43 @@ class Goods extends GoodsModel |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @notes:浏览记录 |
|
|
|
|
* @return array |
|
|
|
|
* @throws BaseException |
|
|
|
|
* @throws DataNotFoundException |
|
|
|
|
* @throws DbException |
|
|
|
|
* @throws ModelNotFoundException |
|
|
|
|
* @author: wanghousheng |
|
|
|
|
*/ |
|
|
|
|
public function browseLogList(): array |
|
|
|
|
{ |
|
|
|
|
$userId = UserService::getCurrentLoginUserId(); |
|
|
|
|
$model = new GoodsBrowseLog; |
|
|
|
|
$end_time = date('Y-m-d'); |
|
|
|
|
$start_time = date('Y-m-d', strtotime($end_time . ' - 3 days')); |
|
|
|
|
$list = $model->with(['sku', 'goods']) |
|
|
|
|
->withoutField(['content']) |
|
|
|
|
->where('ctime', '>=', $start_time) |
|
|
|
|
->where('ctime', '<=', $end_time) |
|
|
|
|
->where(['user_id' => $userId]) |
|
|
|
|
->select(); |
|
|
|
|
$data = []; |
|
|
|
|
$array = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"]; |
|
|
|
|
if (!$list->isEmpty()) { |
|
|
|
|
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_list' => $value['sku'], |
|
|
|
|
'log_id' => $value['id'], |
|
|
|
|
]; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return array_values($data); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function browseLog() |
|
|
|
|
{ |
|
|
|
|
$userId = UserService::getCurrentLoginUserId(true); |
|
|
|
@ -223,7 +256,7 @@ class Goods extends GoodsModel |
|
|
|
|
'store_id' => request()->header()['storeid'], |
|
|
|
|
'goods_id' => $v['goods_id'], |
|
|
|
|
])->field('image_id')->find()->image_id; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$file_path = UploadFileModel::where([ |
|
|
|
|
'store_id' => request()->header()['storeid'], |
|
|
|
|
'file_id' => $file_id, |
|
|
|
|