更新导入
This commit is contained in:
parent
8faa050a78
commit
3a29502fe7
@ -60,20 +60,60 @@ class StoreMicro extends BaseController
|
||||
|
||||
//提交导入商品id
|
||||
public function ProductImport(){
|
||||
$product_id = $this->request->param('id', 0);
|
||||
$id = $this->request->param('id', 0);
|
||||
$price = $this->request->param('price', 0);
|
||||
$stock = $this->request->param('stock', 0);
|
||||
$user = $this->request->userInfo();
|
||||
$where = ['is_used' => 1, 'status' => 1, 'is_del' => 0];
|
||||
try {
|
||||
/** @var ProductRepository $productRepository */
|
||||
$productRepository = app()->make(ProductRepository::class);
|
||||
$a = $productRepository->import($product_id, $user);
|
||||
$mer_id = Db::name('store_service')->where('uid', $user['uid'])->where('status', 1)->value('mer_id');
|
||||
if ($mer_id == 0) {
|
||||
return app('json')->fail('商户不存在');
|
||||
}
|
||||
$find=Db::name('product_library')->where('id',$id)->where($where)->find();
|
||||
if ($find) {
|
||||
|
||||
$exist = Db::name('store_product')->where('source_library_id', $id)->where('mer_id', $mer_id)->find();
|
||||
if ($exist) {
|
||||
return app('json')->fail('已经导入过该商品了');
|
||||
}
|
||||
$find['attrValue']=[
|
||||
['image'=>$find['image'],'price'=>$price,'cost'=>$find['cost'],'ot_price'=>$find['ot_price'],
|
||||
'svip_price'=>$find['svip_price'],'stock'=>$stock,'bar_code'=>$find['bar_code'],'weight'=>0,'volume'=>0,'detail'=>''
|
||||
]];
|
||||
$find['content'] =$find['images'];
|
||||
$find['is_show'] = 1;
|
||||
$find['mer_id'] = $mer_id;
|
||||
$find['temp_id'] = "";
|
||||
$find['give_coupon_ids'] = [];
|
||||
$find['params'] = [];
|
||||
$find['extend'] = [];
|
||||
$find['param_temp_id'] = [];
|
||||
$find['mer_labels'] = [];
|
||||
$find['delivery_way'] = [0 => "2"];
|
||||
$find["guarantee_template_id"] = "";
|
||||
$find['product_type'] = 0;
|
||||
$find['mer_cate_id'] = [0 => 0];
|
||||
$find['is_used'] = 1;
|
||||
$find['status'] = 1;
|
||||
$find['mer_status'] = 1;
|
||||
$find['source_product_id'] = 0;
|
||||
$find['source_library_id'] = 0;
|
||||
$find['slider_image'] = $find['slider_image'];
|
||||
$find['spec_type'] = 0;
|
||||
$find['delivery_free'] = 0;
|
||||
unset($find['create_time']);
|
||||
}
|
||||
$a= app()->make( ProductRepository::class)->create($find,0,1);
|
||||
if($a){
|
||||
return app('json')->success(['data'=>['product_id'=>$a],'msg'=>'导入成功']);
|
||||
}else{
|
||||
return app('json')->fail('导入失败');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return app('json')->fail($e->getMessage());
|
||||
}
|
||||
if($a){
|
||||
return app('json')->success(['data'=>$a,'msg'=>'导入成功']);
|
||||
}else{
|
||||
return app('json')->fail('导入失败');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function eadtProduct(){
|
||||
|
Loading…
x
Reference in New Issue
Block a user