调整商品导入
This commit is contained in:
parent
b5d20191a6
commit
de55a00c58
@ -51,10 +51,13 @@ class StoreMicro extends BaseController
|
||||
if($find['product_type']!=0){
|
||||
return app('json')->fail('该商品不是普通商品');
|
||||
}
|
||||
$exist = Db::name('store_product')->where('old_product_id', $product_id)->where('mer_id', $mer_id)->find();
|
||||
if($exist){
|
||||
return app('json')->fail('已经导入过该商品了');
|
||||
}
|
||||
$find['attrValue']=Db::name('store_product_attr_value')->where('product_id',$find['product_id'])->field('image,price,cost,ot_price,svip_price,stock,bar_code,weight,volume')->select();
|
||||
$find['content']=Db::name('store_product_content')->where('product_id',$find['product_id'])->value('content');
|
||||
$find['is_show']=0;
|
||||
$find['mer_status']=1;
|
||||
$find['mer_id']=$mer_id;
|
||||
$find['temp_id']="";
|
||||
$find['give_coupon_ids']=[];
|
||||
@ -70,6 +73,7 @@ class StoreMicro extends BaseController
|
||||
$find['is_used']=1;
|
||||
$find['status']=1;
|
||||
$find['mer_status']=1;
|
||||
$find['old_product_id']=$product_id;
|
||||
unset($find['product_id'],$find['create_time']);
|
||||
}
|
||||
$make = app()->make(ProductRepository::class);
|
||||
|
@ -3,6 +3,7 @@ declare (strict_types=1);
|
||||
|
||||
namespace app\listener;
|
||||
|
||||
use app\common\repositories\store\product\ProductRepository;
|
||||
use crmeb\services\RedisCacheService;
|
||||
use think\facade\Db;
|
||||
use think\facade\Log;
|
||||
@ -96,11 +97,22 @@ class ProductCreate
|
||||
'create_time'=>date('Y-m-d H:i:s'),
|
||||
'image'=>$product_find['image'],
|
||||
'slider_image'=>$product_find['slider_image'],
|
||||
'svip_price_type' => 0,
|
||||
];
|
||||
$product_id=Db::name('store_product')->insertGetId($datas);
|
||||
$content=Db::name('store_product_content')->where('product_id',$event['product']['product_id'])->find();
|
||||
Db::name('store_product_content')->insert(['product_id'=>$product_id,'content'=>$content['content'],'type'=>$content['type']]);
|
||||
$spu_arr=Db::name('store_spu')->where('mer_id',$product_find['mer_id'])->where('product_id',$event['product']['product_id'])->select()->toArray();
|
||||
|
||||
$datas['attrValue']=Db::name('store_product_attr_value')->where('product_id',$product_find['product_id'])->field('image,price,cost,ot_price,svip_price,stock,bar_code,weight,volume')->select();
|
||||
/** @var ProductRepository $productRepository */
|
||||
$productRepository = app()->make(ProductRepository::class);
|
||||
$settleParams = $productRepository->setAttrValue($datas, (int)$product_id, 0, 0,$datas['mer_id']);
|
||||
$settleParams['cate'] = $productRepository->setMerCate([$datas['mer_cate_id'] ?? 0], (int)$product_id, (int)$datas['mer_id']);
|
||||
$settleParams['attr'] = $productRepository->setAttr($datas['attr'] ?? [], (int)$product_id);
|
||||
unset($datas['attrValue']);
|
||||
$productRepository->save($product_id, $settleParams, $content,$datas,0);
|
||||
|
||||
foreach ($spu_arr as $k=>$v){
|
||||
$spu_arr[$k]['product_id']=$product_id;
|
||||
$spu_arr[$k]['mer_id']=$mer_id;
|
||||
|
Loading…
x
Reference in New Issue
Block a user