更新库存
This commit is contained in:
parent
0b6d5e236f
commit
878219bd7c
@ -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', 'stock_num', 'stock',
|
"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',
|
||||||
["brand_id",0],
|
["brand_id",0],
|
||||||
['once_max_count',0],
|
['once_max_count',0],
|
||||||
['once_min_count',0],
|
['once_min_count',0],
|
||||||
|
@ -83,11 +83,6 @@ 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']);
|
|
||||||
if (!empty($data['stock'])) {
|
|
||||||
unset($data['stock']);
|
|
||||||
}
|
|
||||||
$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);
|
||||||
@ -101,15 +96,15 @@ class StoreProduct extends BaseController
|
|||||||
}else{
|
}else{
|
||||||
$product_type=0;//普通商品
|
$product_type=0;//普通商品
|
||||||
}
|
}
|
||||||
$productId = $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');
|
// $unique = Db::name('store_product_attr_value')->where('product_id', $productId)->value('unique');
|
||||||
if (!empty($unique) && $stockNum > 0) {
|
// if (!empty($unique) && $stockNum > 0) {
|
||||||
$this->repository->stockIn($merId, [
|
// $this->repository->stockIn($merId, [
|
||||||
'product_id' => $productId,
|
// 'product_id' => $productId,
|
||||||
'unique' => $unique,
|
// 'unique' => $unique,
|
||||||
'number' => $stockNum,
|
// 'number' => $stockNum,
|
||||||
]);
|
// ]);
|
||||||
}
|
// }
|
||||||
return app('json')->success('添加成功');
|
return app('json')->success('添加成功');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user