1,文件地址:app/services/product/product/StoreProductServices.php
注释代码放开,如下图:
方法名:getGoodsList
2,文件地址:app/controller/api/v1/product/StoreProduct.php
方法名:lst
替换此方法
public function lst(Request $request, StoreProductCategoryServices $services)
{
$where = $request->getMore([
[['sid', 'd'], 0],
[['cid', 'd'], 0],
[['tid', 'd'], 0],
['keyword', '', '','store_name'],
['priceOrder', ''],
['salesOrder', ''],
['defaultOrder', ''],
[['news', 'd'], 0, '', 'is_new'],
[['type', ''], '', '', 'status'],
['ids', ''],
[['selectId', 'd'], ''],
['cate_id', ''],
['productId', ''],
['brand_id', ''],
['promotions_id', 0],
['promotions_type', 0],
['store_label_id', 0],
['is_big', 0],//是否大图模式
]);
if ($where['selectId'] && (!$where['sid'] || !$where['cid'])) {
$level = $services->value(['id' => (int)$where['selectId']], 'level') ?? 0;
$levelArr = $services->cateField;
$where[$levelArr[$level] ?? 'cid'] = $where['selectId'];
}
$where['ids'] = stringToIntArray($where['ids']);
if (!$where['ids']) {
unset($where['ids']);
}
$where['brand_id'] = stringToIntArray($where['brand_id']);
$where['store_label_id'] = stringToIntArray($where['store_label_id']);
$cateId = $where['cate_id'];
if ($cateId) {
$cateId = is_string($cateId) ? stringToIntArray($where['cate_id']) : $cateId;
$cateId = array_merge($cateId, $services->getColumn(['pid' => $cateId], 'id'));
$cateId = array_unique(array_diff($cateId, [0]));
}
$where['cate_id'] = $cateId;
$type = $where['is_big'] ? 'big' : 'mid';
unset($where['is_big']);
$field = ['image', 'recommend_image'];
if ($where['store_name']) {//搜索
$field = ['image'];
$where['pid'] = 0;
}
$list = $this->services->getGoodsList($where, (int)$request->uid(), (int)$where['promotions_type']);
return app('json')->successful(get_thumb_water($list, $type, $field));
}