更新排序
This commit is contained in:
parent
6856704551
commit
2f86f37838
@ -90,7 +90,7 @@ class SpuRepository extends BaseRepository
|
||||
'keyword' => $param['keyword'] ?? '',
|
||||
'image' => $param['image'],
|
||||
'price' => $param['price'],
|
||||
'status' => $param['status']??0,
|
||||
'status' => $param['status'] ?? 0,
|
||||
'rank' => $param['rank'] ?? 0,
|
||||
'temp_id' => $param['temp_id'],
|
||||
'sort' => $param['sort'] ?? 0,
|
||||
@ -129,7 +129,7 @@ class SpuRepository extends BaseRepository
|
||||
* @author Qinii
|
||||
* @day 12/18/20
|
||||
*/
|
||||
public function getApiSearch($where, $page, $limit, $userInfo = null,$is_sku=false)
|
||||
public function getApiSearch($where, $page, $limit, $userInfo = null, $is_sku = false)
|
||||
{
|
||||
if (isset($where['keyword']) && !empty($where['keyword'])) {
|
||||
if (preg_match('/^(\/@[1-9]{1}).*\*\//', $where['keyword'])) {
|
||||
@ -144,24 +144,37 @@ class SpuRepository extends BaseRepository
|
||||
}
|
||||
$where = array_merge(Product::searchEnable(), $where);
|
||||
$query = $this->dao->search($where);
|
||||
|
||||
|
||||
$query->with([
|
||||
'merchant' => function ($query) {
|
||||
$query->field($this->merchantFiled)->with(['type_names','street_names']);
|
||||
$query->field($this->merchantFiled)->with(['type_names', 'street_names']);
|
||||
},
|
||||
'issetCoupon',
|
||||
'product.attrValue',
|
||||
]);
|
||||
$productMake = app()->make(ProductRepository::class);
|
||||
$count = $query->fetchSql(false)->count();
|
||||
$list = $query->page($page, $limit)->setOption('field', [])->field($this->productFiled)->select()
|
||||
->each(function ($item) use ($is_sku,$productMake,$userInfo) {
|
||||
if($is_sku==true){
|
||||
$sku = $productMake->detailAttrValue($item['product']['attrValue'], $userInfo);
|
||||
$item['sku']=$sku;
|
||||
}
|
||||
});
|
||||
$append = ['stop_time','svip_price','show_svip_info','is_svip_price'];
|
||||
|
||||
if ($limit == 0) {
|
||||
$list = $query->setOption('field', [])->field($this->productFiled)->select()
|
||||
->each(function ($item) use ($is_sku, $productMake, $userInfo) {
|
||||
if ($is_sku == true) {
|
||||
$sku = $productMake->detailAttrValue($item['product']['attrValue'], $userInfo);
|
||||
$item['sku'] = $sku;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$list = $query->page($page, $limit)->setOption('field', [])->field($this->productFiled)->select()
|
||||
->each(function ($item) use ($is_sku, $productMake, $userInfo) {
|
||||
if ($is_sku == true) {
|
||||
$sku = $productMake->detailAttrValue($item['product']['attrValue'], $userInfo);
|
||||
$item['sku'] = $sku;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
$append = ['stop_time', 'svip_price', 'show_svip_info', 'is_svip_price'];
|
||||
if ($productMake->getUserIsPromoter($userInfo))
|
||||
$append[] = 'max_extension';
|
||||
$list->append($append);
|
||||
@ -221,7 +234,7 @@ class SpuRepository extends BaseRepository
|
||||
'issetCoupon'
|
||||
]);
|
||||
$list = $query->setOption('field', [])->field($this->productFiled)->page($page)->limit($limit)->select();
|
||||
$append = ['stop_time','svip_price','show_svip_info','is_svip_price'];
|
||||
$append = ['stop_time', 'svip_price', 'show_svip_info', 'is_svip_price'];
|
||||
$list->append($append);
|
||||
$list = $this->getBorderList($list);
|
||||
$productIdArray = $productSkuArray = [];
|
||||
@ -230,7 +243,7 @@ class SpuRepository extends BaseRepository
|
||||
$item['referer'] = AesUtils::encrypt($entryMerId . '|' . rand(1, 100), env('app_key'));
|
||||
}
|
||||
$productAttrList = Db::name('store_product_attr_value')->whereIn('product_id', $productIdArray)->field(['product_id', 'sku', 'price', 'stock', 'image', 'weight', 'volume', 'sales', 'unique', 'bar_code', 'ot_price', 'svip_price'])->select();
|
||||
foreach($productAttrList as $prod) {
|
||||
foreach ($productAttrList as $prod) {
|
||||
$productSkuArray[$prod['product_id']][$prod['sku']] = [
|
||||
"sku" => $prod['sku'],
|
||||
"price" => $prod['price'],
|
||||
@ -298,7 +311,7 @@ class SpuRepository extends BaseRepository
|
||||
{
|
||||
$make = app()->make(StoreActivityRepository::class);
|
||||
foreach ($list as $item) {
|
||||
$act = $make->getActivityBySpu(StoreActivityRepository::ACTIVITY_TYPE_BORDER,$item['spu_id'],$item['cate_id'],$item['mer_id']);
|
||||
$act = $make->getActivityBySpu(StoreActivityRepository::ACTIVITY_TYPE_BORDER, $item['spu_id'], $item['cate_id'], $item['mer_id']);
|
||||
$item['border_pic'] = $act['pic'] ?? '';
|
||||
}
|
||||
return $list;
|
||||
@ -577,11 +590,11 @@ class SpuRepository extends BaseRepository
|
||||
$ret->save();
|
||||
}
|
||||
|
||||
public function batchLabels($ids, $data,$merId)
|
||||
public function batchLabels($ids, $data, $merId)
|
||||
{
|
||||
$ids = is_array($ids) ? $ids : explode(',',$ids);
|
||||
$ids = is_array($ids) ? $ids : explode(',', $ids);
|
||||
foreach ($ids as $id) {
|
||||
$this->setLabels($id,0,$data,$merId);
|
||||
$this->setLabels($id, 0, $data, $merId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -633,8 +646,8 @@ class SpuRepository extends BaseRepository
|
||||
public function getHotRanking(int $cateId)
|
||||
{
|
||||
$RedisCacheService = app()->make(RedisCacheService::class);
|
||||
$prefix = env('queue_name','merchant').'_hot_ranking_';
|
||||
$ids = $RedisCacheService->handler()->get($prefix.'top_' . intval($cateId));
|
||||
$prefix = env('queue_name', 'merchant') . '_hot_ranking_';
|
||||
$ids = $RedisCacheService->handler()->get($prefix . 'top_' . intval($cateId));
|
||||
$ids = $ids ? explode(',', $ids) : [];
|
||||
if (!count($ids)) {
|
||||
return [];
|
||||
@ -646,7 +659,7 @@ class SpuRepository extends BaseRepository
|
||||
$where['product_type'] = 0;
|
||||
$where['order'] = 'sales';
|
||||
$where['spu_ids'] = $ids;
|
||||
$list = $this->dao->search($where)->setOption('field',[])->field('spu_id,S.image,S.price,S.product_type,P.product_id,P.sales,S.status,S.store_name,P.ot_price,P.cost')->select();
|
||||
$list = $this->dao->search($where)->setOption('field', [])->field('spu_id,S.image,S.price,S.product_type,P.product_id,P.sales,S.status,S.store_name,P.ot_price,P.cost')->select();
|
||||
if ($list) $list = $list->toArray();
|
||||
return $list;
|
||||
}
|
||||
@ -660,17 +673,17 @@ class SpuRepository extends BaseRepository
|
||||
* @author Qinii
|
||||
* @day 2022/9/22
|
||||
*/
|
||||
public function makinList($where,$page, $limit)
|
||||
public function makinList($where, $page, $limit)
|
||||
{
|
||||
$where['spu_status'] = 1;
|
||||
$where['mer_status'] = 1;
|
||||
$query = $this->dao->search($where);
|
||||
$query->with([
|
||||
'merchant' ,
|
||||
'merchant',
|
||||
'issetCoupon',
|
||||
]);
|
||||
$count = $query->count();
|
||||
$list = $query->page($page, $limit)->setOption('field', [])->field($this->productFiled)->select();
|
||||
return compact('count','list');
|
||||
return compact('count', 'list');
|
||||
}
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ class CloudWarehouse extends BaseController
|
||||
$query->whereOr('mer_labels', '')
|
||||
->whereOr('mer_labels',',5,');
|
||||
})->count();
|
||||
$products = $this->spuRepository->getApiSearch($where, $page, 10, false, true);
|
||||
$products = $this->spuRepository->getApiSearch($where, $page, 0, false, true);
|
||||
if ($products['list']) {
|
||||
$list = $products['list'];
|
||||
foreach ($cloud_product_arr as $key => $value) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user