商品导入

This commit is contained in:
mkm 2023-05-19 21:12:34 +08:00
parent 3e1d4ace81
commit a5ec83b8f6
2 changed files with 36 additions and 2 deletions

View File

@ -1,6 +1,6 @@
<?php
namespace app\controller\api\store\product;
use think\exception\ValidateException;
use app\common\repositories\store\product\ProductRepository;
use think\facade\Db;
use crmeb\basic\BaseController;
@ -28,6 +28,7 @@ class StoreMicro extends BaseController
return app('json')->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(){

View File

@ -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 () {