pull/1/head
wangmingchuan321@qq.com 10 months ago
parent 6dfb163982
commit 64a2efeca8
  1. 18
      app/api/model/Goods.php
  2. 2
      app/common/model/Goods.php

@ -21,6 +21,8 @@ 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\model\Goods as GoodsModel;
use app\common\model\GoodsImage as GoodsImageModel;
use app\common\model\UploadFile as UploadFileModel;
use app\common\enum\goods\Status as GoodsStatusEnum;
use cores\exception\BaseException;
use think\db\exception\DataNotFoundException;
@ -209,12 +211,26 @@ class Goods extends GoodsModel
$goods = explode(',', $info->goods_list);
$list = goods::alias('a')
->join('goods_category_rel b', 'a.goods_id = b.goods_id')->where([
->join('goods_category_rel b', 'a.goods_id = b.goods_id')
->where([
'a.store_id' => request()->header()['storeid'],
'a.status' => 10,
'b.category_id' => $_GET['category_id']
])->whereIn('a.goods_id', $goods)->field('a.goods_id,a.goods_name,a.goods_price_min,b.category_id,a.sales_initial,a.sales_actual')->select()->toArray();
//暂时 要优化
foreach ($list as &$v) {
$file_id = GoodsImageModel::where([
'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,
])->field('file_path')->find()->file_path;
$v['image'] = $_SERVER['HTTP_HOST'] . '/uploads/' . $file_path;
}
return $list;
}
return [];

@ -178,7 +178,6 @@ class Goods extends BaseModel
public function getList(array $param = [], int $listRows = 15)
{
// 筛选条件
$query = $this->getQueryFilter($param);
// 设置显示的销量 goods_sales
$query->field(['(sales_initial + sales_actual) as goods_sales', '(line_price_max - goods_price_min) as discount']);
@ -321,7 +320,6 @@ class Goods extends BaseModel
$query->order('paihang asc');
}
// 实例化新查询对象
return $query->where($filter);
}

Loading…
Cancel
Save