导入商品的详情
This commit is contained in:
parent
be53659118
commit
f4b8f07160
@ -52,6 +52,9 @@ class SpuDao extends BaseDao
|
||||
$query->when(isset($where['is_del']) && $where['is_del'] !== '',function($query)use($where){
|
||||
$query->where('P.is_del',$where['is_del']);
|
||||
})
|
||||
->when(isset($where['product_id']) && $where['product_id'] !== '',function($query)use($where){
|
||||
$query->where('P.product_id','in',$where['product_id']);
|
||||
})
|
||||
->when(isset($where['mer_id']) && $where['mer_id'] !== '',function($query)use($where){
|
||||
$query->where('P.mer_id',$where['mer_id']);
|
||||
})
|
||||
|
@ -161,9 +161,15 @@ class SpuRepository extends BaseRepository
|
||||
{
|
||||
$where['spu_status'] = 1;
|
||||
$where['mer_status'] = 1;
|
||||
$RedisCacheService = app()->make(RedisCacheService::class);
|
||||
$exists=$RedisCacheService->exists('CloudMerchanSpu'.$where['mer_id']);
|
||||
if ($exists){
|
||||
$Spu_arr=$RedisCacheService->SRANDMEMBER('CloudMerchanSpu'.$where['mer_id'], 10);
|
||||
$where['product_id'] =$Spu_arr;
|
||||
}
|
||||
$query = $this->dao->search($where);
|
||||
|
||||
$count = $query->count();
|
||||
$count = 0;
|
||||
// $Sql=$query->page($page, $limit)->setOption('field', [])->field($this->productFiled)->fetchSql(true);
|
||||
$query->with([
|
||||
'merchant' => function ($query) {
|
||||
@ -171,7 +177,7 @@ class SpuRepository extends BaseRepository
|
||||
},
|
||||
'issetCoupon',
|
||||
]);
|
||||
$list = $query->page($page, $limit)->setOption('field', [])->field($this->productFiled)->orderRaw('rand()')->select();
|
||||
$list = $query->setOption('field', [])->field($this->productFiled)->orderRaw('rand()')->select();
|
||||
$append = ['stop_time','svip_price','show_svip_info','is_svip_price'];
|
||||
|
||||
$list->append($append);
|
||||
|
@ -102,7 +102,7 @@ class StoreSpu extends BaseController
|
||||
]);
|
||||
if ($where['action']) unset($where['product_type']);
|
||||
$category_id=Db::name('merchant')->where('mer_id',$id)->value('category_id');
|
||||
$mer_id=Db::name('merchant')->where('category_id',$category_id)->where('type_id',11)->value('mer_id');
|
||||
$mer_id=Db::name('merchant')->where('mer_state',1)->where('status',1)->where('category_id',$category_id)->where('type_id',11)->value('mer_id');
|
||||
if (!$mer_id){
|
||||
return app('json')->success(['count'=>0,'list'=>[]]);
|
||||
|
||||
|
@ -3,6 +3,7 @@ declare (strict_types=1);
|
||||
|
||||
namespace app\listener;
|
||||
|
||||
use crmeb\services\RedisCacheService;
|
||||
use think\facade\Db;
|
||||
use think\facade\Log;
|
||||
|
||||
@ -12,6 +13,9 @@ class ProductCreate
|
||||
public function handle($event)
|
||||
{
|
||||
$merchant=Db::name('merchant')->where('mer_id',$event['product']['mer_id'])->find();
|
||||
if ($merchant['type_id']==11){
|
||||
$this->CloudMerchanSpu($merchant,$event);
|
||||
}
|
||||
if ($merchant['type_id']==13 ||$merchant['type_id']==11){
|
||||
return false;
|
||||
}
|
||||
@ -58,6 +62,18 @@ class ProductCreate
|
||||
return false;
|
||||
}
|
||||
|
||||
public function CloudMerchanSpu($data,$event){
|
||||
$RedisCacheService = app()->make(RedisCacheService::class);
|
||||
$exists=$RedisCacheService->exists('CloudMerchanSpu'.$data['mer_id']);
|
||||
if ($exists){
|
||||
$RedisCacheService->SADD ('CloudMerchanSpu'.$data['mer_id'], $event['product']['product_id']);
|
||||
}else{
|
||||
$Spu_arr=Db::name('store_spu')->where('mer_id',$data['mer_id'])->where('status',1)->column('product_id');
|
||||
foreach ($Spu_arr as $k=>$v){
|
||||
$RedisCacheService->SADD ('CloudMerchanSpu'.$data['mer_id'], $v);
|
||||
}
|
||||
}
|
||||
}
|
||||
public function AddProduct($mer_id,$product_find,$event){
|
||||
$datas=[
|
||||
'mer_id'=>$mer_id,
|
||||
|
Loading…
x
Reference in New Issue
Block a user