更新发布商品数量
This commit is contained in:
parent
3f23292dc7
commit
35285c3e8f
@ -69,7 +69,7 @@ class ProductRepository extends BaseRepository
|
|||||||
|
|
||||||
protected $dao;
|
protected $dao;
|
||||||
const CREATE_PARAMS = [
|
const CREATE_PARAMS = [
|
||||||
"image", "slider_image", "store_name", "store_info", "keyword", "bar_code", "guarantee_template_id", "cate_id", "mer_cate_id", "unit_name", "sort" , "is_show", "is_good", 'is_gift_bag', 'integral_rate', "video_link", "temp_id", "content", "spec_type", "extension_type", "attr", 'mer_labels', 'delivery_way', 'delivery_free','param_temp_id','extend', 'source_product_id',
|
"image", "slider_image", "store_name", "store_info", "keyword", "bar_code", "guarantee_template_id", "cate_id", "mer_cate_id", "unit_name", "sort" , "is_show", "is_good", 'is_gift_bag', 'integral_rate', "video_link", "temp_id", "content", "spec_type", "extension_type", "attr", 'mer_labels', 'delivery_way', 'delivery_free','param_temp_id','extend', 'source_product_id', 'stock_num',
|
||||||
["brand_id",0],
|
["brand_id",0],
|
||||||
['once_max_count',0],
|
['once_max_count',0],
|
||||||
['once_min_count',0],
|
['once_min_count',0],
|
||||||
|
@ -83,6 +83,8 @@ class StoreProduct extends BaseController
|
|||||||
{
|
{
|
||||||
$res = $this->request->params($this->repository::CREATE_PARAMS);
|
$res = $this->request->params($this->repository::CREATE_PARAMS);
|
||||||
$data = $this->repository->checkParams($res,$merId);
|
$data = $this->repository->checkParams($res,$merId);
|
||||||
|
$stockNum = $data['stock_num'] ?? 0;
|
||||||
|
unset($data['stock_num']);
|
||||||
$data['mer_id'] = $merId;
|
$data['mer_id'] = $merId;
|
||||||
$data['is_gift_bag'] = 0;
|
$data['is_gift_bag'] = 0;
|
||||||
$merchant = app()->make(MerchantRepository::class)->get($merId);
|
$merchant = app()->make(MerchantRepository::class)->get($merId);
|
||||||
@ -96,7 +98,15 @@ class StoreProduct extends BaseController
|
|||||||
}else{
|
}else{
|
||||||
$product_type=0;//普通商品
|
$product_type=0;//普通商品
|
||||||
}
|
}
|
||||||
$this->repository->create($data, $product_type, 1);
|
$productId = $this->repository->create($data, $product_type, 1);
|
||||||
|
$unique = Db::name('store_product_attr_value')->where('product_id', $productId)->value('unique');
|
||||||
|
if (!empty($unique) && $stockNum > 0) {
|
||||||
|
$this->repository->stockIn($merId, [
|
||||||
|
'product_id' => $productId,
|
||||||
|
'unique' => $unique,
|
||||||
|
'number' => $stockNum,
|
||||||
|
]);
|
||||||
|
}
|
||||||
return app('json')->success('添加成功');
|
return app('json')->success('添加成功');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user