修复商品推荐问题

This commit is contained in:
mkm 2023-09-28 15:28:12 +08:00
parent 63c132b2b6
commit 16fa01085a

View File

@ -1167,6 +1167,8 @@ class ProductRepository extends BaseRepository
$where['product_type'] = $productType; $where['product_type'] = $productType;
} }
$res = $this->dao->getWhere($where, $field, $with); $res = $this->dao->getWhere($where, $field, $with);
$a= $this->getRecommend($res['product_id'], $res['mer_id']);
halt($a);
if (!$res) return []; if (!$res) return [];
switch ($res['product_type']) { switch ($res['product_type']) {
case 0: case 0:
@ -1323,19 +1325,17 @@ class ProductRepository extends BaseRepository
->where('mer_id',$merId); ->where('mer_id',$merId);
$data = []; $data = [];
$count = $query->count(); $count = $query->count();
// if ($count < 3) {
if ($count < 3) { // $productIds[] = $productId;
$productIds[] = $productId; // $data = $this->dao->getSearch([])
$data = $this->dao->getSearch([]) // ->where($this->dao->productShow())
->where($this->dao->productShow()) // ->whereNotIn('product_id',$productIds)
->whereNotIn('product_id',$productIds) // ->where('mer_id', $merId)
->where('mer_id', $merId) // ->field('mer_id,product_id,store_name,image,price,is_show,status,is_gift_bag,is_good,sales,create_time')
->field('mer_id,product_id,store_name,image,price,is_show,status,is_gift_bag,is_good,sales,create_time') // ->order('sort DESC,create_time DESC')
->order('sort DESC,create_time DESC') // ->limit((3 - $count))
->limit((3 - $count)) // ->select()->toArray();
->select()->toArray(); // }
}
if ($count > 0 ){ if ($count > 0 ){
$count = $count > 3 ? 3 : $count; $count = $count > 3 ? 3 : $count;
$res = $query->setOption('field',[])->field('mer_id,product_id,store_name,image,price,is_show,status,is_gift_bag,is_good,sales,create_time') $res = $query->setOption('field',[])->field('mer_id,product_id,store_name,image,price,is_show,status,is_gift_bag,is_good,sales,create_time')