diff --git a/app/controller/api/store/product/StoreMicro.php b/app/controller/api/store/product/StoreMicro.php index 4b68b53b..34e63c46 100644 --- a/app/controller/api/store/product/StoreMicro.php +++ b/app/controller/api/store/product/StoreMicro.php @@ -1,6 +1,6 @@ success($store_product); } + //商品详情 public function ProductDetails($id){ $find=Db::name('store_product')->where('product_id',$id) ->withAttr('attr_value',function ($value,$data){ @@ -35,8 +36,40 @@ class StoreMicro extends BaseController }) ->find(); return app('json')->success(['list'=>$find]); + } - + //提交导入商品id + public function ProductImport(){ + $product_id = $this->request->param('id', 0); + $user = $this->request->userInfo(); + $mer_id =Db::name('store_service')->where('uid',$user['uid'])->where('status',1)->value('mer_id'); + if ($mer_id==0) return app('json')->fail('商户id不能为空'); + $find=Db::name('store_product')->where('product_id',$product_id)->find(); + if($find){ + $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_id']=$mer_id; + $find['temp_id']=""; + $find['give_coupon_ids']=[]; + $find['params']=[]; + $find['extend']=[]; + $find['param_temp_id']=[]; + $find['mer_labels']=[]; + $find['attr']=[]; + $find['delivery_way']=[ 0 => "2"]; + $find["guarantee_template_id"] = ""; + $find['product_type']=0; + $find['mer_cate_id']=[0 => 0]; + unset($find['product_id'],$find['create_time']); + } + $make = app()->make(ProductRepository::class); + $a=$make->create($find,0); + if($a){ + return app('json')->success(['data'=>$a,'msg'=>'导入成功']); + }else{ + return app('json')->fail('导入失败'); + } } public function eadtProduct(){ diff --git a/route/api.php b/route/api.php index 44fce8a7..e71be2c7 100644 --- a/route/api.php +++ b/route/api.php @@ -28,6 +28,7 @@ Route::group('api/', function () { Route::get('seach_bar_code', '/seach_bar_code'); Route::get('product_details', '/ProductDetails'); Route::post('eadt_product', '/eadtProduct'); + Route::post('product_import', '/ProductImport'); })->prefix('api.store.product.StoreMicro'); Route::group('v2', function () {