更新排序
This commit is contained in:
parent
6856704551
commit
2f86f37838
@ -90,7 +90,7 @@ class SpuRepository extends BaseRepository
|
|||||||
'keyword' => $param['keyword'] ?? '',
|
'keyword' => $param['keyword'] ?? '',
|
||||||
'image' => $param['image'],
|
'image' => $param['image'],
|
||||||
'price' => $param['price'],
|
'price' => $param['price'],
|
||||||
'status' => $param['status']??0,
|
'status' => $param['status'] ?? 0,
|
||||||
'rank' => $param['rank'] ?? 0,
|
'rank' => $param['rank'] ?? 0,
|
||||||
'temp_id' => $param['temp_id'],
|
'temp_id' => $param['temp_id'],
|
||||||
'sort' => $param['sort'] ?? 0,
|
'sort' => $param['sort'] ?? 0,
|
||||||
@ -129,7 +129,7 @@ class SpuRepository extends BaseRepository
|
|||||||
* @author Qinii
|
* @author Qinii
|
||||||
* @day 12/18/20
|
* @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 (isset($where['keyword']) && !empty($where['keyword'])) {
|
||||||
if (preg_match('/^(\/@[1-9]{1}).*\*\//', $where['keyword'])) {
|
if (preg_match('/^(\/@[1-9]{1}).*\*\//', $where['keyword'])) {
|
||||||
@ -147,21 +147,34 @@ class SpuRepository extends BaseRepository
|
|||||||
|
|
||||||
$query->with([
|
$query->with([
|
||||||
'merchant' => function ($query) {
|
'merchant' => function ($query) {
|
||||||
$query->field($this->merchantFiled)->with(['type_names','street_names']);
|
$query->field($this->merchantFiled)->with(['type_names', 'street_names']);
|
||||||
},
|
},
|
||||||
'issetCoupon',
|
'issetCoupon',
|
||||||
'product.attrValue',
|
'product.attrValue',
|
||||||
]);
|
]);
|
||||||
$productMake = app()->make(ProductRepository::class);
|
$productMake = app()->make(ProductRepository::class);
|
||||||
$count = $query->fetchSql(false)->count();
|
$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 ($limit == 0) {
|
||||||
if($is_sku==true){
|
$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);
|
$sku = $productMake->detailAttrValue($item['product']['attrValue'], $userInfo);
|
||||||
$item['sku']=$sku;
|
$item['sku'] = $sku;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$append = ['stop_time','svip_price','show_svip_info','is_svip_price'];
|
} 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))
|
if ($productMake->getUserIsPromoter($userInfo))
|
||||||
$append[] = 'max_extension';
|
$append[] = 'max_extension';
|
||||||
$list->append($append);
|
$list->append($append);
|
||||||
@ -221,7 +234,7 @@ class SpuRepository extends BaseRepository
|
|||||||
'issetCoupon'
|
'issetCoupon'
|
||||||
]);
|
]);
|
||||||
$list = $query->setOption('field', [])->field($this->productFiled)->page($page)->limit($limit)->select();
|
$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->append($append);
|
||||||
$list = $this->getBorderList($list);
|
$list = $this->getBorderList($list);
|
||||||
$productIdArray = $productSkuArray = [];
|
$productIdArray = $productSkuArray = [];
|
||||||
@ -230,7 +243,7 @@ class SpuRepository extends BaseRepository
|
|||||||
$item['referer'] = AesUtils::encrypt($entryMerId . '|' . rand(1, 100), env('app_key'));
|
$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();
|
$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']] = [
|
$productSkuArray[$prod['product_id']][$prod['sku']] = [
|
||||||
"sku" => $prod['sku'],
|
"sku" => $prod['sku'],
|
||||||
"price" => $prod['price'],
|
"price" => $prod['price'],
|
||||||
@ -298,7 +311,7 @@ class SpuRepository extends BaseRepository
|
|||||||
{
|
{
|
||||||
$make = app()->make(StoreActivityRepository::class);
|
$make = app()->make(StoreActivityRepository::class);
|
||||||
foreach ($list as $item) {
|
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'] ?? '';
|
$item['border_pic'] = $act['pic'] ?? '';
|
||||||
}
|
}
|
||||||
return $list;
|
return $list;
|
||||||
@ -577,11 +590,11 @@ class SpuRepository extends BaseRepository
|
|||||||
$ret->save();
|
$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) {
|
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)
|
public function getHotRanking(int $cateId)
|
||||||
{
|
{
|
||||||
$RedisCacheService = app()->make(RedisCacheService::class);
|
$RedisCacheService = app()->make(RedisCacheService::class);
|
||||||
$prefix = env('queue_name','merchant').'_hot_ranking_';
|
$prefix = env('queue_name', 'merchant') . '_hot_ranking_';
|
||||||
$ids = $RedisCacheService->handler()->get($prefix.'top_' . intval($cateId));
|
$ids = $RedisCacheService->handler()->get($prefix . 'top_' . intval($cateId));
|
||||||
$ids = $ids ? explode(',', $ids) : [];
|
$ids = $ids ? explode(',', $ids) : [];
|
||||||
if (!count($ids)) {
|
if (!count($ids)) {
|
||||||
return [];
|
return [];
|
||||||
@ -646,7 +659,7 @@ class SpuRepository extends BaseRepository
|
|||||||
$where['product_type'] = 0;
|
$where['product_type'] = 0;
|
||||||
$where['order'] = 'sales';
|
$where['order'] = 'sales';
|
||||||
$where['spu_ids'] = $ids;
|
$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();
|
if ($list) $list = $list->toArray();
|
||||||
return $list;
|
return $list;
|
||||||
}
|
}
|
||||||
@ -660,17 +673,17 @@ class SpuRepository extends BaseRepository
|
|||||||
* @author Qinii
|
* @author Qinii
|
||||||
* @day 2022/9/22
|
* @day 2022/9/22
|
||||||
*/
|
*/
|
||||||
public function makinList($where,$page, $limit)
|
public function makinList($where, $page, $limit)
|
||||||
{
|
{
|
||||||
$where['spu_status'] = 1;
|
$where['spu_status'] = 1;
|
||||||
$where['mer_status'] = 1;
|
$where['mer_status'] = 1;
|
||||||
$query = $this->dao->search($where);
|
$query = $this->dao->search($where);
|
||||||
$query->with([
|
$query->with([
|
||||||
'merchant' ,
|
'merchant',
|
||||||
'issetCoupon',
|
'issetCoupon',
|
||||||
]);
|
]);
|
||||||
$count = $query->count();
|
$count = $query->count();
|
||||||
$list = $query->page($page, $limit)->setOption('field', [])->field($this->productFiled)->select();
|
$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', '')
|
$query->whereOr('mer_labels', '')
|
||||||
->whereOr('mer_labels',',5,');
|
->whereOr('mer_labels',',5,');
|
||||||
})->count();
|
})->count();
|
||||||
$products = $this->spuRepository->getApiSearch($where, $page, 10, false, true);
|
$products = $this->spuRepository->getApiSearch($where, $page, 0, false, true);
|
||||||
if ($products['list']) {
|
if ($products['list']) {
|
||||||
$list = $products['list'];
|
$list = $products['list'];
|
||||||
foreach ($cloud_product_arr as $key => $value) {
|
foreach ($cloud_product_arr as $key => $value) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user